From: <mg...@us...> - 2009-07-04 03:31:12
|
Revision: 3909 http://planeshift.svn.sourceforge.net/planeshift/?rev=3909&view=rev Author: mgist Date: 2009-07-04 03:31:11 +0000 (Sat, 04 Jul 2009) Log Message: ----------- - Changed instanced items to use their own material with their required shaders. Modified Paths: -------------- trunk/src/client/pscelclient.cpp Modified: trunk/src/client/pscelclient.cpp =================================================================== --- trunk/src/client/pscelclient.cpp 2009-07-04 02:48:21 UTC (rev 3908) +++ trunk/src/client/pscelclient.cpp 2009-07-04 03:31:11 UTC (rev 3909) @@ -2076,6 +2076,7 @@ instance->pcmesh = factory->CreateMeshWrapper(); instance->pcmesh->GetFlags().Set(CS_ENTITY_NODECAL | CS_ENTITY_NOHITBEAM); psengine->GetEngine()->GetMeshes()->Add(instance->pcmesh); + psengine->GetEngine()->PrecacheMesh(instance->pcmesh); cel->AddInstanceObject(factName, instance); // Set appropriate shader. @@ -2096,10 +2097,17 @@ } //else // Handle this case if/when it happens... - material->SetShader(shadertype, shader); + // Construct a new material using the selected shaders. + csRef<iTextureWrapper> tex = psengine->GetEngine()->GetTextureList()->CreateTexture(material->GetTexture()); + csRef<iMaterial> mat = psengine->GetEngine()->CreateBaseMaterial(tex); + + mat->SetShader(shadertype, shader); shadertype = strings->Request("diffuse"); - material->SetShader(shadertype, shader); + mat->SetShader(shadertype, shader); + csRef<iMaterialWrapper> matwrap = psengine->GetEngine()->GetMaterialList()->CreateMaterial(mat, factName + "_instancemat"); + instance->pcmesh->GetMeshObject()->SetMaterialWrapper(matwrap); + // Set biggest bbox so that instances aren't wrongly culled. instance->bbox = factory->GetMeshObjectFactory()->GetObjectModel()->GetObjectBoundingBox(); factory->GetMeshObjectFactory()->GetObjectModel()->SetObjectBoundingBox(csBox3(-CS_BOUNDINGBOX_MAXVALUE, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |