Hi Robert,

Here is you proposal:

(v +p) * M = v' + p'
p' = p*M
v' = (v+p)*M - p'

As I understand it, the last line translates v with p, with p' and with -p'.

This means that v' will be translated only with p, as p' and -p' disappears.

Now remember that p' is the new position of the billboard that will be used to translate all vertices (v') in each frame.

The translation will then be: p' + (v+p), which seems incorrect to me....


Hmm... I am just "thinking loud" here. Correct me if I'm wrong, because I am only 95% confident that the things I say are 100% correct :)


All billboards from a flt file are constructed in this way:

M -> B -> v  (Hierarchical view)

Where M is a Transformation Matrix, B is the Billboard Matrix, and v the vertices of the geometry.

The goal is to remove M:

B -> v

The thing is, with the default optimization, M contains the position of the billboard and not B. B always gets the position Bpos = (0,0,0) (at least when using the flt plugin)

I do like this:

Bpos' = Bpos * M

Example:

 If M is:

  0 1 0 0
 -1 0 0 0
  0 0 1 0
 30 0 0 1

 (rotated +90 degrees around Z-axis, and translate +30 in along X-axis)

 If Bpos = (0,0,0) then Bpos' will be (30, 0, 0)

Now, I do the following:

(v * M) - Bpos'

Example:

 Let's look at the (v * M) term.

 If we have v0 = (10,0,0) then v * M results in:

 v0 * M = (30,10,0)

 At this stage, v, B, and M all contain the positional offset.
M will later be removed, so the problem is that both v and B contains the positional offset.

 We have to remove the positional offset in v:

 v0' = v0 * M - Bpos' = (30,10,0) - (30,0,0) = (0,10,0)


With other words: v' will not be a translated vertex, it will only be rotated and scaled.

Since the vertices now are rotated, the axis and normal of the billboard also have to be rotated. So, the axis and normal of the billboard (Baxis and Bnormal, respectively) have to be multiplied with the upper-left 3x3 matrix in M.

Example:

 Baxis = (0,0,1)
 Bnormal = (0,-1,0)
 M3x3 =
  0 1 0
 -1 0 0
  0 0 1


 Baxis' = Baxis * M3x3 = (0,0,1) * M3x3 = (0,0,1)
 Bnormal' = Bnormal * M3x3 = (0,-1,0) * M3x3 = (1,0,0)


Done!


Does this look correct to you?


På Fri, 21 Nov 2008 14:57:04 +0100, skrev Robert Osfield <[EMAIL PROTECTED]>:

Hi Joakim,

I've just done a code review and a bit surprised by the form of the
transformation you've applied, as while it goes in the right
direction, doesn't look right.  You have:

  p' = p * M
  v' = v * M - p'

Where p is the original position of the billboard, v is the local
vertex of the billboard, and M is the matrix we are applying. p' and
v' and the new values.

Looking at the maths I think we should have

(v +p) * M = v' + p'
p' = p*M
v' = (v+p)*M - p'

So it looks like to me we should add the original position, then
multiple my the matrix then subtract the new position.

Does this sounds correct?  Am I missing something?

Robert.




On Mon, Nov 17, 2008 at 6:39 PM, Joakim Simonsson <[EMAIL PROTECTED]> wrote:

Hi,

When using optimizer option
FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS, billboards are not
correctly handled.


Description:

If a (rotated) matrixtransform had a billboard as child, the geometry of the
billboard did get the wrong position and/or rotation.

Fix:

All vertices/normals of a billboard's geometry are now transformed. The
position of the billboard is then subtracted from the vertices of the
geometry.



Files modified:

src\osgUtil\Optimizer.cpp
include\osgUtil\Optimizer




--
Joakim Simonsson
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org


_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



--
Joakim Simonsson
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to