Tutorials or API

paradoxer

31-08-2008 11:14:21

Has NxOgre them? If it has, please, send links.

TWO

31-08-2008 11:36:18

Search before you post!

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=7938

paradoxer

31-08-2008 11:39:00

I have studied that tutorials, I'm talking about others...

betajaen

31-08-2008 11:40:42

NxOgre.org.

paradoxer

31-08-2008 11:54:57

I was there and didn't find anything. Sorry, but can you post there exact link?

mcaden

31-08-2008 12:00:26

http://www.nxogre.org/what

and you can click "Code snippets" on the bottom.

Also you can use google's language tools to translate: http://ogre.irados.org/textos/bibliotecas/NxParte1.htm into your language of choice.

betajaen

31-08-2008 12:26:52

Don't forget the shortguide

http://www.nxogre.org/shortguide

paradoxer

31-08-2008 12:40:52

Sorry, an answer about the cooking and buffering. Are they same like in PhysX?

betajaen

31-08-2008 12:48:39

No, both are handled through NxOgre via various classes.

See Flour and pages like these.

paradoxer

31-08-2008 13:15:36

Thanks, and what about joints?

betajaen

31-08-2008 13:28:25

Most of them wrapped, it's all on NxOgre.org

paradoxer

31-08-2008 13:35:08

ok

mcaden

02-09-2008 09:50:34

Just thought this one should be added, I just found it. It was created by Gugus, although it doesn't really have anything advanced with it.

http://easy3dgames.tuxfamily.org/tuto.php?id=2-51

paradoxer

07-09-2008 13:17:26

2 betajaen:
Well, can you post there a function, which convert Quanternion from PhysX to Ogre. I have created the project with PhysX but I can't solve the problem with orientation.



Number 1: PhysX model in Ogre
Number 3: Ogre model with bones
Number 2: Ogre model, which was combined with PhysX model.

Thanks.

P.S.: Just my point of view - if you remake the PhysX tutorials it will be great.

paradoxer

07-09-2008 13:33:16

There is my project:

PhysX-Ogre_person.rar - 8 Mb

paradoxer

10-09-2008 16:11:15

Need help :roll:
Well, maybe I explaned my problem not very well... So, when I set orientation of the ogre objects, I haven't got any problems, but if I set orientation of bones, its quanternion isn't the same like PhysX bones.



This picture is rather old, I haven't got so big problems now.

xadh00m

10-09-2008 22:29:06

Come on! Some code could help. I had much issues with ragdolls last week, but
with only that picture I cannot give any reasonable advise...

paradoxer

11-09-2008 16:47:01

Well, I don't know what to say....
please, look at the first page.

xadh00m:
Give me your ICQ, please.

paradoxer

12-09-2008 15:27:33

This code is beta:

#include "ExampleApplication.h"
#include "NxPhysics.h"
#include "NxCooking.h"
#include "Stream.h"
#include "NXU_helper.h"

inline Vector3 toOgre(const NxVec3 &v) {
return Vector3(v.x, v.y, v.z);
}

inline NxVec3 toNx(const Vector3 &v) {
return NxVec3(v.x, v.y, v.z);
}

inline Quaternion toOgre(const NxQuat &q) {
return Quaternion(q.w, q.x, q.y, q.z);
}

inline NxQuat toNx(Quaternion& q, bool _normalise = true) {
if (_normalise) q.normalise();
NxQuat a; a.x = q.x; a.y = q.y; a.z = q.z; a.w = q.w;
return a;
}

struct Atom
{
NxActor *actor;
SceneNode *node;
};

class PhysXFrameListener: public ExampleFrameListener
{
private:
SceneManager* mSceneMgr;
NxPhysicsSDK *PxSDK;
NxScene *PxScene;
std::vector<NxActor*> atoms;
std::vector<SceneNode*> nodes;
int AtomID;
String nameOfBone[12];
Entity *ent;
SceneNode *node;
Skeleton *skel;

public:
PhysXFrameListener( RenderWindow* win, Camera* cam, SceneManager *sceneMgr )
: ExampleFrameListener(win, cam), mSceneMgr(sceneMgr)
{
int dis = 100;
initializePhysX();
createPhysicScene();

ent = mSceneMgr->createEntity("www","Body.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(-100,0,0));
node->attachObject(ent);

ent = mSceneMgr->createEntity("www1","Body.mesh");
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,0,0));
node->attachObject(ent);

skel = ent->getSkeleton();
for (int i = 0; i < 24; i++)
skel->getBone(i)->setManuallyControlled(true);

nameOfBone[0] = "L_Calf";
nameOfBone[1] = "L_Thigh";
nameOfBone[2] = "R_Calf";
nameOfBone[3] = "R_Thigh";
nameOfBone[4] = "Pelvis";
nameOfBone[5] = "Spine";
nameOfBone[6] = "Spine1";
nameOfBone[7] = "L_UpperArm";
nameOfBone[8] = "L_Forearm";
nameOfBone[9] = "R_UpperArm";
nameOfBone[10] = "R_Forearm";
nameOfBone[11] = "Head";

createPers(0);

}

void createPers(int i)
{
int dis = 30;

createBody(nameOfBone[0], Vector3(0,0 + dis,0), i);
createBody(nameOfBone[1], Vector3(0,20 + dis,0), i);

createCalfJoint(atoms[0],atoms[1],NxVec3(1,0,0), NxVec3(0,11 + dis,0));

createBody(nameOfBone[2], Vector3(7.5,0 + dis,0), i);
createBody(nameOfBone[3], Vector3(7.5,20 + dis,0), i);

createCalfJoint(atoms[2],atoms[3],NxVec3(1,0,0), NxVec3(7.5,11 + dis,0));

createBody(nameOfBone[4], Vector3(3.5,30 + dis,0), i);

createThingJoint(atoms[1],atoms[4],NxVec3(1,0,0), NxVec3(0,30 + dis,0));
createThingJoint(atoms[3],atoms[4],NxVec3(1,0,0), NxVec3(7.5,30 + dis,0));

createBody(nameOfBone[5], Vector3(3.8,36 + dis,0), i);
createPelvisJoint(atoms[4],atoms[5],NxVec3(1,0,0), NxVec3(3.8,36 + dis,0));

createBody(nameOfBone[6], Vector3(3.8,45 + dis,0), i);
createSpine1Joint(atoms[5],atoms[6],NxVec3(1,0,0), NxVec3(3.8,45 + dis,0));

createBody(nameOfBone[7], Vector3(17,47 + dis,-4), i);
createClavicleJoint(atoms[6],atoms[7],NxVec3(0,1,0), NxVec3(13,47 + dis,0));

createBody(nameOfBone[8], Vector3(32,47 + dis,-4), i);
createUpperArmJoint(atoms[7],atoms[8],NxVec3(0,1,0), NxVec3(22,47 + dis,0));


createBody(nameOfBone[9], Vector3(-9,47 + dis,-4), i);
createClavicleJoint(atoms[6],atoms[9],NxVec3(0,-1,0), NxVec3(-5,47 + dis,0));

createBody(nameOfBone[10], Vector3(-24,47 + dis,-4), i);
createUpperArmJoint(atoms[9],atoms[10],NxVec3(0,-1,0), NxVec3(-14,47 + dis,0));

createBody(nameOfBone[11], Vector3(4,55 + dis,0), i);
createHeadJoint(atoms[6],atoms[11],NxVec3(0,1,0), NxVec3(3,53 + dis,0));

//for (int i = 0; i < 12; i++)
// atoms->raiseBodyFlag(NX_BF_KINEMATIC);

}

void createCalfJoint(NxActor *actor0, NxActor *actor1, NxVec3 globalAxis, NxVec3 globalAnchor)
{

NxD6JointDesc d6Desc;
d6Desc.actor[0] = actor0;
d6Desc.actor[1] = actor1;

d6Desc.setGlobalAnchor(globalAnchor);
d6Desc.setGlobalAxis(globalAxis);

d6Desc.twistMotion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing1Motion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.swing2Motion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.projectionMode = NX_JPM_NONE;

d6Desc.twistLimit.low.value = -0.9*NxPi;
d6Desc.twistLimit.low.restitution = 0;
d6Desc.twistLimit.low.spring = 0;
d6Desc.twistLimit.low.damping = 0;

d6Desc.twistLimit.high.value = 0*NxPi;
d6Desc.twistLimit.high.restitution = 0;

NxJoint* d6Joint = PxScene->createJoint(d6Desc);
}

void createThingJoint(NxActor *actor0, NxActor *actor1, NxVec3 globalAxis, NxVec3 globalAnchor)
{

NxD6JointDesc d6Desc;
d6Desc.actor[0] = actor0;
d6Desc.actor[1] = actor1;

d6Desc.setGlobalAnchor(globalAnchor);
d6Desc.setGlobalAxis(globalAxis);

d6Desc.twistMotion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing1Motion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing2Motion = NX_D6JOINT_MOTION_LIMITED;

d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.projectionMode = NX_JPM_NONE;

d6Desc.swing1Limit.value = 0.1*NxPi;
d6Desc.swing1Limit.restitution = 0;
d6Desc.swing1Limit.spring = 0;
d6Desc.swing1Limit.damping = 0;

d6Desc.swing2Limit.value = 0.1*NxPi;
d6Desc.swing2Limit.restitution = 0;
d6Desc.swing2Limit.spring = 0;
d6Desc.swing2Limit.damping = 0;

d6Desc.twistLimit.low.value = -0.5*NxPi;
d6Desc.twistLimit.low.restitution = 0;
d6Desc.twistLimit.low.spring = 0;
d6Desc.twistLimit.low.damping = 0;

d6Desc.twistLimit.high.value = 0.3*NxPi;
d6Desc.twistLimit.high.restitution = 0;
d6Desc.driveOrientation.rotate(NxVec3(1,-1,0));


NxJoint* d6Joint = PxScene->createJoint(d6Desc);
}

void createPelvisJoint(NxActor *actor0, NxActor *actor1, NxVec3 globalAxis, NxVec3 globalAnchor)
{

NxD6JointDesc d6Desc;
d6Desc.actor[0] = actor0;
d6Desc.actor[1] = actor1;

d6Desc.setGlobalAnchor(globalAnchor);
d6Desc.setGlobalAxis(globalAxis);

d6Desc.twistMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.swing1Motion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing2Motion = NX_D6JOINT_MOTION_LIMITED;

d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.projectionMode = NX_JPM_NONE;

d6Desc.swing2Limit.value = 0.02*NxPi;
d6Desc.swing2Limit.restitution = 0;
d6Desc.swing2Limit.spring = 0;
d6Desc.swing2Limit.damping = 0;

d6Desc.twistLimit.low.value = -0.02*NxPi;
d6Desc.twistLimit.low.restitution = 0;
d6Desc.twistLimit.low.spring = 0;
d6Desc.twistLimit.low.damping = 0;

d6Desc.twistLimit.high.value = 0.04*NxPi;
d6Desc.twistLimit.high.restitution = 0;
d6Desc.driveOrientation.rotate(NxVec3(1,-1,0));


NxJoint* d6Joint = PxScene->createJoint(d6Desc);
}

void createSpine1Joint(NxActor *actor0, NxActor *actor1, NxVec3 globalAxis, NxVec3 globalAnchor)
{

NxD6JointDesc d6Desc;
d6Desc.actor[0] = actor0;
d6Desc.actor[1] = actor1;

d6Desc.setGlobalAnchor(globalAnchor);
d6Desc.setGlobalAxis(globalAxis);

d6Desc.twistMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.swing1Motion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing2Motion = NX_D6JOINT_MOTION_LIMITED;

d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.projectionMode = NX_JPM_NONE;

d6Desc.swing2Limit.value = 0.02*NxPi;
d6Desc.swing2Limit.restitution = 0;
d6Desc.swing2Limit.spring = 0;
d6Desc.swing2Limit.damping = 0;

d6Desc.twistLimit.low.value = -0.02*NxPi;
d6Desc.twistLimit.low.restitution = 0;
d6Desc.twistLimit.low.spring = 0;
d6Desc.twistLimit.low.damping = 0;

d6Desc.twistLimit.high.value = 0.04*NxPi;
d6Desc.twistLimit.high.restitution = 0;
d6Desc.driveOrientation.rotate(NxVec3(1,-1,0));


NxJoint* d6Joint = PxScene->createJoint(d6Desc);
}

void createClavicleJoint(NxActor *actor0, NxActor *actor1, NxVec3 globalAxis, NxVec3 globalAnchor)
{

NxD6JointDesc d6Desc;
d6Desc.actor[0] = actor0;
d6Desc.actor[1] = actor1;

d6Desc.setGlobalAnchor(globalAnchor);
d6Desc.setGlobalAxis(globalAxis);

d6Desc.twistMotion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing1Motion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing2Motion = NX_D6JOINT_MOTION_LIMITED;

d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.projectionMode = NX_JPM_NONE;

d6Desc.swing1Limit.value = 1*NxPi;
d6Desc.swing1Limit.restitution = 0;
d6Desc.swing1Limit.spring = 0;
d6Desc.swing1Limit.damping = 0;

d6Desc.swing2Limit.value = 0.5*NxPi;
d6Desc.swing2Limit.restitution = 0;
d6Desc.swing2Limit.spring = 0;
d6Desc.swing2Limit.damping = 0;

d6Desc.twistLimit.low.value = -0.4*NxPi;
d6Desc.twistLimit.low.restitution = 0;
d6Desc.twistLimit.low.spring = 0;
d6Desc.twistLimit.low.damping = 0;

d6Desc.twistLimit.high.value = 1*NxPi;
d6Desc.twistLimit.high.restitution = 0;
d6Desc.driveOrientation.rotate(NxVec3(1,-1,0));


NxJoint* d6Joint = PxScene->createJoint(d6Desc);
}

void createUpperArmJoint(NxActor *actor0, NxActor *actor1, NxVec3 globalAxis, NxVec3 globalAnchor)
{

NxD6JointDesc d6Desc;
d6Desc.actor[0] = actor0;
d6Desc.actor[1] = actor1;

d6Desc.setGlobalAnchor(globalAnchor);
d6Desc.setGlobalAxis(globalAxis);

d6Desc.twistMotion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing1Motion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.swing2Motion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.projectionMode = NX_JPM_NONE;

d6Desc.twistLimit.low.value = -0.9*NxPi;
d6Desc.twistLimit.low.restitution = 0;
d6Desc.twistLimit.low.spring = 0;
d6Desc.twistLimit.low.damping = 0;

NxJoint* d6Joint = PxScene->createJoint(d6Desc);
}

void createHeadJoint(NxActor *actor0, NxActor *actor1, NxVec3 globalAxis, NxVec3 globalAnchor)
{

NxD6JointDesc d6Desc;
d6Desc.actor[0] = actor0;
d6Desc.actor[1] = actor1;

d6Desc.setGlobalAnchor(globalAnchor);
d6Desc.setGlobalAxis(globalAxis);

d6Desc.twistMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.swing1Motion = NX_D6JOINT_MOTION_LIMITED;
d6Desc.swing2Motion = NX_D6JOINT_MOTION_LIMITED;

d6Desc.xMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.yMotion = NX_D6JOINT_MOTION_LOCKED;
d6Desc.zMotion = NX_D6JOINT_MOTION_LOCKED;

d6Desc.projectionMode = NX_JPM_NONE;

d6Desc.swing2Limit.value = 0.6*NxPi;
d6Desc.swing2Limit.restitution = 0;
d6Desc.swing2Limit.spring = 0;
d6Desc.swing2Limit.damping = 0;

d6Desc.twistLimit.low.value = -0.9*NxPi;
d6Desc.twistLimit.low.restitution = 0;
d6Desc.twistLimit.low.spring = 0;
d6Desc.twistLimit.low.damping = 0;

d6Desc.twistLimit.high.value = 0.9*NxPi;
d6Desc.twistLimit.high.restitution = 0;
d6Desc.driveOrientation.rotate(NxVec3(1,-1,0));


NxJoint* d6Joint = PxScene->createJoint(d6Desc);
}

void createBody(String name, Vector3 pos, int i)
{
//Ñ

paradoxer

12-09-2008 15:34:31

Well, I have created body with bones, from files .mesh I create PhysX bodies, join them with D6Joints :) , and try to combine bones and physX models. But I have problemes with orientation of the bones. Look the first page.

2 betajaen:
Well, can you post there a function, which convert Quanternion from PhysX to Ogre. I have created the project with PhysX but I can't solve the problem with orientation.



Number 1: PhysX model in Ogre
Number 3: Ogre model with bones
Number 2: Ogre model, which was combined with PhysX model.

Thanks.

P.S.: Just my point of view - if you remake the PhysX tutorials it will be great.

mcaden

13-09-2008 14:01:31

Might help if the screenshots weren't pitch-black

paradoxer

14-09-2008 12:58:16

:cry:
I think, the problem is there:


inline Quaternion toOgre(const NxQuat &q) {
return Quaternion(q.w, q.x, q.y, q.z);
}


But I can't rewrite this function to set the right orientation

xadh00m

15-09-2008 08:59:21

Sorry! But I cannot figure out the problem within your pages of code yet.

Just as a hint:
I remind the offset between an ogre bone and the Physx actor (orientation and position). If I have to update my actor pose according to its corresponding bone I do the following:

void RagDoll::updateActors()
{
// get an iterator over the bone actor correspondence list
map<String, BoneActorPair*>::iterator pairIter = mBoneActorPairs.begin();
while(pairIter != mBoneActorPairs.end())
{
BoneActorPair* pair = (*pairIter).second;

// get bone position
Vector3 bonePosition = mCharacterEntity->getParentNode()->_getDerivedPosition() + mCharacterEntity->getParentNode()->_getDerivedOrientation() * pair->getBone()->_getDerivedPosition();

// get bone orientation
Quaternion globalBoneOrientation = mCharacterEntity->getParentNode()->_getDerivedOrientation() * pair->getBone()->_getDerivedOrientation();

//update actor
pair->getActor()->setGlobalPosition(bonePosition + globalBoneOrientation * pair->getBoneActorOrientationPose().getVector3());
pair->getActor()->setGlobalOrientation(globalBoneOrientation * pair->getBoneActorOrientationPose().getQuaternion());
pairIter++;
}
}


I hope this can help you a bit with transformations...

paradoxer

15-09-2008 16:52:40

xadh00m: thank you very much :) , I'll try it.

paradoxer

28-09-2008 16:17:41

And how can I assign the bone to th actor?

xadh00m

28-09-2008 21:13:13

I do this currently with Scythe and my custom importer which connects the actors as stored in the *.phs file. Thats just a temporary solution, because, Scythe has some bugs and is not supported anymore :cry: .

Maybe the new "Loader" for 3dsMax will soon be able to export these data...

paradoxer

29-09-2008 16:28:53

:( xadh00m, do you know some ragdolls, which were made by the PhysX team or other programmers?

Prophet

29-09-2008 21:27:19

Maybe the new "Loader" for 3dsMax will soon be able to export these data...Good idea! Too bad I have absolutely no experience with ragdolls and one week of experience with MaxScripting...

xadh00m

30-09-2008 09:04:28

:( xadh00m, do you know some ragdolls, which were made by the PhysX team or other programmers?

I´m not completely sure what you mean, but there is an Ragdoll example shipped with e.g. PhysX SDK 2.7.3 . Is it this what you want?

Good idea! Too bad I have absolutely no experience with ragdolls and one week of experience with MaxScripting...

If you want to get an idea on how this could be made look at Scythe! It is far
from perfect, but it worked within some limits. Basically it generates collision
shapes for every bone and links both together. The user has then to
transform every shape until they are at the right place. The link between a
bone and the collision shape and the transform offset between them are the
important information for an application as you can see in my posted method
above.

I think one critical aspect for your loader would be the ability to simulate the
Ragdoll to see, how it behaves. This was the best thing about Scythe!
I´m not sure how much effort is needed to use PhysX within 3DsMax.
I have some PlugIn experience with Maya and I know this could be done with
it, but I don´t know how this would work in 3dsMax...

Prophet

30-09-2008 09:27:57

Yes, I took a look at it yesterday and it looks really nice. Makes me wonder why I created the Loader... Anyway, I will definitely try to learn ragdolls, but I haven't tried anything with it so far, but it will be my next little project.
About simulation; as I said, I've had one week of trial and errors with MaxScript, so that feels miles away. But since Autodesk bought Maya, perhaps we could try and co-work something that works for both? I haven't tried Maya, so I don't know the differences between them, but from the screens I've seen they look quite identical.

xadh00m

30-09-2008 16:51:21

To make things clear: The approach I had in mind with Maya was a
whole PlugIn (C++ project). IMHO using PhysX would be easy with this approach.
Maybe such a simulation can also be made with scripts but I´m afraid there is
no way to use PhysX directly.

Scythe is a nice tool but if you work some time with it you see many bugs and
interface problems. Unfortunately the author did not use Maya, 3dsMax or the
Blender (so everyone can use it) as user interface to integrate a PhysX workflow
and invested month of work creating existing interfaces which are in part buggy...

And now Scythe is buried :(

This is the reason why I like your "Loader" approach as a first step.

Prophet

30-09-2008 17:20:43

Ah, sorry, I missed that.
This was really useful information. I didn't know about this. I will try and see if I can create a plug-in for 3ds Max, though I doubt it. Thanks a lot!