Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Implementation #17

Open
UFBPREMIUM opened this issue Sep 14, 2023 · 0 comments
Open

C++ Implementation #17

UFBPREMIUM opened this issue Sep 14, 2023 · 0 comments

Comments

@UFBPREMIUM
Copy link

UFBPREMIUM commented Sep 14, 2023

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant