Mesh primitive creation functions

BlitzMax Forums/MiniB3D Module/Mesh primitive creation functions

JoshK(Posted 2007) [#1]
I have determined that the mesh primitive creation functions create a lot of bad geometry. If you print out the triangle array contents from a sphere, cylinder, or cone, you'll see that they contains lots of duplicate triangles, triangles with duplicate vertices, even invalid indices.


simonh(Posted 2007) [#2]
Yeah, I kind of suspected that. I'll replace the mesh creation functions with the actual Blitz3D ones in the next release.


JoshK(Posted 2007) [#3]
Let me make sure, I have some stuff screwed up ATM...

I am not sure what's going on, but spheres cause Newton to crash.


ninjarat(Posted 2007) [#4]
Really? I've done some attempted Newton simulations, and spheres were never a problem for me... but now that I think about it, it's probably due to the fact that the MiniB3D spheres have invalid verts.


JoshK(Posted 2007) [#5]
Sorry, it was my fault. Apparently Newton goes ape-sh** if you have a lot of tree collisions sitting at the origin.


klepto2(Posted 2007) [#6]
yes, that was also my result with Newton.
But the Newtonspheres, cubes. are independent from the miniB3D geometry as long as you don't build complex hulls in Newton.
Also I hope that cones and cylinders will work much better with Newton in the new Version. Currently they seemed to be flipped in the Z axis by 90 degrees and result in unwanted effects at simulation time.

If someone want to try to implement Newton themselves (not with my physic extension) here is the correct matrix translation for miniB3D --> Newton and back:
Method Update()
		newtonBodyGetMatrix(Node , Mat)
		NewtonBodyGetVelocity(Node,Velocity)
		NewtonBodyGetOmega(Node,Omega)
		Max3DSetMatrix(Self,Mat)
		Local mmp:Float Ptr=Mesh.Mat.grid
		mmp[0]=mat[0]
		mmp[1]=mat[1]
		mmp[2]=-mat[2]
		mmp[4]=mat[4]
		mmp[5]=mat[5]
		mmp[6]=-mat[6]
		mmp[8]=mat[8]
		mmp[9]=mat[9]
		mmp[10]=-mat[10]
		mmp[12]=mat[12]'posx
		mmp[13]=mat[13]'posy
		mmp[14] = - mat[14]'-posz
		
		posx = mat[12]
		posy = mat[13]
		posz = - mat[14]
		
		Mesh.Mat.Scale(-mesh.sx,-mesh.sy,-mesh.sz)
	End Method

A bit offtopic but maybe this is helping some people. Because this was the hardest thing to figure out as I hadn't understand matrices at this time.