Sign in to follow this  
maheshbinny

Confusion

Recommended Posts

Hi, I've small doubt

consider if I created a cylinder in DirectX

and I set that cylinder position to (10,10,10)


so tell me what is the center point of that cylinder?

Share this post


Link to post
Share on other sites
Hey there,

What are you using to create the cylinder?

If you are loading it from a model file, whatever the "origin" is inside of the model file is what will be at (10,10,10) when you place it.

So for instance if you made a model of a cylinder where the origin (0,0,0) was at the center of the cylinder, when you placed it in your program at (10,10,10), the center of the cylinder would be at (10,10,10).

If, however, you made the model such that in your modeling program, the cylinder was resting on the "ground plane" (ie X and Z = 0), when you placed it in your program at (10,10,10), the BOTTOM of the cylinder would be at (10,10,10) and the middle would be up a little ways (1/2 the height of your cylinder from there).

Share this post


Link to post
Share on other sites
Here is other solution (assume you are using dx9) to obtain center:

LPD3DXMESH mesh;//your cylinder mesh previously loaded
D3DXVECTOR3 center;
float radius;
D3DXVECTOR3* pPos;
mesh->LockVertexBuffer(0, (LPVOID*)&pPos);
D3DXComputeBoundingSphere(pPos, mesh->GetNumVertices(),mesh->GetNumBytesPerVertex(), ¢er, &radius);
mesh->UnlockVertexBuffer()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this