Page 1 of 3

Help with Bone manipulations

Posted: Sat Apr 12, 2008 5:07 pm
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

Posted: Sat Apr 12, 2008 8:47 pm
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!

Posted: Sat Apr 12, 2008 8:55 pm
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:

Posted: Sun Apr 13, 2008 9:56 am
by shadowslair
I`m trying to figure out what`s wrong with this EventReceiver initialization...

Posted: Sun Apr 13, 2008 6:11 pm
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...

Posted: Sun Apr 13, 2008 8:30 pm
by PeterWelzien
I believe it should be

Code: Select all

OnEvent(SEvent event &)

Posted: Sun Apr 13, 2008 9:07 pm
by hybrid
Yeah, almost. Should also have a const somewhere before the & of the parameter.

Posted: Sun Apr 13, 2008 9:46 pm
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:

Posted: Sun Apr 13, 2008 10:44 pm
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).

Posted: Sun Apr 13, 2008 11:18 pm
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! =)

Posted: Mon Apr 14, 2008 7:22 am
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.

Posted: Mon Apr 14, 2008 7:35 am
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.

Posted: Mon Apr 14, 2008 8:17 am
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

Posted: Tue Apr 15, 2008 1:02 pm
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.

Posted: Sat Apr 19, 2008 5:38 pm
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: