Java Code Examples for com.jme3.renderer.Renderer#renderMesh()
The following examples show how to use
com.jme3.renderer.Renderer#renderMesh() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTechniqueDefLogic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void renderMeshFromGeometry(Renderer renderer, Geometry geom) { Mesh mesh = geom.getMesh(); int lodLevel = geom.getLodLevel(); if (geom instanceof InstancedGeometry) { InstancedGeometry instGeom = (InstancedGeometry) geom; renderer.renderMesh(mesh, lodLevel, instGeom.getActualNumInstances(), instGeom.getAllInstanceData()); } else { renderer.renderMesh(mesh, lodLevel, 1, null); } }
Example 2
Source File: Material.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * Called by {@link RenderManager} to render the geometry by * using this material. * * @param geom The geometry to render * @param rm The render manager requesting the rendering */ public void render(Geometry geom, RenderManager rm) { autoSelectTechnique(rm); Renderer r = rm.getRenderer(); TechniqueDef techDef = technique.getDef(); r.setShaderWithoutUpdateUniforms(technique.getShader()); if (techDef.getLightMode() == LightMode.MultiPass && geom.getWorldLightList().size() == 0) { return; } if (rm.getForcedRenderState() != null) { r.applyRenderState(rm.getForcedRenderState()); } else { if (techDef.getRenderState() != null) { r.applyRenderState(techDef.getRenderState().copyMergedTo(additionalState, mergedRenderState)); } else { r.applyRenderState(RenderState.DEFAULT.copyMergedTo(additionalState, mergedRenderState)); } } boolean needReloadParams = false; if (technique.isNeedReload()) { technique.makeCurrent(def.getAssetManager(), paramValues); needReloadParams = true; } // update camera and world matrices // NOTE: setWorldTransform should have been called already if (techDef.isUsingShaders()) { // reset unchanged uniform flag clearUniformsSetByCurrent(technique.getShader()); rm.updateUniformBindings(technique.getWorldBindUniforms()); } // setup textures and uniforms for (int i = paramValues.size()-1; i >=0 ; i--) { MatParam param = paramValues.getValue(i); if (param != null) { param.apply(r, technique, i); } } Shader shader = technique.getShader(); // send lighting information, if needed switch (techDef.getLightMode()) { case Disable: r.setLighting(null); break; case SinglePass: updateLightListUniforms(shader, geom, 4); break; case FixedPipeline: r.setLighting(geom.getWorldLightList()); break; case MultiPass: // NOTE: Special case! resetUniformsNotSetByCurrent(shader); renderMultipassLighting(shader, geom, rm); // very important, notice the return statement! return; } // upload and bind shader if (techDef.isUsingShaders()) { // any unset uniforms will be set to 0 resetUniformsNotSetByCurrent(shader); r.setShader(shader); } r.renderMesh(geom.getMesh(), geom.getLodLevel(), 1); }