quads / sprites

Blitz3D Forums/Blitz3D Programming/quads / sprites

Mr Snidesmin(Posted 2005) [#1]
Anyone know how to emulate sprite-like behaviour for a 3d quad mesh?

If I use pointentity to point the quad at the camera, that works okay, but the roll gets screwed up - I'd like the quad always to be aligned the same way (horizonally + vertically) just like a sprite would be.


Mr Snidesmin(Posted 2005) [#2]
Just tried aligntovector, using the vector from the camera to a pivot in front of the camera and that has the same problem. . . looks like I need to calculate a roll to assign depending on the viewing angles - I have no idea how to figure this out!


jfk EO-11110(Posted 2005) [#3]
If you really talk about the roll angle (pitch,yaw,roll) - maybe it works this way:

Pointentity quad,camera
rotateentity quad, entityPitch(quad,1), entityYaw(quad,1),0,1



Mr Snidesmin(Posted 2005) [#4]
unfortunately I tried that - the roll is always zero, on the camera and the quad. . . quads that are on the plane defined by the x-z component of the cameras direction and the y-axis appear on screen with the correct orientation. But whenever they are elsewhere, there is some rotation due to perpective (not really roll).

I want to eliminate this rotation if I can, by giving the quad a counteractive roll. . .


Mr Snidesmin(Posted 2005) [#5]
Here's a couple of pictures that help illustrate my problem.
As you can see, the problem is increased for quads vertically above or below.






Mr Snidesmin(Posted 2005) [#6]

Just tried aligntovector, using the vector from the camera to a pivot in front of the camera and that has the same problem. . .


Actually, just checking again, AlignToVector does seem to orientate all the quads in the same direction, but that orienation varies with the direction you are facing, so they aren't always vertical. However, thinking of the senario I'll be using them in this might be okay.

I guess that getting them vertical might be as simple as setting their roll to the cameras yaw after doing the aligntovector, but maybe not. . .


I'm still open to anyone else's ideas / suggestions as usual :O)


Matty(Posted 2005) [#7]
I use a similar method to what Dark Half suggested in a post a while ago. When you create your quad parent it to the camera and create its 4 vertices in the x/y plane. Using TFormpoint whenever you wish to move the quad allows you to place the quad in the world at its correct location always facing the camera. If you wish to roll the quad about the local z axis of the camera then you simply adjust the x/y coordinates of each corner of the quad using basic trigonometry.

I don't have access to my code at the moment but I'll post it later (probably around 8:00pm Australian Eastern Standard time) if it helps.


Matty(Posted 2005) [#8]
try this...ignore the messiness of the code I basically ripped it out of my quad functions code and cut it down to make what I hope is a simple example. Unfortunately I have left some of the unnecessary bits in but they are commented out....




aab(Posted 2005) [#9]
Heres a simple example JFK made:
http://www.blitzbasic.com/codearcs/codearcs.php?code=321

I had something else slightly more extensive but a bit random: but for somereason all uploading sites i use either forgot that they understand .zips or are down just now, probability having no real account for anything as i use them so rarely.


jfk EO-11110(Posted 2005) [#10]
Ok, I think you will always get soome distotion due to the cameraZoom, maybe you should increase it to 1.4 or something to reduce the fisheye distortion artefacts. Then again, space looks much smaller (eg. rooms in a fps) when you use a Camerazoom of 1.4

If you want to suppress Pitch, you could use the cameras pitch instead, something like:

Pointentity quad,camera
rotateentity quad, entityPitch(camera,1)+180, entityYaw(quad,1),0,1

Tho, I'm only guessing here :)