Skip to content

Instantly share code, notes, and snippets.

@jonathanhirz
Created July 3, 2015 23:39
Show Gist options
  • Save jonathanhirz/137808bee6d2012e3016 to your computer and use it in GitHub Desktop.
Save jonathanhirz/137808bee6d2012e3016 to your computer and use it in GitHub Desktop.
import luxe.options.GeometryOptions;
import luxe.Vector;
import phoenix.Batcher;
import phoenix.geometry.Geometry;
import phoenix.geometry.Vertex;
class TriangleGeometry extends Geometry {
public function new(?options: TriangleOptions) {
super(options);
if (options == null) {
return;
}
primitive_type = PrimitiveType.triangles;
set(options);
}
function set( options:TriangleOptions ) {
var _p0 : Vector = options.p0;
var _p1 : Vector = options.p1;
var _p2 : Vector = options.p2;
var vert0 : Vertex = new Vertex(_p0);
vert0.uv.uv0.set_uv(0.5,1.0);
var vert1 : Vertex = new Vertex(_p1);
vert1.uv.uv0.set_uv(0,0);
var vert2 : Vertex = new Vertex(_p2);
vert2.uv.uv0.set_uv(1.0,0);
add(vert0);
add(vert1);
add(vert2);
}
} //TriangleGeometry
// Set your custom options
typedef TriangleOptions = {
> GeometryOptions,
@:optional var p0 : Vector;
@:optional var p1 : Vector;
@:optional var p2 : Vector;
} //TriangleOptions
// Major credit to Christian (hammeron-art) for getting this custom geometry started for me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment