Advertisement

Setting the pivot point for exportation

Started by July 03, 2015 11:53 AM
6 comments, last by Mussi 9 years, 4 months ago

When exporting an object to X,

I wonder should I put the pivot point at ground zero or the center of the object?

And also Should I place the mesh above ground even though the pivot is at the center of the mesh?

The problems I am facing, if the object is not at ground zero, when I SetPos() to 0,0,0

then the mesh will be below ground

But if I put the pivot point at ground zero, the bounding box will be half the size.

Any ideas?

Thanks

Jack

Does the 3DS Max pivot even export to X? I can't recall that, but I would position models so that (0, 0, 0) is the ground, if you ever want to animate your models this will make your life easier. This means you will have to adjust the position of your bounding box, either manually or automatically.


But if I put the pivot point at ground zero, the bounding box will be half the size.

Why is that? How are you getting your bounding box?

Advertisement
Hi Mussi, I use code something that looks like this...
D3DXComputeBoundingBox((D3DXVECTOR3*)pVertices, m_pStaticMesh->GetNumVertices(),
   D3DXGetFVFVertexSize(m_pStaticMesh->GetFVF()), &m_vMind, &m_vMaxd);

D3DXCreateBox(m_pDevice, fabs(m_vMaxd.x - m_vMind.x), fabs(m_vMaxd.y - m_vMind.y),
		fabs(m_vMaxd.z - m_vMind.z), &m_pBoundingBox, NULL);

Are you sure your bounding box becomes half it's size? I'm guessing half of the box is just clipping through the ground. If you add


(m_vMaxd.y - m_vMind.y) / 2

to the y-position of your bounding box, does it show up correctly?

It's off by 10%-20%

But if I leave out the division, it matches the boundary of the mesh exactly.


D3DXCreateBox(m_pDevice, fabs(m_vMaxd.x - m_vMind.x), fabs(m_vMaxd.y - m_vMind.y) + fabs(m_vMaxd.y - m_vMind.y) / 2,
        fabs(m_vMaxd.z - m_vMind.z), &m_pBoundingBox, NULL);        

That creates a bigger box, but you should really be translating your box upwards(as in add something to it's y position). I'm guessing the box is clipping through your ground where you can't see it's actually bigger than the boundary of the mesh. So something like:

// Draw model here
D3DXMATRIX matrix;
D3DXMatrixTranslation(&matrix, 0.0f, (m_vMaxd.y - m_vMind.y) / 2, 0.0f);
directXDevice->SetTransform(D3DTS_WORLD, &matrix);
// Draw bounding box here
Advertisement

So we are assuming the pivot point is at ground zero and the mesh is sitting on the ground level as well.

Thanks

Jack


So we are assuming the pivot point is at ground zero and the mesh is sitting on the ground level as well.

Yeah, basically when you export the model out of 3DS Max, the pivot point becomes (0,0,0). You can try randomly moving the pivot point inside 3DS Max without moving the model, it should not have any effect on the position of the rendered mesh and bounding box.

This topic is closed to new replies.

Advertisement