Page 2 of 6

Posted: Sat Jul 15, 2006 2:34 pm
by Rowan Lewis
Bugger, I could have sworn Ubuntu was installing 1.1.16... oh well, looks like I have to download the Linux installer...

Posted: Sun Jul 16, 2006 2:38 am
by Rowan Lewis
Well, I've now got 1.1.6 installed, but it still won't build:
Operator '!=' cannot be applied to operands of type 'Irrlicht.NET.NativeElement._raw' and 'null' (CS0019) on line 47 of NativeElements.cs

Code: Select all

if(_raw != null && _raw != IntPtr.Zero)
Makes me wonder exactly what its trying to do :/

Posted: Sun Jul 16, 2006 7:21 am
by DeusXL
Yeah actually there's an error.
Remove the "_raw != null", it won't happen. (I'll upload it corrected)
That's strange because i thought I had compiled it on Mono before but this is something that Mono won't let.

p/invoke performance issue?

Posted: Mon Jul 17, 2006 4:44 am
by buhatkj
ive noticed that on my machine it seems that this wrapper perhaps suffers some performance penalty conpared to the "official" irrlicht .NET wrapper. I haven't precisely done this scientifically, but for example, the original newton tutorial with the official wrapper runs at better than 400 FPS on my machine, while, the converted newton tutorial you PM'd me run at 59 at best. I realize they do have some pretty significant environmental differences, but I wonder also if some of this is not also the performance hit associated with the p/invoke overhead for data marshaling, as summed up a bit here:
http://msdn2.microsoft.com/en-us/library/ky8kkddw.aspx

could this be related?

I notice earlier in the thread you were actually seeing a performance INCREASE in this test DeusXL, were you running it in Linux, perhaps this is a VS bug?

Posted: Mon Jul 17, 2006 7:52 am
by DeusXL
Actuallly there are some code that should run slower than the official .NET wrapper.
But no, P/Invoke is supposed to be really fast and I tried to limitate conversions whereas there are many...
Could you send me your code on both wrappers so that I could test and see ? Because I know that sometimes, P/Invoke may be slow (with heavy conversions) but if you haven't many code in the main loop, there is no reason that P/Invoke is slow since, actually, you are as close from the native code than with native C++ so it really depends of your code !

PS : As I said, differences between both wrappers is perhaps 1 or 2 fps when you have 400 ! Differences I got when testing Newton were really strange and I think it was because of the code I had changed to port the Newton tutorial on my wrapper.

Posted: Tue Jul 18, 2006 6:08 pm
by sh1ny
I did some dirty hack'n'slash and added MD3 wrapper support for Irrlicht.NET CP. It will work as long as you're using this patch.

Since i cant be bothered to figure how to create patches with something i dont have a svn to compare with , here goes :

1. Apply the md3.patch to your irrlicht project. Recompile.

2. Now go to your IrrlichtW project, open animatedmesh.h and find :

Code: Select all

EXPORT IntPtr AnimatedMeshSceneNode_GetXJointNode(IntPtr node, M_STRING jointName);
Under it add :

Code: Select all

    //=========== MD3 Support ============
    EXPORT IntPtr AnimatedMeshSceneNode_GetMD3TagNode(IntPtr node, M_STRING tagName);
		EXPORT void AnimatedMeshSceneNode_SetAnimation(IntPtr node, int animIdx);
		EXPORT void AnimatedMeshSceneNode_AddAnimation(IntPtr node, int firstFrame, int lastFrame, int FPS);
		EXPORT void AnimatedMeshSceneNode_LinkAnimation(IntPtr node, int anim, int linkedAnim);
		//=========== END MD3 Support ========
Open animatedmesh.cpp

Find :

Code: Select all

IntPtr AnimatedMeshSceneNode_GetXJointNode(IntPtr node, M_STRING jointName)
{
    return GetNodeFromIntPtr(node)->getXJointNode(jointName);
}
Under it add :

Code: Select all

//========= MD3 Support =========

IntPtr AnimatedMeshSceneNode_GetMD3TagNode(IntPtr node, M_STRING tagName)
{
	return GetNodeFromIntPtr(node)->getMD3TagNode(tagName);
}

void AnimatedMeshSceneNode_SetAnimation(IntPtr node, int animIdx)
{
	GetNodeFromIntPtr(node)->setAnimation(animIdx);
}

void AnimatedMeshSceneNode_AddAnimation(IntPtr node, int firstFrame, int lastFrame, int FPS)
{
	GetNodeFromIntPtr(node)->addAnimation(firstFrame, lastFrame, FPS);
}

void AnimatedMeshSceneNode_LinkAnimation(IntPtr node, int anim, int linkedAnim)
{
	GetNodeFromIntPtr(node)->linkAnimation(anim, linkedAnim);
}
3. Save and recompile.
4. Now go to your Irrlicht.NET wrapper and find AnimatedMesh.cs in Scene/Meshes

Find :

Code: Select all

	public enum AnimatedMeshType
	{
		Unknown,
		MD2,
		MS2D,
		OBJ,
		BSP,
		T3DS,
		X,
		MY3D,
		LMTS,
		CSM,
		OCT
	}
Make it look like :

Code: Select all

	public enum AnimatedMeshType
	{
		Unknown,
		MD2,
		MD3,
		MS2D,
		OBJ,
		BSP,
		T3DS,
		X,
		MY3D,
		LMTS,
		CSM,
		OCT
	}
Please take it easy on me, im still learning. Im sure i might have missed some stuff here and there. One strange thing i noticed when i fired up Meshviewer.exe ( both Irrlicht and Irrlicht.NET versions ) is that md3 models load strangely positioned. Because this happens on the non-.NET version i assume it's a bug in the patch, but maybe it's my mistake somewhere :oops:

Posted: Tue Jul 18, 2006 7:44 pm
by DeusXL
Excellent sh1ny, I'll try it :)

For now, I try to remain on Irrlicht's official SDK but who knows !

PS : There's just something strange, you create functions in the IrrlichtW wrapper but do not "wrap" them in the C# wrapper. You'll be able to load MD3 in Irrlicht but not manipulate them I think.

Posted: Tue Jul 18, 2006 8:31 pm
by sh1ny
Yes, i was sure im forgetting something :oops: Forgive the noob :)

Here goes :

Open AnimatedMeshSceneNode.cs in your Irrlicht.NET CP project ( located in Scene/SceneNodes ) and find :

Code: Select all

		public SceneNode GetXJointNode(string jointName)
		{
			return (SceneNode)
				NativeElement.GetObject(AnimatedMeshSceneNode_GetXJointNode(_raw, jointName),
										typeof(SceneNode));
		}
Under that add :

Code: Select all

        //MD3 File Support
        public SceneNode GetMD3TagNode(string tagName)
        {
            return (SceneNode)NativeElement.GetObject(AnimatedMeshSceneNode_GetMD3TagNode(_raw, tagName), typeof(SceneNode));
        }

        public void SetAnimation(int animIdx)
        {
            AnimatedMeshSceneNode_SetAnimation(_raw, animIdx);
        }

        public void AddAnimation(int firstFrame, int lastFrame, int FPS)
        {
            AnimatedMeshSceneNode_AddAnimation(_raw, firstFrame, lastFrame, FPS);
        }

        public void LinkAnimation(int anim, int linkedAnim)
        {
            AnimatedMeshSceneNode_LinkAnimation(_raw, anim, linkedAnim);
        }

        //End MD3 File Support
Further down find :

Code: Select all

		[DllImport(Native.Dll)]
		static extern IntPtr AnimatedMeshSceneNode_GetXJointNode(IntPtr node, string jointName);
Under it add :

Code: Select all

        //MD3 File Support
        [DllImport(Native.Dll)]
        static extern IntPtr AnimatedMeshSceneNode_GetMD3TagNode(IntPtr node, string tagName);

        [DllImport(Native.Dll)]
        static extern void AnimatedMeshSceneNode_SetAnimation(IntPtr node, int animIdx);

        [DllImport(Native.Dll)]
        static extern void AnimatedMeshSceneNode_AddAnimation(IntPtr node, int firstFrame, int lastFrame, int FPS);

        [DllImport(Native.Dll)]
        static extern void AnimatedMeshSceneNode_LinkAnimation(IntPtr node, int anim, int linkedAnim);
        //END MD3 Support
Im also thinking of modifying the patch to use SetMD3Animation, AddMD3Animation for the sanity's sake :P Also since Irrlicht's svn version doesnt compile for me ( im sick of removing links to libs that keep appearing again in ms vc++ 2005 ) ill be porting and adding the ogre and obj loaders/managers to current 1.0 code and wrapping them into the CP lib :P And yea it's MSVC's fault that irr svn doesnt compile, but i prefer using it over code::blocks for some reason :P

Posted: Tue Jul 18, 2006 8:54 pm
by hybrid
If you're using the very latest SVN version (version 70 of later) you have to replace CStaticMeshOBJ.{cpp|h} by COBJMeshFileLoader.{cpp|h}, the project files are not updated for VisualStudio, Linux Makefile and dev-cpp are updated.

Posted: Tue Jul 18, 2006 9:08 pm
by sh1ny
Yes i did some cleaning on those, but msvc 2005 insisit i should include libci.dll ( or .lib cant remember right now ). First was odbc32.lib wich is somewhat of "confirmed bug" in the express edition im using, then i fixed the project files and finally i started to get these. I think ill leave it at that for today :P

Posted: Wed Jul 19, 2006 8:14 am
by Rowan Lewis
Good work, again, I'm nearly 1000 lines into my game using this, but I need one thing, I need to use the latest SVN (70) because it fixes some of the bugs that are completely holding me up.

Can you tell me how to do that?

Also, perhaps we need a forum here for 'DeusXLs Irrlich.NET'?

Posted: Wed Jul 19, 2006 8:29 am
by DeusXL
Well I never tested the latest SVN but what if you compile the project IrrlichtW using SVN includes ?

Posted: Wed Jul 19, 2006 8:45 am
by hybrid
Rowan Lewis wrote:Also, perhaps we need a forum here for 'DeusXLs Irrlich.NET'?
You're already posting in it :)
It's simply the common way to have a large thread per project. If there are special things to handle there's no problem to open up a new thread on that topic. Maybe the .net forum would be a good place for it.

Posted: Wed Jul 19, 2006 3:11 pm
by Rowan Lewis
Oh, before I forget, you might want to fix the 'F' key:

Code: Select all

		Key_E            = 0x45,  // E key
		F            = 0x46,  // F key
		Key_G            = 0x47,  // G key

Posted: Wed Jul 19, 2006 5:07 pm
by DeusXL
Rowan Lewis wrote:Oh, before I forget, you might want to fix the 'F' key:

Code: Select all

		Key_E            = 0x45,  // E key
		F            = 0x46,  // F key
		Key_G            = 0x47,  // G key
Thanks, fixed :)