[DirectX] Transform does nothing?

This topic is 3114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

	D3DXMATRIX mat;
D3DXMatrixRotationX(&mat, 45.0f);
d3ddev->SetTransform(D3DTS_WORLD, &mat);

The above code does not rotate my vertices by 45degrees, or anything for that matter.. it's placed after the CreateDevice call by the IDirect3D* interface, so no prior transformations could of been applied. Any ideas why the code does absolutely nothing? Thanks, Leo EDIT: This code has been bugging me all day, I could really appreciate some help, thanks

Share on other sites
Hi xLeo,

Your code seems quite alright, except for one thing:
- D3DXMatrixRotationX expects its second parameter to be specified in radians, not degrees.

Whereas a full circle has 360 degrees, it has 2*Pi radians. Herefrom you can easily deduce that:

45.0 degrees * (2*Pi radians / 360 degrees) =
45.0 degrees * (Pi radians / 180 degrees) =

Kind regards,
Tristan

Share on other sites
D3DXMatrixRotationX(&mat, 0.785398f);
still produces no noticeable effect (no rotation whatsoever)
This is really confusing me..

Share on other sites
Hi xLeo,

Another thing I just realized; what Vertex Format are you using? íf your vertex format includes the D3DFVF_XYZRHW flag, DirectX will think your vertices have already been transformed by you...and therefore will not bother to apply its world matrix to them.

Either manually multiply them by the transformation matrix to solve this, or change your vertex format. (The 2nd option will probably be the best one, considering the fact that DirectX will probably multiply your matrices in a much more optimized manner...)

Kind regards,
Tristan

Share on other sites
Also, using a vertex shader will override any fixed function T/L operations.

Share on other sites
Yeah, realised it was because I had D3DFVF_XYZRHW still in use.
I've heard that what im currently doing (using vertices, built-in transform functions) is called using the FFP (fixed function pipeline) which is bad practice because it's going obsolete in DX10?

If this is the case, could anyone hook me up with some shader tutorials? I have a DirectX 9.0c reference book (by Mr. Luna) but it goes in WAY too much depth for what im after.. I would just like some basic shader tutorials, or some tutorials in the HLSL language if possible, Thanks!

Leo.

Share on other sites
That book is an excellent one to get started (if you mean "3D Game Programming With DirectX9.0c: A Shader Approach"). I've read it cover-to-cover, it includes everything from the basics of HLSL syntax to matrix transforms to more advanced stuff like normal mapping. If you don't need the advanced stuff then you can just read the first 8-10 chapters or so.

It's an excellent resource, I think you'd do fine with it.

Share on other sites
Yeah, thats the one - I'll have to take a look over it again, I seem to remember something on shaders in chapter 8...
The confusing thing is, it says "A shader approach" on the title, so I assumed that what I was learning in the book would not be obsolete come DX10, however it appears chapter 1 - 8 are FFP, correct? If not, then what is classed as the Fixed function pipeline?

Thanks,
Leo.

Share on other sites
Fixed-function vertex processing (superseded by vertex shaders):

-SetMaterial
-SetTransform
-MultiplyTransform
-SetLight
-LightEnable
...and corresponding Get* methods.

FF pixel processing (superseded by pixel shaders):

-SetTextureStageState
...and corresponding Get method.

In addition, there are many render states that only make sense in fixed function usage, such as fog settings.

Share on other sites
Mr Luna also has his new book out which covers Direct3D 10 :-)

I'm no expert, just getting into D3D10 myself after a long time away from DirectX, I've forgotten pretty much everything, lol, but it's fun to get back into and this is why I've now started to learn D3D10.

Share on other sites

This topic is 3114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628722
• Total Posts
2984397

• 25
• 11
• 10
• 16
• 14