Package toxi.geom

Examples of toxi.geom.Vec3D


     
      // Tag aspect ratio * screen aspect ratio
      LOGGER.log(Level.FINEST, "Client "+CLIENT_FATTAG);
     
      // Get a normalized screenBound and scale all points using this
      Vec3D screenScale = Vec3DUtils.getNormalized(gml.environment.screenBounds);     
     
      List<GmlStroke> strokes = (List<GmlStroke>) gml.getStrokes();
      for (GmlStroke stroke : strokes) {
        List<GmlPoint> points = stroke.getPoints();
        for(GmlPoint point: points) {
          point.scaleSelf(screenScale);
        }
        stroke.replacePoints(points);
      }
      gml.replaceStrokes(strokes);
    }

    /*
    Graffiti Analysis v2.0 DustTag
    -> 1 to more
    -> Already scaled
    -> Except z is fucked
    */

    else if (client.indexOf(CLIENT_GRAFANALYSIS) > -1) {
     
      // Reduce z
      // Normalize
      LOGGER.log(Level.FINEST, "Client "+CLIENT_GRAFANALYSIS);
     
      // Get max z from normalized screenBounds
      Vec3D screenScale = Vec3DUtils.getNormalized(gml.environment.screenBounds);     
      AABB boundingBox = gml.getBoundingBox();
           
      // Remap all points' z coords so they fit between 0 and 0.25
      // Might not be super accurate but good enough
      List<GmlStroke> strokes = (List<GmlStroke>) gml.getStrokes();
View Full Code Here


  /**
   * Initializes the Gml with default values
   * @param screen - Vec3D vector (screen dimensions)
   */
  private void initGml(Vec3D screen) {   
    normalizer = new Vec3D(Vec3DUtils.getNormalized(screen));
    gml.client.set(GmlClient.USERNAME, GmlConstants.DEFAULT_CLIENT_NAME);
    gml.environment.screenBounds = new Vec3D(screen);
  }
View Full Code Here

  /**
   * Returns the normalizer used to scale points
   * @return Vec3D
   */
  public Vec3D getNormalizer() {
    return new Vec3D(normalizer);
  }
View Full Code Here

   * @param sessionID - int
   * @param v - Vec3D vetor (shall be within AABB (0,0,0) -> (1,1,1))
   * @param time - float
   */
  public void addPoint(int sessionID, Vec3D v, final float time) {
    addPoint(sessionID, v, time, GmlPoint.DEFAULT_PRESSURE, new Vec3D(), new Vec3D());
  }
View Full Code Here

      g.beginShape();
      for (GmlPoint point : stroke.getPoints()) {
        if (point.time < minTime) continue;
        if (point.time > maxTime) break;

        Vec3D v = point.scale(scale);
        curveVertex(g, v);
      }
      g.endShape();
      g.popStyle();
    }
View Full Code Here

      if (stroke.getPoints().size() > 0) { 

        GmlPoint prev = new GmlPoint();
        GmlPoint pos = new GmlPoint();
        Vec3D a = new Vec3D();
        Vec3D b = new Vec3D();
        Vec3D p = new Vec3D();
        Vec3D q = new Vec3D();
        float weight = 0;

        prev.set(stroke.getPoints().get(0));

        float curPoint = 1;

        for (GmlPoint point: stroke.getPoints()) {
          if (point.time < minTime) continue;
          if (point.time > maxTime) break;
          pos.set(point);

          // use distance to previous point as target stroke weight
          //weight += (pos.distanceTo(prev)*4-weight)*0.1;
          weight = 0.025f;

          // define offset points for the triangle strip
          a.set(pos);
          b.set(pos);
          a.addSelf(0, weight, curPoint * .0005f);
          b.addSelf(0, -weight, curPoint * .0005f);

          if (!q.isZeroVector() && !p.isZeroVector()) {
            // add 2 faces to the mesh
            mesh.addFace(p, b, q);
            mesh.addFace(p, b, a);
          }

          // store current points for next iteration
          prev.set(pos);
          p.set(a);
          q.set(b);
          ++curPoint;
        }
      }
      mesh.computeVertexNormals();
      return mesh;
View Full Code Here

    g.beginShape();
    for (GmlPoint point : stroke.getPoints()) {
      if (point.time < minTime) continue;
      if (point.time > maxTime) break;
     
      Vec3D v = point.scale(scale);
      curveVertex(g, v);
    }
    g.endShape();
    g.popStyle();
  }
View Full Code Here

      TriangleMesh mesh = new TriangleMesh("");

      if (stroke.getPoints().size() > 0) { 

        GmlPoint pos = new GmlPoint();
        Vec3D a = new Vec3D();
        Vec3D b = new Vec3D();
        Vec3D p = new Vec3D();
        Vec3D q = new Vec3D();
        float weight = 0.25f;

        float curPoint = 1;

        for (GmlPoint point: stroke.getPoints()) {
          if (point.time < minTime) continue;
          if (point.time > maxTime) break;

          pos.set(point);

          // define offset points for the triangle strip
          a.set(pos);
          b.set(pos);

          float angle = point.rotation.z;

          Vec3D aShift = new Vec3D(weight/2 * (float) Math.sin(Math.PI * angle - .25f), weight/2 * (float) Math.cos(Math.PI * angle - .25f), (curPoint+1) * .0005f);
          Vec3D bShift = new Vec3D(weight/2 * (float) Math.sin(Math.PI * angle + .25f), weight/2 * (float) Math.cos(Math.PI * angle + .25f), (curPoint+1) * .0005f);

          a.addSelf(aShift);
          b.addSelf(bShift);

          if (!q.isZeroVector() && !p.isZeroVector()) {
View Full Code Here

    if (stroke.getPoints().size() > 0) { 

      GmlPoint prev = new GmlPoint();
      GmlPoint pos = new GmlPoint();
      Vec3D a = new Vec3D();
      Vec3D b = new Vec3D();
      Vec3D p = new Vec3D();
      Vec3D q = new Vec3D();
      float weight = 0;

      prev.set(stroke.getPoints().get(0));

      for (GmlPoint point: stroke.getPoints()) {
        if (point.time < minTime) continue;
        if (point.time > maxTime) break;
        pos.set(point);

        // use distance to previous point as target stroke weight
        weight += (pos.distanceTo(prev)*4-weight)*0.1;

        // define offset points for the triangle strip
        a.set(pos);
        b.set(pos);
        a.addSelf(0, 0, weight);
        b.addSelf(0, 0, -weight);

        // add 2 faces to the mesh
        mesh.addFace(p,b,q);
        mesh.addFace(p, b, a);

        // store current points for next iteration
        prev.set(pos);
        p.set(a);
        q.set(b);
     
    }
    mesh.computeVertexNormals();
    return mesh;
  }
View Full Code Here

  /**
   * Creates a new GmlEnvironment using the given screenBounds and default values
   */
  public GmlEnvironment(Vec3D screenBounds) {
   
    this.screenBounds = new Vec3D(screenBounds);
   
    // Use default values
    up = new Vec3D(GmlConstants.DEFAULT_ENVIRONMENT_UP);
   
    originalOriginShift = new Vec3D(0, 0, 0);
    originalAspectRatio = new Vec3D(1, 1, 1);
    normalizedOriginShift = new Vec3D(0, 0, 0);
    normalizedAspectRatio = new Vec3D(1, 1, 1)
  }
View Full Code Here

TOP

Related Classes of toxi.geom.Vec3D

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.