Wireframe on top of Terrain!
Here is the code, I hope you add it into ETSM code base (after you touch it up to meet your standards.
)
ETSceneManager.h:
Code: Select all
public:
/** Render the terrain wireframe over the terrain texture. */
void showWireFrame(bool show);
...
private:
...
bool mWireFrameShown;
unsigned int mWireFramePassIndex;
ETSceneManager.cpp:
Code: Select all
...
mWireFrameShown(0),
mWireFramePassIndex(0)
...
void ETSceneManager::showWireFrame(bool show)
{
Ogre::MaterialPtr mp = const_cast<const Ogre::MaterialPtr&>(mMaterialHandler->getMaterial());
if (show && !mWireFrameShown)
{
Ogre::Pass* p = mp->getBestTechnique()->createPass();
mWireFramePassIndex = p->getIndex();
p->setDepthBias(2.0);
p->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);
p->setAmbient(0,1,0);
mWireFrameShown = true;
}
else if(!show && mWireFrameShown)
{
mp->getBestTechnique()->removePass(mWireFramePassIndex);
mWireFrameShown = false;
}
}
...
bool ETSceneManager::setOption(const String& name, const void* value)
{
if (name == "ClearWorldGeometry")
{
deleteGeometry();
// create a new material handler
mMaterialHandler = new ETMaterialHandler(getName()+"/Materials/Terrain", ResourceGroupManager::getSingleton().getWorldResourceGroupName(), this, mOptions);
return true;
}
else if (name == "ShowWireFrame")
{
showWireFrame(*static_cast<bool*>(const_cast<void*>(value)));
}
...
bool ETSceneManager::getOption(const String& name, void* value)
{
if (name == "GetTerrainDimensions")
{
Vector3& vec = *static_cast<Vector3*>(value);
vec.x = mOptions.scale.x * (mOptions.width - 1);
vec.y = mOptions.scale.y;
vec.z = mOptions.scale.z * (mOptions.width - 1);
}
else if (name == "GetWireFrameShown")
{
bool* shown = static_cast<bool*>(value);
*shown = mWireFrameShown;
}
...
And modifications to the demo:
Code: Select all
...
case OIS::KC_SPACE:
mWireFrameShown = !(mWireFrameShown);
mSceneMgr->setOption("ShowWireFrame",&mWireFrameShown);
return true;
...
So regarding the Paintbrush size, it seems the size may be dependent on the terrain size?
The following screenshots show 2 spots painted at 1st (2000,300,2000) and then (4000,300,4000):
Does it look like the portion of the terrain that is painted in the second screenshot appear bigger than the first? They both have the same TextureRepeatX and TextureRepeatZ, so the second one would have the texture more stretched. I haven't ran tests against this, just wondering if there is anything wrong, or I'm just making things up.
Hope people like the wireframe capability!
KungFooMasta