starting to use PLSM, API, tuto, example ?

Technogenius

04-03-2007 14:51:03

hello there :mrgreen: ,
I starting to use PLSM, I know how to load a terrain, and now i would like to change it, to draw a road, to make a crater or a mountain, to make footprint...


there is somewhere some tutorials ? or examples ? or someone have a code, wich make a simple brush ?


there is somwhere an API for PLSM ?

asmo

05-03-2007 12:21:35

http://www.ogre3d.org/wiki/index.php/Category:PLSM

Also check the source for GOOFed and other opensource projects using PLSM as well as the source for PLSM.

vanzu

05-03-2007 23:05:21

I just found out how to use brushes. Here is a piece of code i just wrote to learn how to deform terrain. You will need to apply the changes to the plugin submitted by asmo 3 days ago in a post related to smoothing for this code to work though.


void KarmaworldFrameListener::mousePressed(MouseEvent* e)
{
// Left mouse button down
if (e->getButtonID() & InputEvent::BUTTON0_MASK)
{
mClickX = e->getX();
mClickY = e->getY();

// ray scene query to get the location of the mouse pointer on the world
Ray mouseRay = mCamera->getCameraToViewportRay( e->getX(), e->getY() );
mRaySceneQuery->setRay( mouseRay );
mRaySceneQuery->setQueryTypeMask(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK);
mRaySceneQuery->setWorldFragmentType(SceneQuery::WFT_SINGLE_INTERSECTION);
RaySceneQueryResult &result = mRaySceneQuery->execute();
RaySceneQueryResult::iterator itr = result.begin( );

switch(mClickAction)
{
case DEFORM:
if (itr != result.end() && itr->worldFragment)
{
mSceneMgr->setOption( "DeformationCenter", &(itr->worldFragment->singleIntersection) );
}
break;

case FLATTEN:
Vector3 impact;
uint32 brushArrayHeight = 10;
uint32 brushArrayWidth = 10;

if ( itr != result.end() && itr->worldFragment )
{
impact = itr->worldFragment->singleIntersection;

Real brushScale = 1.0;
mSceneMgr->setOption("BrushScale", &brushScale);

// create brush
mBrushArray = new float[10*10];
mSceneMgr->setOption("BrushArray", mBrushArray);
mSceneMgr->setOption("BrushArrayHeight", &brushArrayHeight);
mSceneMgr->setOption("BrushArrayWidth", &brushArrayWidth);

mSceneMgr->setOption("fillBrushArray", &impact);
/*
// FlattenAvg
float avg = 0;
for(uint i=0; i < brushArrayHeight * brushArrayWidth; i++)
avg += mBrushArray[i];

avg /= brushArrayHeight * brushArrayWidth;

for(int i=0; i < brushArrayHeight * brushArrayWidth; i++)
mBrushArray[i] = avg;
*/
//FlattenLowest
//determine the lowest value in the array
float lowest = mBrushArray[0];
for (int i = 1; i < 100; i++)
lowest = (lowest < mBrushArray[i]) ? lowest : mBrushArray[i];

// fill the brush with this value
for(int i =0; i < 100; i++)
mBrushArray[i] = lowest;

//Flatten
mSceneMgr->setOption("setHeightCenter", &impact);
}
break;
}
}

}

Technogenius

13-03-2007 07:53:35

thx vanzu, i will try this in two weeks, my f*c*i*g computer is broken for now