Having a simple plane always facing camera

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Having a simple plane always facing camera

Post by kubatp »

I was trying to find a guidance for this functionality but I didn't find anything what would provide an answer.

I am trying to create a 3D model, which would have a "pedestal" similar to a chess piece and a simple plane on top of it.
Image

Such model would be placed in 3D space and the plane would "roll" according to the angle to camera. Basically the lower part of the plane would keep its vertices' positions and the top two vertices would change its location so the texture/plane would always faces the camera directly (the texture would not be skewed).

I know that I need to use a vertex shader to modify the vertices positions but I cannot figure out how. Did anyone try to solve similar functionality?
Thank you for any advice.
paroj
OGRE Team Member
OGRE Team Member
Posts: 2108
Joined: Sun Mar 30, 2014 2:51 pm
x 1134

Re: Having a simple plane always facing camera

Post by paroj »

kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Having a simple plane always facing camera

Post by kubatp »

Hello paroj,
I am familiar with billboards, yet I haven't really used them (except for particles).

I understood from your reply that it is probably a very beginner's question (since you posted just a link) but I am still not sure what exactly do you recommend.

Wouldn't it be better to just correctly set the position of the two upmost vertices in the vertex shader?
paroj
OGRE Team Member
OGRE Team Member
Posts: 2108
Joined: Sun Mar 30, 2014 2:51 pm
x 1134

Re: Having a simple plane always facing camera

Post by paroj »

it doesnt really matter where you change the vertices. Its just that Ogre already provides the functionality that you need (as linked).
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 480
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 167

Re: Having a simple plane always facing camera

Post by sercero »

The problem with a billboard is that it faces the camera at all times and I think that @kubatp needs something a bit more sophisticated.

If I were to do this, my approach would be to have the plane on the pedestal change its orientation according to the position of the camera relative to the pedestal/plane setup.

So you should have a vector v = (camera - pedestal), proyect that vector onto the xz plane and then you have a direction to set for the plane on the pedestal.

Of course I am assuming here that the plane can only move in y axis, but that is how I am imagining the situation.

Correct me if I am mistaken.