• Advertisement
Sign in to follow this  

Scaling an .x file

This topic is 4580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to scale an .x file? I have a mesh - without any original format model file - and it needs to be scaled up for my game. How can I scale the model? Do I need a converter to change the .X file into a 3ds (or such) object?

Share this post


Link to post
Share on other sites
Advertisement
You can scale it just for rendering using D3DXMatrixScaling().

If you want to scale the mesh inside the file, I think its better you scale it manually in the 3D modelling software you modelled it before exporting.

cya

Share this post


Link to post
Share on other sites
I think this code will help you, it would be easy to modify it to scale the mesh verts.


void CMesh::InvertZ(void)
{
LPD3DXMESH pMeshCopy;
tD3DXCustomVertex *pVertex;
tFace *pFace;
DWORD dwNumVerts = m_pd3dMesh->GetNumVertices();
DWORD dwNumFaces = m_pd3dMesh->GetNumFaces();

m_pd3dMesh->CloneMeshFVF(0, tD3DXCustomVertex::VertexFVF, m_pD3DDevice, &pMeshCopy);

pMeshCopy->LockVertexBuffer(0,(VOID**)&pVertex);
for(unsigned int i = 0; i < dwNumVerts; i++)
{
pVertex.vPosition.z *= -1;
pVertex.vNormal.z *= -1;
}
pMeshCopy->UnlockVertexBuffer();

pMeshCopy->LockIndexBuffer(0,(VOID**)&pFace);
for(unsigned int i = 0; i < dwNumFaces; i++)
{
WORD iTempVert = pFace.vertOne;
pFace.vertOne = pFace.vertThree;
pFace.vertThree = iTempVert;
}
pMeshCopy->UnlockIndexBuffer();

D3DXSaveMeshToX("InvZ.x",pMeshCopy,NULL,m_pD3DXMaterials,NULL,m_dwNumMaterials,0);
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement