and im having some problems...
1. on key press my animated character doesnt play its animation
like when i press w its supposed to play the walking animation but it doesnt play the animation...
2. another problem is that i want to adjust the camera with the character node.. like when i press w the key the node moves and i want the camera to move with it, (behind the character), u no...like how the camera is in 3rd person games...
3. another problem is the cutscenes... can u guys give me any help on cutscenes.???
the code on this link isnt working...
http://irrlicht.sourceforge.net/phpBB2/ ... c&start=45
here is my code... any quick help would be gr8... its for a project im doing and the due date is coming up .... quick help needed...
Code: Select all
#include<irrlicht.h>
#pragma comment(lib, "Irrlicht.lib")
bool keys[irr::KEY_KEY_CODES_COUNT];
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;
class MyEventReceiver : public IEventReceiver {
public:
virtual bool OnEvent(const SEvent& event) {
if(event.EventType == irr::EET_KEY_INPUT_EVENT){
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
return false;
}
};
int main()
{
IrrlichtDevice*device = createDevice(EDT_DIRECT3D9);
core::dimension2d<s32>(1280,800);
IVideoDriver* video = device->getVideoDriver();
ISceneManager*smgr = device->getSceneManager();
//device->getFileSystem("C:/Users/X360/shovq2dm1_cpm.pk3");
//scene::IAnimatedMesh* mash = smgr->getMesh("shovq2dm1_cpm.bsp");
//scene::ISceneNode* nade = 0;
//if (mash)
// nade = smgr->addOctreeSceneNode(mash->>getMesh(0), 0, -1, 1024);
scene::IAnimatedMesh * gamemap = smgr->getMesh("C:/Users/X360/GameMap.3DS");
//smgr->addAnimatedMeshSceneNode(smgr->getMesh("C:/Users/X360/chk111.3DS"));
//smgr->loadScene("C:/Users/X360/chk223.irr");
scene::IAnimatedMeshSceneNode * mapnode = smgr->addAnimatedMeshSceneNode(gamemap);
if (mapnode)
{
mapnode->setMaterialFlag(video::EMF_LIGHTING,false);
}
////////////////////////////////// PART OF COLLISION DETECTION /////////////////////////////////////////
scene::ISceneNode * mnode = 0;
if(gamemap)
mnode = smgr ->addOctTreeSceneNode(gamemap ->getMesh(0));
scene::ITriangleSelector * selector = 0;
if(mnode)
{
selector = smgr->createOctreeTriangleSelector(gamemap ->getMesh(0),mnode, 128);
mnode ->setTriangleSelector(selector);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
IAnimatedMesh* mesh = smgr->getMesh("D:/Project/OOP Project(Main)/Tutes & models/ninja/ninja.b3d");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(video::EMF_LIGHTING,false);
}
node->setMaterialTexture( 0, video->getTexture("D:/Project/OOP Project(Main)/Tutes & models/ninja/nskinwh.jpg") );
//smgr->loadScene("C:/Users/X360/asd.irr");
ISceneNode * Skybox = smgr->addSkyBoxSceneNode(video->getTexture("D:/Project/Models/sky14/Sky1/Side6.png"),video->getTexture("D:/Project/Models/sky14/Sky1/Side1.png"),video->getTexture("D:/Project/Models/sky14/Sky1/Side4.png"),video->getTexture("D:/Project/Models/sky14/Sky1/Side3.png"),video->getTexture("D:/Project/Models/sky14/Sky1/Side5.png"),video->getTexture("D:/Project/Models/sky14/Sky1/Side2.png"));
MyEventReceiver rv;
device->setEventReceiver(&rv);
for(int x=0;x<irr::KEY_KEY_CODES_COUNT;x++)keys[x]=false;
node->setPosition(vector3df(0,35,5));
node->setScale(vector3df(25,25,25));
///////////////////////////////////////////////////////////PART OF COLLISION DETECTION///////////////////////////////////////////
scene::ISceneNodeAnimator *anim = smgr ->createCollisionResponseAnimator(selector, node, vector3df(25,25,25),
vector3df(0,-3,0), vector3df(0,50,0));
selector ->drop();
node ->addAnimator(anim);
anim ->drop();
/////////////////////
ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS();
cam->setTarget(node->getPosition());
while (device->run() && device)
{
core::vector3df nodePosition = node->getPosition();
if(keys[KEY_KEY_S])
{
node->setAnimationSpeed(200);
node->setLoopMode(true);
node->setFrameLoop(1,14);
node->setPosition(node->getPosition()+vector3df(0,0,30));
node->setRotation(core::vector3df(0.0f , 180.0f , 0.0f));
//node->setAnimationEndCallback(0);
cam->setTarget(node->getPosition()+vector3df(0,0,3));
}
else
{
node->setFrameLoop(184,205);
node->setLoopMode(true);
node->setAnimationSpeed(25);
}
if(keys[KEY_KEY_A])
{
node->setAnimationSpeed(200);
node->setLoopMode(true);
node->setFrameLoop(1,14);
node->setPosition(node->getPosition()-vector3df(30,0,0));
node->setMD2Animation(scene::EMAT_RUN);
node->setRotation(core::vector3df(0.0f , 0.0f , 0.0f));
cam->setTarget(node->getPosition());
}
if(keys[KEY_KEY_D])
{
node->setCurrentFrame(1);
node->setAnimationSpeed(200);
node->setLoopMode(true);
node->setFrameLoop(1,14);
node->setPosition(node->getPosition()+vector3df(30,0,0));
node->updateAbsolutePosition();
node->setRotation(core::vector3df(0.0f , 90.0f , 0.0f));
cam->setTarget(node->getPosition());
}
if(keys[KEY_KEY_W])
{
node->setAnimationSpeed(200);
node->setLoopMode(true);
node->setFrameLoop(1,14);
node->setPosition(node->getPosition()-vector3df(0,0,30));
node->setRotation(core::vector3df(0.0f , 180.0f , 0.0f));
cam->setTarget(node->getPosition()+vector3df(4,0,0));
}
if(keys[KEY_KEY_Z])
{
node->setFrameLoop(45,59);
cam->setTarget(node->getPosition());
}
video->beginScene(true,true, video::SColor(245,0,1,255));
smgr->drawAll();
video->endScene();
}
}