Program wrapping PhysX

Topics: Developer Forum
Developer
Mar 5, 2007 at 9:07 PM
I'm currently working on a .NET wrapper for the PhysX SDK. I've ran into a problem, though.

I need to mashal the structure NxActorDesc which inherites from NxActorDescBase. They looks like this:

00100 class NxActorDescBase
00101 {
00102 public:
00117 NxMat34 globalPose;
00118
00132 const NxBodyDesc* body;
00133
00152 NxReal density;
00153
00167 NxU32 flags;
00168
00182 NxActorGroup group;
00183
00197 void* userData;
00198
00210 const char* name;
00211
00224 NxCompartment * compartment;
00225
00226
00230 NX_INLINE NxActorDescBase();
00234 NX_INLINE void setToDefault();
00240 NX_INLINE bool isValid() const;
00241
00247 NX_INLINE NxActorDescType getType() const;
00248 protected:
00249 NX_INLINE bool isValidInternal(bool hasSolidShape) const;
00250
00251 NxActorDescType type;
00252 };
00253
00260 class NxActorDesc : public NxActorDescBase
00261 {
00262 public:
00263
00279 NxArray<NxShapeDesc*, NxAllocatorDefault> shapes;
00280
00284 NX_INLINE NxActorDesc();
00288 NX_INLINE void setToDefault();
00294 NX_INLINE bool isValid() const;
00295 };

I believe I know how to code the NxActorDescBase in C# but don't know if inheritence works the same way in C# as in C+. Can I simply write the two structures in C# in the same way as the C+ ones?

My other problem (which I consider alot worse) is that NxActorDesc has a field of the type NxArray<NxShapeDesc*, NxAllocatorDefault>. I have no idea how to write this in a C# structure. Anybody got any ideas?

Coordinator
Mar 6, 2007 at 2:57 PM

perrs wrote:
Can I simply write the two structures in C# in the same way as the C++ ones?

yes, you can


perrs wrote:
My other problem (which I consider alot worse) is that NxActorDesc has a field of the type NxArray<NxShapeDesc*, NxAllocatorDefault>. I have no idea how to write this in a C# structure. Anybody got any ideas?

you could just transfer it to something like List<NxShapeDesc>
Developer
Mar 6, 2007 at 8:05 PM
I think you might have misunderstood. What I need is to create a structure in C#, that, when mashaled thrue a p/invoke, will map to the native structure NxActorDesc. I am pretty sure that the C# class List cannot simply be mashaled to a NxArray. You are welcome to prove me wrong, though.
Coordinator
Mar 7, 2007 at 1:50 PM
You can wrap main functionality but some small parts like this can be ported... or no? I don't know much about creating wrappers :)