문제

I want to change the terrain size (width + height) in Irrlicht, but I didn't find any function for that. I want a dynamic map with one Texture. Am I using a wrong pattern / class for my case?

Currently I have this:

scene::ITerrainSceneNode* terrain = sceneManager->addTerrainSceneNode("media/terrain-heightmap.bmp", 0, -1,
    core::vector3df(0.f, -4.f, 0.f),     // position
    core::vector3df(0.f, 0.f, 0.f),     // rotation
    core::vector3df(1.f, 0.f, 1.f),  // scale
    video::SColor (255, 255, 255, 255),   // vertexColor
    5,                  // maxLOD
    scene::ETPS_17,             // patchSize
    4                   // smoothFactor
);

terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("media/terrain-texture.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP);

I tried to find some setters for setting width + height (size), but I didn't find any methods.

도움이 되었습니까?

해결책

You can change the scale of the terrain (or any mesh) using setScale.

terrain->setScale(vec3df(2.0f, 0.0f, 2.0f));

When you create the terrain, you pass a scale as the 3rd parameter. So calling the line above would result in your terrain being twice as large (stretched) on the X and Z axis as in your snippet. Note that the 0.0f y-value in the scale parameter is going to make your terrain quite flat since it will be used to scale the values supplied in your height map.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top