Philipp Roßberger wrote:
> Am 30.05.2007, 14:12 Uhr, schrieb Marcus Lindblom <[EMAIL PROTECTED]>:
>
>   
>> Philipp Roßberger wrote:
>>     
>>> 1) Coordinate system differences
>>>
>>> OpenSG and PhysX coordinate systems' use different axis orientations.
>>> While the coordinate system in OpenSG looks like this
>>>
>>>       z
>>>       ^  y
>>>       |  ^
>>>       | /
>>>       -----> x
>>>
>>>
>>> the coordinate system in PhysX looks like this:
>>>
>>>          y
>>>          ^  z
>>>          |  ^
>>>          | /
>>> x <-----
>>>       
>> Both are righthand system. Does this PhysX care about the "front" of an
>> object? (OpenSG does for the camera & lights, but little else, I think)
>>     
> So far I didn't find anything in PhysX where an object front is defined.
>   
Ok. Maybe it's up or right? Or if PhysX doesn't care about that, what is 
the actual problem?

What I'm getting at, is, that you might be able to use OpenSG 
coordinates within PhysX? (i.e. just set the gravity to be in -z).
>> In any case, it's not hard to transform back-and-forth between these, is  
>> it?
>>     
> Not really. Here a short example, that shows how I use values computed by  
> the PhysX engine to transform OpenSG objects:
>
> //PhysX part
> NxVec3 pointerPos = pointer->getGlobalPosition();
> NxQuat pointerRot = pointer->getGlobalOrientationQuat();
>
> //OpenSG part
> mPointer.setTranslate(-pointerPos.x, pointerPos.z, pointerPos.y);
> mPointer.setTransform(Vec3f(-pointerPos.x, pointerPos.z, pointerPos.y),  
> Quaternion(Vec3f (-pointerRot.x, pointerRot.z, pointerRot.y),   
> pointerRot.w));
>   
Either that, or you could define a matrix which rotates from one system 
to the other:

static OSG::Matrix msPhysXtoOpenSGmtx(...);

mPointer.setTransform(PointerPos, Quaternion(PointerRot));
mPointer.mult(msPhysXtoOpenSGmtx); // or multLeft() perhaps

It's a basis change matrix, so either build it from two rotation 
matrices (it looks like it could be done that way) or set the bases 
directly. I.e. set each of the first three columns to each x,y,z vector 
of the other coordinate system, or vice versa (I can never remember 
which way it goes. :)

It's a bit tricky, but you should be able to get it done. Understanding 
transformation matrices well will make your life a lot easier, so read 
up on it if you feel you need it. (I don't know enough either, as you 
can see.)
>>> 2) Object scaling
>>>
>>> Objects instantiated in PhysX with default scaling are twice the size as
>>> their OpenSG counterparts. Here an example:
>>>
>>> Box in OpenSG | Box in PhysX
>>> -----------------------------
>>>       1,1,1    =  0.5,0.5,0.5
>>>
>>>       
>> Yup. Primitives in OpenSG are unit sized, they do not have unit-coords.
>> I don't know which is better actually. :)
>>     
> PhysX parameters are set up by default assuming 1 unit = 1 meter. I am  
> wondering what would be the best way to make sure, that scaling in OpenSG  
> and PhysX is equal. I was thinking about experimenting with the raycast  
> methods in OpenSG and PhysX. Any better ideas?
>   
Right. However, OpenSG doens't care about units. So if you want one unit 
to be one meter, that's perfectly ok. (You could have an OpenSG unit be 
one furlong as well, but that's just weird :-)

I think this problem is just a mismatch between the vertex values of 
each library's box-primitives. Without knowing what you are doing in 
detail, these are some ideas:

* Make your own boxes in OpenSG, with correct values. (might be simpler 
& probably faster, if you can do this)
* Export the OpenSG box to PhysX, as a generic mesh. (avoids any such 
problem, but generic meshes might be slower in PhysX)
> By the way: is there a method in OpenSG that allows you to convert world  
> coordinates into the local coordinate system of an OpenSG body? I need  
> this to create joints between objects. The anchor points of certain joints  
> in PhysX are defined in the local coordinate system of individual bodies.
>   
Yes. The inverse of the toWorld() transform will do that, i.e:

OSG::Matrix fromWorld;
node->getToWorld().inverse(fromWorld);

Pnt3f localCoord = fromWorld.mult(worldCoord);

Cheers
/Marcus

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to