Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

3D Billboarding with vertices

I'm trying to get a sprite to tilt to face the camera in 3D space, at the moment I can get it to spin to face the camera (Rotate on the XZ) but I need it to tilt backwards to face the camera.

I have the:
X, Y, Z position of the sprite I want to face the camera.
X, Y, Z position of the camera.
Forward vector of the camera.
Rotation of the camera.

Where do I start? I can get it to spin to face the camera and that's about it so far.

EDIT: I can get it to lean back now, so all that's left is getting it to rotate so when the camera's facing downwards it doesn't look like all the sprites are leaning over (They're aligned to the screen still, need Z rotation).

The code is literally rotating the 4 vertices to match the camera's rotation.

leanBug.png
 
3 Vertices what do you mean? you need a Quad To Render a Sprite if I am no mistaken so you kinda need at least 6 vertices , 4 if you reuse 2 from one of the triangles, either way I don't get your question Xilef so, could you elaborate a bit more ? Also I don't get why you are rotating the quad, if you make your render render the 2D after the 3D they will always look correct no?

Also, the way I am seing you are trying to make a 2.5D engine (2D sprite on 3D backgrounds) I have a few tutorials here about that if you need help, also in what language are you coding this?


EDIT: WOW, I am a freaking IDIOT to not have looked at the Topic Date! I am sorry!
 
Morphex":2ltkb2md said:
3 Vertices what do you mean? you need a Quad To Render a Sprite if I am no mistaken so you kinda need at least 6 vertices , 4 if you reuse 2 from one of the triangles, either way I don't get your question Xilef so, could you elaborate a bit more ? Also I don't get why you are rotating the quad, if you make your render render the 2D after the 3D they will always look correct no?

Also, the way I am seing you are trying to make a 2.5D engine (2D sprite on 3D backgrounds) I have a few tutorials here about that if you need help, also in what language are you coding this?


EDIT: WOW, I am a freaking IDIOT to not have looked at the Topic Date! I am sorry!

I wasn't referring to vertices in terms of a quad. I was referring to them in terms of rotation. I actually should have said axes, but it's too late to go back and fix that now.
 
I'm going to add some closure to this old topic.
Rotate yz first then zx to get to the screenshot I have above, also in that shot I used the base of the sprites (Origin of the blob shadow) as the anchor point for rotation, I then displaced the vertices from that point into their correct 2D positions based on the XY plane before applying the rotation.
I do not suggest doing this for extreme angles like in the screenshot above, it looks stupid.

In stead, limit it to small angles of attack or consider using XZ aligned billboards. I believe super mario 64 uses the former, uglier method with it's tree billboards, but minecraft uses the latter method for the dropped items (Before they made them 3D spinning models).

Ragnarok online is a good example of the former method, in that game the angle of attack is actually locked at ~45 degrees.

In terms of my project, I'm reconsidering 3D models in stead of billboard sprites, I feel this project here shows why high-quality 2D graphics look stupid: [Days of Dawn]
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top