How to make a 3d coin


#1

I have this code

	public static function createCoin(s3d, color:Int, x:Float, y:Float, z:Float, size:Float, d:Float) {
		var cylinder = new Cylinder(16, size, d, true);
		cylinder.translate(-size / 2, -size / 2, 0);

		// create a material with this texture
		var mat = Material.create();
		mat.mainPass.culling = None;
		mat.color.setColor(color);
		mat.castShadows = true;
		mat.receiveShadows = true;

		// add texture coordinates, no idea if needed
		// cylinder.addUVs();

		// our first cube mesh on the 3D scene with our created material
		var obj = new Mesh(cylinder, mat, s3d);
		obj.material.mainPass.enableLights = true;
		obj.x = x;
		obj.y = y;
		obj.z = z;
		obj.rotate(0, Math.PI * 0.5, 0);
		return obj;
	}

Which creates coins that look like this:

image

Issue; the coin is now more like a ring, I want to make it solid.
How do I make my coin solid?

I’m using heaps 1.6.1


#2

Looking at the implementation for h3d.prim.Cylinder its seems that the class only creates geometry for open cylinders. It shouldn’t be too difficult to add a ‘closed’ flag and use it to add the requisite geometry to close the cylinder at both ends.
You also have the option of loading up an existing model created in a 3d modeling tool like Blender.


#3

Thanks, I raised an issue for that on GitHub.