IMeshBuffer

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
Guest2

IMeshBuffer

Post by Guest2 »

Hello,
i have to add Newton physics into my game. I need the IMeshBuffer class
in Irrlicht.NET but it doesn't exist !

Please tell me what i can do now !

Bye.
Guest2

Post by Guest2 »

Hello,
i added IMeshBuffer myself so here it is:

http://rapidshare.de/files/17278514/IMe ... T.rar.html

Bye !
noone88

Post by noone88 »

Could you

please, please, please, PLEASE

uppload the source?

I want to send niko or one of the other 'main' developers the meshbuffer source so that the next release (or the cvs) includes the files
Guest2

Post by Guest2 »

Nezumi
Posts: 15
Joined: Fri Sep 30, 2005 9:42 pm

Post by Nezumi »

Great !!
Nezumi
Posts: 15
Joined: Fri Sep 30, 2005 9:42 pm

Post by Nezumi »

I try to convert Irrlicht Mesh to ODE TriMesh...

Code: Select all

private void createTriMesh()
		{
			int i,j,ci,cif,cv;
			int indexcount=0;
			int vertexcount=0;
			IMesh omesh = mesh.GetMesh(0);
			// count vertices and indices
			for(i=0;i < omesh.MeshBufferCount;i++)
			{
				IMeshBuffer mb=omesh.GetMeshBuffer(i);
				indexcount+=mb.IndexCount;
				vertexcount+=mb.VertexCount;
			}
			// build structure for ode trimesh geom
			Vector3[] vertices =new Vector3[vertexcount];
			int[] indices= new int[indexcount];
			// fill trimesh geom
			ci=0; // current index in the indices array
			cif=0; // offset of the irrlicht-vertex-index in the vetices array 
			cv=0; // current index in the vertices array
			for(i=0;i<omesh.MeshBufferCount;i++)
			{
				IMeshBuffer mb=omesh.GetMeshBuffer(i);
				// fill indices
				ushort* mb_indices=mb.Indices;
				for(j=0;j < mb.IndexCount;j++)
				{
					// scale the indices from multiple meshbuffers to single index array
					indices[ci]=cif+mb_indices[j];
					ci++;
				}
				// update the offset for the next meshbuffer
				cif=cif+mb.VertexCount;
				// fill vertices
				if(mb.VertexType==VertexType.STANDARD)
				{
					Vertex3D* mb_vertices=	(Vertex3D*)mb.Vertices;
					for(j=0;j<mb.VertexCount;j++)
					{
						vertices[cv].X=mb_vertices[j].Pos.X;
						vertices[cv].Y=mb_vertices[j].Pos.Y;
						vertices[cv].Z=mb_vertices[j].Pos.Z;
						cv++;
					} 
				}
				else if(mb.VertexType==VertexType.TWOTCOORDS)
				{
					Vertex3D2Tex* mb_vertices=	(Vertex3D2Tex*)mb.Vertices;
					for(j=0;j<mb.VertexCount;j++)
					{
						vertices[cv].X=mb_vertices[j].Pos.X;
						vertices[cv].Y=mb_vertices[j].Pos.Y;
						vertices[cv].Z=mb_vertices[j].Pos.Z;
						cv++;
					} 
				} 
			}
			Vector3D pos=m_terrain.Position;
			// build the trimesh data
			if(geom != null)
				geom.Destroy();
			geom = new ODE.Geoms.TriMesh(vertices,indices);
			geom.Position = toODE(pos);
			body.Position = toODE(pos);
			geom.RigidBody = body;
		}
The problem is: my item fall trough the ODE Plane.... why?
buhatkj
Posts: 444
Joined: Fri Dec 12, 2003 4:53 am
Contact:

THANKS!!

Post by buhatkj »

I'd just like to say, that this is pretty awesome. I think if I just rewrite my old C++ meshbuffer crawling routine I can have physics in .NET.

Heh now if somebody will make a .NET newton wrapper....lol
My irrlicht-based projects have gone underground for now, but if you want, check out my webcomic instead! http://brokenboomerang.net
groats
Posts: 7
Joined: Tue Mar 21, 2006 11:49 am

Post by groats »

Heres Nezumi's great little Ode trimesh method in C# for anyone that needs it.

Code: Select all

 protected ODE.Geoms.TriMesh createTriMesh(IAnimatedMesh mesh)
        {
            int i, j, ci, cif, cv;
            int indexcount = 0;
            int vertexcount = 0;
            IMesh omesh = mesh.GetMesh(0);

            // count vertices and indices
            for (i = 0; i < omesh.MeshBufferCount; i++)
            {
                IMeshBuffer mb = omesh.GetMeshBuffer(i);
                indexcount += mb.IndexCount;
                vertexcount += mb.VertexCount;
            }
            // build structure for ode trimesh geom
            ODE.NoMDX.Vector3[] vertices = new ODE.NoMDX.Vector3[vertexcount];
            int[] indices = new int[indexcount];

            // fill trimesh geom
            ci = 0; // current index in the indices array
            cif = 0; // offset of the irrlicht-vertex-index in the vetices array
            cv = 0; // current index in the vertices array
            for (i = 0; i < omesh.MeshBufferCount; i++)
            {
                IMeshBuffer mb = omesh.GetMeshBuffer(i);

                // fill indices
                for (j = 0; j < mb.IndexCount; j++)
                {
                    // scale the indices from multiple meshbuffers to single index array
                    indices[ci] = cif + mb.GetIndex(j);
                    ci++;
                }

                // update the offset for the next meshbuffer
                cif = cif + mb.VertexCount;

                // fill vertices
                if (mb.VertexType == VertexType.STANDARD)
                {
                    //Vertex3D* mb_vertices = (Vertex3D*)mb.Vertices;
                    for (j = 0; j < mb.VertexCount; j++)
                    {
                        vertices[cv].X = mb.GetVertex(j).Pos.X;
                        vertices[cv].Y = mb.GetVertex(j).Pos.Y;
                        vertices[cv].Z = mb.GetVertex(j).Pos.Z;
                        cv++;
                    }
                }
                else if (mb.VertexType == VertexType.TWOTCOORDS)
                {
                    for (j = 0; j < mb.VertexCount; j++)
                    {
                        vertices[cv].X = mb.GetVertex2Tex(j).Pos.X;
                        vertices[cv].Y = mb.GetVertex2Tex(j).Pos.Y;
                        vertices[cv].Z = mb.GetVertex2Tex(j).Pos.Z;
                        cv++;
                    }
                }
            }
I am using this code for my 'Ground' and it works fine ( just remember that once you have created the geom to add it to the Ode Space.
Yeurl
Posts: 31
Joined: Thu Apr 13, 2006 9:34 am

Post by Yeurl »

from buhatkj
if somebody will make a .NET newton wrapper
go to tje newton forum and you will find it ;)
Poganezz
Posts: 7
Joined: Fri May 19, 2006 6:49 am

Post by Poganezz »

Guest2 wrote:Hello,
here it is http://rapidshare.de/files/17412292/IMe ... c.rar.html.

Bye !
I can't download the file. Could you send it on cyr1988pro_left@front.ru
Poganezz
Posts: 7
Joined: Fri May 19, 2006 6:49 am

Post by Poganezz »

Guest2 wrote:Hello,
here it is http://rapidshare.de/files/17412292/IMe ... c.rar.html.

Bye !
I can't download the file. Could you send it on cyr1988pro_left@front.ru
szerg
Posts: 15
Joined: Mon Jun 05, 2006 4:23 pm

what do i do wrong

Post by szerg »

i 'd like to transform the irr terrain to ode trimesh using this syntax and the new Irrlicht.NET CP.., and add it to my car game..
but my car doesnt collide with the terrain/trimesh..

Code: Select all

        public void LoadTerrain()
        {

            if (device == null)
            {
                MessageBox.Show("Couldn't load terrain because device was null.", "Terrain");
                return;
            }

            VideoDriver driver = device.VideoDriver;
            SceneManager smgr = device.SceneManager;

            TerrainSceneNode terrain = smgr.AddTerrainSceneNode(
                mediapath + @"terrain\terrain-heightmap.bmp", null, -1,
                new Vector3D(), new Vector3D(), new Vector3D(40, 4.4f, 40), new Color(255, 255, 255, 255), 100, TerrainPatchSize.TPS33);

            terrain.SetMaterialFlag(MaterialFlag.Lighting, false);
            terrain.SetMaterialType(MaterialType.DetailMap);
            terrain.SetMaterialTexture(0, driver.GetTexture(mediapath + @"terrain\terrain-texture.jpg"));
            terrain.SetMaterialTexture(1, driver.GetTexture(mediapath + @"terrain\detailmap3.jpg"));


            terrain.ScaleTexture(1.0f, 20.0f);
   
            TriangleSelector selector =
                smgr.CreateTerrainTriangleSelector(terrain, 0);
            
            driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, false);

            createTriMesh(terrain);
        }

Code: Select all

        private void createTriMesh(TerrainSceneNode mesh)
        {
            int i, j, ci, cif, cv;
            int indexcount = 0;
            int vertexcount = 0;
            Mesh omesh = mesh.Mesh;

            // count vertices and indices 
            for (i = 0; i < omesh.MeshBufferCount; i++)
            {
                MeshBuffer mb = omesh.GetMeshBuffer(i);
                indexcount += mb.IndexCount;
                vertexcount += mb.VertexCount;
            }
            // build structure for ode trimesh geom 
            Vector3[] vertices = new Vector3[vertexcount];
            int[] indices = new int[indexcount];

            // fill trimesh geom 
            ci = 0; // current index in the indices array 
            cif = 0; // offset of the irrlicht-vertex-index in the vetices array 
            cv = 0; // current index in the vertices array 
            for (i = 0; i < omesh.MeshBufferCount; i++)
            {
                MeshBuffer mb = omesh.GetMeshBuffer(i);

                // fill indices 
                for (j = 0; j < mb.IndexCount; j++)
                {
                    // scale the indices from multiple meshbuffers to single index array 
                    indices[ci] = cif + mb.GetIndex(j);
                    ci++;
                }

                // update the offset for the next meshbuffer 
                cif = cif + mb.VertexCount;

                // fill vertices 
                    //Vertex3D* mb_vertices = (Vertex3D*)mb.Vertices; 
                    for (j = 0; j < mb.VertexCount; j++)
                    {
                        vertices[cv].X = mb.GetVertex(j).Position.X;
                        vertices[cv].Y = mb.GetVertex(j).Position.Y;
                        vertices[cv].Z = mb.GetVertex(j).Position.Z;
                        cv++;
                    }
            }

            Vector3D pos = mesh.Position;

            ODE.Geoms.TriMesh terra = new ODE.Geoms.TriMesh(vertices, indices);
            space.Add(terra);
            terra.Position = new Vector3(pos.X, pos.Y, pos.Z);
            return;

        }
just falls down :roll:
ProSoft
Posts: 59
Joined: Thu Sep 08, 2005 10:55 am
Location: Brasil

Post by ProSoft »

Please, repost the original code or send it to a permanent host. If you cannot, please send it to my mail.

Tks
HantaCore
Posts: 21
Joined: Wed Mar 22, 2006 4:38 pm

Post by HantaCore »

Hi guys, I'd like to know where to find the source-code for the IMeshBuffer, in order to be able to use ODE.NET with Irrlicht.NET

Please could someone repost the file, either as snippet or as a link to the file?

Thanks for any answer
Currently working on a C# MMORPG using Irrlicht.NET
Locked