Help with Bone manipulations

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.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Help with Bone manipulations

Post by shadowslair »

Hi! It`s me again.

I decided to stop filling night_hawk`s PhysX topic with my endless questions, that`s why I created this one.

Here`s what I did so far. It`s almost nothing, although it took me about 5-6 hours... :oops:

== Link deleted ==

This is the code I used. I know that using "setGlobalPosition()" is a childish
solution, so may I ask you which PhysX function should I use to get non-physical alike type of movement?

Code: Select all

angle+=((keys[KEY_KEY_D])-(keys[KEY_KEY_A]))*3;   
	

float mforce=((keys[KEY_KEY_W])-(keys[KEY_KEY_S]))*5;
	     

core::vector3df theposvec;

NxVec3 curposition=Nodes[0]->GetActor()->getGlobalPosition();
NxVec3 aimposition (  (cos(((angle)*PI)/180))*mforce, 0, (-sin(((angle)*PI)/180))*mforce );


Nodes[0]->GetActor()->setGlobalPosition(NxVec3 (curposition+aimposition));


In the beggining 5 boxes, 5 spheres and 5 capsules are created. There isn`t an Irr node capsule mesh ( and it would be insane to have such ), that`s why I used box mesh for them. I wanna ask how can I create a character dummy( capsule or ellipsoid) standing tall. Should I use joints for that?

Ahh, and currently the physics box, represnting the character isn`t rotating. How can I rotate it to "match" the visible "character"?


PS: I`m getting about 80 fps on AMD 1,14Ghz, 512Ram, 128 Ati radeon
Last edited by shadowslair on Sun Apr 27, 2008 2:00 pm, edited 5 times in total.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Have you looked at NxCharacter? There's a tutorial which shows you how to use character controllers which i've started using myself as my previous setup allowed my NPCs and camera to force their way through walls and objects!
Image Image Image
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Do you mean the source and header files in the PhysX SDK? If so I`ll check them tomorrow, `cause here`s getting too late. If not, please send a link to the tutorial. :)

And what is the function you use to move your character? For example "AddForce()" etc. Or using a character controller uses different/better functions? :roll:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

I`m trying to figure out what`s wrong with this EventReceiver initialization...
Last edited by shadowslair on Mon Jun 09, 2008 8:30 pm, edited 1 time in total.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Ok, it seems that there aren`t so many people using PhysX...

Anyone help on the Event Receiver problem? :(

PS: Sorry for double posting, but I still cannot make it work/compile...
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
PeterWelzien
Posts: 6
Joined: Thu Mar 20, 2008 9:04 am
Location: Sweden

Post by PeterWelzien »

I believe it should be

Code: Select all

OnEvent(SEvent event &)
/Peter Welzien
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yeah, almost. Should also have a const somewhere before the & of the parameter.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Thanks for the reply.

I tried almost all combinations of:

Code: Select all

OnEvent(SEvent event &)

OnEvent(SEvent & event )

OnEvent(const SEvent & event )

OnEvent(const SEvent event & )
but it increses the number of the errors. Actually for which OnEvent should I use it? For the virtual bool in the header on for the bool in the source? And what is the sense of the "&"?

I belive it is may be due to a difference in the Irrlicht versions, so it has to be edited someways. Shall I give up? :cry:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The third one is the correct one, and both places have to be changed. This change was made for Irrlicht 1.4, so older versions do need the version without const and &.
The & means (in this case) a reference, so not the whole event structure is passed, but only a reference to the actual event which resides somewhere else. You can use the event as if it were a real SEvent struct, but changes will be back-propagated to the original event. Since we do not want to alter the event in this case, the parameter is a const &, hence we have the optimization of only passing a pointer instead of larger objects, but there's no change of the original event which was referenced (in fact you cannot change the event at all, even not locally).
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Hmm...

Code: Select all

 bool CApplication::OnEvent(const SEvent event&)
 
and

Code: Select all

virtual bool OnEvent(const SEvent event&);
I did it, hoping everything will be fine, but it gives me this:

Code: Select all

CApplication.cpp
d:\gamemaker\irrlicht\irr projects\capplication.h(15) : error C2143: syntax error : missing ',' before '&'
d:\gamemaker\irrlicht\irr projects\capplication.cpp(184) : fatal error C1903: unable to recover from previous error(s); stopping compilation
main.cpp
d:\gamemaker\irrlicht\irr projects\capplication.h(15) : error C2143: syntax error : missing ',' before '&'
d:\gamemaker\irrlicht\irr projects\main.cpp(11) : error C2259: 'CApplication' : cannot instantiate abstract class
        due to following members:
        'bool irr::IEventReceiver::OnEvent(const irr::SEvent &)' : is abstract
        d:\gamemaker\irrlicht\irrlicht-1.4\include\ieventreceiver.h(256) : see declaration of 'irr::IEventReceiver::OnEvent'
Generating Code...
This is really bad... I have no more ideas. I`ll better go to sleep- here`s about 2:10 AM... :lol:

When I do a clean build it is sucessful, but cannot run. Thanks for your efforts and time. Appreciated! =)
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Post by night_hawk »

shadowslair wrote:And what is the function you use to move your character? For example "AddForce()" etc. Or using a character controller uses different/better functions? :roll:
Well, depending on what you want, AddForce gives it a nice realistic touch. SetLinearVelocity (or something like that) makes it go directly in that direction, without acceleration.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Why not try the one hybrid told you was right instead of your own interpretation? ;)

OnEvent(const SEvent & event ), compare that to the one you've posted above, they're different.

Characters in Physx use a 'move' function which takes the direction you want them to move in (including/excluding gravity, as necessary) and then a post-simulation function call will update their position correctly based on other physics objects which they may have hit into. They can also push against other objects, or stop when they hit them or not collide with them at all.

The tutorial is in the SDK somewhere, not sure where but you should be able to find it.
Image Image Image
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

:shock:
Hahahaaaaa...

Shame on me! Seemingly I misread "the third" as "the fourth". Strage...
But not so strange for a person, trying to program at 2:10 AM... :lol:

Thanks a ton to:

hybrid
JP
night_hawk
PeterWelzien


You saved my life, guys! :D
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Post by night_hawk »

JP wrote:Characters in Physx use a 'move' function which takes the direction you want them to move in (including/excluding gravity, as necessary) and then a post-simulation function call will update their position correctly based on other physics objects which they may have hit into. They can also push against other objects, or stop when they hit them or not collide with them at all.
Yes, but the move functions are for kinematic actors. That's good if there's only one such actor, but imo, it's not so good when you want more of the same type.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

OK, now I have problems casting a PhysX ray towards screen coordinate.

My PhysX ray is taking two vectors- one for his origin, and another one specifying his direction (normalized).

I checked the docs, searched the forum and asked the good old Uncle Google, but still there isn`t a solution.

So, the nice question is "How can I do this"? Doing it in Irrlicht wasn`t a big deal, because of his build-in function. How about PhysX? Should I use the old matrix transformations or there is an easier way? :roll:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Post Reply