[SOLVED] BillboardSet scale when setting setCommonDirection

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10
Contact:

[SOLVED] BillboardSet scale when setting setCommonDirection

Post by DanielSefton »

Hi,

For some reason the scale of a BillboardSet is determined by the length of the vector passed to setCommonDirection when the billboard type is BBT_PERPENDICULAR_COMMON.

The only mention in the docs of this behavior is in particle_width and particle_height:
http://www.ogre3d.org/docs/manual/manual_35.html

I've been looking at the source, and so far I saw that on line 588 it sets the bounding radius to the square length:

https://github.com/ehsan/ogre/blob/mast ... ardSet.cpp

Code: Select all

mBoundingRadius = Math::Sqrt(maxSqLen);
But I logged the bounding radius and this doesn't change. So now I have no idea what's causing it.

Basically I want to set the common direction of the billboard set without it affecting the scale at all. :)

Any help appreciated.

Daniel
Last edited by DanielSefton on Mon Sep 01, 2014 1:44 am, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: BillboardSet scaling when setting setCommonDirection

Post by dark_sylinc »

Most likely this is caused by passing a non-unit-length vector? Try a normalizing the direction first.
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10
Contact:

Re: BillboardSet scaling when setting setCommonDirection

Post by DanielSefton »

Sadly not, it occurs with unit-length vectors - when you pass UNIT_Y the scale of the billboard is zero, when you pass UNIT_Z the scale of the billboard is as it should be.

Basically the more direction it is towards UNIT_Y the smaller it gets.

I've solved it for now by just rotating the scene node 90 degrees, still find this issue strange though.

Thanks for the help :)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: BillboardSet scaling when setting setCommonDirection

Post by Kojack »

Are you also setting the common up vector?
BBT_PERPENDICULAR_COMMON uses two vectors: common direction and common up vector. These two must be perpendicular to each other. The code for generating the billboard axes is:

Code: Select all

        case BBT_PERPENDICULAR_COMMON:
            // X-axis is up-vector cross common direction
            // Y-axis is common direction cross X-axis
            *pX = mCommonUpVector.crossProduct(mCommonDirection);
            *pY = mCommonDirection.crossProduct(*pX);
            break;
It appears pX and pY aren't normalised before use, and cross products of vectors are only unit length if they are perpendicular.
The default common up vector is unit y. If the common direction is also unit y then pX will be a vector of 0,0,0.
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10
Contact:

Re: BillboardSet scaling when setting setCommonDirection

Post by DanielSefton »

Yeah that works :) I did try setting the common up vector before, but clearly I was setting the wrong directions. Thanks Kojack.
Post Reply