Help needed , WIP included

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
gershon
Posts: 10
Joined: Tue Aug 30, 2005 7:50 pm
Location: Israel

Help needed , WIP included

Post by gershon »

http://rapidsharing.com/show.php/570_new.zip
(DLL not included)

hey all,
new to irrlicht, but going along pretty good 10x to this forum!
been fiddling with this for a few days now..

my camera needs a lot of work, if any1 could recommend one of the cameras on this forum...

hmmm... physics not fully implement...

see the stupid arrow? its my biggest problem right now.
i want this to be some sort of navigational gizmo in the upper middle of the screen,
i thought i'd just child it to the camera, and make it point to a target.

doest work! :x maybe its my camera code..
any alternative? 10x.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

why not look at thsi function(do some reasearch before posting plz)


core::vector3df getTargetAngle(core::vector3df v, core::vector3df r)
{
#define PI 3.14159265358979323846
//v -position
//r -target

core::vector3df angle;
float x,y,z;
x = r.X - v.X;
y = r.Y - v.Y;
z = r.Z - v.Z;

//angle in X-Z plane
angle.Y = atan2 (x, z);
angle.Y *= (180 / PI); //converting from rad to degrees

//angle.Y-=90;
//just making sure angle is somewhere between 0-360 degrees
if(angle.Y < 0) angle.Y += 360;
if(angle.Y >= 360) angle.Y -= 360;

//angle in Y-Z plane while Z and X axes are already rotated around Y
float z1 = sqrt(x*x + z*z);

angle.X = atan2 (z1, y);
angle.X *= (180 / PI); //converting from rad to degrees

//angle.X -= 90;
//just making sure angle is somewhere between 0-360 degrees
if(angle.X < 0) angle.X += 360;
if(angle.X >= 360) angle.X -= 360;


return angle;

}
gershon
Posts: 10
Joined: Tue Aug 30, 2005 7:50 pm
Location: Israel

Post by gershon »

i'm sorry, didnt get it...
and where could i research?
10x
Guest

Post by Guest »

You can utlise the search function or look in the faq section or the wiki
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

if u dont get this function learn more C++

v=cammera pos r=target pos

apply the rotation angle to the arrow thing

core::vector3df getTargetAngle(core::vector3df v, core::vector3df r)
gershon
Posts: 10
Joined: Tue Aug 30, 2005 7:50 pm
Location: Israel

Post by gershon »

hmm... yeah... i think i googled before :?

anyway, i thought maybe buildCameraLookAtMatrixRH() could help me here but i'm still lost...


HELP!
Same same but diffrent.
omaremad_guest

Post by omaremad_guest »

Use the function i gave you.

vector3df arrowangle=core::vector3df getTargetAngle(camera->getAbsolutePosition(), camera->getAbsolutePosition());

arrow->setRotation(arrowangle);

put in update loop
Guest

Post by Guest »

i meant this

vector3df arrowangle=core::vector3df getTargetAngle(camera->getAbsolutePosition(), target->getAbsolutePosition());

arrow->setRotation(arrowangle);
gershon
Posts: 10
Joined: Tue Aug 30, 2005 7:50 pm
Location: Israel

Post by gershon »

but what about its position?
Same same but diffrent.
gershon
Posts: 10
Joined: Tue Aug 30, 2005 7:50 pm
Location: Israel

Post by gershon »

well, kinda solved I guess...

i used the above function to set camera rotation, which being targeted has'nt got any of its own, hence the arrow was just sitting still.

took me while...

so:

cam->setRotation ( getTargetAngle(cam->getPosition(), cam->getTarget() );


just keep in mind that now if you arrow->setPosition(), it will translate with camera's orientation.

hope this made sense.
Same same but diffrent.
Post Reply