Moved camera...

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Texel
Posts: 3
Joined: Tue May 18, 2004 1:11 pm
Location: Russia
Contact:

Moved camera...

Post by Texel »

How to make in order to the camera moved forward to the left button of the mouse at the press?
Oz
Posts: 81
Joined: Tue Aug 31, 2004 3:34 pm

Post by Oz »

smgr->addCameraSceneNodeMaya(0);

Allows the camera to be controlled using the mouse. Both mousebuttons + left-right movements are in/out or backward/forward.

But I think what your asking is how to get the IN vector of the camera then add it to its position. Im not sure how to do that yet, ill take a look ...

EDIT: Golly, this was easy with Genesis3D!

geXForm3d_GetIn(&cameramatrix, &in);
geVec3d_AddScaled(&cameratranslation, &in, movespeed);

/* this is essentially a 'standard' 4x4 transform matrix,
with the bottom row always 0,0,0,1

| AX, AY, AZ, Translation.X |
| BX, BY, BZ, Translation.Y |
| CX, CY, CZ, Translation.Z |
| 0, 0, 0, 1 |
*/

The in vector is (Genesis3D)
In.X = -Matrix.AZ;
In.Y = -Matrix.BZ;
In.Z = -Matrix.CZ;

Since my head is about to explode ill also ask a question which could be brain-dead simple. (so in the wrong forum, but hey)

In IrrLicht, how do you get the In vector from a matrix? :?
"When we looked at the relics of the precursors, we saw what heights civilization can attain.
When we looked at their ruins, we marked the danger of that height." -Keeper Annals
(Thief2: The Metal Age)
Texel
Posts: 3
Joined: Tue May 18, 2004 1:11 pm
Location: Russia
Contact:

Post by Texel »

It is an old piece of a code

Code: Select all

core::vector3df  vec;
vec = smgr->getActiveCamera()->getPosition();
vec += core::vector3df(5,0,5);
smgr->getActiveCamera()->setPosition(vec);

One more variant

Code: Select all

// get line of camera

core::vector3df start = global_camera->getPosition();
core::vector3df end = (global_camera->getTarget() - start);
end.normalize();
end = start + (end * global_camera->getFarValue());

core::line3d<f32> line(start, end);
And then I do not know as to do(make)...
If there was getRotation() in degrees.
Oz
Posts: 81
Joined: Tue Aug 31, 2004 3:34 pm

Post by Oz »

LOL took me a while to figure out the In vector. Im rusty :oops:

Code: Select all

	matrix4 cameramatrix = camera->getRelativeTransformation();

		/*
		0  1  2  3
		4  5  6  7
		8  9  10 11
		12 13 14 15
		*/

	vector3df	in(	cameramatrix.M[8],
					cameramatrix.M[9],
					cameramatrix.M[10]);
	vector3df pos = camera->getPosition();

	pos += in;
	camera->setPosition(pos);
Put that in your event reciever for your left-mouse button.

Hope this helps!

EDIT: BTW I just answered my own question too, it was fun! :)
EDIT2:
Look here too
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3708
"When we looked at the relics of the precursors, we saw what heights civilization can attain.
When we looked at their ruins, we marked the danger of that height." -Keeper Annals
(Thief2: The Metal Age)
Oz-not logged in

Post by Oz-not logged in »

I hope someone will explain what I meant to you (in Russian)

If I didnt help, ask again.
Texel
Posts: 3
Joined: Tue May 18, 2004 1:11 pm
Location: Russia
Contact:

Post by Texel »

The thank!!!
This code works! =)))))
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

basically the camera's Z axis is its front
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

basically the camera's Z axis is its front
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Post Reply