make an quad point to camera blitz3d
Blitz3D Forums/Blitz3D Programming/make an quad point to camera blitz3d
| ||
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 :( |
| ||
You attach them to quad pivots - rotate (using RotateEntity - pitch and yaw is from the camera) the quad pivot to the same global orientation as the camera - the quads pivots are parented to the tree. |
| ||
Use the PointEntity() function to point at the camera. This points in the entity's local positive Z direction, so your quads must be facing in the positive Z direction in order to see them using this technique. By default, your quads probably face the negative Z direction. You can use RotateMesh to turn it around 180 on the yaw. |
| ||
This is already solved ? And ressulted in a complete example :) http://www.blitzbasic.co.nz/Community/posts.php?topic=71682 |
| ||
http://www.blitzbasic.co.nz/Community/posts.php?topic=71625 Facit ;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 |
| ||
You can't use either PointEntity or Pivots with a single surface quad system. Yes, the code StevieG gave you should be exactly what you need. Somewhere I have some code that does it without using TFormVector, but it's probably slower, so I'd stick with what you have unless you have any problems. |
| ||
BlitzTree3D uses pivots - I assumed it was single-surface. |
| ||
Single-surface operations, all the chunks (leaf) are sorted to use a single surface per tree for speed |
| ||
Or do it the simple way: Use a sprite you position at the particles position and read the vertex positions from it. |
| ||
Sorrie. I cant use sprites. My gfx card cand handle it. after 300 surfaces its slowing bad. max for an x800 is 700 milions vertices per second. but the bottelnec is its poor surface support. the Intel 82855 GME is faster than the Radeon X800 at 10000 surfaces the intel spots 10 fps at 10000 surfaces the Radeaon spots 1 fps so radeon x800 is a poor thing. (on the other hand the Intel chip has poor vertices handling and lacking much advanced stuff. maby thats why its faster with many surfaces. cause its a sneak gfx chip.) |