If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Dances
Posts: 454 Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:
Post
by Dances » Sun Sep 04, 2005 4:59 am
I created a Camera but for some reason I can't get it to collide with the map. My character collides properly. My Camera is NOT a child of the character.
Code: Select all
//level params and set up as collideable
LevelTriangleSelector = irrSMgr->createOctTreeTriangleSelector(
Level->getMesh(0), LevelNode, 128);
LevelNode->setTriangleSelector(LevelTriangleSelector);
LevelTriangleSelector->drop();
//billboard for crosshair
CrosshairBillboard = irrSMgr->addBillboardSceneNode();
CrosshairBillboard->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
CrosshairBillboard->setMaterialTexture(0, irrDriver->getTexture("2d/crosshair.tga"));
CrosshairBillboard->setMaterialFlag(EMF_LIGHTING, false);
CrosshairBillboard->setSize(dimension2d<f32>(10.0f, 10.0f));
//character params and set up collision detection
CharacterNode->setMaterialFlag(EMF_LIGHTING, false);
CharacterNode->setFrameLoop(0, 310);
CharacterNode->setMaterialTexture(0, irrDriver->getTexture("textures/characters/sydney.bmp"));
CharacterNode->setPosition(vector3df(0,0,0));
ISceneNodeAnimator* CharacterAnimator = irrSMgr->createCollisionResponseAnimator(
LevelTriangleSelector, CharacterNode, vector3df(15,25,5),
vector3df(0,-3,0));
CharacterNode->addAnimator(CharacterAnimator);
CharacterAnimator->drop();
//create camera
ThirdPView = irrSMgr->addCameraSceneNode(0, vector3df(-60,0,0));
ISceneNodeAnimator* CameraAnimator = irrSMgr->createCollisionResponseAnimator(
LevelTriangleSelector, ThirdPView, vector3df(30,30,30),
vector3df(0,0,0));
ThirdPView->addAnimator(CameraAnimator);
CameraAnimator->drop();
Why wont it collide with anything?
Elise
Posts: 48 Joined: Tue Jul 19, 2005 6:30 am
Contact:
Post
by Elise » Sun Sep 04, 2005 8:19 am
How do you move the camera around?
Dances
Posts: 454 Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:
Post
by Dances » Sun Sep 04, 2005 4:18 pm
Code: Select all
void CharacterStuff::MouseLook() //Allow the mouse to control looking
{
if (EscMenu == false)
{
RelMousePos = irrDevice->getCursorControl()->getRelativePosition(); //Get Mouse Pos
if(RelMousePos.X != 0.5) //If Mouse's Pos is not at half of X screen width
{
vector3df r = CharacterNode->getRotation(); //Get Character's rotation
r.Y += (RelMousePos.X - 0.5) * 100.0f; //Rotate the character appropriately
CharacterNode->setRotation(r); //Set the character's rotation
irrDevice->getCursorControl()->setPosition(MousePos[0], MousePos[1]); //recenter mouse
}
if(RelMousePos.Y != 0.5) //If mouse's pos is not at half of Y screen width
{
r = ThirdPView->getRotation();
r.Y -= (RelMousePos.Y - 0.5) * 100.0f;
if (r.Y > 90)
r.Y = 90;
if (r.Y < -90)
r.Y = -90;
ThirdPView->setRotation(r);
irrDevice->getCursorControl()->setPosition(MousePos[0], MousePos[1]); //recentermouse
}
v = CharacterNode->getPosition();
r = CharacterNode->getRotation();
r2 = ThirdPView->getRotation();
CameraTranslate = cos(r2.Y*M_PI/180) * 100;
v.Z = v.Z + (sin(r.Y*M_PI/180) * CameraTranslate);
CameraTranslate = cos(r2.Y*M_PI/180) * 100;
v.X = v.X - (cos(r.Y*M_PI/180) * CameraTranslate);
v.Y = (v.Y - sin(r2.Y*M_PI/180) * 60) + 20;
ThirdPView->setPosition(v);
}
}
I also set its target in the main loop:
Code: Select all
v = CharacterNode->getPosition();
r = v;
r.Y += 20;
ThirdPView->setTarget(r);
I switched the variable to 'r' because I still use 'v' for other things.
Dances
Posts: 454 Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:
Post
by Dances » Mon Sep 05, 2005 7:52 pm
bump. Can no one help?
Zoulz
Posts: 12 Joined: Fri Aug 19, 2005 11:07 am
Location: Sweden
Contact:
Post
by Zoulz » Wed Sep 07, 2005 2:46 pm
Same problem I am having... =/
Guest
Post
by Guest » Fri Sep 30, 2005 6:14 pm
I'm doing this fine.
However, when I:
camMain->updateAbsolutePosition();
I goes through the "walls"
I used:
camMain->setPosition(pos);
To set the position.
It doesn't seem to matter much where in the main loop the camera position update is called.
Dunno if that helps.