; AddVertex Example ; ----------------- ; AddVertex adds a point to a surface and returns its index number, ; counting from 0. The optional u,v parameters say which part of a ; texture the vertex pins to: 0,0 is the texture's top-left corner, ; 1,1 its bottom-right. Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-4 banner=CreateMesh() surf=CreateSurface(banner) ; Four vertices make the corners of a banner - the documented command v0=AddVertex(surf,-2,1,0,0,0) ; top left (u 0, v 0) v1=AddVertex(surf,2,1,0,1,0) ; top right (u 1, v 0) v2=AddVertex(surf,2,-1,0,1,1) ; bottom right (u 1, v 1) v3=AddVertex(surf,-2,-1,0,0,1) ; bottom left (u 0, v 1) ; Two clockwise triangles connect the four corners into a quad AddTriangle surf,v0,v1,v2 AddTriangle surf,v0,v2,v3 ; Texture the banner so we can see the uv mapping at work tex=LoadTexture("media/b3dlogo.jpg") EntityTexture banner,tex ; Fullbright (1) + two-sided (16) so it stays visible while spinning EntityFX banner,17 While Not KeyDown(1) TurnEntity banner,0,1,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"AddVertex returned indices "+v0+","+v1+","+v2+","+v3 Text 0,40,"Each vertex pins one texture corner: uv 0,0 = top left" Flip Wend End