Problem with Hill Plane Mesh with 2 texture coords

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
erictheturtle
Posts: 5
Joined: Fri Jun 20, 2008 5:27 pm

Problem with Hill Plane Mesh with 2 texture coords

Post by erictheturtle »

I want to create a Hill Plane Mesh that has separate texture coords for each of the textures, and will be used in a CWaterSurfaceSceneNode. Using the CSceneManager::addHillPlaneMesh() method as a reference, I created my own function to create the mesh.

Code: Select all

IAnimatedMesh* addHillPlaneMesh2T(ISceneManager *smgr,
		const core::dimension2d<f32>& tileSize,
		const core::dimension2d<u32>& tileCount,
		video::SMaterial* material, f32 hillHeight,
		const core::dimension2d<f32>& countHills,
		const core::dimension2d<f32>& textureRepeatCount)
{
	IMesh* mesh = CGeometryCreator::createHillPlaneMesh(tileSize,
			tileCount, material, hillHeight, countHills,
			textureRepeatCount);
            
	if (!mesh)
		return 0;

    IMesh* mesh2T = smgr->getMeshManipulator()->createMeshWith2TCoords(mesh);
    mesh->drop();
    
    if (!mesh2T)
        return 0;
    
	SAnimatedMesh* animatedMesh = new SAnimatedMesh();
	if (!animatedMesh)
	{
		mesh2T->drop();
		return 0;
	}

	animatedMesh->addMesh(mesh2T);
	mesh2T->drop();
	animatedMesh->recalculateBoundingBox();

	return animatedMesh;
}
I'm using the SpecialFX example as a testing ground. So I replaced the smgr->addHillPlaneMesh() with a call to the function above.

However, the results look kind of strange.
Image

It's really evident when you remove the stones.
Image

For reference, this is how it should look like.
Image

I've walked through lots of Irrlicht code, but can't understand why it is doing this.

* CGeometryCreator::createHillPlaneMesh() creates a mesh with 1 texture coord.
* CMeshManipulator::createMeshWith2TCoords() converts the mesh to use 2 texture coords, duplicating the first set of texture coords into the 2nd set.
* CSceneManager::addWaterSurfaceSceneNode() creates the CWaterSurfaceSceneNode instance, which doesn't do anything more than duplicate the mesh.

So from what I can tell, CWaterSurfaceSceneNode() shouldn't care whether the mesh is of S3DVertex, S3DVertex2TCoords, or S3DVertexTangents. It only changes the Y coord of the Pos, and the Normal.

Does anyone have any thoughts on what the problem could be?

FYI Mac OS X, Irrlicht 1.4.1, OpenGL device
Post Reply