Skip to main content
gamedev.net
🔒 Locked

Some vector questions...

Started by Solarbeam 8 replies 250+ views
Original Post
Solarbeam
Solarbeam
Ok, its like this. I''m trying to build a 3d shooter using the d3d API. Everything was going well until I started make the camera controllable. Naturally, i used 3 vectors (origin, look at point, and up). Now, i cant figure out how to rotate the look vector around the origin. Any help/resources are appreciated. Oh yeah, whats a good format for level files with d3d? X files? I need one thats supported by 3d studio max...
------------------------------Large explosion consumes building, hero walks away unharmed (wtf? why?) CUT
Meduzza
Meduzza
Try this...


D3DXMATRIX rotationMatrix;
look -= origin;
D3DXMatrixRotationY( &rotationMatrix, 0.1 );
D3DXVec3TransformCoord( &look, &look, &rotationMatrix );
look += origin;


Achoo!
Meduzza
cruZ
cruZ
I wouldn''t use 3ds MAX for building a level unless you have a tool to convert the 3d data to a more efficient format. The x file format works only well for models. For storing level data I would recommend some bsp type fileformat. The x file format prevents you from using visibility determination algorithms like portal rendering or BSP, which are essential for a solid 3d shooter.
Solarbeam
Solarbeam
Hmm, ok...Dyou know where I can find any tutorials on parsing bsp files and/or doing visiblity? As of now, im pretty much clueless...Also, is it ok to use DrawPrimitive for all of my drawing calls? Or should I use something else...?

[MODIFIED]
Oh yeah, Meduzza, I dont quite get what you're saying...which part do I modify to make it rotate left or right based on input? And where should this call be? And how do I implement the up vector, just leave it alone? Also, what about rotation on several axes? Also...

Edited by - Solarbeam on September 18, 2000 9:56:26 PM
------------------------------Large explosion consumes building, hero walks away unharmed (wtf? why?) CUT
Solarbeam
Solarbeam
Er, um, it doesnt go to the top if i just modify my post, does it...
------------------------------Large explosion consumes building, hero walks away unharmed (wtf? why?) CUT
cruZ
cruZ
Programming recources on the web are mostly incomplete or do
not cover all the stuff you might need.
For BSP try this: BSP FAQ, http://reality.sgi.com/bspfaq/index.html


Well, and maybe you try one of these books, they helped me alot.

Advanced 3D Game Programming
using DirectX 7
by Adrian Perez, published by Wordware

3D Graphics Programming
by Sergei Savechenko, published by SAMS

Real-Time Rendering by
Tomas Molles and Eric Haines, A K Peters Ltd. 1999

Edited by - cruz on September 19, 2000 9:52:27 AM
Solarbeam
Solarbeam
Um, ok, here''s the problem:

SetViewMatrix only works with vars of type D3DVECTOR. D3DXVec3TransformCoord() only works with types of D3DXVECTOR (note the ''x''). Now, how do i convert between the two? Is it even possible? Should I just use D3DXVECTORs, which most of my functions dont support? HELP!
------------------------------Large explosion consumes building, hero walks away unharmed (wtf? why?) CUT
BeRSeRKeR[DGT]
BeRSeRKeR[DGT]
example:

D3DMATRIX matProj;
D3DXMatrixOrthoOffCenterLH((D3DXMATRIX *)&matProj, 0.0f, (float)m_nScreenW, (float)m_nScreenH, 0.0f, -1.0f, 1.0f);
pD3DDev->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);

it should work!.


Meduzza
Meduzza
You can cast D3DVECTOR* to D3DXVECTOR3* and back with no problems. They are essentially the same. I have no idea why did MS use both of them, but i know in DX8 they fixed it.

Solarbeam: in code i gave you "look" is "look at vector"; "origin" is "camera position vector". We rotate "look" around "origin" and Y axis (that''s left and right rotation). You''ll need to recreate view matrix after that:

D3DXMatrixLookAt( &viewMatrix, &origin, &look, &D3DXVECTOR3( 0, 1, 0 ) );



------------

Cheers
Meduzza
InFerN0
InFerN0
for D3D stuff go to Mr Gamemaker. I was able to port his bsp code to opengl and he gives a very good explanation of how it works, why it works, and explains ALL the code it needs unlike most other resources. If you do D3D this is the site.

InFerN0

Not all who wander are lost...
InFerN0Not all who wander are lost...

Topic Locked

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

Sign in to reply to this topic.