Skip to content

C++ Implementation #17

@UFBPREMIUM

Description

@UFBPREMIUM

Hi, im a beginner in panda3d and trying to implement your code to c++. Im trying to make my own terrain load system. (Iike your editor) (and the editor is amazing thanks for this). Here is some example for py->c++;

def setupTerrain(path, detail_map1, detail_map2, height_map):
mesh=loader.loadModel(path+'data/mesh80k.bam')
mesh.reparentTo(render)
mesh.setShader(Shader.load(Shader.SLGLSL, path+"shaders/terrain_v.glsl", path+"shaders/terrain_f.glsl"))
h_map=loader.loadTexture(height_map)
h_map.setWrapU(Texture.WMClamp)
h_map.setWrapV(Texture.WMClamp)
mesh.setShaderInput("height", h_map)
mesh.setShaderInput("atr1", loader.loadTexture(detail_map1))
mesh.setShaderInput("atr2", loader.loadTexture(detail_map2))
render.setShaderInput("z_scale", 100.0)
mesh.setShaderInput("tex_scale", 16.0)
mesh.setTransparency(TransparencyAttrib.MNone)
mesh.node().setBounds(OmniBoundingVolume())
mesh.node().setFinal(1)
mesh.setBin("background", 11)
#mesh.setShaderInput("water_level",26.0)
return mesh

void Background::setupTerrain(string detail_map1, string detail_map2, string height_map) {
NodePath mesh = Engine::loadModel("mesh", "bin/neuera/models/mesh80k.bam");
mesh.reparent_to(window->get_render());
mesh.set_shader(Shader::load(Shader::SL_GLSL, "bin/neuera/shaders/terrain_v.glsl", "bin/neuera/shaders/terrain_f.glsl"));
Texture* h_map = Engine::loadTexture(height_map);
h_map->set_wrap_u(SamplerState::WM_clamp);
h_map->set_wrap_v(SamplerState::WM_clamp);
mesh.set_shader_input("height", h_map);
mesh.set_shader_input("atr1", Engine::loadTexture(detail_map1));
mesh.set_shader_input("atr2", Engine::loadTexture(detail_map2));
window->get_render().set_shader_input("z_scale",LVecBase2i(100.0));
mesh.set_shader_input("tex_scale", LVecBase2i(16.0));
mesh.set_transparency(TransparencyAttrib::M_none);
PT(OmniBoundingVolume) omni = new OmniBoundingVolume();
mesh.get_node(0)->set_bounds(omni);
mesh.get_node(0)->set_final(true);
mesh.set_bin("background", 11);
}

But when i tried, i have only flat mesh (i have heightmap.png);
ss1

Also i got this shader error even file is there;
errss

Thanks for your time and sorry for my english..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions