SGeometry*	CResourceManager::CreateGeom		(u32 FVF, IDirect3DVertexBuffer9* vb, IDirect3DIndexBuffer9* ib)
{
	D3DVERTEXELEMENT9	dcl	[MAX_FVF_DECL_SIZE];
	CHK_DX				(D3DXDeclaratorFromFVF(FVF,dcl));
	SGeometry* g		=  CreateGeom	(dcl,vb,ib);
	return	g;
}
clGeom* clResourcesManager::CreateGeomForNamedVA( const LString& VAName, clVertexAttribs* VA ) const
{
	clGeom* Geom = CreateGeom();

	Geom->GetCurrentMesh()->AddVertexAttribs( VAName, VA, LMatrix4::Identity(), -1, -1 );

	return Geom;
}
Esempio n. 3
0
 void Init(Texture *t, OurShader *shader, float aspect,
         float umin, float vmin, float umax, float vmax) {
     mTexture = t;
     mOurShader = shader;
     mAspect = aspect;
     mWidth = mAspect;
     mHeight = 1.0f;
     mCenterX = mCenterY = 0.0f;
     mScale = 1.0f;
     CreateGeom(umin, vmin, umax, vmax);
 }
clGeom* clResourcesManager::CreatePlane( float X1, float Y1, float X2, float Y2, float Z, int Subdiv ) const
{
	guard();

	// allocate clGeom container
	clGeom* Geom = CreateGeom();

	// add vertices to the mesh
	Geom->GetCurrentMesh()->AddVertexAttribs( "Plane", clGeomServ::CreateRect2D( X1, Y1, X2, Y2, Z, false, Subdiv ), LMatrix4::Identity(), -1, -1 );

	return Geom;

	unguard();
}
clGeom* clResourcesManager::MergeGeoms( const std::vector<clGeom*>& Geoms, const std::vector<LMatrix4>& Transforms ) const
{
	clGeom* CombinedGeom = CreateGeom();

//	CombinedGeom->GetCurrentMesh()->DisposeObject();

	std::vector<clMesh*> MeshList( Geoms.size() );

	for ( size_t j = 0 ; j < Geoms.size() ; j++ )
	{
		MeshList[j] = Geoms[j]->GetCurrentMesh();
	}

	clMesh* NewMesh = MergeMeshes( MeshList, Transforms );

	CombinedGeom->SetMesh( NewMesh );

	return CombinedGeom;
}
clGeom* clResourcesManager::LoadGeom( const LString& FileName )
{
	double StartTime = Env->GetSeconds();

	clGeom* Resource = FindResourceFile<clGeom>( FileName );

	if ( !Resource )
	{
		Resource = CreateGeom();
		Resource->SetAsyncLoadComplete( false );
		Resource->SetFileName( FileName );

		EnqueueLoading( new clLoaderThread::clLoadOp_Geom( Resource ) );

		if ( FLockedLoading->GetBool() )
		{
			Resource->WaitLoad();
		}
	}

	FTime_Meshes += Env->GetSeconds() - StartTime;

	return Resource;
}