Hi folks, since my PhysX-related contract work is now finished (I will soon write about this in the projects forum, when I find some spare time), development time for the PhysX plugin is rare now, since I concentrate now on other tasks (its a commercial project, I am working on a level editor). Rojart sent me some code for cloth physics and as soon as I enabled the most of the PhysX foundation, I will work on it and fluid particles.

Here are the news about the last commit I made today:

  • change: all pXmat... functions were renamed to pXmat33..., since they deal with 3x3 rotation matrices and PhysX knows also 3x4 matrices (see below)
  • new: 3x4 matrix datatype NxMat34 (+functions). Combination of a 3x3 rotation matrix and a translation vector. Homogenous transform composed of a matrix and a vector. See functions below.
  • new: plane datatype NxPlane (+functions)
  • new: sphere datatype NxSphere (+functions)
  • added: NxSphericalJointFlag's
  • added: specific functions for manipulating spherical joints and its rotation axis, limits, etc. Can be used to simulate arm joints for ragdolls.
  • new: I was **SO** annoyed of not having trinary operators in Lite-C, so I added a custom function to the dll: float pXtrinary (BOOL b, float fTrue, float fFalse); NOTE: This is not part of the official PhysX SDK, but is quiet handy
  • new: pXvecDeb (NxVec3*, char* name, char* str) prints 'vec "name" xyz=(...)' into str (for debugging)
  • new: pXquatGetAngle (NxQuat* q, ANGLE* angle) converts a quaternion into a Gamestudio Euler-angle
  • new: pXquatDeb (NxQuat*, char* name, char* str) prints 'quat "name" xyzw=(%.3f, %.3f, %.3f, %.3f)' into str (for debugging)
  • internal: to mainstream the conversions between Gamestudio and PhysX and due to the introduction of Gamestudio structs that are data facades to the PhysX classes, new conversion classes have been introduced, which should bridge the gap between plain numeric conversions (Plain) from and to Gamestudio and conversions from Gamestudio worldspace to PhysX world space (World; X/Z swap of axis and rotation matrices) and percentages (Percent). Overloaded static member functions ::fromGs and ::toGs should serve the purpose. Seems to be more elegant than my previous approaches and definitely than the previous approaches by the original author of the plugin. Use this from now on!
  • internal: because of the renaming of the exported pXmat functions, the file pXmat.h/cpp was also renamed to pXmat33.h/cpp


New spherical joint functions:
Click to reveal..
NxJoint* pXconAddSphericalJoint (ENTITY* eFrom, VECTOR* pos, VECTOR* axis,
ENTITY* eTo, BOOL collision,
float swingLimit, float swingRestitution,
float twistLowLimit, float twistLowRestitution,
float twistHighLimit, float twistHighRestitution);

// swing limit axis defined in the joint space of the first actor
NxJoint* pXconSetSphericalJointSwingAxis (NxJoint*, NxVec3* axis);

// distance above which to project joint
NxJoint* pXconSetSphericalJointProjectionDistance (NxJoint*, float dist);

// limits rotation around twist and swing axis
NxJoint* pXconSetSphericalJointTwistLimit (NxJoint*, float lowAngle, float lowRestitution, float highAngle, float highRestitution);
NxJoint* pXconSetSphericalJointSwingLimit (NxJoint*, float angle, float restitution);

// spring that works against twisting / swinging
NxJoint* pXconSetSphericalJointTwistSpring (NxJoint*, float spring, float damper, float targetAngle);
NxJoint* pXconSetSphericalJointSwingSpring (NxJoint*, float spring, float damper, float targetAngle);

// spring that lets the joint get pulled apart
NxJoint* pXconSetSphericalJointSpring (NxJoint*, float spring, float damper, float targetDistance);

// sets/gets the flags to enable/disable the spring/motor/limit (see NxSphericalJointFlag)
NxJoint* pXconSetSphericalJointFlags (NxJoint*, NxSphericalJointFlag flags);
long pXconGetSphericalJointFlags (NxJoint*);

// use this to set/get the joint projection mode
NxJoint* pXconSetSphericalJointProjectionMode (NxJoint*, NxJointProjectionMode projectionMode);
NxJointProjectionMode pXconGetSphericalJointProjectionMode (NxJoint*);


New 3x4 matrix (homogenous transform) functions:
Click to reveal..
// by default m is inited and t isn't. Use bInitialized = true to init in full
NxMat34* pXmat34create (BOOL bInitialized);
NxMat34* pXmat34createRT (NxMat33* rot, NxVec3* trans);

NxMat34* pXmat34zero (NxMat34* m);

NxMat34* pXmat34id (NxMat34* m);

// returns true for identity matrix
BOOL pXmat34isIdentity (NxMat34* m);

// returns true if all elems are finite (not NAN or INF, etc.)
BOOL pXmat34isFinite (NxMat34* m);

// assigns inverse to dest
NxMat34* pXmat34isFinite (NxMat34* m, NxMat34* dest);

// same as pXmat34getInverse, but assumes that M is orthonormal
BOOL pXmat34getInverseRT (NxMat34* m, NxMat34* dest);

// m = left * right
NxMat34* pXmat34multiply (NxMat34* m, NxMat34* left, NxMat34* right);

// dst = m * src
NxVec3* pXmat34multiplyVec (NxMat34* m, NxVec3* src, NxVec3* dst);

// dst = inverse(this) * src - assumes that m is rotation matrix!!!
NxVec3* pXmat34multiplyByInverseRT (NxMat34* m, NxVec3* src, NxVec3* dst);

// this = inverse(left) * right - assumes m is rotation matrix!!!
NxMat34* pXmat34multiplyInverseRTLeft (NxMat34* m, NxMat34* left, NxMat34* right);

// this = left * inverse(right) -- assumes m is rotation matrix!!!
NxMat34* pXmat34multiplyInverseRTRight (NxMat34* m, NxMat34* left, NxMat34* right);

// convert from a matrix format appropriate for rendering
NxMat34* pXmat34setColumnMajor44 (NxMat34* m, float* f);
float* pXmat34getColumnMajor44 (NxMat34* m, float* f);

// set the matrix given a row major matrix
NxMat34* pXmat34setRowMajor44 (NxMat34* m, float* f);
float* pXmat34getRowMajor44 (NxMat34* m, float* f);


New plane functions:
Click to reveal..
// constructors
NxPlane* pXplaneCreate ();
NxPlane* pXplaneCreateNormalDist (NxVec3* n, float d); // normal & dist
NxPlane* pXplaneCreateNormalXYZDist (float nx, float ny, float nz, float d); // normal & dist
NxPlane* pXplaneCreatePointNormal (NxVec3* p, NxVec3* n); // point on the plane & normal
NxPlane* pXplaneCreatePoints (NxVec3* p0, NxVec3* p1, NxVec3* p2); // from 3 points
NxPlane* pXplaneCreateCopy (NxPlane* p); // copy constructor

// sets plane to zero
NxPlane* pXplaneZero (NxPlane* p);

NxPlane* pXplaneSetNormalDist (NxPlane* p, NxVec3* n, float d);
NxPlane* pXplaneSetNormalXYZDist (NxPlane* p, float nx, float ny, float nz, float d);
NxPlane* pXplaneSetPointNormal (NxPlane* p, NxVec3* pt, NxVec3* n);
NxPlane* pXplaneSetPoints (NxPlane* p, NxVec3* p0, NxVec3* p1, NxVec3* p2);

float pXplaneDistance (NxPlane* p, NxVec3* pt);

BOOL pXplaneBelongs (NxPlane* p, NxVec3* pt);

// projects p into the plane
NxVec3* pXplaneProject (NxPlane* p, NxVec3* pt);

// find an arbitrary point in the plane
NxVec3* pXplaneFindPoint (NxPlane* p, NxVec3* pt);

NxPlane* pXplaneNormalize (NxPlane* p);

NxPlane* pXplaneTransform (NxPlane* p, NxMat34* transform, NxPlane* transformed);
NxPlane* pXplaneInverseTransform (NxPlane* p, NxMat34* transform, NxPlane* transformed);


New sphere functions:
Click to reveal..
// constructors
NxSphere* pXsphereCreate ();
NxSphere* pXsphereCreateInit (NxVec3* center, float radius);
NxSphere* pXsphereCreateCopy (NxSphere* s);

// checks the sphere is valid
BOOL pXsphereIsValid (NxSphere* s);

// tests if a point is contained within the sphere
BOOL pXsphereContainsVec (NxSphere* s, NxVec3* p);

// tests if another sphere is contained within the sphere
BOOL pXsphereContainsSphere (NxSphere* s, NxSphere* other);

// tests if a box is contained within the sphere
BOOL pXsphereContainsBox (NxSphere* s, NxVec3* vMin, NxVec3* vMax);

// tests if the sphere intersects another sphere
BOOL pXsphereIntersect (NxSphere* s, NxSphere* other);


You can download the dll + lib + header here: ackphysx.20111208.dll.h.lib.rar; you'll find the source as always on SVN.

So, this is essentially not a "big" release, but I hope you understand. I hope to make another release this year with the rest of the PhysX foundation and that it is useful for anyone.

Best regards,
-Christian

Last edited by HeelX; 12/08/11 21:58.