Hi
I have a problem with my own tree system
i am going to create a single surface leaf. instead of sprite i use Quads aka 2 triangles merged to a rectangle freemoving.
problem i have i have no idea how to make the quad always point at camera. i cant use turn entity cause there is not entity for each leaf.
Type Leaf
Field surface
field x#,y#,z#
field vert1
field vert2
field vert3
field vert4
end type
now how do i make it point to camera :(
i am at work/school right now. when i get home, i will show you how. it basicaly works with tformpoints.
sx# = size x
sy# = size y
piv = CreatePivot()
RotateEntity piv, >>Rotation of the camera<<
TFormVector sx#, -sy#, 0, piv, 0
v1x# = TFormedX() + x#
v1y# = TFormedY() + y#
v1z# = TFormedZ() + z#
TFormVector -sx#, -sy#, 0, piv, 0
v2x# = TFormedX() + x#
v2y# = TFormedY() + y#
v2z# = TFormedZ() + z#
TFormVector sx#, sy#, 0, piv, 0
v3x# = TFormedX() + x#
v3y# = TFormedY() + y#
v3z# = TFormedZ() + z#
TFormVector -sx#, sy#, 0, piv, 0
v4x# = TFormedX() + x#
v4y# = TFormedY() + y#
v4z# = TFormedZ() + z#
here ya go :)
You only need 2 x tforms here. I'll post details later.
Good
this is dmm realy usfull instructions Devil...
ill await for you stevie G
This is the kinda thing I use. It should be a fair bit faster with alot of particles ...
;p\size = size of particle ( assume square )
;p\Vertex = First vertex of 4 For this quad
;p\Pos = 3d coords of particle
;s = surface of particle mesh
;point quad to face the camera
TFormVector -p\size,0,0, Camera , 0
x1# = TFormedX()
y1# = TFormedY()
z1# = TFormedZ()
TFormVector 0,-p\size,0,Camera, 0
x2# = TFormedX()
y2# = TFormedY()
z2# = TFormedZ()
VertexCoords s, p\Vertex + 0 , p\Pos\x - x1 - x2 , p\Pos\y - y1 - y2 , p\Pos\z - z1 - z2
VertexCoords s, p\Vertex + 1 , p\Pos\x - x1 + x2 , p\Pos\y - y1 + y2 , p\Pos\z - z1 + z2
VertexCoords s, p\Vertex + 2 , p\Pos\x + x1 + x2 , p\Pos\y + y1 + y2 , p\Pos\z + z1 + z2
VertexCoords s, p\Vertex + 3 , p\Pos\x + x1 - x2 , p\Pos\y + y1 - y2 , p\Pos\z + z1 - z2
thanks Stevie G
that realy want i wanted.
i give it test run now..
And here is ressult code
Quick and dirty codeing here.
[CODE]
mesh=CreateMesh()
surface=CreateSurface(mesh)
p.quad = New quad
p\s=surface
p\size#=1
p\posx=0
p\posy=0
p\posz=5
p\Vertex=AddVertex(p\s,0,0,0,0,0)
AddVertex(p\s,1,0,0,1,0)
AddVertex(p\s,1,1,0,1,1)
AddVertex(p\s,0,1,0,0,1)
AddTriangle p\s,0,1,2
AddTriangle p\s,0,2,3
While Not KeyHit(1)
;p\size = size of particle ( assume square )
;p\Vertex = First vertex of 4 For this quad
;p\Pos = 3d coords of particle
;s = surface of particle mesh
;point quad to face the camera
p.quad = First quad
s=p\s
TFormVector -p\size,0,0, Camera , 0
x1# = TFormedX()
y1# = TFormedY()
z1# = TFormedZ()
TFormVector 0,-p\size,0,Camera, 0
x2# = TFormedX()
y2# = TFormedY()
z2# = TFormedZ()
VertexCoords s, p\Vertex + 0 , p\Posx - x1 - x2 , p\Posy - y1 - y2 , p\Posz - z1 - z2
VertexCoords s, p\Vertex + 1 , p\Posx - x1 + x2 , p\Posy - y1 + y2 , p\Posz - z1 + z2
VertexCoords s, p\Vertex + 2 , p\Posx + x1 + x2 , p\Posy + y1 + y2 , p\Posz + z1 + z2
VertexCoords s, p\Vertex + 3 , p\Posx + x1 - x2 , p\Posy + y1 - y2 , p\Posz + z1 - z2
TurnEntity camera,0,0.1,0
UpdateWorld()
RenderWorld()
Flip
Wend
[\CODE]
Thanks every one.. now i can continue to write voidrpg.