protected Vector3f worldCoordinateToLocal(Vector3f loc) { Vector3f translated = new Vector3f(); translated.x = loc.x/getWorldScale().x - getWorldTranslation().x; translated.y = loc.y/getWorldScale().y - getWorldTranslation().y; translated.z = loc.z/getWorldScale().z - getWorldTranslation().z; return translated; }
/** * Get the triangle of this geometry at the specified local coordinate. * @param x local to the terrain patch * @param z local to the terrain patch * @return the triangle in world coordinates, or null if the point does intersect this patch on the XZ axis */ public Triangle getTriangle(float x, float z) { return geomap.getTriangleAtPoint(x, z, getWorldScale() , getWorldTranslation()); }
/** * Get the triangles at the specified grid point. Probably only 2 triangles * @param x local to the terrain patch * @param z local to the terrain patch * @return the triangles in world coordinates, or null if the point does intersect this patch on the XZ axis */ public Triangle[] getGridTriangles(float x, float z) { return geomap.getGridTrianglesAtPoint(x, z, getWorldScale() , getWorldTranslation()); }
/** * Caches the transforms (except rotation) so the LOD calculator, * which runs on a separate thread, can access them safely. */ protected void cacheTerrainTransforms() { this.worldScaleCached = getWorldScale().clone(); this.worldTranslationCached = getWorldTranslation().clone(); }
/** * recalculate all of the normal vectors in this terrain patch */ protected void updateNormals() { FloatBuffer newNormalBuffer = geomap.writeNormalArray(null, getWorldScale()); getMesh().getBuffer(Type.Normal).updateData(newNormalBuffer); FloatBuffer newTangentBuffer = null; FloatBuffer newBinormalBuffer = null; FloatBuffer[] tb = geomap.writeTangentArray(newNormalBuffer, newTangentBuffer, newBinormalBuffer, (FloatBuffer)getMesh().getBuffer(Type.TexCoord).getData(), getWorldScale()); newTangentBuffer = tb[0]; newBinormalBuffer = tb[1]; getMesh().getBuffer(Type.Tangent).updateData(newTangentBuffer); getMesh().getBuffer(Type.Binormal).updateData(newBinormalBuffer); }
tracer.getGridSpacing().set(patch.getWorldScale()); tracer.setGridOrigin(patch.getWorldTranslation());
Vector3f binormal) Vector3f scale = getWorldScale();
protected Vector3f worldCoordinateToLocal(Vector3f loc) { Vector3f translated = new Vector3f(); translated.x = loc.x/getWorldScale().x - getWorldTranslation().x; translated.y = loc.y/getWorldScale().y - getWorldTranslation().y; translated.z = loc.z/getWorldScale().z - getWorldTranslation().z; return translated; }
/** * Get the triangle of this geometry at the specified local coordinate. * @param x local to the terrain patch * @param z local to the terrain patch * @return the triangle in world coordinates, or null if the point does intersect this patch on the XZ axis */ public Triangle getTriangle(float x, float z) { return geomap.getTriangleAtPoint(x, z, getWorldScale() , getWorldTranslation()); }
/** * Get the triangles at the specified grid point. Probably only 2 triangles * @param x local to the terrain patch * @param z local to the terrain patch * @return the triangles in world coordinates, or null if the point does intersect this patch on the XZ axis */ public Triangle[] getGridTriangles(float x, float z) { return geomap.getGridTrianglesAtPoint(x, z, getWorldScale() , getWorldTranslation()); }
/** * Caches the transforms (except rotation) so the LOD calculator, * which runs on a separate thread, can access them safely. */ protected void cacheTerrainTransforms() { this.worldScaleCached = getWorldScale().clone(); this.worldTranslationCached = getWorldTranslation().clone(); }
/** * recalculate all of the normal vectors in this terrain patch */ protected void updateNormals() { FloatBuffer newNormalBuffer = geomap.writeNormalArray(null, getWorldScale()); getMesh().getBuffer(Type.Normal).updateData(newNormalBuffer); FloatBuffer newTangentBuffer = null; FloatBuffer newBinormalBuffer = null; FloatBuffer[] tb = geomap.writeTangentArray(newNormalBuffer, newTangentBuffer, newBinormalBuffer, (FloatBuffer)getMesh().getBuffer(Type.TexCoord).getData(), getWorldScale()); newTangentBuffer = tb[0]; newBinormalBuffer = tb[1]; getMesh().getBuffer(Type.Tangent).updateData(newTangentBuffer); getMesh().getBuffer(Type.Binormal).updateData(newBinormalBuffer); }
tracer.getGridSpacing().set(patch.getWorldScale()); tracer.setGridOrigin(patch.getWorldTranslation());
Vector3f binormal) Vector3f scale = getWorldScale();