shadmar Posted May 30, 2015 Share Posted May 30, 2015 It works but seem to render only every other frame. Maybe someone can figure it out: function Script:Start() --make a vertex buffer vbo = { } maxvbo = 100 mat=Material:Create() mat:SetBackFaceCullMode(false) --fill it with nonsense positions local pos=self.entity:GetPosition(true) for x=1,maxvbo,2 do --just insert some data table.insert(vbo,Vec3(pos.x-.5,pos.y+x,pos.z)) table.insert(vbo,Vec3(pos.x+.5,pos.y+x,pos.z)) end lasttime=0 --create a model model = Model:Create() model:SetOcclusionCullingMode(false) model:SetColor(1.0,0.0,1.0) --make surface local surface = model:AddSurface() --add vertices for k,v in ipairs(vbo) do surface:AddVertex(v.x,v.y,v.z, 0,0,-1) end --make triangle strip surface:AddTriangle(2,1,0) surface:AddTriangle(0,3,2) for x=1,maxvbo-4,2 do surface:AddTriangle(x+3,x+1,x+2) surface:AddTriangle(x+2,x+4,x+3) end surface:Update() model:UpdateAABB(Entity.LocalAABB) model:UpdateAABB(Entity.GlobalAABB) model:SetMaterial(mat) end function Script:UpdateWorld() if Time:GetCurrent()-20 > lasttime then --get positions local pos=self.entity:GetPosition(false) table.insert(vbo,Vec3(pos.x+.5,pos.y,pos.z)) table.insert(vbo,Vec3(pos.x-.5,pos.y,pos.z)) --remove last vertex each loop table.remove(vbo,1) table.remove(vbo,2) lasttime=Time:GetCurrent() --ok move all vertices according to vbo local surface = model:GetSurface(0) for v=0, surface:CountVertices()-1 do surface:SetVertexPosition(v,vbo[v+1]) end surface:Update() model:UpdateAABB(Entity.LocalAABB) model:UpdateAABB(Entity.GlobalAABB) end end 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted May 31, 2015 Author Share Posted May 31, 2015 Fixed. / updated. 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.