Esempio n. 1
0
void SphericalXZ::ToCartesian( Matrix4* out )
{
    Matrix4 roty;	// theta
    Matrix4 rotz;	// rho
    Matrix4 trans;

    roty.SetYRotation( theta );
    rotz.SetZRotation( rho );
    trans.SetTranslation( r, 0.f, 0.f );

    *out = roty * rotz * trans;
}
Esempio n. 2
0
void ProcessAC( ACObject* ob, lilith3d::StaticResource* meshRes )
{
	Matrix4 matrix;
	matrix.SetTranslation( ob->loc.x, ob->loc.y, ob->loc.z );

	meshRes->PushObject( ob->name, matrix, ob->texture );

	for( int i = 0; i < ob->num_surf; ++i )
	{
		ACSurface *surf = &ob->surfaces[i];
		meshRes->PushSurface( surf->num_vertref, surf->normal.x, surf->normal.y, surf->normal.z );

		int st = surf->flags & 0xf;
		if (    st == SURFACE_TYPE_POLYGON 
		     && (surf->num_vertref == 3 || surf->num_vertref == 4 ) )
		{
			for( int j=0; j<surf->num_vertref; ++j )
			{
			    ACVertex *v = &ob->vertices[surf->vertref[j]];
				float tx = 0, ty = 0;
	
				if (ob->texture )
				{
					float tu = surf->uvs[j].u;
					float tv = surf->uvs[j].v;

					tx = ob->texture_offset_x + tu * ob->texture_repeat_x;
					ty = ob->texture_offset_y + tv * ob->texture_repeat_y;
				}
				meshRes->PushVertex( v->x, v->y, v->z, tx, ty );
			}
	    }
		else
		{
			GLLOG(( "Input polygon or type not supported.\n" ));
			GLASSERT( 0 );
		}
	}
	for ( int n = 0; n < ob->num_kids; n++)
	    ProcessAC(ob->kids[n], meshRes ); 

	meshRes->PopObject();
}
Esempio n. 3
0
bool ImportAC3D(	const std::string& filename,
                    ModelBuilder* builder,
                    const grinliz::Vector3F origin,
                    const std::string& group )
{
    ACObject* acObject = ac_load_ac3d( (char*) filename.c_str() );
    GLASSERT( acObject );
    if ( acObject )
    {
        // Kind of a wicked recursive thing.
        Matrix4 matrix;
        matrix.SetTranslation( -origin );
        ProcessAC3D( acObject, builder, matrix, group.empty() ? 0 : group.c_str() );
    }
    builder->Flush();

    bool importOk = ( acObject != 0 );
    if ( acObject )
        ac_object_free( acObject );
    return importOk;
}
Esempio n. 4
0
	void Matrix4::SetOrientation(const Quaternion &pQuat){
		Matrix4 tempMat = pQuat.ToMatrix();
		tempMat.SetTranslation(this->GetTranslation());
		*this = tempMat;
	}
Esempio n. 5
0
//---------------------------------
//
//---------------------------------
void Matrix4::Translate(const Vector3& trans)
{
	Matrix4 translation;
	translation.SetTranslation( trans );
	*this *= translation;
}