Skip to main content
GameDev.net gamedev.net
🔒 Locked

Unaffecting SetTransform()s

Started by Pfhoenix Jan 5, 2003 at 2:05 AM 1 replies 1k views
Original Post
Pfhoenix
Pfhoenix
I''m porting a project of mine from SDL to DX9, and learning D3D as I do so. I''ve been following a couple tutorials for setting up a basic D3D9 app, and what I have works.. until I try to make my little two tri test texture move around the screen. The results are exactly the same, whether I set a projection matrices or not, whether I set rotation matrices or not, whether I set translation matrices or not. Looking over my setup code for the umpteenth time has me stumped; it''s a copy and paste from the DX9 SDK tutorial I''ve been following. My rendering code does only this : - set the texture to the main device - set my vertex buffer stream in the main device call my SetupMatrices() function (calling or not makes no difference at this point) - create a new D3DXMATRIX and translate it by how far I want - call maindevice->SetTransform() with the above (which doesn''t seem to have an effect) into the World matrix (I''ve also tested into View, no difference) - DrawPrimitive(at least something works) It may be informative to note that I must have something setup right, since I can texture and draw my little quad just fine - with or without any matrix setup whatsoever (it was my intention to use ortho projection until in my testing, I learned that just not having any projection matrix setup appears to be de facto ortho). Any help that anybody can give would be much appreciated. I never had this much of a problem with OpenGL (nor following simple tutorials, for that matter). - Pfhoenix
Pfhoenix
S1CA
S1CA
It sounds like you''re using "transformed vertices", i.e. D3D is interpreting all of the vertices in your vertex buffer as "the user has already transformed these vertices into screen/clip space so I don''t have to".

Take a look at where your FVF is specified, my guess is you''ve got D3DFVF_XYZRHW in there which is the signal to D3D that the vertex is [already] transformed.

Vertices which will have D3D transformation & lighting performed on them use D3DFVF_XYZ instead.


I''d suggest working through the tutorials which come with the SDK first before you start with any from external sources. The D3D docs also take you through what is going on with the code:

Tutorial 1: Creating a Device
Tutorial 2: Rendering Vertices
Tutorial 3: Using Matrices
Tutorial 4: Creating and Using Lights
Tutorial 5: Using Texture Maps
Tutorial 6: Using Meshes

The first two tutorials in the DirectX SDK use [already] transformed vertices D3DFVF_XYZRHW. If the tutorial you''re following is based on the D3D ones, it could be doing the same.

It''s only when you get to the 3rd tutorial in the SDK that they start using untransformed vertices and matrices - base your code off the 3rd tutorial (a spinning triangle with perspective projection) and all should be fine.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Pfhoenix
Pfhoenix
Thank you, that was it. I was following the DX9 tutorials, but missed that change. =)

- Pfhoenix
Pfhoenix

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.