1. FlorianGeorge
  2. Ogitor_default

Commits

Shockeye  committed 30dccc3

Changed terrain cut to use transparent decal instead of stencil
-material of hole mesh changed to transparent (blend with terrain to make hole)
-moved Zone meshes into an earlier render queue (So mesh will be visible thru hole)
-also added cleanup function to TerrainCut class (fixes some issues with order of destruction)

  • Participants
  • Parent commits 0049163
  • Branches default

Comments (0)

Files changed (3)

File Plugins/OgModularZone/ModularZoneEditor.cpp

View file
 
 		mZoneMesh->setQueryFlags(QUERYFLAG_MOVABLE);
         mZoneMesh->setCastShadows(false);
+		mZoneMesh->setRenderQueueGroup(Ogre::RENDER_QUEUE_WORLD_GEOMETRY_1);
 
 
     }

File Plugins/OgModularZone/PortalEditor.cpp

View file
 //----------------------------------------------------------------------------------------
 PortalEditor::~PortalEditor(void)
 {
-#ifdef TERRAIN_CUT
-	delete mTerrainCut;
-#endif
+
 }
 //----------------------------------------------------------------------------------------
 void PortalEditor::showBoundingBox(bool bShow) 
 		mPortalOutline = 0;
 	}
 
+	#ifdef TERRAIN_CUT
+	if(mTerrainCut)
+	{
+		mTerrainCut->cleanup();
+		delete mTerrainCut;
+	}
+	#endif
+
   
     return Ogitors::CNodeEditor::unLoad();
 }
 			if(menuresult == 0)//Carve tunnel thru terrain
 			{
 				carveTerrainTunnel();
-				QMessageBox::information(QApplication::activeWindow(),"qtOgitor", "This doesn't do anything yet...",  QMessageBox::Ok);
+				
 			}
 		}
 #endif //TERRAIN_CUT
 		//export terrain tunnel mesh and stencil cut
 		PROJECTOPTIONS* options = OgitorsRoot::getSingletonPtr()->GetProjectOptions();
 		
-		Ogre::String tunnelname = getName()+"Tunnel.mesh";
-		Ogre::String stencilname = getName()+"Stencil.mesh";
+		
+		Ogre::String tunnelname = mTerrainCut->mTunnel->getName()+".mesh";
+		Ogre::String stencilname = mTerrainCut->mStencil->getName()+".mesh";
 
 		Ogre::MeshPtr tunnel = mTerrainCut->mTunnel->convertToMesh(tunnelname);
 		Ogre::MeshPtr stencil = mTerrainCut->mStencil->convertToMesh(stencilname);
 	return true;
 }
 //----------------------------------------------------------------------------------------
-
+void TerrainCut::cleanup(void)
+{
+	if(mTunnel)
+	{
+		OgitorsRoot::getSingletonPtr()->GetSceneManager()->destroyManualObject(mTunnel);
+	}
+	if(mStencil)
+	{
+		OgitorsRoot::getSingletonPtr()->GetSceneManager()->destroyManualObject(mStencil);
+	}
+}
+//----------------------------------------------------------------------------------------
 void TerrainCut::create(Ogre::String name, Ogre::Vector3 position,Ogre::Quaternion orientation,Ogre::Real width,Ogre::Real height)
 {
 	//create mesh for stencil cut:
 	if(result.second)
 	{  
 		Ogre::MaterialPtr stencilMaterial = result.first;
-		stencilMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+		stencilMaterial->getTechnique(0)->getPass(0)->createTextureUnitState();
+		stencilMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setColourOperationEx( Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue( 0, 0, 0, 1) );
+		
+		stencilMaterial->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SceneBlendType::SBT_TRANSPARENT_COLOUR);
+		stencilMaterial->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CompareFunction::CMPF_GREATER_EQUAL, 1);
+		stencilMaterial->getTechnique(0)->getPass(0)->setDepthBias(3.5f, 3.5f);
 		Ogre::MaterialSerializer matexp;
 		matexp.exportMaterial(stencilMaterial,options->ProjectDir+"/Zones/MZP_StencilMat.material");
 	}
+
 	mStencil = OgitorsRoot::getSingletonPtr()->GetSceneManager()->createManualObject(name + "Stencil");
 	mStencil->begin("MZP_StencilMat", Ogre::RenderOperation::OT_TRIANGLE_LIST);
 	for(int p = 0;p<9;++p)
 	mStencil->quad(8,5,4,3);
 	mStencil->quad(7,6,5,8);
 	mStencil->end();
-
+	
 	mTunnel = OgitorsRoot::getSingletonPtr()->GetSceneManager()->createManualObject(name + "Tunnel");
 
 	Ogre::String tunnelMat = "MZP_TunnelMat";
 		mTunnel->end();
 	}
 
+	mTunnel->setRenderQueueGroup(Ogre::RENDER_QUEUE_WORLD_GEOMETRY_1);
 	update(position,orientation,width,height);
 }
 //----------------------------------------------------------------------------------------
 		Ogre::Vector3 point;
 		if(!terrain->hitTest(ray,&points[i]/*&point*/))
 		{return false;}//if no hit, abort
-		//points[i] = point;
+		points[i].y+=0.1;	//TODO: replace this epsilon value with 
+							//one moved along the ray
 		mStencil->position(points[i]);
 		mStencil->textureCoord(texture[i].x,texture[i].y);
 	}

File Plugins/OgModularZone/PortalEditor.h

View file
 #include "PortalOutlineRenderable.h"
 
 using namespace Ogitors;
+//#define TERRAIN_CUT
 
 namespace MZP
 {
 		bool update(Ogre::Vector3 position,Ogre::Quaternion orientation,Ogre::Real width,Ogre::Real height);
 		bool TerrainCut::updateStencil(Ogre::Quaternion orientation,Ogre::Vector3 points[13]);
 		bool updateTunnel(Ogre::Quaternion orientation,Ogre::Vector3 points[13],Ogre::Real width,Ogre::Real height);
-
+		void cleanup(void);
 	};
 #endif //TERRAIN_CUT
 }
 
-#endif
+#endif