ok i put the pistol in front of the camera i can see it WHEN IT IS NOT PARENTED but when it is I cant see it.
my assumption is that the pistol is automatically put at the cameras center when i parented it so can i move with it but can i set its position while its parented? so i can see it
ok here is my code
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
IrrlichtDevice *device =
createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480), 16, false);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
device->getFileSystem()->addZipFileArchive("../media/map-20kdm2.pk3");
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* q3node = 0;
scene::IAnimatedMesh* pistol = smgr->getMesh("../media/pistol.3ds");
scene::ISceneNode* pistolnode = 0;
if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));
if (pistol)
pistolnode = smgr->addOctTreeSceneNode(pistol->getMesh(0));
scene::ITriangleSelector* selector = 0;
pistolnode->setPosition(core::vector3df(5,17,10));
if (q3node)
{
q3node->setPosition(core::vector3df(-1350,-140,-1410));
selector = smgr->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector);
}
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f, -1, 0, 0, true);
camera->setPosition(core::vector3df(0,50,0));
if (selector)
{
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-3,0),
core::vector3df(0,50,0));
selector->drop();
camera->addAnimator(anim);
anim->drop();
}
device->getCursorControl()->setVisible(false);
scene::ISceneNode* selectedSceneNode = 0;
scene::ISceneNode* lastSelectedSceneNode = 0;
pistolnode->setParent(camera);
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0);
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"test[";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}