Package ch.blackspirit.graphics.shape

Examples of ch.blackspirit.graphics.shape.Triangle


    });
    context.draw();
  }
  @Test (expected=IllegalArgumentException.class)
  public void fillTexturedTriangleWithTexCoordNull() throws IOException {
    final Triangle triangle = getTriangle(false, true);
    final ch.blackspirit.graphics.Image image = imageFactory.createImage(this.getClass().getResource("/player1.png"), true);
    context.setGraphicsListener(new GraphicsListener() {
      public void draw(View view, Graphics graphics) {
        graphics.clear();
        graphics.fillTriangle(triangle, false, image);
View Full Code Here


    });
    context.draw();
  }
  @Test (expected=IllegalArgumentException.class)
  public void fillTexturedTriangleWithColorAndTexCoordNull() throws IOException {
    final Triangle triangle = getTriangle(false, true);
    final ch.blackspirit.graphics.Image image = imageFactory.createImage(this.getClass().getResource("/player1.png"), true);
    context.setGraphicsListener(new GraphicsListener() {
      public void draw(View view, Graphics graphics) {
        graphics.clear();
        graphics.fillTriangle(triangle, true, image);
View Full Code Here

    });
    context.draw();
  }

  private Triangle getTriangle(boolean includeColorNull, boolean includeTexCoordNull) {
    Triangle t = new Triangle();
    t.getPoint(0).set(0,0);
    t.getPoint(1).set(50,50);
    t.getPoint(2).set(0,50);
    if(!includeColorNull) {
      setColor(t, new Color4f(0, 1, 0, 1));
    }
    if(!includeTexCoordNull) {
      setTexCoords(t);
View Full Code Here

    return t;
  }

  private Triangle[] getTriangles(boolean includeNull, boolean includeColorNull, boolean includeTexCoordNull) {
    Triangle[] triangles = new Triangle[3];
    Triangle t1 = new Triangle();
    t1.getPoint(0).set(0,0);
    t1.getPoint(1).set(50,50);
    t1.getPoint(2).set(0,50);
    setColor(t1, new Color4f(1, 0, 0, 1));
    setTexCoords(t1);
    triangles[0] = t1;
   
    if(!includeNull) {
      Triangle t2 = new Triangle();
      t2.getPoint(0).set(100,100);
      t2.getPoint(1).set(150,150);
      t2.getPoint(2).set(100,150);
      setColor(t2, new Color4f(0, 1, 0, 1));
      setTexCoords(t2);
      triangles[1] = t2;
    }

    Triangle t3 = new Triangle();
    t3.getPoint(0).set(200,200);
    t3.getPoint(1).set(250,250);
    t3.getPoint(2).set(200,250);
    if(!includeColorNull) {
      setColor(t3, new Color4f(0, 0, 1, 1));
    }
    if(!includeTexCoordNull) {
      setTexCoords(t3);
View Full Code Here

    this.image = image;
  }

  public void start() {
    for(int i = 0; i < pool.length; i++) {
      pool[i] = new Triangle();
      pool[i].setColor(0, new Color4f());
      pool[i].setColor(1, new Color4f());
      pool[i].setColor(2, new Color4f());
      pool[i].setTextureCoordinate(0, new Vector2f());
      pool[i].setTextureCoordinate(1, new Vector2f());
View Full Code Here

      float x = particle.getPosition().x - width / 2;
      float y = particle.getPosition().y - height / 2;
      Color4f color = particle.getColor();
     
      // TODO test in joglgraphicsdelegate if texturecoordinates are available
      Triangle t = pool[triangles];
      t.getPoint(0).set(x, y);
      t.getPoint(1).set(x + width, y);
      t.getPoint(2).set(x, y + height);
      t.getTextureCoordinate(0).set(0, 0);
      t.getTextureCoordinate(1).set(imageWidth, 0);
      t.getTextureCoordinate(2).set(0, imageHeight);
      t.getColor(0).set(color);
      t.getColor(1).set(color);
      t.getColor(2).set(color);
      temp[triangles] = t;
      triangles++;

      t = pool[triangles];
      t.getPoint(0).set(x + width, y);
      t.getPoint(1).set(x + width, y + width);
      t.getPoint(2).set(x, y + height);
      t.getTextureCoordinate(0).set(imageWidth, 0);
      t.getTextureCoordinate(1).set(imageWidth, imageHeight);
      t.getTextureCoordinate(2).set(0, imageHeight);
      t.getColor(0).set(color);
      t.getColor(1).set(color);
      t.getColor(2).set(color);
      temp[triangles] = t;
      triangles++;
     
      if(triangles == numTriangles) {
        graphics.fillTriangles(temp, true, image);
View Full Code Here

        float randomTriangleY2 = 530;
        float randomTriangleWidth = randomTriangleX2 - randomTriangleX1;
        float randomTriangleHeight = randomTriangleY2 - randomTriangleY1;
        // Update random triangles
        alphaC++;
        Triangle triangle = null;
        Color4f triangleColor = null;
        if(triangles.size() == triangleCount) {
          triangle = triangles.remove(0);
          triangleColor = triangle.getColor(0);
        } else {
          triangle = new Triangle();
          triangleColor = new Color4f();
          triangle.setColor(0, triangleColor);
          triangle.setColor(1, triangleColor);
          triangle.setColor(2, triangleColor);
        }
        float alpha = 1;
        if(alphaC == 5){
          alpha = random.nextFloat();
          alphaC = 0;
        }
        triangleColor.set(random.nextFloat(), random.nextFloat(), random.nextFloat(), alpha);
        for(int i = 0; i < 3; i++) {
          triangle.getPoint(i).x = random.nextFloat() * randomTriangleWidth + randomTriangleX1;
          triangle.getPoint(i).y = random.nextFloat() * randomTriangleHeight + randomTriangleY1;
        }
        triangles.add(triangle);
       
        // Triangles
        renderer.setColor(white);
View Full Code Here

TOP

Related Classes of ch.blackspirit.graphics.shape.Triangle

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.