Using d3d8 without d3dx

Started by
9 comments, last by etran1 23 years, 2 months ago
I''ve been trying to learn d3d8 without using d3dx but I can''t find any tutorials on it. I could write my own functions but the problem is that I don''t know what goes on in the d3dx functions. For example, what goes on when you do a call to D3DXMatrixLookAtLH? Any help would be greatly appreciated. Etran1
Advertisement

I''ve written a small library called "dxUtility" to replace D3DX:

void dxuMatrixLookAtLH(D3DMATRIX *mat, D3DVECTOR *Eye,                                        D3DVECTOR *At, D3DVECTOR *Up){ D3DVECTOR view, upVec, rightVec, tmp;  float len, dot;  dxuVectorSub(view, At, Eye);   // subtract vectors  len = dxuVectorLength(view);     // normalise dxuVectorDiv(view, &view, len);  //  dot = dxuDotProduct(Up, &view); dxuVectorMul(tmp, &view, dot); dxuVectorSub(upVec, Up, &tmp);                                  dxuNormalize(upVec); dxuCrossProduct(rightVec,&upVec, &view);  mat->_11 = rightVec.x; mat->_12 = upVec.x; mat->_13 = view.x; mat->_21 = rightVec.y; mat->_22 = upVec.y; mat->_23 = view.y; mat->_31 = rightVec.z; mat->_32 = upVec.z; mat->_33 = view.z;  mat->_41 = -dxuDotProduct(Eye, &rightVec); mat->_42 = -dxuDotProduct(Eye, &upVec); mat->_43 = -dxuDotProduct(Eye, &view); mat->_14 = 0; mat->_24 = 0; mat->_34 = 0; mat->_44 = 1;} 


Replace the Cross/Dot product and other vector functions and that will work for you

"You say I''m a bitch like it''s a *bad* thing..."[email=alanetcetc@hotmail.com]Mail[/email] Site
Thanks for the help. I'm still wondering how you figured out what matrix and vector operations happened during that function. I understand what the individual operations do by themselves but I'm still not sure how they all fit together. I'm looking to do this without using d3dx at all, meaning that I need to write the other functions too. I don't want people to just give them to me. I'll learn more by coding them myself. What material did you use to learn this?

Thanks again

Etran1

Edited by - etran1 on January 26, 2001 11:17:33 AM
I don''t know whether you''ve got the DX7 SDK, but since D3DX was nothing more than a collection of helper function (which MS probably didn''t expect anyone to use) in DX7, Microsoft included code in the SDK docs to show you how to do yourself lots of the things which D3DX now does.

Things like generating an Identity Matrix, Matrix Multiplcation, Scaling, Rotation and Translation Matrices, as well as View and Projection Matrix generating functions are all there for you to disect.

If you haven''t got the DX7 SDK, I can send you the code from those functions if it would be helpful. As for knowing where this code comes from, and how to write it yourself, I suggest a good book on how to code a software 3D engine (ie done with maths).

"Black Art of 3D Game Programming" by Andre Lamothe and "Buliding a 3d game engine in C++" by Brian Hook are both excellent.

quote:
What material did you use to learn this?


Like you, I knew what these functions were and what they did, but not specific conventions/formats etc..Luckily I had a book called "Advanced 3D Game Programming in DirectX 7.0" which was written by an ex-Microsoft intern and his code was identical to that used in D3DX. Unfortunately his DDS texture loading functions were absolutely terrible so I wrote my own (better ) code for that..It doesn''t take long

Whoops .. that last post was by me :D
"You say I''m a bitch like it''s a *bad* thing..."[email=alanetcetc@hotmail.com]Mail[/email] Site
To Simon:
For D3D I''ve been using DX8 but I have the SDK docs for versions 6 and 7. In what section of the docs is the information you''re refering to located?

Etran1
To Simon:
For D3D I''ve been using DX8 but I have the SDK docs for versions 6 and 7. In what section of the docs is the information you''re refering to located?

Etran1
You don''t have to install the SDK, just find the directx.chm html-style help file on the dx7 cd (path=d:\DXF\doc\directx.chm). Take a look at ''Setting up a view matrix'', ''Setting up a projection matrix'' and ''3D Transformations''.

The code uses some DX7 helper functions, like Dot and Cross Product functions, and a few of the data-types used now have slightly different names, like D3DVECTOR is now D3DXVECTOR3, so the code needs to be altered a little to work in DX8. I suppose it wouldn''t be too much effort to re-write these functions without using D3DX at all if that''s what you need.

If you want I''ll send you the set of matrix function from DX7, updated to DX8.
I''ve uploaded the code at http://www.sbdev.pwp.blueyonder.co.uk/Matrix%20Functions.cpp

This topic is closed to new replies.

Advertisement