Hi area51,
Managed to make an md2 animation of a sliding door with milkshape.
I'm getting a bit confused now though. At the moment i have the following code in my Game level init():
Code: Select all
scene::IAnimatedMeshSceneNode* slideNode;
scene::IAnimatedMesh* slide = pManager->getSceneManager()->getMesh("media/door.md2");
slideNode = pManager->getSceneManager()->addAnimatedMeshSceneNode(slide);
slideNode->setMaterialFlag(EMF_LIGHTING, false);
slideNode->setMaterialTexture( 0, pManager->getDriver()->getTexture("media/stripes.jpg") );
slideNode->setRotation(core::vector3df(0,90,0));
slideNode->setScale(core::vector3df(1.8,1.8,1));
slideNode->setPosition(core::vector3df(890, 510, -10));
slideNode->setLoopMode(false);
scene::ITriangleSelector* slideSelector = pManager->getSceneManager()->createTriangleSelectorFromBoundingBox(slideNode);
if(slideSelector)
pManager->getMetaSelector()->addTriangleSelector(slideSelector);
I stop the animation with the loopmode but how do i get the animation running with a trigger??
I have tried various ways including using the md2 as a Doorpickup and not with the code above ie:
Code: Select all
//! Add DOOR to level
void CGameStateLevel02::addDoorPickups(CGameManager* pManager)
{
// load in pickups, DOOR
for (u32 i=0; i < 5; i++)
{
scene::IAnimatedMesh* doorMesh = 0;
doorMesh = pManager->getSceneManager()->getMesh("media/door.md2");
CGameItem* door = new CGameItem(GAME_ITEM_DOOR);
door->setMeshNode(pManager->getSceneManager()->addAnimatedMeshSceneNode(doorMesh));
if (door->getMeshNode())
{
door->getMeshNode()->setMaterialTexture(0, pManager->getDriver()->getTexture("media/intro.jpg"));
door->getMeshNode()->setPosition(pManager->getPathManager()->getWaypointAt(1));
door->getMeshNode()->setScale(core::vector3df(.5,.5,.5));
door->getMeshNode()->setMaterialFlag(video::EMF_LIGHTING, false);
door->getMeshNode()->addShadowVolumeSceneNode();
door->getMeshNode()->setID(GAME_ITEM_DOOR); //OBJECT_PICKUP
door->setTriggerRegion(70);//reduce radius due to model size
}
}
}
I got it working this way but can't seem to put a triangleselector to it for collisions. (I'm going straight through it) and also, the trigger won't reset.
the code in the gameitemmanager is as follows:
Code: Select all
//! DOOR Trigger activated
void CGameItemManager::processTriggerDoor(CGameManager* pManager, CGameItem* pItem)
{
// reset trigger at animation end
m_bAnimationEnd = false;
pItem->getMeshNode()->setLoopMode(false);
pItem->getMeshNode()->setAnimationEndCallback(this);
pItem->getMeshNode()->setAnimationSpeed(30);
pItem->getMeshNode()->setFrameLoop(0, 220);
pItem->setLocalInt("door_open", 0); // testing using NWN style softcoded variables
}
I hope you understand what i mean. I am a newbie when it comes to c++ (have a little experience with Delphi, but I like a challange
regards
dutch