Package javax.vecmath

Examples of javax.vecmath.Vector2f


    private Texture effectsTexture;
    private Material defaultTextured;

    public BlockSelectionRenderer(Texture effectsTexture) {
        this.effectsTexture = effectsTexture;
        Vector2f texWidth = new Vector2f(1.f / effectsTexture.getWidth(), 1.f / effectsTexture.getHeight());
        initialize(texWidth);
    }
View Full Code Here


        Vector2f texWidth = new Vector2f(1.f / effectsTexture.getWidth(), 1.f / effectsTexture.getHeight());
        initialize(texWidth);
    }

    private void initialize(Vector2f effectsTextureWidth) {
        Vector2f texPos = new Vector2f(0.0f, 0.0f);
        Tessellator tessellator = new Tessellator();
        TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1, 1, 1, 1f), texPos, effectsTextureWidth, 1.001f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
        overlayMesh = tessellator.generateMesh();
        tessellator = new Tessellator();
        TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1, 1, 1, .2f), texPos, effectsTextureWidth, 1.001f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
View Full Code Here

public final class Line implements ch.blackspirit.graphics.Line {
  private Vector2f[] points = new Vector2f[2];
  private Color4f[] colors = new Color4f[2];
 
  public Line() {
    points[0] = new Vector2f();
    points[1] = new Vector2f();
  }
View Full Code Here

  private Vector2f[] points = new Vector2f[3];
  private Vector2f[] textureCoordinates = new Vector2f[3];
  private Color4f[] colors = new Color4f[3];
 
  public Triangle() {
    points[0] = new Vector2f();
    points[1] = new Vector2f();
    points[2] = new Vector2f();
  }
View Full Code Here

  }
  public void drawLines(Line[] lines, boolean useColor) {
    if (lines == null) throw new IllegalArgumentException("lines must not be null");
      startPrimitive(Primitive.LINE, null);
    GL2 gl = drawable.getGL().getGL2();
    Vector2f p;
    if(useColor) {
      Color4f c;
      for(int i = 0; i < lines.length; i++) {
        Line l = lines[i];
        if(l == null) continue;
View Full Code Here

  }
  public void drawTriangles(Triangle[] triangles, boolean useColors) {
    if (triangles == null) throw new IllegalArgumentException("triangles must not be null");
      startPrimitive(Primitive.LINE, null);
    GL2 gl = drawable.getGL().getGL2();
    Vector2f p;
    if(useColors) {
      Color4f c;
      for(int i = 0; i < triangles.length; i++) {
        Triangle t = triangles[i];
        if(t == null) continue;
View Full Code Here

  public void fillTriangles(Triangle[] triangles, boolean useColors) {
    if (triangles == null) throw new IllegalArgumentException("triangles must not be null");
    GL2 gl = drawable.getGL().getGL2();

    Vector2f p;
   
    startPrimitive(Primitive.TRIANGLE, null);

    if(useColors) {
      Color4f c = null;
View Full Code Here

  public void fillTriangles(Triangle[] triangles, boolean useColors, ch.blackspirit.graphics.Image image) {
    if (triangles == null) throw new IllegalArgumentException("triangles must not be null");
    if (image == null) throw new IllegalArgumentException("image must not be null");
    GL2 gl = drawable.getGL().getGL2();

    Vector2f p;
    Image joglImage = null;

    joglImage = (Image)image;
    startPrimitive(Primitive.TEXTURED_TRIANGLE, joglImage);

    TextureCoords coords = joglImage.texture.getImageTexCoords();
   
    if(useColors) {
      Color4f c;
        for(int i = 0; i < triangles.length; i++) {
        Triangle t = triangles[i];
        if(t == null) continue;

        Vector2f tc1 = t.getTextureCoordinate(0);
        if (tc1 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc2 = t.getTextureCoordinate(1);
        if (tc2 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc3 = t.getTextureCoordinate(2);
        if (tc3 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
   
        p = t.getPoint(0);
        c = t.getColor(0);
        if(c == null) c = color;
        gl.glColor4f(c.x, c.y, c.z, c.w);
        float texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc1.x;
        float texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc1.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
       
            p = t.getPoint(1);
        c = t.getColor(1);
        if(c == null) c = color;
        gl.glColor4f(c.x, c.y, c.z, c.w);
        texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc2.x;
        texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc2.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
       
            p = t.getPoint(2);
        c = t.getColor(2);
        if(c == null) c = color;
        gl.glColor4f(c.x, c.y, c.z, c.w);
        texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc3.x;
        texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc3.y;
        gl.glTexCoord2f(texX, texY);
            gl.glVertex2f(p.x, p.y);
   
        }
    } else {
        for(int i = 0; i < triangles.length; i++) {
        Triangle t = triangles[i];
        if(t == null) continue;
 
        Vector2f tc1 = t.getTextureCoordinate(0);
        if (tc1 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc2 = t.getTextureCoordinate(1);
        if (tc2 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");
        Vector2f tc3 = t.getTextureCoordinate(2);
        if (tc3 == null) throw new IllegalArgumentException("Texture coordinate for triangle must not be null");

        p = t.getPoint(0);
        float texX = coords.left() + (coords.right() - coords.left()) / joglImage.texture.getImageWidth() * tc1.x;
        float texY = coords.top() + (coords.bottom() - coords.top()) / joglImage.texture.getImageHeight() * tc1.y;
 
View Full Code Here

      color.z += source.color.z * weight;
      color.w += source.color.w * weight;
    }
    for(int i = 0; i < lineSources.size(); i++) {
      LineSource source = lineSources.get(i);
      float dist = Geometry.pointSegmentDistance(new Vector2f(x,y), new Vector2f(source.x1, source.y1), new Vector2f(source.x2, source.y2));

      float weight = 1f - (1 / source.dist * dist);
      if(weight < 0) weight = 0;

      totalWeight+=weight;
View Full Code Here

    Line[] lines = new Line[totalLines];

    // Populate with outline lines
    int currentLine = 0;
    for(int i = 0; i < outline.size() - 1; i++) {
      lines[currentLine] = new ch.blackspirit.graphics.shape.Line(new Vector2f(outline.get(i)), new Vector2f(outline.get(i+1)));
      currentLine++;
    }
    lines[currentLine] =
      new ch.blackspirit.graphics.shape.Line(new Vector2f(outline.get(outline.size() - 1)), new Vector2f(outline.get(0)));
    currentLine++;
   
    // Populate with cut-out lines
    if(cutouts != null) {
      for(int l = 0; l < cutouts.size(); l++) {
        List<Vector2f> cutout = cutouts.get(l);
 
        for(int i = 0; i < cutout.size() - 1; i++) {
          lines[currentLine] = new ch.blackspirit.graphics.shape.Line(new Vector2f(cutout.get(i)), new Vector2f(cutout.get(i+1)));
          currentLine++;
        }
        lines[currentLine] =
          new ch.blackspirit.graphics.shape.Line(new Vector2f(cutout.get(cutout.size() - 1)), new Vector2f(cutout.get(0)));
        currentLine++;
      }
    }
   
    return new ch.blackspirit.graphics.shape.SimpleShape(triangles, lines);
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector2f

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.