/** * Upload geometry data, including a texture image * @param vertices Vertex attribute data: x,y,z, nx,ny,nz, u,v (position, normal, texture) * @param indices Face data * @param textureBitmap An image to be used as the texture */ public void setGeometry(Vector <double> vertices, Vector <uint> indices, BitmapData textureBitmap) { // Upload vertex data if (vertexBuffer != null) { vertexBuffer.dispose(); } vertexBuffer = context.createVertexBuffer((int)(vertices.length / DATA32_PER_VERTEX), (int)DATA32_PER_VERTEX); vertexBuffer.uploadFromVector(vertices, 0, (int)(vertices.length / DATA32_PER_VERTEX)); // Upload polygon data (vertex indices) if (indexBuffer != null) { indexBuffer.dispose(); } indexBuffer = context.createIndexBuffer((int)indices.length); indexBuffer.uploadFromVector(indices, 0, (int)indices.length); // Upload texture if (texture3D != null) { texture3D.dispose(); } texture3D = context.createTexture(textureBitmap.width, textureBitmap.height, Context3DTextureFormat.BGRA, false); texture3D.uploadFromBitmapData(textureBitmap); }
public void setGeometry(Vector <double> vertices, Vector <uint> indices) { // Upload vertex data if (vertexBuffer != null) { vertexBuffer.dispose(); } vertexBuffer = context.createVertexBuffer((int)vertices.length / (int)DATA32_PER_VERTEX, (int)DATA32_PER_VERTEX); vertexBuffer.uploadFromVector(vertices, 0, (int)vertices.length / (int)DATA32_PER_VERTEX); // Upload polygon data (vertex indices) if (indexBuffer != null) { indexBuffer.dispose(); } indexBuffer = context.createIndexBuffer((int)indices.length); indexBuffer.uploadFromVector(indices, 0, (int)indices.length); }
/** * Upload geometry data, including a texture image * @param vertices Vertex attribute data: x,y,z, nx,ny,nz, u,v (position, normal, texture) * @param indices Face data * @param textureBitmap An image to be used as the texture */ public void setGeometry(Vector<double> vertices, Vector<uint> indices, BitmapData textureBitmap) { // Upload vertex data if (vertexBuffer != null) vertexBuffer.dispose(); vertexBuffer = context.createVertexBuffer((int)(vertices.length / DATA32_PER_VERTEX), (int)DATA32_PER_VERTEX); vertexBuffer.uploadFromVector(vertices, 0, (int)(vertices.length / DATA32_PER_VERTEX)); // Upload polygon data (vertex indices) if (indexBuffer != null) indexBuffer.dispose(); indexBuffer = context.createIndexBuffer((int)indices.length); indexBuffer.uploadFromVector(indices, 0, (int)indices.length); // Upload texture if (texture3D != null) texture3D.dispose(); texture3D = context.createTexture(textureBitmap.width, textureBitmap.height, Context3DTextureFormat.BGRA, false); texture3D.uploadFromBitmapData(textureBitmap); }