Page 1 of 1
IMeshBuffer
Posted: Wed Apr 05, 2006 12:53 pm
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.
Posted: Wed Apr 05, 2006 5:54 pm
by Guest2
Hello,
i added IMeshBuffer myself so here it is:
http://rapidshare.de/files/17278514/IMe ... T.rar.html
Bye !
Posted: Thu Apr 06, 2006 6:51 pm
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
Posted: Fri Apr 07, 2006 1:33 pm
by Guest2
Posted: Tue Apr 11, 2006 10:30 am
by Nezumi
Great !!
Posted: Tue Apr 11, 2006 5:20 pm
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?
THANKS!!
Posted: Tue Apr 25, 2006 11:29 pm
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
Posted: Tue May 02, 2006 5:02 pm
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.
Posted: Wed May 03, 2006 6:55 am
by Yeurl
from buhatkj
if somebody will make a .NET newton wrapper
go to tje newton forum and you will find it

Posted: Sun May 21, 2006 7:43 am
by Poganezz
I can't download the file. Could you send it on
cyr1988pro_left@front.ru
Posted: Sun May 21, 2006 7:43 am
by Poganezz
I can't download the file. Could you send it on
cyr1988pro_left@front.ru
what do i do wrong
Posted: Sun Jul 23, 2006 9:15 pm
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

Posted: Mon Aug 21, 2006 1:58 pm
by ProSoft
Please, repost the original code or send it to a permanent host. If you cannot, please send it to my mail.
Tks
Posted: Mon Dec 11, 2006 9:15 am
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