ackphysx.dll community version

Posted By: HeelX

ackphysx.dll community version - 10/12/11 22:57

Hi,
as some may have noticed, I needed to modify the ackphysx.dll to add some things which were not yet implemented, like prismatic joints ( see here ).

I made it working under Visual Studio 2005 and since I am working on a project that relies on PhysX, I am currently developing it further. I hosted it over at SourceForge, because since JCL released the source of the ackphysx.dll for free, I do so, too:

PhysX for A8 SourceForge page

If you want just the updated ackphysx.dll and the header, just go to https://sourceforge.net/projects/a8physx...0header%20file/ and download the latest archive.

If you just want to get the whole source, checkout with SVN via http://svn.code.sf.net/p/a8physx/code/

You can also contribute new features if you like, for this you have to have a user account on SourceForge and then you can checkout and commit via SVN from/to https://svn.code.sf.net/p/a8physx/code

Here are the current list of additions / bugfixes / whatever:

-new: prismatic joints
-fixed: inverted axis used for limits on slider/prismatic joints
- pXcon_getposition returned radians instead of degrees (fixed)
- added: BOOL pXconGetPrismaticLimits (ENTITY* e, VECTOR* vInit, VECTOR* vLimitForw, VECTOR* vLimitBackw), which fetches the position, in which the prismatic (!) constraint has been formed (vInit), the position, where the forward limit point has been set (vLimitForw) and where the backward limit point is (vLimitBackw). Returns false, if anything went wrong.
- bugfix: pXcon_add has been changed for PH_PRISMATIC joints, so that the global anchor is -always- defined for the position of the 1st entity. This way, the anchor is correctly returned with pXconGetPrismaticLimits and pXcon_getposition, so that is settled on the joint axis.
- added: helper function NxToVec, which transfers a NxVec3 correctly from PhysX domain into world space VECTOR, corresponding to PhX.NXSize
- added: helper function NxForVec, which transfers a VETCOR correctly from Gamestudio domain into world space PhysX NxVec3, corresponding to PhX.NXSize (this will replace in a long term NxforVEC, which doesn't scale by PhX.NXSize).

I want to underline that I am doing this for free and that the dll can, and most likely will not correspond with the official ackphysx.dll smile so don't expect that you can just copy over this one and everything works, please read the changelog to get to know what features went in and what changed wink

I post updates here, have fun!

Kind regards,
-Christian
Posted By: PadMalcom

Re: ackphysx.dll community version - 10/13/11 07:00

This is really nice, we can only hope that OPGroup picks up all the good features and finally implements it into the official dll.

Btw, I'm really looking forward to your current project!

AND I'm happy that you solve the physx-problems yourself, so more time for my new WED wink
Posted By: 3run

Re: ackphysx.dll community version - 10/13/11 08:05

Great dude! Thank you laugh One question, will this work with A7?
Posted By: HeelX

Re: ackphysx.dll community version - 10/13/11 08:33

Originally Posted By: PadMalcom
This is really nice, we can only hope that OPGroup picks up all the good features and finally implements it into the official dll.


Well, as long as I did no errors, you can of course also try this one smile

Originally Posted By: 3run
One question, will this work with A7?


I don't know... theoretically, yes, since both entity structs under A7 and A8 have a void* body; attribute for PhysX. But I think there are some reasons, why the physX_open function terminates, when not A8 is used. I guess it is related to on_level_load and on_ent_remove, are there existent in A7?

It would be great if you could try it out. Download the current dll and the current header and try to modify the functions in ackphysx.h...?

If it is just the events, I guess we can work it out by providing replacement functions for level_load, ent_remove and so on that trigger the same events.
Posted By: Rei_Ayanami

Re: ackphysx.dll community version - 10/13/11 08:48

Well, you will need to recompile the dll, because there is a version check in one function (something like

If(v(version) < _VAR(8))
return _VAR(0);

(line 48 / physX_load() )
Posted By: HeelX

Re: ackphysx.dll community version - 10/13/11 22:03

- added constraint type identifiers and marked the old ones as deprecated (still valid): PH_SPHERICAL for PH_BALL, PH_REVOLUTE for PH_HINGE, PH_CYLINDRICAL for PH_SLIDER and PH_DISTANCE for PH_ROPE
- added constraint types for (yet unsupported): PH_FIXED, PH_POINTINPLANE, PH_POINTONLINE, PH_PULLEY (commented in the Lite-C header; available internally)
- added internal DLL function pXconGetJointData to remove overhead for joint functions; will reduce code in the future
- added internal DLL function int pXconGetType (ENTITY* e, int* refType) to retrieve constraint type in DLL scope (int); supports the unsupported constraints also (upward compatibility!)
- added external DLL function var pXconGetType (ENTITY* e), which returns the constraint type in Lite-C scope (var)
Posted By: HeelX

Re: ackphysx.dll community version - 10/24/11 20:36

  • removed version checking, should work for A7, theoretically
  • new: pXconGetAxis (returns the global axis of the constraint)
  • new: pXconGetLimits (returns the limiting scalar of 1D constraints, like PH_REVOLUTE or PH_PRISMATIC; including limits in degrees (PH_REVOLUTE) or quants (PH_PRISMATIC)).
  • refactoring: added new pXent.cpp and pXcon.cpp which will be the future home of all _ent and _con functionality
  • new: PH_NUM_JOINTTYPES indicates how much joint types are available; e.g. for array initializations
  • redefinitions for the old ODE functions were removed from ackphysx.h


checkout or download now!
Posted By: HeelX

Re: ackphysx.dll community version - 10/26/11 22:05

bugfix: if -360, 360 were passed to pXcon_setparams2 to make a free revolute (hinge) joint, the joint was still limited to -180, 180 degrees, though.

only on SVN for now
Posted By: HeelX

Re: ackphysx.dll community version - 10/31/11 15:01

LITE-C:
  • new: pXentScaleMass scales the mass of an entity by a scale factor
  • new: pXentIsWheel returns, if an entity is a wheel or not
  • new: pXconGetChassis (ENTITY* e) returns the chassis entity of an entity e that was assigned to the chassis entity with a wheel constraint
  • bugfix: each new added wheel/joint constraint to an entity was saved as a to-1 associations, so, old constraints were overwritten
  • new: pXconNumJoints/-Wheel returns the number of associated joints/wheels of an entity
  • new: pXconGetJoint/-Wheel.. functions return joints/wheels of an entity
  • new: pXconRemoveJoint/-Wheel... functions removes and releases joints/wheels of an entity

INTERNAL:
  • the JointUserData class got it's own cpp/h file
  • static JointUserData::fromEntity (ENTITY* e) returns the joint user data of an entity
  • JointUserData holds now unlimited joint & wheel constraints, with getter and setter functions
  • all legacy functions that accessed the Joint or Wheel member of JointUserData were refactored to get and use the first Joint/Wheel, but..
  • pXcon_remove releases all joints of an actor, of course, and
  • if pXcon_remove is used on a wheel, the association is removed in the chassis entity as well
  • void *Joint & *Wheel were removed from the JointUserData class
  • new helper: pXconReleaseJoint releases an NxJoint* joint (all associations remain)
  • new helper: pXconReleaseWheel releases a NxWheelShape* wheel (all associations remain)


download just the new dll and the header (ackphysx.20111031.dll.h.rar) or checkout via SVN from http://svn.code.sf.net/p/a8physx/code/
Posted By: Rackscha

Re: ackphysx.dll community version - 10/31/11 15:15

Good work laugh.

I know you just started with it but are you planning on going to implement things like destruction in the future?
Posted By: HeelX

Re: ackphysx.dll community version - 10/31/11 15:23

Thanks! What kind of destruction - for clothes or so?

I add, repair or change some features at the moment only with regards to some requirements of a project I am working on. For now, I need proper implementation of joints. My next objective are fixed joints: two objects are then tied together so that they are immovable, but if a force (e.g. a bullet, or a ball, or an explosion) exceeds the joint's break limits, the constraint is removed automatically - imagine a wall of bricks.

In my case I need them for something different, but that doesn't matter. In fact, I need to establish two constraints between two entities at the same time and need access to the different joints - until now, the plugin just saved a to-1 association and not multiple joints. You were able to add them, of course, but the pointers were overwritten, so that they vanished into your PC's Nirvana. In the meantime, I did the same thing for wheels and the possibility to get the chassis pointer back from a wheel entity - I don't need that, but it just popped up here as a possibility and I thought it would be nice for you to have a function for that.

I also had a look on particle physics - as far as I believe, these are also scheduled by JCL as "liquid" particles. They seem to be easy to implement and are great for fluids, smoke, blood and scatter, influenced by wind, rigid object dynamics and the like.
Posted By: Rackscha

Re: ackphysx.dll community version - 10/31/11 16:53

The first part sounds usefull.

What i thought when writing about destruction was realtime destruction.
Someone wrote a PhysX dll in the past of ODE times and implemented a very rough version of realtime destruction.

I dont know if PhysX itself has an interface to do this.

Greets
Rackscha
Posted By: HeelX

Re: ackphysx.dll community version - 10/31/11 22:38

Originally Posted By: Rackscha
What i thought [..] was realtime destruction. Someone wrote a PhysX dll [..] and implemented a very rough version of realtime destruction. I dont know if PhysX itself has an interface to do this. [..]


Afaik, PhysX doesn't provide such an interface; you would have to do it on your own.

Just out of interest - is anybody trying my new things out or am I developing into the blue?
Posted By: alibaba

Re: ackphysx.dll community version - 10/31/11 22:43

doesn´t work with A7 smirk
Posted By: HeelX

Re: ackphysx.dll community version - 10/31/11 22:52

Originally Posted By: alibaba
doesn´t work with A7 smirk


Hm... it should. It was originally developed for A7, but afaik development got late (WHO has expected this? NO ONE) and it was released for A8... can you please download the current version and make a small example, like creating a terrain and throwing some boxes from the camera or so?
Posted By: alibaba

Re: ackphysx.dll community version - 10/31/11 23:05

as soon as i call pysX_run, i get empty prototype in
Posted By: HeelX

Re: ackphysx.dll community version - 11/01/11 10:06

Originally Posted By: alibaba
as soon as i call pysX_run, i get empty prototype in
Have you tried to compile it against the A7 plugin SDK? This could be the reason, why it doesn't work - because I compile it against the A8 plugin SDK.
Posted By: alibaba

Re: ackphysx.dll community version - 11/01/11 10:40

Hmm. no haven´t tried it, but i also have no experience in this.
Posted By: Rackscha

Re: ackphysx.dll community version - 11/01/11 12:29

@HeelX: Absolutely like your current work. But atm iam very busy and not doing any 3dgs projects.

PS: maybe you could work together with JCL so that your changes/improvements get implemented in a future official 3dgs version?
Posted By: HeelX

Re: ackphysx.dll community version - 11/01/11 14:08

Originally Posted By: alibaba
Hmm. no haven´t tried it, but i also have no experience in this.
It is simple. Just checkout the current version, load the project in VS 2005 (or later) and bind the A7 SDK files instead of the A8 ones. If you really gonna try it, don't hesitate to ask here, I'll help you.

Originally Posted By: Rackscha
@HeelX: Absolutely like your current work
Thanks!

Originally Posted By: Rackscha
maybe you could work together with JCL so that your changes/improvements get implemented in a future official 3dgs version?
I don't think so that this will happen soon. From what I see here, our development focuses and -speeds differ very much and afaik they don't invest much into user projects at the moment due to a massive schedule for some massive features. Though, JCL said that he will look from time to time into my source code on SourceForge, he will **eventually** adapt some stuff.
Posted By: HeelX

Re: ackphysx.dll community version - 11/01/11 15:13

Yay! New version!

Major new features:
  • PH_FIXED joints
  • support of NxJoint* pointers in Lite-C, so that you can store and pass them instead of using the entity - this is required from now on, if you establish more than one joint per entity. Of course, there are legacy functions that work always on the first joint; and all GS functions were modified to this behavior
  • you can set the default number of iterations globally via pXSetDefaultSolverIterationCount
  • typed access to joints (e.g. "give me the second ball joint of the my entity") and various helper functions
  • fixed a memory leak when calling pXcon_add more than once on entities

changelog:
  • bugfix: the userData member of actors wasn't resetted to NULL, so, it was not possible to detect if an actor already has an associated JointUserData object or not
  • change: the functions pXconGetLimits, pXconGetAxis were changed, so that they work as described for the first joint
  • change: pXconGetPrismaticLimits works now for the -first- prismatic (!) joint
  • change: pXconGetType returns the type of the first joint, otherwise PH_WHEEL if it is a wheel, otherwise 0 if it has no constraints at all, otherwise -1 if it has no joints, but wheels, otherwise -2 when an error occurs
  • new: pXconGetJointLimits returns the limits of a joint
  • new: pXconGetJointType returns the type of a joint
  • new: pXconGetJointAxis returns the axis of a joint
  • new: pXconGetTypedJoint... returns the joint with a given type by index, first, or last
  • new: pXconNumTypedJoints returns the number of joints of a given type, associated with an entity
  • new: pXconGetPrismaticJointLimits works like pXconGetPrismaticLimits, but for a specific prismatic (!) joint
  • new: pXcon_add support now the PH_FIXED joint constraint; a second entity is always required
  • new: pXentGetSolverIterationCount(Ref) retrieves the number of solver iterations of an entity
  • change: pXent_setiterations is deprecated now; use pXentSetSolverIterationCount instead
  • new: new pX.cpp/.h for all upcoming system-related functions (internal)
  • new: pXGetDefaultSolverIterationCount returns the default value for solver iterations, assigned to a new physics entity
  • new: pXSetDefaultSolverIterationCount can be used to change the default value for solver iterations, assigned to new physics entities

Fixes lots of bugs compared to the prior version, please use this now; link for dll and header: ackphysx.20111101.dll.h.rar; source to be checked out as always.
Posted By: HeelX

Re: ackphysx.dll community version - 11/02/11 13:49

Small but important update! At least for those people, who are interested in running it on customer PC's grin

  • new: pXconHas(Joint)Limits returns if the -first- joint of an entity or a given one has limits or not
  • change: the compiler settings were changed, so that dependencies to msvcp80.dll are gone - the dll should work now on every customer PC and not just on dev PC's
  • added a todo list with some notes


ackphysx.20111102.dll.h.rar and whole source via SVN
Posted By: HeelX

Re: ackphysx.dll community version - 11/03/11 23:33

- change: all joint types have been renamed, and defined again, to match the PhysX names and values (!!!)
- change: due to the joint type value changes, pXconGetType got a slighty different return

- new: spring parameters for revolute joints, either via pXcon_setparams2 or the new functions (see below)
- change: pXcon_setparams2 receives for revolute joints on vecParam5 x: spring force, y: damping, z: target in degrees

- bugfix: pXcon_setparams2 didn't processed the restitution factor properly

new general joint functions
- pXconSet(Joint)GlobalAnchor sets the point where the two actors are attached in global coordinates
- pXconSet(Joint)GlobalAxis sets the direction of the joint's primary axis, specified in global coordinates
- pXconSet(Joint)Breakable sets the maximum force magnitude that the joint is able to withstand without breaking
- pXconSet(Joint)SolverExtrapolationFactor sets the solver extrapolation factor
- pXconSet(Joint)UseAccelerationSpring switches between acceleration and force based spring
- pXconSet(Joint)Name sets a (referenced) name string for a joint
- pXconSet(Joint)LimitPoint(Ex) sets the limit point

new revolute joint functions
- pXconSetRevolute(Joint)Limits sets the limits of revolute joints
- pXconAddRevoluteJoint adds a revolute joint, with an unified, almost complete parameter list
- pXconSetRevoluteSpring sets spring parameters

new prismatic joint functions
- pXconSetPrismatic(Joint)Limits sets the limits of prismatic joints
- pXconAddPrismaticJoint adds a prismatic joint, with an unified, almost complete parameter list

- new: ackphysxHelloWorld() can be used to check, if the dll is connected to the engine (for debugging)

internal
- PercentToFloat & FloatToPercent can be used to convert GS percentages to PhysX percentages
- isPercentValid can be used to check if a percentage is valid
- NxForVecNormal converts a GS normal into a normalized PhysX normal
- NxForQuant, NxForVarQuant, NxToQuant and NxToVarQuant can be used to transfer quant measures into physx

Here you go: ackphysx.20111104.dll.h.rar or source in SVN.
Posted By: TechMuc

Re: ackphysx.dll community version - 11/13/11 20:03

One of the best projects here laugh to bad almost noone cares.

if there were more active 3dgs users i would help you out a little bit with the svn, but sadly I'm pretty sure almost noone will be able to use this great plugin..

Nevertheless, thanks a lot christian.
Posted By: 3run

Re: ackphysx.dll community version - 11/13/11 21:28

Thank you Christian, I always enjoy working with your projects (fmod for example). Techmuc, will be great if you could help Christian a little bit I guess.
Posted By: HeelX

Re: ackphysx.dll community version - 11/13/11 21:46

Originally Posted By: TechMuc
One of the best projects here laugh to bad almost noone cares
Thanks!

Originally Posted By: TechMuc
I'm pretty sure almost noone will be able to use this great plugin
Well, I hope clicking on a download link to download the dll and header is not "too much"... almost all new features are described here and I try to document the header as much as possible, so "not being able" to use that is a bit.. well.. I hope that is not true, because that means my documentation abilities are like junk smile
Posted By: ventilator

Re: ackphysx.dll community version - 11/13/11 21:51

i don't think this is what he meant. laugh
Posted By: TechMuc

Re: ackphysx.dll community version - 11/13/11 21:57

"not to be able" in a sense of:

the common user:
1) does not understand physics
2) does not understand what you are posting at all (joints? what the fuck? wink )
3) thinks "waaa download sth. without a fantastic demo-- no"

Is there any existing project left here, which still needs complex physics - or even more harsh: If you are not using the contribution yourself, i highly doubt that there will be anyone left using your enhancements (really seriously using) besides a maximum of maybe 5 people laugh

PS: 1st: Your documentations are probably the best docs i've ever read (especially for an open source product).

PS: 2nd: Actually as this is pretty senseless you can just ignore this post. It is not relevant to your enhancements, and i do NOT want to start a dumb discussion here.


Posted By: HeelX

Re: ackphysx.dll community version - 11/13/11 22:56

OK, sorry, I was confused wink you are welcome smile

Well, I think that physics can enhance a game more than fancy shaders, they are the future (if done properly, of course)! So I am considering to keep on working on this after I finished my client work, well.. since I want to work again on some own games/tech stuff again in 2012, I especially want to have some fluid particles, wind, soft bodies and fracturing. So, after fixing the gaps in joints (which are VERY important imho), I will see what I can do.
Posted By: Quad

Re: ackphysx.dll community version - 11/13/11 23:33

I did not look into the code, but when i do and if i see i can, i will help here and there. I got something more like an physics util library sort of thing in mind, but that's another plugin/library.
Posted By: rojart

Re: ackphysx.dll community version - 11/14/11 10:59

Once the shock wears off after my dad's death, I'll help especially with cloth (90%), soft bodies (95%), fluids and destruction also.

HeelX, thanks for your time and contribution to this project.
Posted By: darkinferno

Re: ackphysx.dll community version - 11/14/11 12:07

I have alot of use for a good physics engine that works with A7, question though, is the engine deterministic? what would it take to make it that way? this is for multiplayer/replay reasons

@rojart: sorry about your dad man, idk what i'll do if mine was to pass..
Posted By: Emre

Re: ackphysx.dll community version - 11/14/11 14:34

Too bad i am still using a7. But great project and contribution as always anyway. I really appreciate your effort HeelX.
Regards
Posted By: HeelX

Re: ackphysx.dll community version - 11/14/11 14:41

As I said, I am pretty sure that the DLL works, if you compile it against the A7 SDK, just try it! smile
Posted By: Emre

Re: ackphysx.dll community version - 11/14/11 15:33

Ohh... I missed that part. (: This is really good suprize for me, and gonna be awesome for my game. I will try it. Thanks!
Posted By: 3run

Re: ackphysx.dll community version - 11/14/11 16:55

rojart, I'm sorry about your dad.
Posted By: Random

Re: ackphysx.dll community version - 11/14/11 17:27

rojart, no one forces you to do it, after your fathers death...
Posted By: darkinferno

Re: ackphysx.dll community version - 11/14/11 22:20

Originally Posted By: darkinferno
Is physX deterministic? what would it take to make it that way? this is for multiplayer/replay reasons

Posted By: HeelX

Re: ackphysx.dll community version - 11/14/11 22:51

Originally Posted By: darkinferno
Is physX deterministic? what would it take to make it that way? this is for multiplayer/replay reasons


Yes, it is. NO IT ISNT! - But it could be a bit tricky for multiplayer, though, since in a PhysX environment you don't "set" player positions, you have to move them via forces and doing that in a proper way in a multiplayer environment could be... complicated.

But that is not a particular PhysX issue, nor a Gamestudio one, this is a general problem you encounter when you use a physics solver. But I bet that there are already best practices and patterns for that in the game dev community, try to search for it.


Posted By: ventilator

Re: ackphysx.dll community version - 11/14/11 23:10

physx isn't deterministic.
Posted By: WretchedSid

Re: ackphysx.dll community version - 11/14/11 23:33

The NVIDIA forum and google confirm this.
Posted By: Rackscha

Re: ackphysx.dll community version - 11/14/11 23:40

Created this long time ago with ODE for A/.

dont remember if the multiplayer source is included.

Multiplayer Physic

If the file doesnt exist, tell me and i'll search for it on my HDD
Posted By: HeelX

Re: ackphysx.dll community version - 11/15/11 00:23

Originally Posted By: JustSid
The NVIDIA forum and google confirm this.
Gotcha ^^
Posted By: Superku

Re: ackphysx.dll community version - 11/15/11 00:48

Eagerly waiting for your 6Djoint update! wink
Posted By: darkinferno

Re: ackphysx.dll community version - 11/15/11 11:37

Originally Posted By: Rackscha
If the file doesnt exist, tell me and i'll search for it on my HDD
file doesnt seem to exist ^^ so please give that HDD a look when you get time
Posted By: HeelX

Re: ackphysx.dll community version - 11/15/11 19:38

New update! Big new shape- and 6D-joint features!

shapes
  • NxShape datatype was introduced, old hull types were renamed (e.g. PH_BOX -> NX_SHAPE_BOX) to be in canon with PhysX
  • PH_MODIFIED was renamed to NX_SHAPE_RAW_MESH
  • new: pXentAddShape can be used to add a sphere, box, capsule, wheel or convex-shape (!!!) from the same entity, another entity, at the local position/orientation of the source/other entity; or a given global position and/or orientation
  • new: pXentAddBoxShapeByEnt, pXentAddCapsuleShapeByEnt, pXentAddConvexShapeByEnt, pXentAddSphereShapeByEnt, pXentAddWheelShapeByEnt can be used to add like with pXentAddShape a shape, but directly for the given shape type
  • new: pXentNumShapes returns the number of shapes an entity has
  • new: pXentGetShapeId returns the index of a given shape in the shape list of an entity
  • new: pXentShapeIsType returns true/false if a given shape is of a given type
  • new: pXentGetShape... returns a shape by its id, first or last
  • new: pXentGetTypedShape... returns the a shape of a given type, by its index, first, or last
  • new: pXentRemoveShape removes and deletes a given shape of an entity
  • new: pXentRemoveShapeById does the same as pXentRemoveShape, but with an index rather than with a passed shape


joints
  • for joint types, the NxJointType datatype was introduced
  • NxJointProjectionMode datatype and values were introduced for future functions using that
  • NxD6JointMotion, NxD6JointFlag and NxD6JointDriveType datatypes were introduced
  • all (!) characterizing 6D-joint parameters are now settable (except drive orientation), see below
  • pXconAddDistanceJoint creates a new distant joint, with a full parameter list


new 6D functions:
Click to reveal..
Code:
// defines the linear and angular degree of freedom, default: NX_D6JOINT_MOTION_FREE
NxJoint* pXconSetD6JointLinearMotion (NxJoint*, NxD6JointMotion x, NxD6JointMotion y, NxD6JointMotion z);
NxJoint* pXconSetD6JointAngularMotion (NxJoint*, NxD6JointMotion swing1, NxD6JointMotion swing2, NxD6JointMotion twist);

// Sets the characteristics of linear limit (if some linear DOF is limited)
NxJoint* pXconSetD6JointLinearLimit (NxJoint*, float quants, float restitution, float spring, float damping);

// Sets the characteristics of the angular limit of swing1/2 (if swing1/2Motion is NX_D6JOINT_MOTION_LIMITED)
NxJoint* pXconSetD6JointSwing1Limit (NxJoint*, float degree, float restitution, float spring, float damping);
NxJoint* pXconSetD6JointSwing2Limit (NxJoint*, float degree, float restitution, float spring, float damping);

// Sets the characteristics of the lower and upper limit of the twist (if twistMotion is NX_D6JOINT_MOTION_LIMITED)
NxJoint* pXconSetD6JointTwistLowLimit (NxJoint*, float low, float restitution, float spring, float damping);
NxJoint* pXconSetD6JointTwistHighLimit (NxJoint*, float high, float restitution, float spring, float damping);

// Sets the drive properties of the three linear DOF's 
NxJoint* pXconSetD6JointXDrive (NxJoint*, NxD6JointDriveType type, float spring, float damping, float forceLimit);
NxJoint* pXconSetD6JointYDrive (NxJoint*, NxD6JointDriveType type, float spring, float damping, float forceLimit);
NxJoint* pXconSetD6JointZDrive (NxJoint*, NxD6JointDriveType type, float spring, float damping, float forceLimit);

// Sets the drive types of the three linear DOF's
NxJoint* pXconSetD6JointLinearDriveType (NxJoint* joint, NxD6JointDriveType x, NxD6JointDriveType y, NxD6JointDriveType z);

// Sets the swing/twist drive, which is used, if flag NX_D6JOINT_SLERP_DRIVE is not set
NxJoint* pXconSetD6JointSwingDrive (NxJoint*, NxD6JointDriveType type, float spring, float damping, float forceLimit);
NxJoint* pXconSetD6JointTwistDrive (NxJoint*, NxD6JointDriveType type, float spring, float damping, float forceLimit);

// Sets the slerp drive, if the flag NX_D6JOINT_SLERP_DRIVE is set
NxJoint* pXconSetD6JointSlerpDrive (NxJoint*, NxD6JointDriveType type, float spring, float damping, float forceLimit);

// Sets the swing, twist and slerp drive type
NxJoint* pXconSetD6JointAngularDriveType (NxJoint* joint, NxD6JointDriveType swing, NxD6JointDriveType twist, NxD6JointDriveType slerp);

// If the x,y, and/or z linear drive type is NX_D6JOINT_DRIVE_POSITION, pos defines the
// goal position, in local entity coordinates
NxJoint* pXconSetD6JointDrivePosition (NxJoint*, VECTOR* pos);

//NxJoint* pXconSetD6JointDriveOrientation (NxJoint*, ...); // TODO

// If the x,y, and/or z linear drive type is NX_D6JOINT_DRIVE_VELOCITY, vel/ang defines
// the goal linear velocity / angular velocity
NxJoint* pXconSetD6JointDriveLinearVelocity (NxJoint*, VECTOR* vel);
NxJoint* pXconSetD6JointDriveAngularVelocity (NxJoint*, VECTOR* vel);

// If mode is NX_JPM_NONE, projection is disabled. If NX_JPM_POINT_MINDIST, bodies are
// projected to limits leaving an linear error of the projection distance and an angular
// error of the projection angle.
NxJoint* pXconSetD6JointProjection (NxJoint*, NxJointProjectionMode mode, float dist, float angle);

// When the flag NX_D6JOINT_GEAR_ENABLED is set, the angular velocity of the second actor
// is driven towards the angular velocity of the first actor times gearRatio (both w.r.t.
// their primary axis) 
NxJoint* pXconSetD6JointGearRatio (NxJoint*, float ratio);

// Sets flags, which control the general behavior of D6 joints
NxJoint* pXconSetD6JointFlags (NxJoint*, NxD6JointFlag flags);



internal
  • new "pXent" and "pXcon" filter added to VS project
  • pXentShape.cpp/.h will be the new future home of all shape-related functions
  • pXconD6.cpp/.h will be the new future home of all D6 joint related functions
  • NxMat33ForAngle returns the rotation matrix for an ANGLE*
  • NxForEntScale returns the scale of an entity as NxVec3
  • NxForEntPos returns the transformed position of a given entity
  • NxMat33ForEntAngle returns the rotation matrix of a given entity
  • InvNxMat33ForEntAngle like NxMat33ForEntAngle, but the inverse


Remarks:
The new 6D-joints features were kindly sponsored by Superku. Thank you!

Download the new dll for A8 (and the header) here: ackphysx.20111115.dll.h.rar

Checkout on SVN as always.

Cheers,
-Christian
Posted By: HeelX

Re: ackphysx.dll community version - 11/21/11 00:56

Update! New math stuff! New revolute joint functions! Fixed 6D-joint bugs smile

Lite-C:
  • new: complete PhysX math library is now available for scalar operations. Here are the new functions:
    Click to reveal..
    // Returns true if the two numbers are within eps of each other
    BOOL pXequals (float a, float b, float eps);

    // The floor/ceil function returns a value representing the largest/smallest integer that
    // is less than or equal to x
    float pXfloor (float a);
    float pXceil (float a);

    // Truncates the float to an integer
    int pXtrunc (float a);

    // abs returns the absolute value of its argument
    float pXabs (float a);

    // sign returns the sign of its argument. The sign of zero is undefined
    float pXsign (float a);

    // The return value is the greater/lesser of the two specified values
    float pXmax (float a, float b);
    float pXmin (float a, float b);

    // mod returns the floating-point remainder of x / y
    float pXmod (float x, float y);

    // Clamps v to the range [hi,lo]
    float pXclamp (float v, float hi, float low);

    // Square root = x^(1/2) and reciprocal square root = x^(-1/2)
    float pXsqrt (float a);
    float pXrecipSqrt (float a);

    // Calculates x^y (x raised to the power of y)
    float pXpow (float x, float y);

    // Calculates e^n
    float pXexp (float a);

    // Calculates logarithm to base = e, 2, 10
    float pXlogE (float a);
    float pXlog2 (float a);
    float pXlog10 (float a);

    // Converts degrees into radians and radians to degrees
    float pXdegToRad (float deg);
    float pXradToDeg (float rad);

    // Sine, cosine, sin & cosine or tangent of an angle in degrees
    float pXsin (float a);
    float pXcos (float a);
    void pXsinCos (float a, float* s, float* c);
    float pXtan (float a);

    // Arcsine, arccosine, arctangent ot arctangen o (x/y) with correct sign
    float pXasin (float a);
    float pXacos (float a);
    float pXatan (float);
    float pXatan2 (float x, float y);

    // Uniform random number in [a,b]
    float pXrand (float a, float b);

    // Hashes an array of n 32 bit values to a 32 bit value
    int pXhash (int* arr, int n);

    // Returns true if the number is a finite floating point number as opposed to INF, NAN, etc.
    BOOL pXisFinite (float a);
  • new: all remaining specific functions for revolute joints were enabled, like
    • pXconSet/GetRevolute(Joint)Motor
    • pXconSet/GetRevolute(Joint)Spring
    • pXconGetRevolute(Joint)Angle
    • pXconGetRevolute(Joint)Velocity
    • pXconGet/SetRevolute(Joint)Flags
    • pXconGet/SetRevolute(Joint)ProjectionMode
  • bugfix: there are two restitution factors for revolute joints. This was overlooked all the time, also in the original GS plugin. The new functions were changed, so that they became a second restitution factor.
  • new: all 6D-joints functions, which were added in the last release, were enhanced by version with ENTITY* parameter like the revolute joint functions, so that they work on the first (!) 6D-Joint of an entity
  • bugfix: pXconSetD6LinearMotion and pXconSetD6AngularMotion had no effect
  • bugfix/change: pXconSetD6Swing1Limit, pXconSetD6Swing2Limit had no effect. Now, if called, they also enforce NX_D6JOINT_MOTION_LIMITED on swing1/2
  • new: pXconGetJointEntities returns the two entities constrained with a given joint


Internally:
  • pXconRevolute.h/.cpp is the new home of all functions related to revolute joints


Download the new dll for A8 (and the header) here: ackphysx.20111121.dll.h.rar, checkout on SVN as always. Upcoming: direct support for essential (and native) PhysX datatypes like NxMat33, NxVec3, NxQuat, etc. from within Lite-C ^^

Cheers,
-Christian
Posted By: PadMalcom

Re: ackphysx.dll community version - 11/21/11 08:59

Thanks for the effort HeelX! laugh
Posted By: Nighthawk

Re: ackphysx.dll community version - 11/21/11 11:18

Hi HeelX,
danke fürs teilen.
Wäre es noch möglich die lib-Datei dem Download hinzuzufügen?

Gruß
Nighthawk
Posted By: HeelX

Re: ackphysx.dll community version - 11/21/11 12:23

Originally Posted By: Nighthawk
Wäre es noch möglich die lib-Datei dem Download hinzuzufügen?


Of course I can add the lib. So, let's go...
Posted By: HeelX

Re: ackphysx.dll community version - 11/21/11 12:41

Update! Whole PhysX vector library was enabled for Lite-C. PhysX has an own class for vectors, called NxVec3 - for enabling it in Lite-C, I typedef'ed VECTORS as NxVec3:
Code:
typedef VECTOR NxVec3;


The rest (conversion, etc.) is done in my dll-backyard, so you can simply pass regular Lite-C vectors to the following functions. But if you are cool and sort of an NVidia hipster, you can also write always NxVec3 wink I just invented the typedef, because other basic datatypes will follow soon, like NxMat33 (rotation matrices), NxQuat (quaternions), etc.

Here are the new, bulletproof functions from NVidia for you. Some of them are really cool, even if it is just vector math wink

Quote:
// constructors
NxVec3* pXvecCreate (); // new uninitialized v
NxVec3* pXvecCreateScalar (float); // v = a,a,a
NxVec3* pXvecCreateXYZ (float, float, float); // v = x,y,z
NxVec3* pXvecCreateCopy (NxVec3*); // makes copy of another vector v
NxVec3* pXvecCreateArr (float* arr); // from array: v = [0],[1],[2]

// assignment
NxVec3* pXvecSet (NxVec3*, NxVec3* a); // v = a
NxVec3* pXvecSetXYZ (NxVec3*, float, float, float); // v = (x,y,z)
NxVec3* pXvecSetX (NxVec3*, float); // v.x = x
NxVec3* pXvecSetY (NxVec3*, float); // v.y = y
NxVec3* pXvecSetZ (NxVec3*, float); // v.z = z
NxVec3* pXvecSetS (NxVec3*, float); // v = (s,s,s)
NxVec3* pXvecZero (NxVec3*); // v = (0,0,0)

// writes out the 3 values to dest array
NxVec3* pXvecGetArr (NxVec3*, float* dest);

// gets element by index
float pXvecGet (NxVec3*, int);

// true if all the components of v are smaller
BOOL pXvecIsLesser (NxVec3*, NxVec3* greater);

// true if the vectors are -exactly- (un)equal
BOOL pXvecEqual (NxVec3*, NxVec3*);
BOOL pXvecUnequal (NxVec3*, NxVec3*);

// true if a and b's elems are within epsilon of each other
BOOL pXvecEqualEps (NxVec3*, NxVec3*, float eps);

// inverse
NxVec3* pXvecInv (NxVec3*); // v = -v
NxVec3* pXvecSetInv (NxVec3*, NxVec3* a); // v = -a

// v = (0,0,0)
NxVec3* pXvecZero (NxVec3*);

// tests for exact zero vector
BOOL pXvecIsZero (NxVec3*);

// sets minus/plus infinity
NxVec3* pXvecSetPlusInfinity (NxVec3*);
NxVec3* pXvecSetMinusInfinity (NxVec3*);

// v = element wise min(v,a) / max(v,a)
NxVec3* pXvecSetMin (NxVec3*, NxVec3* a);
NxVec3* pXvecSetMax (NxVec3*, NxVec3* a);

// arithmetics
NxVec3* pXvecAdd (NxVec3*, NxVec3* a); // v = v + a
NxVec3* pXvecSub (NxVec3*, NxVec3* a); // v = v - a
NxVec3* pXvecScale (NxVec3*, float s); // v = v * s
NxVec3* pXvecMul (NxVec3*, NxVec3* s); // element wise v = v * s
NxVec3* pXvecMulAdd (NxVec3*, float s, NxVec3* a); // v = v * s + a

// normalizes to length = 1
NxVec3* pXvecNormalize (NxVec3*);

// sets the vector's length to s
NxVec3* pXvecSetLength (NxVec3*, float);

// returns the length and squared length
float pXvecLength (NxVec3*);
float pXvecLengthSq (NxVec3*);

// returns the distance (and squared distance) between v and a
float pXvecDist (NxVec3*, NxVec3*);
float pXvecDistSq (NxVec3*, NxVec3*);

// returns the number of closest axis: 0 = x.., 1 = y.., 2 = z axis
int pXvecClosestAxis (NxVec3*);

// snaps to closest axis and normalizes vector
NxVec3* pXvecSnapToClosestAxis (NxVec3*);

// returns true if all 3 elems of the vector are finite (not NAN or INF, etc.)
BOOL pXvecIsFinite (NxVec3*);

// returns the scalar product of v and a
float pXvecDot (NxVec3*, NxVec3*);

// calculates the cross product of v and a: n = v X a
NxVec3* pXvecCross (NxVec3* n, NxVec3* v, NxVec3* a);

// compares orientations
BOOL pXvecSameDirection (NxVec3*, NxVec3*);


Download the dll + header + lib here: ackphysx.20111121_2.dll.h.lib.rar and checkout the whole as always on SVN.

Cheers!
-Christian

P.S: is anyone interested into swizzling functions for vectors?
Posted By: Rackscha

Re: ackphysx.dll community version - 11/21/11 15:48

really cool stuff, thanks laugh
Posted By: HeelX

Re: ackphysx.dll (new: quaternions + 3x3 matrices) - 11/27/11 13:49

- new: whole quaternion library enabled for Lite-C
- new: whole 3x3 rotation matrix library enabled for Lite-C
- new: some PI constants (single, double, inverted...)

quaternion library functions
Click to reveal..
// quaternion
typedef struct NxQuat {
float x, y, z, w;
} NxQuat;

//...

// constructors
NxQuat* pXquatCreate (); // uninitialized quaternion
NxQuat* pXquatCreateCopy (NxQuat*); // from another quaternion (copy)
NxQuat* pXquatCreateVec0 (NxVec3* v); // from v = x,y,z and w = 0
NxQuat* pXquatCreateVecW (NxVec3* v, float w); // from v = x,y,z and w
NxQuat* pXquatCreateAngAxis (float angle, NxVec3* axis); // from angle-axis representation
NxQuat* pXquatCreateAngle (ANGLE* a); // from euler angle
NxQuat* pXquatCreateMat (NxMat33* m); // from orientation matrix

// setters
NxQuat* pXquatSet (NxQuat*, NxQuat* other); // from other quaternion
NxQuat* pXquatSetWXYZ (NxQuat*, float w, float x, float y, float z);
NxQuat* pXquatSetArrWXYZ (NxQuat*, float* wxyz); // from array
NxQuat* pXquatSetXYZW (NxQuat*, float x, float y, float z, float w);
NxQuat* pXquatSetArrXYZW (NxQuat*, float* xyzw); // from array
NxQuat* pXquatSetX (NxQuat*, float);
NxQuat* pXquatSetY (NxQuat*, float);
NxQuat* pXquatSetZ (NxQuat*, float);
NxQuat* pXquatSetW (NxQuat*, float);

// getters
NxQuat* pXquatGetWXYZ (NxQuat*, float* wxyz); // to array
NxQuat* pXquatGetXYZW (NxQuat*, float* xyzw); // to array

// sets q to the identity rotation
NxQuat* pXquatId (NxQuat* q);

// sets q to the quaternion to [0,0,0,1]
NxQuat* pXquatZero (NxQuat* q);

// randomizes q as unit quaternion
NxQuat* pXquatRandom (NxQuat* q);

// sets the quaterion to the opposite rotation
NxQuat* pXquatInvert (NxQuat*);

// creates from angle-axis representation, euler angle, or rotation matrix
NxQuat* pXquatFromAngleAxis (NxQuat*, float angle, NxVec3* axis);
NxQuat* pXquatFromAngleAxisFast (NxQuat*, float angle, NxVec3* axis);
NxQuat* pXquatFromMat (NxQuat*, NxMat33* m);
NxQuat* pXquatFromAngle (NxQuat* q, ANGLE* a);

// fetches the angle/axis or euler angle given by the NxQuat
NxQuat* pXquatGetAngleAxis (NxQuat*, float* angle, NxVec3* axis);

// gets the angle between the quat and another quat or the identity quaternion
float pXquatGetAngleIdentity (NxQuat*);
float pXquatGetAngle (NxQuat*, NxQuat* other);

// squared 4D vector length, should be 1 for unit quaternions
float pXquatGetLengthSq (NxQuat*);

// returns the scalar product of two quaternions
float pXquatDot (NxQuat*, NxQuat*);

// maps to the closest unit quaternion
NxQuat* pXquatNormalize (NxQuat*);

// conjugates q
NxQuat* pXquatConjugate (NxQuat* q);

// multiplies a with b/v
NxQuat* pXquatMultiply (NxQuat* a, NxQuat* b);
NxQuat* pXquatMultiplyVec (NxQuat* a, NxVec3* v);

// spherical linear interpolation between a and b by t percent (0...100)
// result is stored in q: q = slerp(t, a, b)
NxQuat* pXquatSlerp (NxQuat* q, float t, NxQuat* a, NxQuat* b);

// rotates a vector
NxVec3* pXquatRotate (NxQuat*, NxVec3* v);
NxVec3* pXquatInvRotate (NxQuat*, NxVec3* v);

// transforms a vector at position p
NxQuat* pXquatTransform (NxQuat*, NxVec3* v, NxVec3* p);
NxQuat* pXquatInvTransform (NxQuat*, NxVec3* v, NxVec3* p);

// negates q
NxQuat* pXquatNegate (NxQuat* q);

// arithmethics
NxQuat* pXquatSub (NxQuat* q, NxQuat* other);
NxQuat* pXquatMul (NxQuat* q, NxQuat* other);
NxQuat* pXquatMulS (NxQuat* q, float s);
NxQuat* pXquatAdd (NxQuat* q, NxQuat* other);

// tests
BOOL pXquatIsIdentityRotation (NxQuat*);
BOOL pXquatIsFinite (NxQuat*);

rotation matrix library functions
Click to reveal..
typedef struct NxMat33 {
float m[3][3];
} NxMat33;

typedef int NxMatrixType;
#define NX_ZERO_MATRIX 0 // all zeros
#define NX_IDENTITY_MATRIX 1 // identity matrix

//...

// constructors
NxMat33* pXmatCreate ();
NxMat33* pXmatCreateType (NxMatrixType type);
NxMat33* pXmatCreateRows (NxVec3* row0, NxVec3* row1, NxVec3* row2);
NxMat33* pXmatCreateCopy (NxMat33* m);
NxMat33* pXmatCreateQuat (NxQuat* q);
NxMat33* pXmatCreateAngle (ANGLE* a);

// setters
NxMat33* pXmatSet (NxMat33* m, int row, int col, float value);
NxMat33* pXmatSetRow (NxMat33* m, int row, NxVec3* v);
NxMat33* pXmatSetRowMajor (NxMat33* m, float* v);
NxMat33* pXmatSetRowMajorStride4 (NxMat33* m, float* v);
NxMat33* pXmatSetColumn (NxMat33* m, int col, NxVec3* v);
NxMat33* pXmatSetColumnMajor (NxMat33* m, float* v);
NxMat33* pXmatSetColumnMajorStride4 (NxMat33* m, float* v);

// getters
float pXmatGet (NxMat33* m, int row, int col);
NxVec3* pXmatGetRow (NxMat33* m, int row, NxVec3* v);
NxMat33* pXmatGetRowMajor (NxMat33* m, float* v);
NxMat33* pXmatGetRowMajorStride4 (NxMat33* m, float* v);
NxVec3* pXmatGetColumn (NxMat33* m, int col, NxVec3* v);
NxMat33* pXmatGetColumnMajor (NxMat33* m, float* v);
NxMat33* pXmatGetColumnMajorStride4 (NxMat33* m, float* v);

// returns true for identity matrix
BOOL pXmatIsIdentity (NxMat33* m);

// returns true for zero matrix
BOOL pXmatIsZero (NxMat33* m);

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

// sets this matrix to the zero matrix
NxMat33* pXmatZero (NxMat33* m);

// sets this matrix to the identity matrix
NxMat33* pXmatId (NxMat33* m);

// m = -m
NxMat33* pXmatSetNegative (NxMat33* m);

// sets this matrix to the diagonal matrix
NxMat33* pXmatDiagonal (NxMat33* m, NxVec3* d);

// sets this matrix to the star (skew symmetric) matrix
NxMat33* pXmatStar (NxMat33* m, NxVec3* v);

NxMat33* pXmatFromQuat (NxMat33* m, NxQuat* q);
NxQuat* pXmatToQuat (NxMat33* m, NxQuat* q);

NxMat33* pXmatFromAngle (NxMat33* m, ANGLE* a);
ANGLE* pXmatToAngle (NxMat33* m, ANGLE* a);

NxMat33* pXmatAdd (NxMat33* m, NxMat33* other);
NxMat33* pXmatAddDest (NxMat33* m, NxMat33* other, NxMat33* dest);
NxMat33* pXmatSub (NxMat33* m, NxMat33* other);
NxMat33* pXmatSubDest (NxMat33* m, NxMat33* other, NxMat33* dest);
NxMat33* pXmatScale (NxMat33* m, float s); // m = m * s
NxMat33* pXmatScaleDest (NxMat33* m, float s, NxMat33* dest); // dest = m * s
NxMat33* pXmatMultiply (NxMat33* m, NxMat33* other); // m = m * other
NxMat33* pXmatMultiplyDest (NxMat33* m, NxMat33* other, NxMat33* dest); // dest = m * other
NxVec3* pXmatMultiplyVec (NxMat33* m, NxVec3* v);
NxVec3* pXmatMultiplyVecDest (NxMat33* m, NxVec3* v, NxVec3* dest);
NxMat33* pXmatMultiplyTransposeLeft (NxMat33* m, NxMat33* left, NxMat33* right); // m = transpose(left) * right
NxMat33* pXmatMultiplyTransposeRight (NxMat33* m, NxMat33* left, NxMat33* right); // m = left * transpose(right)
NxMat33* pXmatMultiplyTransposeRightVec (NxMat33* m, NxVec3* left, NxVec3* right); // m = left * transpose(right)
NxMat33* pXmatDiv (NxMat33* m, float s);

// returns determinant
float pXmatDeterminant (NxMat33* m);

// assigns inverse to dest
BOOL pXmatGetInverse (NxMat33* m, NxMat33* dest);

// m = transpose(other)
NxMat33* pXmatSetTransposed (NxMat33* m, NxMat33* other);

// m = transpose(m)
NxMat33* pXmatTranspose (NxMat33* m);

// m = m * [ d.x 0 0; 0 d.y 0; 0 0 d.z ]
NxMat33* pXmatMultiplyDiagonal (NxMat33* m, NxVec3* d);

// dest = m * [ d.x 0 0; 0 d.y 0; 0 0 d.z ]
NxMat33* pXmatMultiplyDiagonalDest (NxMat33* m, NxVec3* d, NxMat33* dest);

// m = transpose(m) * [ d.x 0 0; 0 d.y 0; 0 0 d.z ]
NxMat33* pXmatMultiplyDiagonalTranspose (NxMat33* m, NxVec3* d);

// dest = transpose(m) * [ d.x 0 0; 0 d.y 0; 0 0 d.z ]
NxMat33* pXmatMultiplyDiagonalTransposeDest (NxMat33* m, NxVec3* d, NxMat33* dest);

// rotate m around x, y or z axis
NxMat33* pXmatRotX (NxMat33* m, float angle);
NxMat33* pXmatRotY (NxMat33* m, float angle);
NxMat33* pXmatRotZ (NxMat33* m, float angle);

// returns if matrix rows and columns are normalized
BOOL pXmatIsNormalized (NxMat33* m);

// returns if matrix rows and columns are orthogonal
BOOL pXmatIsOrthogonal (NxMat33* m);

// returns if matrix is rotation matrix
BOOL pXmatIsRotation (NxMat33* m);


Download lib, dll and header here: ackphysx.20111126.dll.h.lib.rar and on SVN the whole source code as always.

Have fun,
-Christian
Posted By: HeelX

Re: ackphysx.dll (new: 3x4 matrices, spheres, planes, ...) - 12/08/11 21:56

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
Posted By: alibaba

Re: ackphysx.dll (new: 3x4 matrices, spheres, planes, ...) - 03/26/12 09:11

Okay, so i tried to compile it, but it´s asking me for a "NxWheel.h"
Posted By: Rei_Ayanami

Re: ackphysx.dll (new: 3x4 matrices, spheres, planes, ...) - 08/02/12 13:44

If you want to use PhysX in Gamestudio (and especially Joints) - use this version!
Posted By: HeelX

Re: ackphysx.dll (new: 3x4 matrices, spheres, planes, ...) - 08/02/12 13:49

Originally Posted By: alibaba
Okay, so i tried to compile it, but it´s asking me for a "NxWheel.h"
I'm sorry that I forgot to answer to this, but I was in the US at that time. Answer: Make sure that you added the include paths from the NVidia SDK and the demos for that. The SDK code files are not included.

Originally Posted By: Rei_Ayanami
If you want to use PhysX in Gamestudio (and especially Joints) - use this version!


Thanks! As I use VisualStudio 2010 from now on, I will eventually update the repository for that. If JCL updates the PhysX Plugin Source download to the state of A8.40, I will eventually add the cloth support and so on, too.
Posted By: gameplan

Re: ackphysx.dll (new: 3x4 matrices, spheres, planes, ...) - 08/19/12 21:50

Hi,

I replaced the dll, h and lib file in the gamestudio programm folder, but now I get the errormessage "cant initialize physx". Did I something wrong?
Posted By: HeelX

Re: ackphysx.dll (new: 3x4 matrices, spheres, planes, ...) - 08/20/12 08:30

Hi gameplan. This happens only when PhysX can't be initialized at all. Do not overwrite the original files, but put the dll and the h file aside your project.
Posted By: HeelX

Re: ackphysx.dll (new: 3x4 matrices, spheres, planes, ...) - 08/20/12 08:31

I also see, that you use A8 free. You can use Plugin extensions only with A8 Extra or higher, I think.
© 2024 lite-C Forums