Skip to main content
gamedev.net
🔒 Locked

Rendering Model Speed Problem

Started by Eric kim 1 reply 600+ views
Original Post
Eric kim
Eric kim
I've found a source code for a model viewer but it is ridiculously slow. I get 50fps(80fps w/o animation) for a model with 5458 triangles and animation. My computer spec is Athlon XP 2400 256 DDR RAM Geforce4Ti4200 DDR 128MB Here's the updating part. Is there any problems?

HRESULT CRenderObject::UpdateVB(MOV_STATE State)
{	
	m_MovState = State;
	int j = 0;
	if(State==MOV_IDLE){
		for(int k=0; k<(int)(m_Triangle.size()); ++k)
		{
			SX_SKELETON_REF * pRef;
			for(int i=0; i<3; ++i)
			{
				int iNode = m_Triangle[k].sxVtx.iNode;
				pRef = &(m_SkelAct[m_iCurrAnim][m_iFrameID].paRef[iNode]);
				m_paVertex[j++].position = Multiply(m_Triangle[k].sxVtx.OrgVertex.position, &(pRef->matTransform))+pRef->NewPivot;
			}
		}
	}else{
		for(int k=0; k<(int)(m_Triangle.size()); ++k)
		{
			SX_SKELETON_REF * pRef;
			for(int i=0; i<3; ++i)
			{
				int iNode = m_Triangle[k].sxVtx.iNode;
				if(iNode>73||iNode<4) pRef = &(m_SkelAct[m_iCurrMovAnim][m_iMovFrameID].paRef[iNode]);
				else if(iNode<74&&iNode>3) pRef = &(m_SkelAct[m_iCurrAnim][m_iFrameID].paRef[iNode]);
				
				//m_paVertex[j].normal = Multiply(m_Triangle[k].sxVtx.OrgVertex.normal, &(pRef->matTransform));
				m_paVertex[j++].position = Multiply(m_Triangle[k].sxVtx.OrgVertex.position, &(pRef->matTransform))+pRef->NewPivot;
			}
		}
	}
	if(FAILED(SetVB()))//Releases vertices to VB
		return E_FAIL;
	return S_OK;
}

Hello
jollyjeffers
jollyjeffers
Thats not a lot of code to go on, but it looks like it doing some form of software transform per-vertex on the CPU (skeletal animation?). This will mean that you have to upload (and worse, download AND upload) the new vertex data each frame before its rendered. This won't be very friendly to your performance [smile]

Thats about all I can see from your fragment.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Muhammad Haggag
Muhammad Haggag
Is the vertex buffer dynamic? Locking static vertex buffers frequently is a bad idea.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.