/** * Initialize the meshdata object with data. * * @param vertices * @param normals * @param colors * @param coords */ private void setupData(final FloatBuffer vertices, final FloatBuffer normals, final FloatBuffer colors, final FloatBufferData coords) { _meshData.setVertexBuffer(vertices); _meshData.setNormalBuffer(normals); _meshData.setColorBuffer(colors); _meshData.setTextureCoords(coords, 0); }
/** * Initialize the meshdata object with data. * * @param vertices * @param normals * @param colors * @param coords */ private void setupData(final FloatBuffer vertices, final FloatBuffer normals, final FloatBuffer colors, final FloatBufferData coords) { _meshData.setVertexBuffer(vertices); _meshData.setNormalBuffer(normals); _meshData.setColorBuffer(colors); _meshData.setTextureCoords(coords, 0); }
/** * Initialize the meshdata object with data. * * @param vertices * @param normals * @param colors * @param coords */ private void setupData(final FloatBuffer vertices, final FloatBuffer normals, final FloatBuffer colors, final FloatBufferData coords) { _meshData.setVertexBuffer(vertices); _meshData.setNormalBuffer(normals); _meshData.setColorBuffer(colors); _meshData.setTextureCoords(coords, 0); _meshData.setIndices(null); }
/** * Initialize the meshdata object with data. * * @param vertices * @param normals * @param colors * @param coords */ private void setupData(final FloatBuffer vertices, final FloatBuffer normals, final FloatBuffer colors, final FloatBufferData coords) { _meshData.setVertexBuffer(vertices); _meshData.setNormalBuffer(normals); _meshData.setColorBuffer(colors); _meshData.setTextureCoords(coords, 0); _meshData.setIndices(null); }
/** * * <code>setNormalData</code> sets the normals of each of the box's planes. * * */ private void setNormalData() { final Vector3[] vert = computeVertices(); // returns 8 _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), 8)); final Vector3 norm = new Vector3(); _meshData.getNormalBuffer().clear(); for (int i = 0; i < 8; i++) { norm.set(vert[i]).normalizeLocal(); _meshData.getNormalBuffer().put(norm.getXf()).put(norm.getYf()).put(norm.getZf()); } }
/** * * <code>setNormalData</code> sets the normals of each of the box's planes. * * */ private void setNormalData() { final Vector3[] vert = computeVertices(); // returns 8 _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), 8)); final Vector3 norm = new Vector3(); _meshData.getNormalBuffer().clear(); for (int i = 0; i < 8; i++) { norm.set(vert[i]).normalizeLocal(); _meshData.getNormalBuffer().put(norm.getXf()).put(norm.getYf()).put(norm.getZf()); } }
/** * Creates an Icosahedron (think of 20-sided dice) with center at the origin. The length of the sides will be as * specified in sideLength. * * @param name * The name of the Icosahedron. * @param sideLength * The length of each side of the Icosahedron. */ public Icosahedron(final String name, final double sideLength) { super(name); _sideLength = sideLength; // allocate vertices _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(NUM_POINTS), 0); setVertexData(); setNormalData(); setTextureData(); setIndexData(); }
/** * Creates an Icosahedron (think of 20-sided dice) with center at the origin. The length of the sides will be as * specified in sideLength. * * @param name * The name of the Icosahedron. * @param sideLength * The length of each side of the Icosahedron. */ public Icosahedron(final String name, final double sideLength) { super(name); _sideLength = sideLength; // allocate vertices _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(NUM_POINTS), 0); setVertexData(); setNormalData(); setTextureData(); setIndexData(); }
public ProjectedGrid(final String name, final Camera camera, final int sizeX, final int sizeY, final float textureScale, final HeightGenerator heightGenerator, final Timer timer) { super(name); this.sizeX = sizeX; this.sizeY = sizeY; this.textureScale = textureScale; this.heightGenerator = heightGenerator; this.camera = camera; this.timer = timer; buildVertices(sizeX * sizeY); texs = BufferUtils.createVector2Buffer(_meshData.getVertexCount()); _meshData.setTextureBuffer(texs, 0); normBuf = BufferUtils.createVector3Buffer(_meshData.getVertexCount()); _meshData.setNormalBuffer(normBuf); vertBufArray = new float[_meshData.getVertexCount() * 3]; normBufArray = new float[_meshData.getVertexCount() * 3]; texBufArray = new float[_meshData.getVertexCount() * 2]; for (int i = 0; i < 24; i++) { intersections[i] = new Vector3(); } }
public ProjectedGrid(final String name, final Camera camera, final int sizeX, final int sizeY, final float textureScale, final HeightGenerator heightGenerator, final Timer timer) { super(name); this.sizeX = sizeX; this.sizeY = sizeY; this.textureScale = textureScale; this.heightGenerator = heightGenerator; this.camera = camera; this.timer = timer; buildVertices(sizeX * sizeY); texs = BufferUtils.createVector2Buffer(_meshData.getVertexCount()); _meshData.setTextureBuffer(texs, 0); normBuf = BufferUtils.createVector3Buffer(_meshData.getVertexCount()); _meshData.setNormalBuffer(normBuf); vertBufArray = new float[_meshData.getVertexCount() * 3]; normBufArray = new float[_meshData.getVertexCount() * 3]; texBufArray = new float[_meshData.getVertexCount() * 2]; for (int i = 0; i < 24; i++) { intersections[i] = new Vector3(); } }
private void setData() { getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(getMeshData().getVertexBuffer(), trailVertices)); getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(getMeshData().getNormalBuffer(), trailVertices)); setDefaultColor(new ColorRGBA(ColorRGBA.WHITE)); setTextureData(); setIndexData(); }
/** * Hexagon Constructor instantiates a new Hexagon. This element is center on 0,0,0 with all normals pointing up. The * user must move and rotate for positioning. * * @param name * the name of the scene element. This is required for identification and comparision purposes. * @param sideLength * The length of all the sides of the triangles */ public Hexagon(final String name, final float sideLength) { super(name); _sideLength = sideLength; // allocate vertices _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(NUM_POINTS), 0); _meshData.setIndices(BufferUtils.createIndexBufferData(3 * NUM_TRIS, NUM_POINTS - 1)); setVertexData(); setIndexData(); setTextureData(); setNormalData(); }
/** * Creates an octahedron with center at the origin. The lenght sides are given. * * @param name * The name of the octahedron. * @param sideLength * The length of each side of the octahedron. */ public Octahedron(final String name, final double sideLength) { super(name); _sideLength = sideLength; // allocate vertices _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(NUM_POINTS), 0); _meshData.setIndices(BufferUtils.createIndexBufferData(3 * NUM_TRIS, NUM_POINTS - 1)); setVertexData(); setNormalData(); setTextureData(); setIndexData(); }
private void allocateVertices() { final int verts = (2 * (_axisSamples + 1) * (_radialSamples + 1) + _radialSamples * 4); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(_meshData.getTextureBuffer(0), verts), 0); final int tris = (4 * _radialSamples * (1 + _axisSamples)); if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }
/** * Creates an octahedron with center at the origin. The lenght sides are given. * * @param name * The name of the octahedron. * @param sideLength * The length of each side of the octahedron. */ public Octahedron(final String name, final double sideLength) { super(name); _sideLength = sideLength; // allocate vertices _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(NUM_POINTS)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(NUM_POINTS), 0); _meshData.setIndices(BufferUtils.createIndexBufferData(3 * NUM_TRIS, NUM_POINTS - 1)); setVertexData(); setNormalData(); setTextureData(); setIndexData(); }
private void allocateVertices() { final int verts = (2 * (_axisSamples + 1) * (_radialSamples + 1) + _radialSamples * 4); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(_meshData.getTextureBuffer(0), verts), 0); final int tris = (4 * _radialSamples * (1 + _axisSamples)); if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }
private void allocateVertices() { // allocate vertices final int verts = _axisSamples * (_radialSamples + 1) + (_closed ? 2 : 0); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals if requested _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); final int count = ((_closed ? 2 : 0) + 2 * (_axisSamples - 1)) * _radialSamples; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * count) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * count, verts - 1)); } setGeometryData(); setIndexData(); }
private void allocateVertices() { // allocate vertices final int verts = _axisSamples * (_radialSamples + 1) + (_closed ? 2 : 0); _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals if requested _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); final int count = ((_closed ? 2 : 0) + 2 * (_axisSamples - 1)) * _radialSamples; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * count) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * count, verts - 1)); } setGeometryData(); setIndexData(); }
private void recreateBuffers() { // determine vert quantity - first the sphere caps final int sampleLines = (2 * sphereSamples - 1 + axisSamples); final int verts = (radialSamples + 1) * sampleLines + 2; _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); // determine tri quantity final int tris = 2 * radialSamples * sampleLines; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }
private void recreateBuffers() { // determine vert quantity - first the sphere caps final int sampleLines = (2 * sphereSamples - 1 + axisSamples); final int verts = (radialSamples + 1) * sampleLines + 2; _meshData.setVertexBuffer(BufferUtils.createVector3Buffer(_meshData.getVertexBuffer(), verts)); // allocate normals _meshData.setNormalBuffer(BufferUtils.createVector3Buffer(_meshData.getNormalBuffer(), verts)); // allocate texture coordinates _meshData.setTextureBuffer(BufferUtils.createVector2Buffer(verts), 0); // determine tri quantity final int tris = 2 * radialSamples * sampleLines; if (_meshData.getIndices() == null || _meshData.getIndices().getBufferLimit() != 3 * tris) { _meshData.setIndices(BufferUtils.createIndexBufferData(3 * tris, verts - 1)); } setGeometryData(); setIndexData(); }