About MOGRE headers files..

Marioko

11-11-2006 19:44:48

:D Hi again..

Hey Bekas, i need the .h file of Mogre for a c++/cli wrapper that i trying to do..
In the SVN repository under /trunk/Mogre/Mogre/Include are 2 folders Custom and auto. I need download custom or auto headers??

In other hand, i could see that headers in auto folder are generate with some Autowrapper, where can i found that autowrapper???

Thanks..

Bekas

11-11-2006 22:19:51

Don't worry, you don't need the include files. In order to use a .NET dll by C++/CLI you just reference it:

-Either by adding
#using "Mogre.dll"
at your include file [edit] and setting 'C:\OgreSDK\bin\$(ConfigurationName)' at project properties -> C/C++ -> General -> Resolve #using References [/edit]

-or by going to Project properties -> Common Properties -> Add New Reference.

Bekas

11-11-2006 22:23:27

And, as a hint, to get the Ogre object out of the Mogre object you can use casting:
Ogre::Camera* ogreCamera = (Ogre::Camera*) mogreCamera;
and vice versa:
Mogre::Camera^ mogreCamera = (Mogre::Camera^) ogreCamera;

Marioko

12-11-2006 01:56:35

Oohh, thanks even better.

Marioko

12-11-2006 05:28:00

Hey Bekas, i need some help with porting NxOgre to MOGRE project..

I have two little problems:

1) When i compiling i get this warning:

'__asm' : causes native code generation for function 'void NxMath::sinCos(NxF32,NxF32 &,NxF32 &)'

The part of NxMath.h where is the problem
NX_INLINE void NxMath::sinCos(NxF32 f, NxF32& s, NxF32& c)
{
#ifdef WIN32
NxF32 localCos, localSin;
NxF32 local = f;

_asm fld local
_asm fsincos
_asm fstp localCos
_asm fstp localSin
c = localCos;
s = localSin;
#else
c = cosf(f);
s = sinf(f);
#endif
}


NxMath.h is a header from PhysX SDK and not from NxOgre, and i dont want to touch this file.

2) When is linking i get this error:
error LNK2022: metadata operation failed bla bla bla

That link error is beacuse exist two or more definition of the same class. I detect the problem and is because a template<..> that is defined in various files.

Do you have some idea to solve these problem about /clr

Another question about Mogre:
Where is Mogre::String??

Thanks.

Bekas

12-11-2006 11:10:23

1) Ignore it, it's just a warning.

2) What does the full message say ?

3) There is no Mogre::String. In order to convert between Ogre::String and .NET String add a include file (i.e 'Marshalling.h'):
#include <vcclr.h>
#include "OgrePrerequisites.h"

#define DECLARE_OGRE_STRING(nvar,mstr) \
Ogre::String nvar; \
InitOgreStringWithCLRString(nvar,mstr);

#define SET_OGRE_STRING(nvar,mstr) InitOgreStringWithCLRString(nvar,mstr);
#define TO_CLR_STRING(ogrestr) gcnew System::String((ogrestr).c_str())

void InitOgreStringWithCLRString(Ogre::String& ostr, System::String^ mstr);


and 'Marshalling.cpp':
#include "Marshalling.h"

void InitOgreStringWithCLRString(Ogre::String& ostr, System::String^ mstr)
{
if (mstr == nullptr)
throw gcnew System::NullReferenceException("A null string cannot be converted to an Ogre string.");

//If Ogre is compiled with Unicode strings (OGRE_WCHAR_T_STRINGS=1) it will speed up string conversions
#if OGRE_WCHAR_T_STRINGS
pin_ptr<const wchar_t> p_mstr = PtrToStringChars(mstr);
ostr = p_mstr;
#else
IntPtr p_mstr = Marshal::StringToHGlobalAnsi(mstr);
ostr = static_cast<char*>(p_mstr.ToPointer());
Marshal::FreeHGlobal( p_mstr );
#endif
}


The code
DECLARE_OGRE_STRING(nvar,mstr)

is "kind of" writing
Ogre::String nvar = mstr;


SET_OGRE_STRING is used with an already existing Ogre::String variable.
TO_CLR_STRING converts to a System::String^:
return TO_CLR_STRING( ogreCamera->getName() );


There are other stuff in Mogre's 'Marshalling.h' that you may find useful (just ignore all DEFINE_MANAGED_NATIVE_CONVERSIONS_FOR_XXX stuff)

Marioko

12-11-2006 12:28:42

1) Mmm i fixed, i just comment the __asm lines that i relly dont need

2) This is the complete list of link errors:


nxOgre_scene.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (NxMogre.blueprint<NxMogre::scene>): (0x020002d4).
nxOgre_scene.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_Node): (0x020004d4).
nxOgre_scene.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std.pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::pair<Ogre::SceneManager *,NxMogre::blueprint<NxMogre::scene> > >): (0x0200051d).
nxOgre_scene_blueprint.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (NxMogre.blueprint<NxMogre::scene>): (0x020002bd).
nxOgre_scene_blueprint.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_Node): (0x02000466).
nxOgre_scene_blueprint.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std.pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::pair<Ogre::SceneManager *,NxMogre::blueprint<NxMogre::scene> > >): (0x020004a8).
nxOgre_serialiser.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (NxMogre.blueprint<NxMogre::scene>): (0x020002bd).
nxOgre_serialiser.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_Node): (0x0200045a).
nxOgre_serialiser.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std.pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::pair<Ogre::SceneManager *,NxMogre::blueprint<NxMogre::scene> > >): (0x0200049e).
nxOgre_textstream.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (NxMogre.blueprint<NxMogre::scene>): (0x020002c3).
nxOgre_textstream.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_Node): (0x02000472).
nxOgre_textstream.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std.pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::pair<Ogre::SceneManager *,NxMogre::blueprint<NxMogre::scene> > >): (0x020004b8).
nxOgre_world.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (NxMogre.blueprint<NxMogre::scene>): (0x020002d6).
nxOgre_world.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_Node): (0x020004a7).
nxOgre_world.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std.pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::pair<Ogre::SceneManager *,NxMogre::blueprint<NxMogre::scene> > >): (0x020004f4).
LINK : fatal error LNK1255: link failed because of metadata errors


3) Ok thanks, i going to use it..

8)

Bekas

12-11-2006 16:13:04

1) This is risky, how can you be sure that they are not needed or that you'll remember to uncomment them later if you do ? You may end up with weird errors.
If the warning bothers you, just disable it:
#pragma warning( disable: 4793 )

2) Hmm, this never occured to me, you probably need to 'google' around for this..

Marioko

13-11-2006 04:31:44

ok.. thanks..