protected Mesh clone(final Mesh original) { Mesh copy = null; try { copy = original.getClass().newInstance(); } catch (final InstantiationException e) { logger.log(Level.SEVERE, "Could not access final constructor of class " + original.getClass().getCanonicalName(), e); throw new RuntimeException(e); } catch (final IllegalAccessException e) { logger.log(Level.SEVERE, "Could not access final constructor of class " + original.getClass().getCanonicalName(), e); throw new RuntimeException(e); } copy.setName(original.getName() + "_copy"); copy.getSceneHints().set(original.getSceneHints()); copy.setTransform(original.getTransform()); copy.setDefaultColor(original.getDefaultColor()); for (final StateType type : StateType.values()) { final RenderState state = original.getLocalRenderState(type); if (state != null) { copy.setRenderState(state); } } return copy; }
protected Mesh clone(final Mesh original) { Mesh copy = null; try { copy = original.getClass().newInstance(); } catch (final InstantiationException e) { logger.log(Level.SEVERE, "Could not access final constructor of class " + original.getClass().getCanonicalName(), e); throw new RuntimeException(e); } catch (final IllegalAccessException e) { logger.log(Level.SEVERE, "Could not access final constructor of class " + original.getClass().getCanonicalName(), e); throw new RuntimeException(e); } copy.setName(original.getName() + "_copy"); copy.getSceneHints().set(original.getSceneHints()); copy.setTransform(original.getTransform()); copy.setDefaultColor(original.getDefaultColor()); for (final StateType type : StateType.values()) { final RenderState state = original.getLocalRenderState(type); if (state != null) { copy.setRenderState(state); } } return copy; }
public void apply(final Renderable renderable) { if (renderable instanceof Mesh) { final Mesh mesh = (Mesh) renderable; isVisible = mesh.isVisible(); if (!mesh.getSceneHints().isCastsShadows()) { mesh.setVisible(false); } cullState = (CullState) mesh.getWorldRenderState(StateType.Cull); if (cullState != null) { cullFace = cullState.getCullFace(); if (cullFace != Face.None) { cullState.setCullFace(Face.Front); } } } }
public AreaEntry(final int maxSamples, final StatType type) { this.maxSamples = maxSamples; area = new Mesh("a"); area.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(maxSamples * 2)); area.getSceneHints().setRenderBucketType(RenderBucketType.Ortho); area.getMeshData().setIndexMode(IndexMode.LineStrip); area.setDefaultColor(getColorConfig(type, ConfigKeys.Color.name(), new ColorRGBA(ColorRGBA.LIGHT_GRAY))); if (!getBooleanConfig(type, ConfigKeys.ShowAreas.name(), true)) { area.getSceneHints().setCullHint(CullHint.Always); } } }
public AreaEntry(final int maxSamples, final StatType type) { this.maxSamples = maxSamples; area = new Mesh("a"); area.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(maxSamples * 2)); area.getSceneHints().setRenderBucketType(RenderBucketType.OrthoOrder); area.getMeshData().setIndexMode(IndexMode.LineStrip); area.setDefaultColor(getColorConfig(type, ConfigKeys.Color.name(), new ColorRGBA(ColorRGBA.LIGHT_GRAY))); if (!getBooleanConfig(type, ConfigKeys.ShowAreas.name(), true)) { area.getSceneHints().setCullHint(CullHint.Always); } } }
public void update(final double time, final Spatial caller) { if (_target == null) { return; } final ColorRGBA color = ColorRGBA.fetchTempInstance().set(_target.getDefaultColor()); float alpha = color.getAlpha(); alpha += _rate * time; if (_dir && alpha <= _targetAlpha) { alpha = _targetAlpha; } else if (!_dir && alpha >= _targetAlpha) { alpha = _targetAlpha; } if (alpha != 0) { _target.getSceneHints().setCullHint(CullHint.Inherit); } else { _target.getSceneHints().setCullHint(CullHint.Always); } color.setAlpha(alpha); _target.setDefaultColor(color); ColorRGBA.releaseTempInstance(color); if (alpha == _targetAlpha) { _target.removeController(this); // enable gc _target = null; } }
/** * This function checks for intersection between this mesh and the given one. On the first intersection, true is * returned. * * @param toCheck * The intersection testing mesh. * @return True if they intersect. */ public static boolean hasPrimitiveCollision(final Mesh testMesh, final Mesh toCheck) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return false; } final CollisionTree thisCT = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree checkCT = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (thisCT == null || checkCT == null) { return false; } final ReadOnlyTransform worldTransform = testMesh.getWorldTransform(); thisCT.getBounds().transform(worldTransform, thisCT.getWorldBounds()); return thisCT.intersect(checkCT); }
public void update(final double time, final Spatial caller) { if (_target == null) { return; } final ColorRGBA color = ColorRGBA.fetchTempInstance().set(_target.getDefaultColor()); float alpha = color.getAlpha(); alpha += _rate * time; if (_dir && alpha <= _targetAlpha) { alpha = _targetAlpha; } else if (!_dir && alpha >= _targetAlpha) { alpha = _targetAlpha; } if (alpha != 0) { _target.getSceneHints().setCullHint(CullHint.Inherit); } else { _target.getSceneHints().setCullHint(CullHint.Always); } color.setAlpha(alpha); _target.setDefaultColor(color); ColorRGBA.releaseTempInstance(color); if (alpha == _targetAlpha) { _target.removeController(this); // enable gc _target = null; } }
/** * This function finds all intersections between this mesh and the checking one. The intersections are stored as * PrimitiveKeys. * * @param toCheck * The Mesh to check. * @param testIndex * The array of PrimitiveKeys intersecting in this mesh. * @param otherIndex * The array of PrimitiveKeys intersecting in the given mesh. */ public static void findPrimitiveCollision(final Mesh testMesh, final Mesh toCheck, final List<PrimitiveKey> testIndex, final List<PrimitiveKey> otherIndex) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return; } final CollisionTree myTree = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree otherTree = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (myTree == null || otherTree == null) { return; } myTree.getBounds().transform(testMesh.getWorldTransform(), myTree.getWorldBounds()); myTree.intersect(otherTree, testIndex, otherIndex); }
/** * This function checks for intersection between this mesh and the given one. On the first intersection, true is * returned. * * @param toCheck * The intersection testing mesh. * @return True if they intersect. */ public static boolean hasPrimitiveCollision(final Mesh testMesh, final Mesh toCheck) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return false; } final CollisionTree thisCT = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree checkCT = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (thisCT == null || checkCT == null) { return false; } final ReadOnlyTransform worldTransform = testMesh.getWorldTransform(); thisCT.getBounds().transform(worldTransform, thisCT.getWorldBounds()); return thisCT.intersect(checkCT); }
/** * This function finds all intersections between this mesh and the checking one. The intersections are stored as * PrimitiveKeys. * * @param toCheck * The Mesh to check. * @param testIndex * The array of PrimitiveKeys intersecting in this mesh. * @param otherIndex * The array of PrimitiveKeys intersecting in the given mesh. */ public static void findPrimitiveCollision(final Mesh testMesh, final Mesh toCheck, final List<PrimitiveKey> testIndex, final List<PrimitiveKey> otherIndex) { if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return; } final CollisionTree myTree = CollisionTreeManager.getInstance().getCollisionTree(testMesh); final CollisionTree otherTree = CollisionTreeManager.getInstance().getCollisionTree(toCheck); if (myTree == null || otherTree == null) { return; } myTree.getBounds().transform(testMesh.getWorldTransform(), myTree.getWorldBounds()); myTree.intersect(otherTree, testIndex, otherIndex); }
final boolean useVBO = (getSceneHints().getDataMode() == DataMode.VBO || getSceneHints().getDataMode() == DataMode.VBOInterleaved) && caps.isVBOSupported();
protected Mesh getFullScreenQuad() { if (_fsq != null) { return _fsq; } _fsq = new Mesh("fsq"); _fsq.getMeshData().setVertexBuffer(BufferUtils.createFloatBuffer(-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1)); _fsq.getMeshData().setTextureBuffer(BufferUtils.createFloatBuffer(0, 0, 1, 0, 1, 1, 0, 1), 0); _fsq.getMeshData().setIndices(BufferUtils.createIndexBufferData(new int[] { 0, 1, 3, 1, 2, 3 }, 3)); _fsq.getSceneHints().setCullHint(CullHint.Never); _fsq.getSceneHints().setLightCombineMode(LightCombineMode.Off); final ZBufferState zState = new ZBufferState(); zState.setEnabled(false); _fsq.setRenderState(zState); _fsq.updateGeometricState(0); return _fsq; }
protected void renderVBO(final Renderer renderer, final MeshData meshData, final int primcount) { if (getSceneHints().getDataMode() == DataMode.VBOInterleaved) { if (meshData.getColorCoords() == null) { renderer.applyDefaultColor(_defaultColor); renderer.applyNormalsMode(getSceneHints().getNormalsMode(), _worldTransform); renderer.setupTextureDataVBO(null); } else { renderer.applyNormalsMode(getSceneHints().getNormalsMode(), _worldTransform); if (getSceneHints().getNormalsMode() != NormalsMode.Off) { renderer.setupNormalDataVBO(meshData.getNormalCoords()); } else {
renderer.setupTextureData(null); } else { renderer.applyNormalsMode(getSceneHints().getNormalsMode(), _worldTransform); if (getSceneHints().getNormalsMode() != NormalsMode.Off) { renderer.setupNormalData(meshData.getNormalCoords()); } else {
_particleMesh.getSceneHints().setCastsShadows(false);
_particleMesh.getSceneHints().setCastsShadows(false);
_particleMesh.getSceneHints().setCastsShadows(false);
_particleMesh.getSceneHints().setCastsShadows(false);
_particleMesh.getSceneHints().setCastsShadows(false);