Модератор: Mikle
lellel писал(а):вот только при большом отдалении колонна кажется плоской...
d3dDevice.SetRenderState D3DRS_LIGHTING, 1
d3dDevice.LightEnable 0, 1
d3dDevice.SetRenderState D3DRS_AMBIENT, &H666666
Public Sub InitLight()
Dim Light As D3DLIGHT8
Light.Type = D3DLIGHT_DIRECTION
Light.Direction = vec3(10 * Sin(Timer), 10, 10 * Cos(Timer))
Light.diffuse.r = 1
Light.diffuse.g = 1
Light.diffuse.b = 1
d3dDevice.SetLight 0, Light
End Sub
Public Sub InitMaterial()
Dim Mat As D3DMATERIAL8
Mat.diffuse.r = 1
Mat.diffuse.g = 1
Mat.diffuse.b = 1
Mat.Ambient = Mat.diffuse
d3dDevice.SetMaterial Mat
End Sub
Private Type vFormat2
Pos As D3DVECTOR
Normal As D3DVECTOR
tu0 As Single
tv0 As Single
End Type
Private Const vFlag2 = D3DFVF_XYZ Or D3DFVF_NORMAL Or D3DFVF_TEX1
d3dDevice.SetTextureStageState 0, D3DTSS_COLOROP, D3DTOP_MODULATE
d3dDevice.SetTextureStageState 0, D3DTSS_COLORARG1, D3DTA_TEXTURE
d3dDevice.SetTextureStageState 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE
d3dDevice.SetLight 0, Light
Dim VertPot(5) As vFormat2
vSizePot = Len(VertPot(0))
Set vBufPot = d3dDevice.CreateVertexBuffer(6 * vSizePot, 0, vFlag2, D3DPOOL_DEFAULT)
p = 25
p1 = 25
VertPot(0) = Vertex2(25, 2.99, -25, 0, 0, -25, 1.99, -25)
VertPot(1) = Vertex2(-25, 2.99, -25, 0, p, -25, 1.99, -25)
VertPot(2) = Vertex2(25, 2.99, 25, p, 0, 25, 1.99, 25)
VertPot(3) = Vertex2(-25, 2.99, -25, 0, p, -25, 1.99, -25)
VertPot(4) = Vertex2(25, 2.99, 25, p, 0, 25, 1.99, 25)
VertPot(5) = Vertex2(-25, 2.99, 25, p, p, -25, 1.99, 25)
D3DVertexBuffer8SetData vBufPot, 0, 6 * vSizePot, 0, VertPot(0)
Private Function Vertex2(x As Single, y As Single, z As Single, tu0 As Single, tv0 As Single, normx As Single, normy As Single, normz As Single) As vFormat2
Vertex2.Pos = vec3(x, y, z)
Vertex2.tu0 = tu0
Vertex2.tv0 = tv0
Vertex2.Normal.x = normx
Vertex2.Normal.y = normy
Vertex2.Normal.z = normz
End Function
d3dDevice.SetStreamSource 0, vBufPot, vSizePot
d3dDevice.SetVertexShader vFlag2
d3dDevice.DrawPrimitive D3DPT_TRIANGLELIST, 0, 2
VertPot(0) = Vertex2(25, 2.99, -25, 0, 0, 0, -1, 0)
VertPot(1) = Vertex2(-25, 2.99, -25, 0, p, 0, -1, 0)
VertPot(2) = Vertex2(25, 2.99, 25, p, 0, 0, -1, 0)
VertPot(3) = Vertex2(-25, 2.99, -25, 0, p, 0, -1, 0)
VertPot(4) = Vertex2(25, 2.99, 25, p, 0, 0, -1, 0)
VertPot(5) = Vertex2(-25, 2.99, 25, p, p, 0, -1, 0)
Dim Light As D3DLIGHT8
With Light
.Attenuation0 = Attenuation0
.Attenuation1 = Attenuation1
.Attenuation2 = Attenuation2
.Diffuse = Diffuse
.Position = Pos
.Range = Range
.Specular = Diffuse
.Type = D3DLIGHT_POINT
End With
Set LTex = d3dx.CreateTexture(d3dDevice, Size, Size, 1&, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT)
Set d3dDevice = d3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, d3dpp)
Set d3dDevice = d3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp)
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 32