0
0

Hello,

I have some small problem with figure out how to proper set rotation of simple scaled box. Heres code :

[code:qufm39xg]
static const Vector3f T[8] =
{

``````        Vector3f( -1 , -1 , 1 ) ,
Vector3f( 1 , -1 , 1 ) ,
Vector3f( 1 , 1 , 1 ) ,
Vector3f( -1 , 1 , 1 ) ,

Vector3f( -1 , -1 , -1 ) ,
Vector3f( 1 , -1 , -1 ) ,
Vector3f( 1 , 1 , -1 ) ,
Vector3f( -1 , 1 , -1 )

};

static int idx[24] =
{

0 , 1 , 2 , 3 ,
1 , 5 , 6 , 2 ,
5 , 4 , 7 , 6 ,
4 , 0 , 3 , 7 ,
6 , 7 , 3 , 2 ,
4 , 5 , 1 , 0

};

int mask = SeparateWallOccluder ? ~0 : 0;

if( !f_geometry )
{
FMOD_System_CreateGeometry( Fsystem , 6 , 24 , &amp;f_geometry );

static Vector3f _T[ 4 ];

for( int i = 0 ; i &lt; 6; ++i )
{

for( int j = 0 ; j &lt; 4; ++j )
_T[ j ] = T[ idx[ i * 4 + j ] ];

FMOD_Geometry_AddPolygon( f_geometry , WallOccluder[ i &amp; mask ] . directocclusion , WallOccluder[ i &amp; mask ] . reverbocclusion , WallOccluder[ i &amp; mask ] . doublesided , 4 , (FMOD_VECTOR*)_T , NULL );
}

} else {

int ile;

FMOD_Geometry_GetNumPolygons( f_geometry , &amp;ile );

for( int i = 0 ; i &lt; ile; ++i )
{
FMOD_Geometry_SetPolygonAttributes( f_geometry , i , WallOccluder[ i &amp; mask ] . directocclusion , WallOccluder[ i &amp; mask ] . reverbocclusion , WallOccluder[ i &amp; mask ] . doublesided );
}

}

Vector3f pos = P;
Vector3f scale = S;

Vector3f forward( 0 , 0 , 1 ) ; // = q . GetForwardVector();
Vector3f up( 0 , 1 , 0 ) ; // = q . GetUpVector();

Q . rotate( forward ); // rotate vectors using quaternion
Q . rotate( up );

FMOD_Geometry_SetPosition( f_geometry , (FMOD_VECTOR*)&amp;pos );

FMOD_Geometry_SetRotation( f_geometry , (FMOD_VECTOR*)&amp;forward , (FMOD_VECTOR*)&amp;up );

FMOD_Geometry_SetScale( f_geometry , (FMOD_VECTOR*)&amp;scale );
``````

[/code:qufm39xg]

It works that in special cases – rotation quaterion as a identity vector. When I try to rotate occluding box it stops calculating proper occ coefficent at ray sound – camera eye ( listener ).

Does scaling works at geometry before rotation or after ?

Mayby I’m setting wrong forward – up vectors . Thanks for any help.

• You must to post comments
0
0

Ok i figured it out 😀 You have to inverse quaternion before setting rotation. :p

• You must to post comments
Showing 1 result