Skip to content
Alexander Orzechowski edited this page Oct 21, 2015 · 1 revision

Geometry is similar to Tessellator.Object but is a higher level where it defines its own standard attributes. Geometry is commonly better to use then just a Tessellator.Object because it gives you more options for creating geometry and a bunch of helper methods that set defaults for some attributes.

The geometry objects was primarily designed to be used with Tessellator.Model so it would be best fit to do so as the predefined attributes are based of the ones that the default model shaders have.

###Usage

var tessellator = ...;

var geom = new Tessellator.Geometry(Constant.POLYGON);

geom.setColor("red");
goem.setVertex(0, 0, 0);
goem.setVertex(0, 0, 1);
goem.setVertex(0, 1, 1);
goem.setVertex(0, 1, 0);
geom.createObject(tessellator);

//you can ether render the create object.
geom.getObject().render(...);
//or you can add it to a model and that will configure everything for you.
model.add(geom);

###Constructor

  • Tessellator.Geometry(Constant type)
    Constructs a new Tessellaor.Geometry object that will create geometry by the specified type. For example: Tessellator.QUAD will configure this geometry object to create what are essentially rectangles with 4 vertices per object. Tessellator.TRIANGLE will draw a bunch of triangles with 3 vertices per object.
  • ARGUMENT type: The way this geometry should interpret geometry as.

###Properties

This will create a low level counterpart of this geometry. A object will need to be created from this geometry in order for things to be rendered.


  • .getObject()
  • RETURN: The Tessellator.Object that is associated with this Tessellator.Geometry. If no object is avaliable, undefined is returned.
  • SEE: .createObject()

  • .dispose()
    All the resources associated with this object will be deleted from memory including the Tessellator.Object liked to this geometry. The .diposed function will be set and is this object is already disposed, there will be no effect.
  • NOTE: The .disposable property of the internal Tessellator.Object is ignored.

  • .addPositions(Array array)
    This will add vertex positions to the position attribute. It will apply any matrix transformations difined by this Tessellator.Geometry.
  • ARGUMENT array: The array of positions to be concatinated. If not a multiple of 3, the last remaining positions will be ignored.

  • .addPositions(...)
    This will add vertex positions to the position attribute. It will apply any matrix transformations difined by this Tessellator.Geometry.
  • ARGUMENTS: All arguments passed will be acted as an array and be concatenated to the position attribute. If not a multiple of 3, the last remaining positions will be ignored.

  • .setColor(Tessellator.vec4 vec)
    When using the .setVertex() function, colors will automatically be concatenated to the color attribute.
  • ARGUMENT vec: A (r, g, b, a) vector of the set color.
  • SEE: .setVertex()

  • .setVertex(...)
    Similar to .setPositions() it will call it with whatever arguments were passed. This will take into account the set color defined by .setColor() and will automatically fill the color attribute.
  • SEE: .setPositions()
  • SEE: .setColor()

  • .generateTextureCoordinates(x, y)
    Depending on the positions and the indices, the color attribute will be automatically filled (if using a model and it has a texture bound). The coodinates will only be applied to mode Tessellator.TRIANGLES and it will follow this pattern: The first 3 indices will be set to: (0, 0), (x, 0), (x, y). The next 3 will be: (0, 0), (x, y), (0, y). It will repeat this pattern until the entire array is filled and finished.
Clone this wiki locally