Mesh help
BlitzMax Forums/MiniB3D Module/Mesh help
| ||
I created a ramp mesh like what Maplet has, but I cannot figure out how to do all of the VertexTexCoords stuff. Any help? Is it even really needed?Function CreateRamp:TMesh(parent_ent:TEntity=Null) Local mesh:TMesh=TMesh.CreateMesh(parent_ent) Local surf:TSurface=mesh.CreateSurface() Local v0:Int,v1:Int,v2:Int,v3:Int v0=surf.AddVertex(-1.0,-1.0,-1.0) v1=surf.AddVertex(-1.0, 1.0,-1.0) v2=surf.AddVertex( 1.0,-1.0,-1.0) surf.AddTriangle(v0,v1,v2) surf.VertexTexCoords(v1,0.0,0.0) surf.VertexTexCoords(v0,0.0,1.0) surf.VertexTexCoords(v2,1.0,1.0) v0=surf.AddVertex( 1.0,-1.0, 1.0) v1=surf.AddVertex(-1.0, 1.0, 1.0) v2=surf.AddVertex(-1.0,-1.0, 1.0) surf.AddTriangle(v0,v1,v2) surf.VertexTexCoords(v0,1.0,1.0) surf.VertexTexCoords(v1,0.0,0.0) surf.VertexTexCoords(v2,0.0,1.0) v0=surf.AddVertex(-1.0,-1.0,-1.0) v1=surf.AddVertex( 1.0,-1.0,-1.0) v2=surf.AddVertex(-1.0,-1.0, 1.0) v3=surf.AddVertex( 1.0,-1.0, 1.0) surf.AddTriangle(v0,v1,v3) surf.AddTriangle(v2,v0,v3) surf.VertexTexCoords(v0,0.0,0.0) surf.VertexTexCoords(v1,0.0,1.0) surf.VertexTexCoords(v2,1.0,0.0) surf.VertexTexCoords(v3,1.0,1.0) v0=surf.AddVertex(-1.0,-1.0,-1.0) v1=surf.AddVertex(-1.0, 1.0,-1.0) v2=surf.AddVertex(-1.0,-1.0, 1.0) v3=surf.AddVertex(-1.0, 1.0, 1.0) surf.AddTriangle(v2,v1,v0) surf.AddTriangle(v3,v1,v2) surf.VertexTexCoords(v0,1.0,1.0) surf.VertexTexCoords(v1,1.0,0.0) surf.VertexTexCoords(v2,0.0,1.0) surf.VertexTexCoords(v3,0.0,0.0) v0=surf.AddVertex(-1.0, 1.0,-1.0) v1=surf.AddVertex(-1.0, 1.0, 1.0) v2=surf.AddVertex( 1.0,-1.0,-1.0) v3=surf.AddVertex( 1.0,-1.0, 1.0) surf.AddTriangle(v0,v1,v3) surf.AddTriangle(v2,v0,v3) surf.VertexTexCoords(v0,0.0,0.0) surf.VertexTexCoords(v1,1.0,0.0) surf.VertexTexCoords(v2,0.0,1.0) surf.VertexTexCoords(v3,1.0,1.0) mesh.UpdateNormals() Return mesh EndFunction |
| ||
It's needed if you want to texture the ramp, yes. You just need to assign the four corner co-ordinates of a texture (0,0; 0,1; 1,1; 1,0) to each face of your ramp. |
| ||
Oh, OK. I updated the code at the top. Is that correct? |
| ||
If it looks corrent, it's correct! That's up to you to decide. |
| ||
:) But looking back through the CreateCube function, it has all of the VertexTexCoords functions again but with the last parameter set to 1. Is that for the stretching or tiling? |
| ||
That's for the second UV set, if you need multi-texturing. |
| ||
OK. Thanks for the quick replies. |
| ||
Also, could this possibly be added to MiniB3D? |
| ||
Here is a wedge mesh:Function CreateWedge:TMesh(parent_ent:TEntity=Null) Local mesh:TMesh=TMesh.CreateMesh(parent_ent) Local surf:TSurface=mesh.CreateSurface() Local v0:Int,v1:Int,v2:Int,v3:Int v0=surf.AddVertex(-1.0, 1.0,-1.0,0.0,0.0) v1=surf.AddVertex( 1.0, 1.0,-1.0,1.0,0.0) v2=surf.AddVertex(-1.0,-1.0,-1.0,0.0,1.0) v3=surf.AddVertex( 1.0,-1.0,-1.0,1.0,1.0) surf.AddTriangle(v0,v1,v2) surf.AddTriangle(v2,v1,v3) v0=surf.AddVertex(-1.0, 1.0,-1.0,0.0,1.0) v1=surf.AddVertex( 1.0, 1.0,-1.0,1.0,1.0) v2=surf.AddVertex( 0.0, 1.0, 1.0,0.5,0.0) surf.AddTriangle(v2,v1,v0) v0=surf.AddVertex(-1.0,-1.0,-1.0,0.0,1.0) v1=surf.AddVertex( 1.0,-1.0,-1.0,1.0,1.0) v2=surf.AddVertex( 0.0,-1.0, 1.0,0.5,0.0) surf.AddTriangle(v0,v1,v2) v0=surf.AddVertex(-1.0, 1.0,-1.0,1.0,0.0) v1=surf.AddVertex(-1.0,-1.0,-1.0,1.0,1.0) v2=surf.AddVertex( 0.0, 1.0, 1.0,0.0,0.0) v3=surf.AddVertex( 0.0,-1.0, 1.0,0.0,1.0) surf.AddTriangle(v0,v1,v2) surf.AddTriangle(v2,v1,v3) v0=surf.AddVertex( 1.0, 1.0,-1.0,0.0,0.0) v1=surf.AddVertex( 1.0,-1.0,-1.0,0.0,1.0) v2=surf.AddVertex( 0.0, 1.0, 1.0,1.0,0.0) v3=surf.AddVertex( 0.0,-1.0, 1.0,1.0,1.0) surf.AddTriangle(v2,v1,v0) surf.AddTriangle(v3,v1,v2) mesh.UpdateNormals() Return mesh EndFunction |