I have been using some single surface code I found either in a code archives on posted on these boards some time ago for my latest game. But I now need one of the quads in the system to rotate for a certain effect. Its a bit late in the project to completely change the system so I am planning to modify what is already there to take into account an angle variable at the end of each frame when it faces towards the camera. The angle will be Z (roll) or the angle you usually change with RotateSprite (although I think rotatesprite is iverted Z).
My 3D math skills are pretty much non existent, so I'd like to ask if anyone could either give me some code, or some steps to get me started. Here is what the system does at the end of each frame to make the quad face the camera.
x = x pos
y = y pos
z = z pos
a = alpha
s = scale
r = red
g = green
b = blue
life = time until death
visible = err visible or not
I'd like to change what is there to take into account a new angle variable within the type.
Thanks in Advance :)
My 3D math skills are pretty much non existent, so I'd like to ask if anyone could either give me some code, or some steps to get me started. Here is what the system does at the end of each frame to make the quad face the camera.
For s.sprite=Each sprite If s\life>0 And s\visible>0 s\life#=s\life#-(1.0*FL\SpeedFactor) s\x=s\x+(s\vx*FL\SpeedFactor) s\y=s\y+(s\vy*FL\SpeedFactor) s\z=s\z+(s\vz*FL\SpeedFactor) s\s=s\s+(s\vs*FL\SpeedFactor) s\a=s\a+(s\va*FL\SpeedFactor) TFormPoint s\x,s\y,s\z,0,camera\model If TFormedZ#()>0 TFormVector -s\s,-s\s,0,camera\model,0 VertexCoords s\surf,s\verti[0],s\x+TFormedX#(),s\y+TFormedY#(),s\z+TFormedZ#() TFormVector s\s,-s\s,0,camera\model,0 VertexCoords s\surf,s\verti[1],s\x+TFormedX#(),s\y+TFormedY#(),s\z+TFormedZ#() TFormVector -s\s,s\s,0,camera\model,0 VertexCoords s\surf,s\verti[2],s\x+TFormedX#(),s\y+TFormedY#(),s\z+TFormedZ#() TFormVector s\s,s\s,0,camera\model,0 VertexCoords s\surf,s\verti[3],s\x+TFormedX#(),s\y+TFormedY#(),s\z+TFormedZ#() VertexColor s\surf,s\verti[0],s\r,s\g,s\b,s\a VertexColor s\surf,s\verti[1],s\r,s\g,s\b,s\a VertexColor s\surf,s\verti[2],s\r,s\g,s\b,s\a VertexColor s\surf,s\verti[3],s\r,s\g,s\b,s\a EndIf dbug=dbug+1 EndIf If s\life <= 0 HideSprite(Handle(s)) EndIf Next
x = x pos
y = y pos
z = z pos
a = alpha
s = scale
r = red
g = green
b = blue
life = time until death
visible = err visible or not
I'd like to change what is there to take into account a new angle variable within the type.
Thanks in Advance :)