gosse
27-01-2008 18:13:25
I have integrated ETM (awesome add-on, by the way!) to our game framework and use it to load our map. It works great. I have 6 textures (512) onto 2 coverage maps (128), one lightmap (128), and one height map (513) that extends to 4096x853x4096.
I am currently making a map editor for our project. Now, editing the height works fine, with multiple brushes and everything. I am having problems painting on it with the splatting manager. I really can't figure out what I'm doing wrong, as I followed the sample very closely. It just doesn't paint anything
Here's some pieces of my map editor, which I hope, will make the problem pop out
Init
Map loading
Painting the terrain
Thanks to anyone who tries to help me out on this one!
I am currently making a map editor for our project. Now, editing the height works fine, with multiple brushes and everything. I am having problems painting on it with the splatting manager. I really can't figure out what I'm doing wrong, as I followed the sample very closely. It just doesn't paint anything
Here's some pieces of my map editor, which I hope, will make the problem pop out
Init
gpTerrainManager = new ET::TerrainManager( gpSceneManager );
gpTerrainManager->setLODErrorMargin( 2, aiHeight );
gpTerrainManager->setUseLODMorphing( true, 0.25, "morphFactor" );
gpSplatManager = new ET::SplattingManager( "ETSplatting", "General", 128, 128, 3 );
gpSplatManager->setNumTextures( 6 );
Map loading
Ogre::Image image;
gpTerrainManager->destroyTerrain();
image.load( Ogre::String( "Level" ) + aszLevelNumber + "_HM.png", "General");
ET::TerrainInfo info;
ET::loadHeightmapFromImage(info, image);
info.setExtents(Ogre::AxisAlignedBox(0, 0, 0, MAP_SIZE, MAP_HEIGHT, MAP_SIZE));
gpTerrainManager->createTerrain(info);
gpTerrainInfo = & gpTerrainManager->getTerrainInfo();
image.load(Ogre::String( "Level" ) + aszLevelNumber + "_C1.png", "General");
gpSplatManager->loadMapFromImage(0, image);
image.load(Ogre::String( "Level" ) + aszLevelNumber + "_C2.png", "General");
gpSplatManager->loadMapFromImage(1, image);
Ogre::MaterialPtr material (Ogre::MaterialManager::getSingleton().getByName(Ogre::String( "Level" ) + aszLevelNumber));
gpTerrainManager->setMaterial(material);
Ogre::TexturePtr lightmapTex = Ogre::TextureManager::getSingleton().createManual("ETLightmap", "General", Ogre::TEX_TYPE_2D, 128, 128, 1, Ogre::PF_BYTE_RGB);
image.load( Ogre::String( "Level" ) + aszLevelNumber + "_LM.png", "General");
lightmapTex->getBuffer(0, 0)->blitFromMemory(image.getPixelBox(0, 0));
Painting the terrain
Ogre::Ray oRay = camDefault.GetOgreCamera()->getCameraToViewportRay( (float)gpMouse->getMouseState().X.abs / (float)gpMouse->getMouseState().width, (float)gpMouse->getMouseState().Y.abs / (float)gpMouse->getMouseState().height );
std::pair<bool, Ogre::Vector3> oResult = gpTerrainInfo->rayIntersects( oRay );
int iX = gpTerrainInfo->posToVertexX( oResult.second.x );
int iZ = gpTerrainInfo->posToVertexZ( oResult.second.z );
stBrush oBrush = mapBrushes[(CEGUI::ListboxTextItem*)gpCurrentBrush];
gpSplatManager->paint( guiCurrentTexture, iX, iZ, oBrush.oBrush, 10.0f * GetDeltaTime() * ( gpBrushIntensity->getScrollPosition() - 1.0f ) );
Thanks to anyone who tries to help me out on this one!