camera.. problem

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.
Rusty06
Posts: 11
Joined: Mon Jan 29, 2007 12:40 pm

camera.. problem

Post by Rusty06 »

ok, so ive got my camera in the scene, and in the constructor i told it to become a child of Bodymesh

Code: Select all

camera = smgr->addCameraSceneNode(bodynode);
but in my 'game' the camera moves with the "bodynode" but still looks at the center of the world :shock:

i need my camera to constantly be set at 1,1,0 position and 0,-90,0 rotation, Relative to Bodynode.. how can i do this?

Can you help?

Thanks
Rusty
RapchikProgrammer
Posts: 279
Joined: Fri Dec 24, 2004 6:37 pm

Post by RapchikProgrammer »

setRotation wont change the view of the camera, setTarget will! I think that is what you didnt know!
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

should the body not be a child of the camera ???
you made the camera a child of the body...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Rusty06
Posts: 11
Joined: Mon Jan 29, 2007 12:40 pm

Post by Rusty06 »

hmm... no i want to attach the camera to the body...

World
-BODY
--wheel
--wheel
--wheel
--wheel
--camera

I tryed set target but how to i set the target to 5 units infront of the body?

its for a camera inside a car...

Rusty
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

this depends on where ur car is looking intially.
lets asume it looks at (0,0,1)
then u would do the following:

vector3df lookat(0,0,1);
matrix4 mat;
mat.setTranslation(BODY->getAbsolutePosition());
mat.setRotationDegrees(BODY->getRotation());
mat.transformVector(lookat);

there you go....lookat is the point which your camera has to target.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Rusty06
Posts: 11
Joined: Mon Jan 29, 2007 12:40 pm

Post by Rusty06 »

204 'class irr::core::matrix4' has no member named 'transformVector'
:roll:

maby i explaned it wrong?

Image

i just need to find how to work out the position that is x units infront of the car.. then i can position the camera, attach it to the car and then use LookAt to make the camera look infront of the car..

Rusty
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

dude my last post is doing what u want....the only thing it didn't handel was positioning the camera...but i thought u could do that on your own.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Rusty06
Posts: 11
Joined: Mon Jan 29, 2007 12:40 pm

Post by Rusty06 »

but still, my camera is allways looking at the center of the world.. even when i move my camera or set another lookat function it still looks at the center of the world...

you never explaned what the parts of your code do.. could you explain them?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Code: Select all

core::vector3df fore(0, 0, 10);

// rotate so it points in the direction the car is facing
car->getAbsoluteTransformation().rotateVect(fore);

// add the camera position, so fore is 10 units in front of the camera
fore += camera->getAbsolutePosition();

// set the target
camera->setTarget(fore);
Last edited by vitek on Tue Jan 30, 2007 6:31 pm, edited 1 time in total.
Rusty06
Posts: 11
Joined: Mon Jan 29, 2007 12:40 pm

Post by Rusty06 »

aha! now i have a different problem.

that above code is working, but for some reason it dosent follow my car, instead it follows the position where the car's body node was first spawned..

getAbsoluteTransformation isnt working with my newton car

very strainge.. what should i do?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Not sure what you mean when you say it doesn't 'follow' your car. The camera should be a child of the car. It is my understanding that your newton callbacks should be used to update the position and rotation of the car. Are you doing that?

Travis
Rusty06
Posts: 11
Joined: Mon Jan 29, 2007 12:40 pm

Post by Rusty06 »

i dont know, im using the iphysics engine

what i mean is:

The camera loads into the scene, but when the car moves the camera dosent move with the car

maby i need to use some callbacks.. im totally loosing intrest now. i could do this in Ogre in 5 mins..
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

So why you don't use OGRE then ???


Travis is right, if the cam is a child of the car and the car moves then the cam also should move...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Rusty06 wrote:maby i need to use some callbacks.. im totally loosing intrest now. i could do this in Ogre in 5 mins..
I agree, 9 posts, one day, its completly worthless to continue on. Forget learning, the easy road is the way to go.

[/sarcasm]
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Yeah, right, why should I learn if its over my head and it doesn't fall from heaven anyways ?!?!? :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply