Paging Landscape Scene Manager

saladin

13-11-2007 03:17:59

Hi,

I did a search and the same question was asked a year ago. Is it able to use PLSM2 for terrains and world geometry in current python-ogre version?

andy

13-11-2007 07:45:19

No -- There is OgreForests which might do what you need.

I hadn't added support as the PLSM still appears to be in a state of 'flux', there is much talk about the problems with the current v2 implementation, and yet I didn't see much happening with v3..

I also wonder if the portal scene manager (currently only in the Ogre CVS head version - however I may switch to this for my binary builds anyway) will make a suitable replacement for PLSM ??

Anyway -- have a look at both Forests and Protal and let me know if you still need PLSM -- if so I'll look to add it.

Cheers
Andy

Game_Ender

13-11-2007 07:56:47

Does that mean you will be dropping support for Ogre 1.4.x? If you will be doing this I suggest a branch that at least retains the ability so it will be easier to generate fixes for Ogre 1.4 specific areas.

andy

13-11-2007 09:53:49

I'm not dropping support for anything at this time..

Cheers

Andy

saladin

13-11-2007 10:02:25

No -- There is OgreForests which might do what you need.

I hadn't added support as the PLSM still appears to be in a state of 'flux', there is much talk about the problems with the current v2 implementation, and yet I didn't see much happening with v3..

I also wonder if the portal scene manager (currently only in the Ogre CVS head version - however I may switch to this for my binary builds anyway) will make a suitable replacement for PLSM ??

Anyway -- have a look at both Forests and Protal and let me know if you still need PLSM -- if so I'll look to add it.

Cheers
Andy


There's a big chance that I won't be needing them actually. All I need is a heightmap terrain which doesn't fix the terrain with the top left corner of the heightmap at the origin. And which can easily be converted into a newton tree collision geometry. I thought PLSM is actually quite active and well supported. I'll look further into portal and forest scene managers.

Cheers.

saladin

13-11-2007 12:28:12

I was looking at the C++ code of the ETM. And it looks like it can generate vertex normals for dynamic lighting. If only I can gain access to TerrainManager.mTerrain data, I can use the vertex data to create treeColision in ogre newt. Is it possible to wrap the ETM in a way that the mTerrain member is accessible?

void Tile::createVertexData(size_t startx, size_t startz)
{
mTerrain = new VertexData;
mTerrain->vertexStart = 0;
mTerrain->vertexCount = mOpt.tileSize * mOpt.tileSize;

VertexDeclaration* decl = mTerrain->vertexDeclaration;
VertexBufferBinding* bind = mTerrain->vertexBufferBinding;

// first we need to declare the contents of our vertex buffer
size_t offset = 0;
decl->addElement(MAIN_BINDING, offset, VET_FLOAT3, VES_POSITION);
offset += VertexElement::getTypeSize(VET_FLOAT3);
if (mOpt.vertexNormals)
{
decl->addElement(MAIN_BINDING, offset, VET_FLOAT3, VES_NORMAL);
offset += VertexElement::getTypeSize(VET_FLOAT3);
}
decl->addElement(MAIN_BINDING, offset, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0);
offset += VertexElement::getTypeSize(VET_FLOAT2);

mMainBuffer = HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(MAIN_BINDING), mTerrain->vertexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY);

// bind the buffer
bind->setBinding(MAIN_BINDING, mMainBuffer);

// declare delta buffers, if requested
if (mOpt.useLODMorph)
{
decl->addElement(DELTA_BINDING, 0, VET_FLOAT1, VES_BLEND_WEIGHTS);
}


// now construct the vertex buffer from the heightmap data
size_t endx = startx + mOpt.tileSize;
size_t endz = startz + mOpt.tileSize;
Real minHeight = mInfo.getOffset().y + mInfo.getScaling().y, maxHeight = mInfo.getOffset().y;

const VertexElement* posElem = decl->findElementBySemantic(VES_POSITION);
const VertexElement* texElem0 = decl->findElementBySemantic(VES_TEXTURE_COORDINATES, 0);

unsigned char* pBase = static_cast<unsigned char*>(mMainBuffer->lock(HardwareBuffer::HBL_DISCARD));

for (size_t j = startz; j < endz; ++j)
{
for (size_t i = startx; i < endx; ++i)
{
float* pPos, * pTex0;//, * pTex1;
posElem->baseVertexPointerToElement(pBase, &pPos);
texElem0->baseVertexPointerToElement(pBase, &pTex0);

Real height = mInfo.getOffset().y + mInfo.at(i, j) * mInfo.getScaling().y;
*pPos++ = mInfo.getOffset().x + mInfo.getScaling().x * i;
*pPos++ = height;
*pPos++ = mInfo.getOffset().z + mInfo.getScaling().z * j;

*pTex0++ = float(i) / (mInfo.getWidth() - 1);
*pTex0++ = float(j) / (mInfo.getHeight() - 1);

if (height < minHeight)
minHeight = height;
if (height > maxHeight)
maxHeight = height;

pBase += mMainBuffer->getVertexSize();
}
}
mMainBuffer->unlock();

// set the extents of this terrain tile
mBounds.setExtents(mInfo.getOffset().x + mInfo.getScaling().x * startx, minHeight,
mInfo.getOffset().z + mInfo.getScaling().z * startz,
mInfo.getOffset().x + mInfo.getScaling().x * endx, maxHeight,
mInfo.getOffset().z + mInfo.getScaling().z * (endz));

mCenter = mBounds.getCenter();

mBoundingRadius = (mBounds.getMaximum() - mCenter).length();

// if using LOD morphing, create the delta buffers now (they'll be filled in _calculateMinLevelDist2)
if (mOpt.useLODMorph)
{
for (unsigned int i = 0; i < mOpt.maxMipMapLevel-1; ++i)
{
HardwareVertexBufferSharedPtr buf = HardwareBufferManager::getSingleton().createVertexBuffer(
VertexElement::getTypeSize(VET_FLOAT1), mOpt.tileSize*mOpt.tileSize,
HardwareBuffer::HBU_STATIC_WRITE_ONLY);
emptyBuffer(buf);
mDeltaBuffers.push_back(buf);
}
}


// calc vertex normals, if necessary
if (mOpt.vertexNormals)
calculateVertexNormals();
}



void Tile::calculateVertexNormals()
{
// set the vertex normals of the tile

size_t startx = mStartX;
size_t startz = mStartZ;
size_t endx = startx + mOpt.tileSize;
size_t endz = startz + mOpt.tileSize;
Real minHeight = mInfo.getOffset().y + mInfo.getScaling().y, maxHeight = mInfo.getOffset().y;

const VertexElement* normElem = mTerrain->vertexDeclaration->findElementBySemantic(VES_NORMAL);
unsigned char* pBase = static_cast<unsigned char*>(mMainBuffer->lock(HardwareBuffer::HBL_NORMAL));

for (size_t j = startz; j < endz; ++j)
{
for (size_t i = startx; i < endx; ++i)
{
float* pNorm;
normElem->baseVertexPointerToElement(pBase, &pNorm);

Vector3 normal = mInfo.getNormalAt(mInfo.vertexToPosX((int)i), mInfo.vertexToPosZ((int)j));
*pNorm++ = normal.x;
*pNorm++ = normal.y;
*pNorm++ = normal.z;

pBase += mMainBuffer->getVertexSize();
}
}
mMainBuffer->unlock();
}

andy

13-11-2007 14:22:31

I'll take a look, shouldn't be an issue

Andy

SirGolan

13-11-2007 16:04:36

I'd like to cast a vote for the portal scene manager. :D