Pavl_G
February 11, 2021, 5:32pm
1
So, this problem happens sometimes with some mesh terrains(Ground up-Face culling) , i think it’s a camera frustum problem as i have solved it before by translating the camera frustum plane upward(but image get interrupted when i use the cam in another calculation like ScreenFilters) , but i think there’s an optimum standard fix for this ? , also if there’s examples from jme repos on using different camera features , please share !
thanks
Problem :
real mesh(town.zip):
code(demoApp) :
// soccerPlayGround.setFloat("ShadowMapSize",0.1f); // soccerPlayGround.setTexture("EnvMap",assetManager.loadTexture("RocketLeauge/assets/Textures/sky.jpg")); //// soccerPlayGround.selectTechnique("PostShadow",getRenderManager()); // //// soccerPlayGround.setTexture("DiffuseMap", assetManager.loadTexture("RocketLeauge/assets/Textures/soccer.jpg")); // soccerPlayGround.setBoolean("UseMaterialColors",true); // // soccerPlayGround.setColor("Ambient",ColorRGBA.LightGray); // soccerPlayGround.setColor("Specular",ColorRGBA.LightGray); // soccerPlayGround.setFloat("Shininess",1f); Spatial floorGeometry = assetManager.loadModel("RocketLeauge/assets/Scenes/town/main.scene"); DirectionalLight directionalLight=new DirectionalLight(new Vector3f(-3,-floorGeometry.getLocalScale().getY()*4,-3).normalize()); directionalLight.setColor(ColorRGBA.White.mult(2f)); floorGeometry.addLight(a); rootNode.addLight(directionalLight); floorGeometry.setLocalTranslation(0f,-10f,0f); floorGeometry.setLocalScale(10f); RigidBodyControl rigidBodyControl=new RigidBodyControl(CollisionShapeFactory.createMeshShape(floorGeometry),0); floorGeometry.setCullHint(Spatial.CullHint.Never); rigidBodyControl.setFriction(20f);
sgold
February 11, 2021, 5:51pm
2
floorGeometry.getMaterial().getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
1 Like
Pavl_G
February 11, 2021, 6:02pm
3
It gives me ClassCastException
when trying to cast to Geometry
like this Spatial :: jMonkeyEngine Docs
Spatial floorGeometry = assetManager.loadModel("RocketLeauge/assets/Scenes/town/main.scene");
DirectionalLight directionalLight=new DirectionalLight(new Vector3f(-3,-floorGeometry.getLocalScale().getY()*4,-3).normalize());
directionalLight.setColor(ColorRGBA.White.mult(2f));
floorGeometry.addLight(a);
rootNode.addLight(directionalLight);
((Geometry)floorGeometry).getMaterial().getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
what’s wrong ?
sgold
February 11, 2021, 6:09pm
4
Not all spatials are geometries. Some are nodes. Iterate over all geometries in the model.
1 Like
Pavl_G
February 11, 2021, 6:15pm
5
the childs of the Spatial or Node retrieved in the form of other nodes of Spatial , how to get Geometry
instance from a Spatial or Node.
Pavl_G
February 11, 2021, 6:24pm
6
Hmm , the materials are done here programmatically :
material.setTexture("NormalMap", normalMap); material.setFloat("NormalType", 1.0f); // material.setColor("BaseColor", ColorRGBA.LightGray); // material.setFloat("Roughness", 0.75f); material.setFloat("Metallic", 0.001f); // material.setBoolean("UseFog", true); // material.setColor("FogColor", new ColorRGBA(0.5f, 0.6f, 0.7f, 1.0f)); // material.setFloat("ExpSqFog", 0.002f); RenderState additional = material.getAdditionalRenderState(); additional.setFaceCullMode(RenderState.FaceCullMode.Off); Spatial playground = assetManager.loadModel("Models/vehicle-playground/vehicle-playground.j3o"); playground.setMaterial(material); Node p = (Node) playground; p.breadthFirstTraversal(spatial -> spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive)); playground.setName("playground"); return playground;
but that’s not the case , the town.zip is done in an editor & i am just trying to load the material of it , but i cannot because i cannot cast a Node to a Geometry when they already have the same origin(Spatial)…?