/** * @param height * The height to set. */ public void setHeight(final double height) { this.height = height; recreateBuffers(); }
/** * Change the radius of this cylinder. * * @param radius * The radius to set. */ public void setRadius(final double radius) { this.radius = radius; setGeometryData(); }
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(); }
public void reconstruct(final Vector3 top, final Vector3 bottom, final double radius) { // our temp vars final Vector3 localTranslation = Vector3.fetchTempInstance(); final Vector3 capsuleUp = Vector3.fetchTempInstance(); // first make the capsule the right shape height = top.distance(bottom); this.radius = radius; setGeometryData(); // now orient it in space. localTranslation.set(_localTransform.getTranslation()); top.add(bottom, localTranslation).multiplyLocal(.5); // rotation that takes us from 0,1,0 to the unit vector described by top/center. top.subtract(localTranslation, capsuleUp).normalizeLocal(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromStartEndLocal(Vector3.UNIT_Y, capsuleUp); _localTransform.setRotation(rotation); Vector3.releaseTempInstance(localTranslation); Vector3.releaseTempInstance(capsuleUp); Matrix3.releaseTempInstance(rotation); updateWorldTransform(false); }
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(); }
public void reconstruct(final Vector3 top, final Vector3 bottom, final double radius) { // our temp vars final Vector3 localTranslation = Vector3.fetchTempInstance(); final Vector3 capsuleUp = Vector3.fetchTempInstance(); // first make the capsule the right shape height = top.distance(bottom); this.radius = radius; setGeometryData(); // now orient it in space. localTranslation.set(_localTransform.getTranslation()); top.add(bottom, localTranslation).multiplyLocal(.5); // rotation that takes us from 0,1,0 to the unit vector described by top/center. top.subtract(localTranslation, capsuleUp).normalizeLocal(); final Matrix3 rotation = Matrix3.fetchTempInstance(); rotation.fromStartEndLocal(Vector3.UNIT_Y, capsuleUp); _localTransform.setRotation(rotation); Vector3.releaseTempInstance(localTranslation); Vector3.releaseTempInstance(capsuleUp); Matrix3.releaseTempInstance(rotation); updateWorldTransform(false); }
/** * @param height * The height to set. */ public void setHeight(final double height) { this.height = height; recreateBuffers(); }
/** * Change the radius of this cylinder. * * @param radius * The radius to set. */ public void setRadius(final double radius) { this.radius = radius; setGeometryData(); }
/** * Creates a new Cylinder. By default its center is the origin. Usually, a higher sample number creates a better * looking cylinder, but at the cost of more vertex information. <br> * If the cylinder is closed the texture is split into axisSamples parts: top most and bottom most part is used for * top and bottom of the cylinder, rest of the texture for the cylinder wall. The middle of the top is mapped to * texture coordinates (0.5, 1), bottom to (0.5, 0). Thus you need a suited distorted texture. * * @param name * The name of this Cylinder. * @param axisSamples * Number of triangle samples along the axis. * @param radialSamples * Number of triangle samples along the radial. * @param radius * The radius of the cylinder. * @param height * The cylinder's height. */ public Capsule(final String name, final int axisSamples, final int radialSamples, final int sphereSamples, final double radius, final double height) { super(name); this.axisSamples = axisSamples; this.sphereSamples = sphereSamples; this.radialSamples = radialSamples; this.radius = radius; this.height = height; recreateBuffers(); }
/** * Creates a new Cylinder. By default its center is the origin. Usually, a higher sample number creates a better * looking cylinder, but at the cost of more vertex information. <br> * If the cylinder is closed the texture is split into axisSamples parts: top most and bottom most part is used for * top and bottom of the cylinder, rest of the texture for the cylinder wall. The middle of the top is mapped to * texture coordinates (0.5, 1), bottom to (0.5, 0). Thus you need a suited distorted texture. * * @param name * The name of this Cylinder. * @param axisSamples * Number of triangle samples along the axis. * @param radialSamples * Number of triangle samples along the radial. * @param radius * The radius of the cylinder. * @param height * The cylinder's height. */ public Capsule(final String name, final int axisSamples, final int radialSamples, final int sphereSamples, final double radius, final double height) { super(name); this.axisSamples = axisSamples; this.sphereSamples = sphereSamples; this.radialSamples = radialSamples; this.radius = radius; this.height = height; recreateBuffers(); }