private void createVLines() { // some basic stats: final int texWidth = _textureRenderer.getWidth(); final int texHeight = _textureRenderer.getHeight(); final FloatBuffer verts = BufferUtils.createVector3Buffer(((int) (texWidth / _vSpan) + 1) * 2); for (float x = _vSpan; x <= texWidth + _vSpan; x += _vSpan) { verts.put(x).put(0).put(0); verts.put(x).put(texHeight).put(0); } _verticals = new Line("vert", verts, null, null, null); _verticals.getMeshData().setIndexMode(IndexMode.Lines); _verticals.getSceneHints().setRenderBucketType(RenderBucketType.OrthoOrder); _verticals.setDefaultColor( getColorConfig(LineGrapher.Vertical, ConfigKeys.Color.name(), new ColorRGBA(ColorRGBA.RED))); _verticals.setLineWidth(getIntConfig(LineGrapher.Vertical, ConfigKeys.Width.name(), 1)); _verticals.setAntialiased(getBooleanConfig(LineGrapher.Vertical, ConfigKeys.Antialias.name(), true)); }
@Override public void draw(final Renderer r) { final Camera camera = Camera.getCurrentCamera(); boolean anyAlive = false; for (int i = 0; i < _particles.length; i++) { final Particle particle = _particles[i]; if (particle.getStatus() == Particle.Status.Alive) { particle.updateVerts(camera); anyAlive = true; } } // Since we've updated our verts, update the model boundary where applicable if (getParticleGeometry().getWorldBound() != null && anyAlive) { getParticleGeometry().updateModelBound(); } if (!_particlesInWorldCoords) { getParticleGeometry().setWorldTransform(getWorldTransform()); } else { getParticleGeometry().setWorldTranslation(Vector3.ZERO); getParticleGeometry().setWorldRotation(Matrix3.IDENTITY); getParticleGeometry().setWorldScale(getWorldScale()); } getParticleGeometry().draw(r); }
/** * Creates a new <code>Line</code> from the given control point indices. It will have the name <code>curve</code>, * no normals, colour or texture, these can be added to the returned line if needed. * * @param start * The index of the control point to start from, must be greater than or equal to one and less than * <code>end</code>. * @param end * The index of the control point to end with, must be less than {@link #getControlPointCount() * controlPointCount} minus one and greater than <code>start</code>. * @param steps * The number of iterations to perform between control points, the higher this number the smoother the * returned line will be, but it will also contain more vertices, must be greater than one. * @return A <code>Line</code> representing this curve, will not be <code>null</code>. */ public Line toRenderableLine(final int start, final int end, final int steps) { final Vector3[] vertex = toVector3(start, end, steps); final Vector3[] normal = null; final ColorRGBA[] color = null; final Vector2[] texture = null; final Line line = new Line("curve", vertex, normal, color, texture); line.getMeshData().setIndexMode(IndexMode.LineStrip); return line; }
lineFrustum = new Line("Lines", verts, null, colors, null); lineFrustum.getMeshData().setIndexModes( new IndexMode[] { IndexMode.LineLoop, IndexMode.LineLoop, IndexMode.Lines, IndexMode.Lines }); lineFrustum.getMeshData().setIndexLengths(new int[] { 4, 4, 8, 8 }); lineFrustum.setLineWidth(2); lineFrustum.getSceneHints().setLightCombineMode(LightCombineMode.Off); lineBlendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha); lineBlendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha); lineFrustum.setRenderState(lineBlendState); lineFrustum.setRenderState(zstate); lineFrustum.updateGeometricState(0.0); lineFrustum.getSceneHints().setRenderBucketType(RenderBucketType.Skip); lineFrustum.setDefaultColor(color); lineFrustum.setStipplePattern(pattern); final FloatBuffer colors = lineFrustum.getMeshData().getColorBuffer(); for (int i = 0; i < 16; i++) { BufferUtils.setInBuffer(color, colors, i); final FloatBuffer verts = lineFrustum.getMeshData().getVertexBuffer(); BufferUtils.setInBuffer(corners[0], verts, 0); BufferUtils.setInBuffer(corners[1], verts, 1); lineFrustum.draw(r);
final FloatBuffer colors = BufferUtils.createColorBuffer(24); lineFrustum = new Line("Lines", verts, null, colors, null); lineFrustum.getMeshData().setIndexModes( new IndexMode[] { IndexMode.LineLoop, IndexMode.LineLoop, IndexMode.Lines, IndexMode.Lines }); lineFrustum.getMeshData().setIndexLengths(new int[] { 4, 4, 8, 8 }); lineFrustum.getSceneHints().setLightCombineMode(LightCombineMode.Off); lineBlendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha); lineBlendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha); lineFrustum.setRenderState(lineBlendState); lineFrustum.setRenderState(zstate); lineFrustum.updateGeometricState(0.0); lineFrustum.getSceneHints().setRenderBucketType(RenderBucketType.Skip); lineFrustum.setDefaultColor(color); final FloatBuffer colors = lineFrustum.getMeshData().getColorBuffer(); for (int i = 0; i < 16; i++) { BufferUtils.setInBuffer(color, colors, i); final FloatBuffer verts = lineFrustum.getMeshData().getVertexBuffer(); BufferUtils.setInBuffer(corners[0], verts, 0); BufferUtils.setInBuffer(corners[1], verts, 1); lineFrustum.draw(r);
return null; final Line lineMesh = new Line(extractName(colladaGeometry, lines)); pipe.setupBuffer(numEntries, lineMesh.getMeshData(), _dataCache); lineMesh.updateModelBound();
final FloatBuffer verts = mesh.getMeshData().getVertexBuffer(); if (norms != null && verts != null && norms.limit() == verts.limit()) { FloatBuffer lineVerts = normalLines.getMeshData().getVertexBuffer(); if (lineVerts.capacity() < (3 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setVertexBuffer(null); lineVerts = BufferUtils.createVector3Buffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setVertexBuffer(lineVerts); } else { lineVerts.clear(); lineVerts.limit(3 * 2 * mesh.getMeshData().getVertexCount()); normalLines.getMeshData().setVertexBuffer(lineVerts); FloatBuffer lineColors = normalLines.getMeshData().getColorBuffer(); if (lineColors.capacity() < (4 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setColorBuffer(null); lineColors = BufferUtils.createColorBuffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setColorBuffer(lineColors); } else { lineColors.clear(); IndexBufferData<?> lineInds = normalLines.getMeshData().getIndices(); if (lineInds == null || lineInds.getBufferCapacity() < (normalLines.getMeshData().getVertexCount())) { normalLines.getMeshData().setIndices(null); lineInds = BufferUtils.createIndexBufferData(mesh.getMeshData().getVertexCount() * 2, normalLines.getMeshData().getVertexCount() - 1); normalLines.getMeshData().setIndices(lineInds); } else { lineInds.getBuffer().clear(); lineInds.getBuffer().limit(normalLines.getMeshData().getVertexCount());
if (!_graphRoot.equals(_horizontals.getParent())) { _graphRoot.attachChild(_horizontals); if (!_graphRoot.equals(_verticals.getParent())) { _graphRoot.attachChild(_verticals); entry.line.removeFromParent(); entry.point.removeFromParent(); i.remove(); final double scaleHeight = texHeight / (entry.max * 1.02); entry.point.setScale(new Vector3(scaleWidth, scaleHeight, 1)); entry.line.getMeshData().setVertexBuffer(fb); entry.line.setScale(new Vector3(scaleWidth, scaleHeight, 1)); fb.rewind(); if (!_graphRoot.equals(entry.line.getParent())) { _graphRoot.attachChild(entry.line);
private Line createGrid() { final Vector3[] vertices = new Vector3[GRID_LINES * 2 * 2]; final float edge = GRID_LINES / 2 * GRID_SPACING; for (int ii = 0, idx = 0; ii < GRID_LINES; ii++) { final float coord = (ii - GRID_LINES / 2) * GRID_SPACING; vertices[idx++] = new Vector3(-edge, 0f, coord); vertices[idx++] = new Vector3(+edge, 0f, coord); vertices[idx++] = new Vector3(coord, 0f, -edge); vertices[idx++] = new Vector3(coord, 0f, +edge); } final Line grid = new Line("grid", vertices, null, null, null) { @Override public void draw(final Renderer r) { StatCollector.pause(); super.draw(r); StatCollector.resume(); } }; grid.setDefaultColor(ColorRGBA.DARK_GRAY); grid.getSceneHints().setCullHint(_prefs.getBoolean("showgrid", true) ? CullHint.Dynamic : CullHint.Always); return grid; }
final FloatBuffer shapeBuffer = shape.getMeshData().getVertexBuffer(); final FloatBuffer shapeNormalBuffer = shape.getMeshData().getNormalBuffer(); final IndexMode indexMode = shape.getMeshData().getIndexMode(0);
final FloatBuffer verts = mesh.getMeshData().getVertexBuffer(); if (norms != null && verts != null && norms.limit() == verts.limit()) { FloatBuffer lineVerts = normalLines.getMeshData().getVertexBuffer(); if (lineVerts.capacity() < (3 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setVertexBuffer(null); lineVerts = BufferUtils.createVector3Buffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setVertexBuffer(lineVerts); } else { lineVerts.clear(); lineVerts.limit(3 * 2 * mesh.getMeshData().getVertexCount()); normalLines.getMeshData().setVertexBuffer(lineVerts); FloatBuffer lineColors = normalLines.getMeshData().getColorBuffer(); if (lineColors.capacity() < (4 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setColorBuffer(null); lineColors = BufferUtils.createColorBuffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setColorBuffer(lineColors); } else { lineColors.clear(); IndexBufferData<?> lineInds = normalLines.getMeshData().getIndices(); if (lineInds == null || lineInds.getBufferCapacity() < (normalLines.getMeshData().getVertexCount())) { normalLines.getMeshData().setIndices(null); lineInds = BufferUtils.createIndexBufferData(mesh.getMeshData().getVertexCount() * 2, normalLines .getMeshData().getVertexCount() - 1); normalLines.getMeshData().setIndices(lineInds); } else { lineInds.getBuffer().clear(); lineInds.getBuffer().limit(normalLines.getMeshData().getVertexCount());
@Override public void draw(final Renderer r) { StatCollector.pause(); super.draw(r); StatCollector.resume(); } };
lineFrustum = new Line("Lines", verts, null, colors, null); lineFrustum.getMeshData().setIndexModes( new IndexMode[] { IndexMode.LineLoop, IndexMode.LineLoop, IndexMode.Lines, IndexMode.Lines }); lineFrustum.getMeshData().setIndexLengths(new int[] { 4, 4, 8, 8 }); lineFrustum.setLineWidth(2); lineFrustum.getSceneHints().setLightCombineMode(LightCombineMode.Off); lineBlendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha); lineBlendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha); lineFrustum.setRenderState(lineBlendState); lineFrustum.setRenderState(zstate); lineFrustum.updateGeometricState(0.0); lineFrustum.getSceneHints().setRenderBucketType(RenderBucketType.Skip); lineFrustum.setDefaultColor(color); lineFrustum.setStipplePattern(pattern); final FloatBuffer colors = lineFrustum.getMeshData().getColorBuffer(); for (int i = 0; i < 16; i++) { BufferUtils.setInBuffer(color, colors, i); final FloatBuffer verts = lineFrustum.getMeshData().getVertexBuffer(); BufferUtils.setInBuffer(testCam._corners[0], verts, 0); BufferUtils.setInBuffer(testCam._corners[1], verts, 1); lineFrustum.draw(r);
final FloatBuffer colors = BufferUtils.createColorBuffer(24); lineFrustum = new Line("Lines", verts, null, colors, null); lineFrustum.getMeshData().setIndexModes( new IndexMode[] { IndexMode.LineLoop, IndexMode.LineLoop, IndexMode.Lines, IndexMode.Lines }); lineFrustum.getMeshData().setIndexLengths(new int[] { 4, 4, 8, 8 }); lineFrustum.getSceneHints().setLightCombineMode(LightCombineMode.Off); lineBlendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha); lineBlendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha); lineFrustum.setRenderState(lineBlendState); lineFrustum.setRenderState(zstate); lineFrustum.updateGeometricState(0.0); lineFrustum.getSceneHints().setRenderBucketType(RenderBucketType.Skip); lineFrustum.setDefaultColor(color); final FloatBuffer colors = lineFrustum.getMeshData().getColorBuffer(); for (int i = 0; i < 16; i++) { BufferUtils.setInBuffer(color, colors, i); final FloatBuffer verts = lineFrustum.getMeshData().getVertexBuffer(); BufferUtils.setInBuffer(testCam._corners[0], verts, 0); BufferUtils.setInBuffer(testCam._corners[1], verts, 1); lineFrustum.draw(r);
final Line line = new Line(name, vertices, null, null, hasUVs ? uvs : null); final IndexBufferData<? extends Buffer> indexBuffer = BufferUtils .createIndexBufferData(_lineManager.getIndices().size(), vertices.length - 1); indexBuffer.put(index); line.getMeshData().setIndices(indexBuffer); if (_lineManager.getLengths().size() > 1) { final int[] lengths = new int[_lineManager.getLengths().size()]; lengths[i++] = l; line.getMeshData().setIndexLengths(lengths); mapToGroups(line); line.updateModelBound();
final FloatBuffer verts = mesh.getMeshData().getVertexBuffer(); if (norms != null && verts != null && norms.limit() == verts.limit()) { FloatBuffer lineVerts = normalLines.getMeshData().getVertexBuffer(); if (lineVerts.capacity() < (3 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setVertexBuffer(null); lineVerts = BufferUtils.createVector3Buffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setVertexBuffer(lineVerts); } else { lineVerts.clear(); lineVerts.limit(3 * 2 * mesh.getMeshData().getVertexCount()); normalLines.getMeshData().setVertexBuffer(lineVerts); FloatBuffer lineColors = normalLines.getMeshData().getColorBuffer(); if (lineColors.capacity() < (4 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setColorBuffer(null); lineColors = BufferUtils.createColorBuffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setColorBuffer(lineColors); } else { lineColors.clear(); IndexBufferData<?> lineInds = normalLines.getMeshData().getIndices(); if (lineInds == null || lineInds.getBufferCapacity() < (normalLines.getMeshData().getVertexCount())) { normalLines.getMeshData().setIndices(null); lineInds = BufferUtils.createIndexBufferData(mesh.getMeshData().getVertexCount() * 2, normalLines .getMeshData().getVertexCount() - 1); normalLines.getMeshData().setIndices(lineInds); } else { lineInds.getBuffer().clear(); lineInds.getBuffer().limit(normalLines.getMeshData().getVertexCount());
/** * Creates a new <code>Line</code> from the given control point indices. It will have the name <code>curve</code>, * no normals, colour or texture, these can be added to the returned line if needed. * * @param start * The index of the control point to start from, must be greater than or equal to one and less than * <code>end</code>. * @param end * The index of the control point to end with, must be less than {@link #getControlPointCount() * controlPointCount} minus one and greater than <code>start</code>. * @param steps * The number of iterations to perform between control points, the higher this number the smoother the * returned line will be, but it will also contain more vertices, must be greater than one. * @return A <code>Line</code> representing this curve, will not be <code>null</code>. */ public Line toRenderableLine(final int start, final int end, final int steps) { final Vector3[] vertex = toVector3(start, end, steps); final Vector3[] normal = null; final ColorRGBA[] color = null; final Vector2[] texture = null; final Line line = new Line("curve", vertex, normal, color, texture); line.getMeshData().setIndexMode(IndexMode.LineStrip); return line; }
if (!_graphRoot.equals(_horizontals.getParent())) { _graphRoot.attachChild(_horizontals); if (!_graphRoot.equals(_verticals.getParent())) { _graphRoot.attachChild(_verticals); entry.line.removeFromParent(); entry.point.removeFromParent(); i.remove(); final double scaleHeight = texHeight / (entry.max * 1.02); entry.point.setScale(new Vector3(scaleWidth, scaleHeight, 1)); entry.line.getMeshData().setVertexBuffer(fb); entry.line.setScale(new Vector3(scaleWidth, scaleHeight, 1)); fb.rewind(); if (!_graphRoot.equals(entry.line.getParent())) { _graphRoot.attachChild(entry.line);
_particleMesh = line; attachChild(line); line.getMeshData().setVertexBuffer(_geometryCoordinates); line.getMeshData().setColorBuffer(_appearanceColors); line.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(numParticles * 2), 0); getSceneHints().setRenderBucketType(RenderBucketType.Opaque); getSceneHints().setLightCombineMode(LightCombineMode.Off); for (int a = verts - 1; a >= 0; a--) { final int ind = (k * verts) + a; BufferUtils.setInBuffer(sharedTextureData[a], line.getMeshData().getTextureCoords(0).getBuffer(), ind); BufferUtils.setInBuffer(_particles[k].getCurrentColor(), _appearanceColors, (ind));
final FloatBuffer verts = mesh.getMeshData().getVertexBuffer(); if (norms != null && verts != null && norms.limit() == verts.limit()) { FloatBuffer lineVerts = normalLines.getMeshData().getVertexBuffer(); if (lineVerts.capacity() < (3 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setVertexBuffer(null); lineVerts = BufferUtils.createVector3Buffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setVertexBuffer(lineVerts); } else { lineVerts.clear(); lineVerts.limit(3 * 2 * mesh.getMeshData().getVertexCount()); normalLines.getMeshData().setVertexBuffer(lineVerts); FloatBuffer lineColors = normalLines.getMeshData().getColorBuffer(); if (lineColors.capacity() < (4 * (2 * mesh.getMeshData().getVertexCount()))) { normalLines.getMeshData().setColorBuffer(null); lineColors = BufferUtils.createColorBuffer(mesh.getMeshData().getVertexCount() * 2); normalLines.getMeshData().setColorBuffer(lineColors); } else { lineColors.clear(); IndexBufferData<?> lineInds = normalLines.getMeshData().getIndices(); if (lineInds == null || lineInds.getBufferCapacity() < (normalLines.getMeshData().getVertexCount())) { normalLines.getMeshData().setIndices(null); lineInds = BufferUtils.createIndexBufferData(mesh.getMeshData().getVertexCount() * 2, normalLines.getMeshData().getVertexCount() - 1); normalLines.getMeshData().setIndices(lineInds); } else { lineInds.getBuffer().clear(); lineInds.getBuffer().limit(normalLines.getMeshData().getVertexCount());