# Confusion

## Recommended Posts

maheshbinny    118
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 on other sites
smasherprog    568
When ever you position something, the position is usually the center of the object. In this case, the center is 10 10 10

##### Share on other sites
Atrix256    539
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 on other sites
belfegor    2834
Here is other solution (assume you are using dx9) to obtain center:
LPD3DXMESH mesh;//your cylinder mesh previously loadedD3DXVECTOR3 center;float radius;D3DXVECTOR3* pPos;mesh->LockVertexBuffer(0, (LPVOID*)&pPos);D3DXComputeBoundingSphere(pPos, mesh->GetNumVertices(),mesh->GetNumBytesPerVertex(), ¢er, &radius);mesh->UnlockVertexBuffer()