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.
Fy_Hertz
Posts: 6 Joined: Mon Nov 07, 2005 3:39 pm
Post
by Fy_Hertz » Wed Nov 09, 2005 12:04 am
Hi guys,
I'm trying to add a new virtual member to the ISceneNode class.
This is the fonction:
Code: Select all
virtual void Point(irr::core::vector3df Vec2,f32 Speed)
{
core::vector3df Vec = this*->getPosition();
Vec.X+=(Speed*((Vec2.X-Vec.X)/sqrt((Vec2.X-Vec.X)*(Vec2.X-Vec.X)+(Vec2.Z-Vec.Z)*(Vec2.Z-Vec.Z))));
Vec.Z+=(Speed*((Vec2.Z-Vec.Z)/sqrt((Vec2.X-Vec.X)*(Vec2.X-Vec.X)+(Vec2.Z-Vec.Z)*(Vec2.Z-Vec.Z))));
Vec.Y+=(Speed*((Vec2.Y-Vec.Y)/sqrt((Vec2.Y-Vec.Y)*(Vec2.Y-Vec.Y)+(Vec2.Z-Vec.Z)*(Vec2.Z-Vec.Z))));
this*->setPosition(Vec);
}
With this fonction the ISceneNode can follow a vector.
When i try to compile my program crash without any error: why ?
Otherwise, i can use this following fonction witch works correctly.
Code: Select all
void Point(irr::scene::ISceneNode* Node,irr::core::vector3df Vec2,f32 Speed)
{
core::vector3df Vec = Node->getPosition();
Vec.X+=(Speed*((Vec2.X-Vec.X)/sqrt((Vec2.X-Vec.X)*(Vec2.X-Vec.X)+(Vec2.Z-Vec.Z)*(Vec2.Z-Vec.Z))));
Vec.Z+=(Speed*((Vec2.Z-Vec.Z)/sqrt((Vec2.X-Vec.X)*(Vec2.X-Vec.X)+(Vec2.Z-Vec.Z)*(Vec2.Z-Vec.Z))));
Vec.Y+=(Speed*((Vec2.Y-Vec.Y)/sqrt((Vec2.Y-Vec.Y)*(Vec2.Y-Vec.Y)+(Vec2.Z-Vec.Z)*(Vec2.Z-Vec.Z))));
Node->setPosition(Vec);
}
++
"Un seul oiseau est en cage et la liberté est en deuil"
Guest
Post
by Guest » Wed Nov 09, 2005 1:49 am
core::vector3df Vec = this*->getPosition();
wtf you do here? this->getPosition
Spintz
Posts: 1688 Joined: Thu Nov 04, 2004 3:25 pm
Post
by Spintz » Wed Nov 09, 2005 3:04 am
it should just be getPosition and setPosition, no need for the this operator. However, when using the this operator, it is a pointer to yourself, so you could do this - (*this).getPosition, or this->getPosition. I'm unsure how this*->getPosition even compiles!
Fy_Hertz
Posts: 6 Joined: Mon Nov 07, 2005 3:39 pm
Post
by Fy_Hertz » Wed Nov 09, 2005 7:34 am
Okay, It works now but only if my function isn't virtual.
Actually this:
makes my program crash too !
Why do i can't add virutal fonction ?
"Un seul oiseau est en cage et la liberté est en deuil"
FlyHigh
Posts: 111 Joined: Wed Mar 23, 2005 12:05 am
Post
by FlyHigh » Wed Nov 09, 2005 10:57 am
You are linking against the correct (modified) library file and not the standard one arn't you?
Guest
Post
by Guest » Wed Nov 09, 2005 1:02 pm
PEOPLE!!! why dont you start learning c++ before you start coding games.... god damn it. but well, its your choice (you dont come far with that)
Fy_Hertz
Posts: 6 Joined: Mon Nov 07, 2005 3:39 pm
Post
by Fy_Hertz » Wed Nov 09, 2005 2:17 pm
heu... well... that's not going to help me
"Un seul oiseau est en cage et la liberté est en deuil"