The following code snippets are from the NxOgre libraries. I'm coming from a Java background, and statements like the following just confused me:

Body* body = NxNew(Body)(identifier, this, firstShapeDescription, pose, params);

What's happening on the right side of the equals sign? Is NxNew the class? Is (Body) a cast?

class NxPublicClass SceneParams : Params {

Does this class have two names? I know it a subclass of Params, but why are there two class identifiers?

8 Years
Discussion Span
Last Post by ArkM

Don't worry: no revolution in C++ syntax and semantics. For example, NxPublicClass is a macros defined in NxOgrePlatform.h header. It substitutes sacramental __declspec(dllexport) if the code compiled as DLL. Ignore it if you want to understand this code semantics only.

Obviously, NxNew is a macros (with parameter) too. I don't use NxOgre so I can't say you where NxNew was defined. Try to search on NxOgre forums. It's possible to expand the macros in this position as a some kind of new op, or as a call to a class factory function created a new instance of Body type. Ask the author or search sources.

There are tons of other macros in NxOgre sources. Probably the NxOgre is a wonderful library but its documentation looks like a nightmare. On the other hand library sources are prepared for Doxygen autodoc system - try it if you wish.

I think, the best place for NxOgre discussions is www.nxogre.org site.


NxPublicClass is a preprocessor macro that gets replaced with __declspec(dllexport) on Windows and gets replaced with nothing on other platforms.

That is, there is # define NxPublicClass __declspec(dllexport) in NxOgrePlatform.h, which says that, before any code is compiled, replace that token with that replacement text.

You could discover this by crawling up the #include chain.

Welcome to C++ :P

You desrve credit for this post - so +1-ing you =P

NxNew is defined in the NxOgreAllocator header as a macro that expands to

::NxOgre::WatchMyPointer<T>(__FILE__, __FUNCTION__, __LINE__, 0) = new T

Which means you have

Body* body = ::NxOgre::WatchMyPointer<Body>(__FILE__, __FUNCTION__, __LINE__, 0) = new Body(identifier, this, firstShapeDescription, pose, params);

And __FILE__, __FUNCTION__, and __LINE__ resolve to the file name, function name, and line number.

It's rather obscene that they use pointers directly in the first place.


Everything makes a lot more sense now, thank you! I'm also surprised by the number of people here familiar with NxOgre library!!!


Alas, it was my maiden flight over NxOgre landscape...
Google search then fast inet channel - that's all...
Truth to tell, I don't like it...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.