Пример #1
0
//----------------------------------------------------------------//
void MOAIQuadBrush::TransformUVs ( const ZLAffine3D& mtx ) {

	mtx.Transform ( this->mUVQuad.mV [ 0 ]);
	mtx.Transform ( this->mUVQuad.mV [ 1 ]);
	mtx.Transform ( this->mUVQuad.mV [ 2 ]);
	mtx.Transform ( this->mUVQuad.mV [ 3 ]);
}
Пример #2
0
//----------------------------------------------------------------//
void ZLPrism::Transform ( const ZLAffine3D& mtx ) {

	mtx.Transform ( mLoc );
	mtx.TransformVec ( mXAxis );
	mtx.TransformVec ( mYAxis );
	mtx.TransformVec ( mZAxis );
}
Пример #3
0
//----------------------------------------------------------------//
bool ZLFrustum::GetXYSectRect ( const ZLAffine3D& mtx, ZLRect& rect ) const {

	u32 nHits = 0;
	ZLVec2D hits [ 12 ];

	ZLVec3D nlt = this->mPoints [ NEAR_LT_POINT ];
	ZLVec3D nrt = this->mPoints [ NEAR_RT_POINT ];
	ZLVec3D nrb = this->mPoints [ NEAR_RB_POINT ];
	ZLVec3D nlb = this->mPoints [ NEAR_LB_POINT ];
	
	ZLVec3D flt = this->mPoints [ FAR_LT_POINT ];
	ZLVec3D frt = this->mPoints [ FAR_RT_POINT ];
	ZLVec3D frb = this->mPoints [ FAR_RB_POINT ];
	ZLVec3D flb = this->mPoints [ FAR_LB_POINT ];
	
	mtx.Transform ( nlt );
	mtx.Transform ( nrt );
	mtx.Transform ( nrb );
	mtx.Transform ( nlb );
	
	mtx.Transform ( flt );
	mtx.Transform ( frt );
	mtx.Transform ( frb );
	mtx.Transform ( flb );
	
	if ( _vecToXYPlane ( nlt, flt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrt, frt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrb, frb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nlb, flb, hits [ nHits ])) ++nHits;
	
	if ( _vecToXYPlane ( nlt, nrt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrt, nrb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nrb, nlb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( nlb, nlt, hits [ nHits ])) ++nHits;
	
	if ( _vecToXYPlane ( flt, frt, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( frt, frb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( frb, flb, hits [ nHits ])) ++nHits;
	if ( _vecToXYPlane ( flb, flt, hits [ nHits ])) ++nHits;
	
	if ( nHits ) {
		rect.Init ( hits [ 0 ]);
		for ( u32 i = 1; i < nHits; ++i ) {
			rect.Grow ( hits [ i ]);
		}
		return true;
	}
	return false;
}
//----------------------------------------------------------------//
void MOAISurfaceSampler2D::SetObjectMtx ( const ZLAffine3D& localToWorld, const ZLAffine3D& worldToLocal ) {

	this->mLocalToSampleMtx = localToWorld;
	this->mLocalToSampleMtx.Append ( this->mWorldToSampleMtx );
	
	this->mLocalRect = this->mWorldRect;
	worldToLocal.Transform ( this->mLocalRect );
}
Пример #5
0
int GIIHelper::_setWorldLoc( lua_State *L ){
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "UN" )) return 0;
	MOAITransform* dst = state.GetLuaObject< MOAITransform >(1, true);
	float x = state.GetValue< float >( 2, 0.0f );
	float y = state.GetValue< float >( 3, 0.0f );
	float z = state.GetValue< float >( 4, 0.0f );
	ZLVec3D loc;
	loc.Init( x, y, z );		
	const ZLAffine3D* inherit = dst->GetLinkedValue < ZLAffine3D* >( PACK_ATTR ( MOAITransformBase, MOAITransformBase::INHERIT_TRANSFORM ), 0 );	
	if( inherit ) {
		ZLAffine3D inverse;
		inverse.Inverse( *inherit ); 
		inverse.Transform( loc );
	}
	dst->SetLoc( loc );	
	dst->ScheduleUpdate();
	return 0;
}
Пример #6
0
int GIIHelper::_copyWorldTransform( lua_State *L ){
	ZLAffine3D tmp;
	ZLAffine3D tmp1;
	float rx,ry,rz;
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "UU" )) return 0;
	MOAITransform* src = state.GetLuaObject< MOAITransform >(1, true);
	MOAITransform* dst = state.GetLuaObject< MOAITransform >(2, true);
	const ZLAffine3D& srcMtx = src->GetLocalToWorldMtx ();
	const ZLAffine3D* inherit = dst->GetLinkedValue < ZLAffine3D* >( PACK_ATTR ( MOAITransformBase, MOAITransformBase::INHERIT_TRANSFORM ), 0 );	
	tmp.Init( src->GetLocalToWorldMtx() );
	if( inherit ) {
		tmp1.Inverse( *inherit ); 
		tmp.Append( tmp1 );
	}
	ZLVec3D loc   = tmp.GetTranslation();
	ZLVec3D scale = tmp.GetStretch();
	dst->SetLoc( loc );
	dst->SetScl( scale );
	rz = tmp.GetRot();
	dst->SetRot( 0, 0, rz );
	dst->ScheduleUpdate();
	return 0;
}
Пример #7
0
//----------------------------------------------------------------//
void ZLQuaternion::Set ( const ZLMatrix4x4& m ) {

	ZLAffine3D affine;
	affine.Init ( m );
	this->Set ( affine );
}