This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

anar+

by   LaBelle + Nembrini
©2008

built with ( )
   examples index
Rotate: middle click or key[1]
Zoom in|out: wheel button or key[2]
AutoRotate: key[5]
(First Click inside the applet to enable keys)

This applet use OpenGL, you might have to install extra jogl libraries once to view this applet. You may have a look at image capture and video at the bottom of this page. You might accept security security permenently to remove the security prompts on each pages.



sourcecode


   PDE Download:   Test03fFoldingDisasterB.pde
   JAVA Download:   Test03fFoldingDisasterB.java


Click on anar+ terms to get the documentation.

import processing.opengl.*;
import anar.*;
 
 
 
 
 
/*
 * Example for Anar library by Guillaume LaBelle + Julien Nembrini
 * http://anar.ch
 */
 
 
Obj myObj = new Obj();
 
 
void setup(){
    size(800,400,OPENGL);
  frameRate(200);
 
  Anar.init(this);
  Anar.drawAxis(true);
 
  initForm();
}
 
 
void initForm(){
 
 
  // CREATE TWO CONTAINERS TO STORE THE POINTS
  // TWO LINES PARRALELS WITH POINTS
  Pts ptsA = new Pts();
  Pts ptsB = new Pts();
 
 
  // SET TWO TRANSFORMATIONS FOR REUSE
  Translate sideWidth = new Translate(0,10,0);
  Translate sideHeight = new Translate(10,10,0);
 
 
  // CREATE A FIRST POINT
  // ASECOND FOR THE NEXT LINE
  Pt oriA = Anar.Pt(10,20,30);
  Pt oriB = Anar.Pt(oriA,sideWidth);
 
 
  // CREATE ALL POINTS FROM sideHeight at EACH STEPS
  for (int i = 0; i<5; i++){
    Pt tmpA = Anar.Pt(oriA,sideHeight);
    Pt tmpB = Anar.Pt(oriB,sideHeight);
 
    ptsA.add(tmpA);
    ptsB.add(tmpB);
 
    // Swap oriA and oriB
    oriA = tmpA;
    oriB = tmpB;
  }
 
 
  Obj tmpFaces = new Obj();
 
  // I HAVE THEN TWO PARRALLEL LINES
  // I'LL CREATE FACES FROM EACH PAIRS
  for (int i = 0; i<ptsA.numOfPts()-1; i++){
 
    // FIRST TRIANGLE ADJ
    Face triangleA = new Face();
    triangleA.add(ptsA.pt(i));
    triangleA.add(ptsA.pt(i+1));
    triangleA.add(ptsB.pt(i));
 
    tmpFaces.add(triangleA);
 
 
    // FIRST TRIANGLE OPPOSITE
    Face triangleB = new Face();
    triangleB.add(ptsB.pt(i));
    triangleB.add(ptsB.pt(i+1));
    triangleB.add(ptsA.pt(i+1));
 
    tmpFaces.add(triangleB);
  }
 
 
  // myObj.add(ptsA);
  // myObj.add(ptsB);
 
  RotateZ r = new RotateZ((float)Math.PI/16);
 
  myObj.add(tmpFaces);
 
 
  // For each pair of faces (expt. the last)
  for (int i = 0; i<myObj.numOfFaces()-1; i++){
    Face face1 = myObj.face(i);
    Face face2 = myObj.face(i+1);
 
    Transform relativeRotation = new Transform(face1.pt(2),face1.pt(1),r);
 
 
    face2.apply(relativeRotation);
  }
 
  myObj.fill(255,255,0);
 
  Anar.camTarget(myObj);
  Anar.sliders(myObj);
}
 
 
void draw(){
  background(155);
 
  myObj.draw();
}
 
 
 



screenshots