BillboardSet - Yaw, but don't pitch to face camera?

Problems building or running the engine, queries about how to use features etc.
Post Reply
cyberjunk
Halfling
Posts: 51
Joined: Tue Jun 05, 2012 4:33 pm
x 1

BillboardSet - Yaw, but don't pitch to face camera?

Post by cyberjunk »

Hey,

I'm currently using BBT_POINT for my billboardset type.
This makes the billboards completely facing the camera by 'yawing' and 'pitching' them automatically (in my 3. person camera system).

Say if I want them to 'yaw' only to face the camera, but not to 'pitch' - is this possible with one of the other types?

I think those two are uninteresting, because they don't face the camera at all?
BBT_PERPENDICULAR_COMMON
BBT_PERPENDICULAR_SELF

But at least one of these two might look like what I'm desperate for, but may be I was kinda too stupid to setup them up correctly?
BBT_ORIENTED_COMMON
BBT_ORIENTED_SELF

I tried the last two with different Up- and Direction-Vectors, but none actually showed the results I was looking for. :cry:

The world y-axis gives the height in my world - so (0,1,0) would be a valid normal-vector pointing up from the ground floor (ground-floor: plane, y=0)
The billboards are supposed to always face into a direction like (x,0,z) where x,z should be derived from the camera location ('yaw' it to face camera) and y=0 is don't 'pitched' to face camera).

Thanks :D
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: BillboardSet - Yaw, but don't pitch to face camera?

Post by areay »

Your intuition serves you well, it is indeed the BBT_ORIENTED_* type that you want.

Here's how I do a laser beam using billboards, you'll have to wade through my variable naming but it's not that difficult to see what's going on. I use BBT_ORIENTED_SELF as each laser beam will have its own orientation.

Code: Select all


//init
		s_pSineBeamBBS = m_pGameStatePlay->m_pSceneMgr->createBillboardSet("s_pSineBeamBBS", 150);
		s_pSineBeamBBS->setMaterialName("SineBeam");
		s_pSineBeamBBS->setBillboardType(Ogre::BBT_ORIENTED_SELF);
		s_pSineBeamBBS->setBillboardRotationType(Ogre::BBR_VERTEX);
		s_pSineBeamBBS->setBillboardOrigin(Ogre::BBO_BOTTOM_CENTER);
		m_pGameStatePlay->m_pSceneMgr->getRootSceneNode()->attachObject(s_pSineBeamBBS);

//on some event create the actual laser beam

	m_pSineBeamB = s_pSineBeamBBS->createBillboard(Ogre::Vector3::ZERO);
	m_pSineBeamB->setColour(m_PrimaryColour);

//and then make it to size (I do this in an update(time) function as it's usually firing at a moving target)

	m_pSineBeamB->mDirection = m_TargetingInfo.directionToTarget;
	m_pSineBeamB->setDimensions(1, m_TargetingInfo.distanceToTarget);

	m_pSineBeamB->setPosition(m_TargetingInfo.sourceTargetingLocation);

//and when we're done with it

		s_pSineBeamBBS->removeBillboard(m_pSineBeamB);
		m_pSineBeamB = NULL;
cyberjunk
Halfling
Posts: 51
Joined: Tue Jun 05, 2012 4:33 pm
x 1

Re: BillboardSet - Yaw, but don't pitch to face camera?

Post by cyberjunk »

Thank you very much. The 'mDirection' field on the Billboard itself was what I've missed.
In my case:

Code: Select all

// create billboardset
....
billboardSet->setBillboardType(BillboardType::BBT_ORIENTED_SELF);

// create billboard
....
billboard->mDirection = ::Ogre::Vector3::UNIT_Y;
Post Reply