A great addition to make better types of SFX by supporting animated OBJ_'s!

Take a look at the example below.

Example:

In order to support animated OBJ_'s in your Neuz(source code), you need to be able to compile it and have some experience adding new code!

First, open your ..\_Common\sfxbase.cpp

Go into the following function: void CSfxPartMesh::Render(D3DXVECTOR3 vPos, WORD nFrame, FLOAT fAngle, D3DXVECTOR3 vScale) Scroll a bit down until you see the following:

	if (pMesh)
	{

Paste the following BELOW it:

bool bAnimatedMesh = FALSE;
if (pMesh->GetModelType() == MODELTYPE_ANIMATED_MESH && m_strTex.Left(4) == "obj_") {
	bAnimatedMesh = TRUE;
	WORD nFirstFrame = GetFirstKeyframeFrame();

	if (nFrame >= nFirstFrame) {
		float relativeFrame = (float)(nFrame - nFirstFrame);
		int maxModelFrames = pMesh->GetMaxFrame();
		if (maxModelFrames > 0) {
			float currentFrame = fmodf(relativeFrame, (float)maxModelFrames);
			pMesh->m_fFrameCurrent = currentFrame;
		}
		else {
			pMesh->m_fFrameCurrent = relativeFrame;
		}
	}
	else {
		pMesh->m_fFrameCurrent = 0.0f;
	}
}

Now scroll down a little bit until you see this:

pMesh->Render(CSfxMng::m_pd3dDevice, &matTemp1);

Paste the following BELOW it:

if (bAnimatedMesh) {
pMesh->m_fFrameCurrent = 0.0f;
}

Next, paste the following function above void CSfxPartMesh::Render(D3DXVECTOR3 vPos, WORD nFrame, FLOAT fAngle, D3DXVECTOR3 vScale):

WORD CSfxPartMesh::GetFirstKeyframeFrame() {
	if (m_apKeyFrames.GetSize() > 0)
		return Key(0)->nFrame;
	return 0; 
}

Don't forget to declare it in sfxbase.h:

class CSfxPartMesh : public CSfxPart
{
public:
	CSfxPartMesh();
	~CSfxPartMesh();
#ifndef __WORLDSERVER
	virtual void Render(D3DXVECTOR3 vPos, WORD nFrame, FLOAT fAngle, D3DXVECTOR3 vScale = D3DXVECTOR3(1.0f, 1.0f, 1.0f));
#endif
	virtual void Load(CResFile& file);
	virtual void Load2(CResFile& file);
	virtual void Load3(CResFile& file) {};
	virtual void OldLoad(CResFile& file);
	WORD GetFirstKeyframeFrame();//<-------ADD THIS HERE
};

Lastly, go into CModelObject* CSfxMeshMng::AddMesh(CString str)

You will see the following near the top:

pMesh->LoadModel(str);

Add this BELOW it:

	if (str.Left(4) == "obj_") {
		CObject3D* pObject3D = pMesh->GetObject3D();
		if((pObject3D && pObject3D->m_nHavePhysique) ||
		   (pMesh->GetMaxFrame() > 0)) {
			pMesh->SetModelType(MODELTYPE_ANIMATED_MESH);
		}
	}

That's it! Your Neuz should now support animated obj_ type O3D's inside SFX! Make sure to compile your Neuz and try it - enjoy!

Last updated