Archived

This topic is now archived and is closed to further replies.

tom76

a 3D ship in a 3D realm...

Recommended Posts

tom76    122
This is taken from donuts3D on the directx8 SDK, but probably applies to other games too. What does the Point of ship, Point ahead of ship, and Point to side of ship mean? does it mean the vectors in the Centre/center of the model, the front of the model (the nose), and the furthest right sided point of the model? // Render the ship if( g_pShip->bVisible && g_bFirstPersonView == FALSE ) { // Point of ship, on terrain D3DXVECTOR3 vShipPt; // vector declaration vShipPt.x = g_pShip->vPos.x; // x position vShipPt.z = -g_pShip->vPos.y; // z position vShipPt.y = 0.1f + HeightField( vShipPt.x, vShipPt.z ); // y position is computed // Point ahead of ship, on terrain D3DXVECTOR3 vForwardPt; // vector declaration vForwardPt.x = vShipPt.x+sinf(g_pShip->fAngle); vForwardPt.z = vShipPt.z+cosf(g_pShip->fAngle); vForwardPt.y = 0.1f + HeightField( vForwardPt.x, vForwardPt.z ); // Point to side of ship, on terrain D3DXVECTOR3 vSidePt; vSidePt.x = vShipPt.x+sinf(g_pShip->fAngle + D3DX_PI/2.0f); vSidePt.z = vShipPt.z+cosf(g_pShip->fAngle + D3DX_PI/2.0f); vSidePt.y = 0.1f + HeightField( vSidePt.x, vSidePt.z ); Observe everything, remember more!

Share this post


Link to post
Share on other sites
Oluseyi    2109
To fully specify the position and orientation of an object in 3D space, you need 2 vectors: one along the object''s direction and another perpendicular to that (many people use "front" and "up", but "front" and "right" [or left] work just as well)

So I said we need 2 vectors, but they declare 3 points. Why? Because a vector has 2 points - a begin point (origin) and an endpoint. The direction vector ("front") has origin at the ships position and its endpoint at the point in front of the ship, while the side vector ("left" or "right") extends from the position to the point by the ship''s side.

Alles klar?

Share this post


Link to post
Share on other sites