Single Surface System
Blitz3D Forums/Blitz3D Programming/Single Surface System
| ||
Hey i'm stumped, on my previous versions of my game i'm just creating grass and using linepick() to randomly position it on my terrain... However it causes a major slowdown in framerate so what i'm trying to do is make a single surface system... but how would i go about duplicating my 3 vertices / 1 triangle without creating the next surface? here's my code ;Grass Single Surface Grass System AppTitle "Vertex Test" Graphics3D 800,600,16,2 SetBuffer BackBuffer() Global mesh Global grasstex ;Create Mesh mesh = CreateMesh() ;Create Surface surface = CreateSurface(mesh) ;Create Vertices v0 = AddVertex(surface,0,2,0,0.5,-1,0) v1 = AddVertex(surface,2,0,0,1,0,0) v2 = AddVertex(surface,-2,0,0,0,0,0) ;Create Triangle grass = AddTriangle(surface,v0,v1,v2) EntityFX mesh, 16 ;Load Grass Texture grasstex = LoadTexture("HeightMap\Grass\Weed.jpg",4) EntityTexture mesh, grasstex ;Create Camera camera = CreateCamera() PositionEntity camera,0,0,-2 While Not KeyHit(1) If KeyDown(200) MoveEntity camera,0,0,0.1 EndIf If KeyDown(208) MoveEntity camera,0,0,-0.1 EndIf RenderWorld() Flip Wend End |
| ||
Just keep adding three more vertices and a triangle to the mesh :o) |
| ||
should i make a function to keep 3 vertices in a triangle shape? I copyentity(mesh) and countsurfaces(mesh) came up with only 1 surface... is that a working single surface particle system? |
| ||
Only one surface on that mesh. Each mesh is a surface on it's own. You need to add more vertices and triangles to the same mesh. Basic sort of example. All the triangles and vertices are added to the one surface. Press the 1 key to add more grass :o) Graphics3D 800,600 SetBuffer BackBuffer() Global camera = CreateCamera() PositionEntity camera,0,3,-15 Global plane = CreatePlane() EntityColor plane,50,50,50 Global mesh = CreateMesh() EntityColor mesh,0,255,0 Global surface = CreateSurface(mesh) While Not KeyHit(1) If KeyHit(2) Then add_grass() UpdateWorld RenderWorld Flip Wend End Function add_grass() px = Rnd(-10,10) py = 0 pz = Rnd(-10,10) v0 = AddVertex(surface,px ,py+2, pz, 0.5,-1) v1 = AddVertex(surface,px+2,py, pz, 1,0) v2 = AddVertex(surface,px-2,py, pz, 0,0) AddTriangle(surface,v0,v1,v2) UpdateNormals(mesh) End Function |
| ||
okay i finally figured it out! thanks alot Ross :-P for a second i thot i'd have to make a hundred vertexes in diff positions with the same triangle :-P thanks for the help! |
| ||
Decent example of how to do grass. |