Translate Triangles
Blitz3D Forums/Blitz3D Beginners Area/Translate Triangles
| ||
Hi. I have a problem to find the command for moving triangles. I've searched the help files for this but i didn't found anything, so i want to ask this here. I want to translate an triangle. My script does include the selection of triangles (which give me the number of the tris) and the CameraPick() command after an "if"-command. My goal is to write an 3D Modeling Software, so i want to learn the basics of the 3D tools of Blitz3D. Can someone help me? Thanks in advance... Greetings Argandos |
| ||
There isn't one. Triangles don't have a position in their own right - they're just a grouping construct for three vertices (literally, the only data a triangle "object" actually holds is the IDs of its vertices). Vertices have position and other properties, so to "move" a triangle, you actually move the three vertices that comprise it in the direction you want.Function MoveTriangle(surf, tri, x#, y#, z#) Local v0 = TriangleVertex(surf, tri, 0), v1 = TriangleVertex(surf, tri, 1), v2 = TriangleVertex(surf, tri, 2) VertexCoords(surf, v0, VertexX(surf, v0) + x, VertexY(surf, v0) + y, VertexZ(surf, v0) + z) VertexCoords(surf, v1, VertexX(surf, v1) + x, VertexY(surf, v1) + y, VertexZ(surf, v1) + z) VertexCoords(surf, v2, VertexX(surf, v2) + x, VertexY(surf, v2) + y, VertexZ(surf, v2) + z) End Function |
| ||
Wow, that was fast! I will add this to my code - Thanks ;) |
| ||
Sorry, still don't get it. I need the position of the vertices, right? And with that position, i can translate the vertice to another position? Is there an command to show the position of the vertices like: "Text 0,200,"PickedSurface: "+PickedSurface()" or something? I'm using a simple cube with the command CreateCube, maybe this is wrong? Would be really nice if you can help me again, this is an really important topic for me ;) |
| ||
Here's something I wrote ages ago when Blitz3D was young. I used it to decipher how meshes worked. The example is more complicated than it needs to be. At the time I was trying to figure out what AddMesh did; one surface, multiple surfaces...? Have a look through the Blitz3D - Category list, the Mesh and Surface sections should have all the relevant commands. ; Function to dump vertex info to debug log. Graphics3D 800,600,16,2 s1=CreateSphere() s2=CopyEntity(s1) cone=CreateCone(5) PositionMesh s2,2,0,0 ;DumpVertices(s1,5,"Sphere 1 vertex info.") ;DumpVertices(s2,5,"Sphere 2 vertex info.") clone=CreateMesh() AddMesh cone,clone dumpvertices(cone,100,"Cone") WaitKey() End Function DumpVertices( mesh, maxVertices, message$="Vertex list" ) Local nSurfs, sIndex, surface, vCount, lf$, txt$ Local x$,y$,z$, nx$,ny$,nz$ lf$=Chr$(10) nSurfs=CountSurfaces( mesh ) DebugLog lf+message+lf DebugLog "Number of surfaces = "+nSurfs+lf For sIndex=1 To nSurfs DebugLog "Surface = "+sIndex+lf surface=GetSurface( mesh, sIndex ) For v=0 To CountVertices( surface ) - 1 vCount = vCount + 1 If vCount > maxVertices DebugLog lf+"Number of vertices shown = "+(vCount-1) Return End If x = RSet( VertexX( surface, v ), 13) y = RSet( VertexY( surface, v ), 13) z = RSet( VertexZ( surface, v ), 13) nx = RSet( VertexNX( surface, v ), 13) ny = RSet( VertexNY( surface, v ), 13) nz = RSet( VertexNZ( surface, v ), 13) txt="v="+RSet(v,4)+" "+x+y+z+" "+nx+ny+nz DebugLog txt Next Next DebugLog lf+"Number of vertices shown = "+vCount End Function |