Ok i know how to do loads of things with direct graphics in Dx 8 but how can i make my camera move.. i know how to rotate it but moving it is not known to me :S can anybody help me with that?
Printable View
Ok i know how to do loads of things with direct graphics in Dx 8 but how can i make my camera move.. i know how to rotate it but moving it is not known to me :S can anybody help me with that?
How are you creating your camera in the first place? D3DX functions?
The D3DXMatrixLookAt*H functions are the easiest to use (use the LH version if you are using a left handed coordinate system, RH if right handed, I use LH, personally). The pEye parameter is a vector containing the position of the camera, the pAt parameter contains the point the camera should be looking at. To move the camera, simply recalculate the view matrix with the new data, and re set it, D3DDevice.SetTransform(...).
Z.
aha yeah just found it out :) hehe :) but now i get it much better :) can you also help me with how to position object? like moving them? only got them on the 0 , 0 , 0 standard place yet :S
D3DXMatrixTranslation() to generate a translation (position) matrix, then SetTransform to change the world matrix, then render the object. You do that for each object you want to move.
Z.
D3DXMatrixTranslation() to generate a translation (position) matrix, and use the object or something ? :S can you provide a little code example? only the d3dxmatrixtranslation should be fine :)
this doesnt seem to work
Public Sub model_move(index As Integer, x As Single, y As Single, z As Single)
D3DXMatrixTranslation objectmodel(index), x, y, z
End Sub
but what should the MOUT be :S
Simple enough...Code:D3DMATRIX m
Dim i as long
For i = 0 to numObjects - 1
D3DXMatrixTranslation m, Objects(i).pos.x, Objects(i).pos.y, Objects(i).pos.z
D3DDevice.SetTransform D3DTS_WORLD, m
Draw Object(i)
Next i
Z.
ok help me out here plz :(
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:
Variable not defined
---------------------------
OK Help
---------------------------
\/
D3DMATRIX m
as what should i define that and numObjects should be? :S trying to figure it out but need some help though :S
this is what i have up to now
Public Sub model_move(index As Integer, x As Single, y As Single, z As Single)
D3DMATRIX m
Dim i As Long
For i = 0 To numObjects - 1
D3DXMatrixTranslation m, x, y, z
D3DDevice.SetTransform matWorld, m
Next i
End Sub
i hope matworld is correct that declared as
Private matWorld As D3DMATRIX
Whoops... C++ style variable declarations =).
should have been
Dim m as D3DMATRIX
You function should look like this:
And you would call it for each object you have, and render that object after calling it.Code:Public Sub model_move(x As Single, y As Single, z As Single)
D3DMATRIX m
D3DXMatrixTranslation m, x, y, z
D3DDevice.SetTransform matWorld, m
End Sub
Z.
is what i have now.. the first line works perfectly though the second one fails at the matworldVB Code:
Public Sub model_move(index As Integer, x As Single, y As Single, z As Single) D3DXMatrixTranslation objectmodel(index).matpos, x, y, z D3DDevice.SetTransform matWorld, objectmodel(index).matpos End Sub
this is how i declared it all
VB Code:
Private matWorld As D3DMATRIX '//How the vertices are positioned Private matView As D3DMATRIX '//Where the camera is/where it's looking Private matProj As D3DMATRIX '//How the camera projects the 3D world onto the 2D screen Private matTemp As D3DMATRIX Private screenwidth As Long Private screenheight As Long '////////////////////////////////////////////////////////////////////////////MODELING Private Type smodel Mesh As D3DXMesh MeshMaterials(100) As D3DMATERIAL8 ' Mesh Material data MeshTextures(100) As Direct3DTexture8 ' Mesh Textures nMaterials As Long 'How may materials/textures we have.... used As Boolean matpos As D3DMATRIX End Type
Though if you are going to store the matrix in the object itself, you can just use that second line right before you draw the object.Code:Public Sub model_move(index As Integer, x As Single, y As Single, z As Single)
D3DXMatrixTranslation objectmodel(index).matpos, x, y, z
D3DDevice.SetTransform D3DTS_WORLD, objectmodel(index).matpos
End Sub
Z.
WOOHOO GOT IT WORKING :D
any idea why i get this error?
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:
Forward reference to user-defined type
---------------------------
OK Help
---------------------------
with this code?
VB Code:
Private Type smodel Mesh As D3DXMesh MeshMaterials(100) As D3DMATERIAL8 ' Mesh Material data MeshTextures(100) As Direct3DTexture8 ' Mesh Textures nMaterials As Long 'How may materials/textures we have.... used As Boolean position As poss ' right here (Seems to work normally) matpos As D3DMATRIX End Type Private Type poss x As Single y As Single z As Single End Type
never had problems with a type in a type
oh well nevermind that :) i got it all working.. but now i am working on camera movement.. but it keeps looking at a certain point how do i make my camera like a first person shooter has? looking up down etc etc :) and not looking at a certain object or something :)
Store the angles that the camera is looking, and use those to convert to lookat vector (look up spherical coordinates on google, use 1.0 for r).
Z.
ok will look for that tommorow right now i am tired as hell :P thanks zaei , you always seemed to help me out :)
oh 1 other thing the fps is always at 60 fps no matter windowed fullscreen nor the resolution (1600x1200x32) i have a ati radeon 9700 pro. is it the fact that it is limited or something? tried changing this but that doesnt seem to work
D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC '//We'll refresh when the monitor does