; VertexColor Example ; ------------------- ; VertexColor tints a single vertex; the GPU blends the colours ; smoothly across each triangle. Vertex colours only show when the ; entity has EntityFX flag 2 set. Here each corner of a quad cycles ; through colours at its own pace. Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-4 panel=CreateMesh() surf=CreateSurface(panel) ; A simple quad with one vertex per corner v0=AddVertex(surf,-1.5,1.5,0) v1=AddVertex(surf,1.5,1.5,0) v2=AddVertex(surf,1.5,-1.5,0) v3=AddVertex(surf,-1.5,-1.5,0) AddTriangle surf,v0,v1,v2 AddTriangle surf,v0,v2,v3 ; Flag 2 = use vertex colours instead of lighting EntityFX panel,2 While Not KeyDown(1) ; Cycle each corner's colour with offset phases - the documented ; command, called once per vertex per frame t#=MilliSecs()*0.1 r0#=127+128*Sin(t) g0#=127+128*Sin(t+120) b0#=127+128*Sin(t+240) VertexColor surf,v0,r0,g0,b0 VertexColor surf,v1,g0,b0,r0 VertexColor surf,v2,b0,r0,g0 VertexColor surf,v3,255-r0,255-g0,255-b0 ; 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,"VertexColor surf,v0,"+Int(r0)+","+Int(g0)+","+Int(b0) Flip Wend End