Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

[Dx9 - Direct3D] World/View/Projection Matrices *The Horror!*

Feb 23 2003 5:54 PM
hi all. Ive been fiddling with Dx9 for a bit and im starting to like it a lot. Directdraw is a complete breeze. very easy!. I thought, I can do that with D3d.. boy was I wrong :P Ive been programming 3D games in quite some other languages, but never had to deal with the lowlevel stuff of Dx before. Ive ran into a lil confusing issue. When I render my scene I have to set the World/Projection and View Matrices for the camera. All fine n dandy, but when I try to move a 3D object, nothing happens.. reading some samples Ive noticed that I have to set a seperate matrix for world/view/projection for each and every single mesh I want displayed.. Fine, no problem, bt im not sure if this is the right thing to do and how I would go about this.. Basicly the concept of these matrices aludes me a bit.. consider the following pseudo code: Scene 1: [code] ClearDeviceBuffer(); SetupCameraMatrices(); SetupLights(); PushAllMeshesVertextBuffersToDevice(); RenderScene(); PresentRenderedImage(); [/code] This worls ok if you have 1 object in the world. But what if I have multiple objects wich all move in different ways, and get positioned differently? is it either: Scene 2a: [code] ClearDeviceBuffer(); SetupCameraMatrices(); SetupLights(); foreach(Mesh in MeshCollection){ PushAllMeshesVertextBuffersToDevice(); } RenderScene(); PresentRenderedImage(); [/code] or: Scene 2b: [code] ClearDeviceBuffer(); foreach(Mesh in MeshCollection){ SetupCameraMatrices(); SetupLights(); PushAllMeshesVertextBuffersToDevice(); } RenderScene(); PresentRenderedImage(); [/code] or even: Scene 2c: [code] ClearDeviceBuffer(); foreach(Mesh in MeshCollection){ SetupCameraMatrices(); SetupLights(); PushAllMeshesVertextBuffersToDevice(); RenderScene(); } PresentRenderedImage(); [/code] After much ado, I have came close to believing the last example is true. wich means I need a renderloop for each seperate mesh in wich I specify the World/view/Projection matrix for each object seperatly.. but I havnt gotten any visual rresults from it wich confirm this. Any DX guru's about who can clarify this a bit? All help is greatly appreciated. Regards, Jim