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:   Test02pTower.pde
   JAVA Download:   Test02pTower.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
 */
 
 
Face    f;
Obj     myObj        = new Obj();
Obj     contourLines = new Obj();
Obj     verticales   = new Obj();
Obj     windows      = new Obj();
 
Sliders mySliders;
 
 
void setup(){
    size(800,400,OPENGL);
  Anar.init(this);
  initForm();
 
  Pts.globalRender = new RenderPtsLine();
  Anar.drawAxis(true);
 
  CSpline.globalRender.splineRes.set(5);
}
 
 
void initForm(){
 
  int numberOfNodes = 10;
 
  f = new Star(100,70,5);
  // println(f.parentList());
 
  Param d = new Param(.14f,0,1);
 
  Transform t = new Transform();
  t.translate(0,0,5);
  t.scale(0.98f,0.93f,1.01f);
  t.rotateZ(d);
 
  // myObj.add(f);
 
  // LEVEL
 
  for (int i = 0; i<40; i++){
    Face tmpFace = new Face(f,t);
    myObj.add(tmpFace);
    f = tmpFace;
 
    Pts ptContour;
    Pts ptCollector = new Pts(); // Where I store all points
 
    for (int j = 0; j<f.numOfPts(); j++){
      int jj = (j+1)%f.numOfPts();
 
      ptContour = new PtsMid(f.pt(j),f.pt(jj),numberOfNodes);
      // ptContour.remove(f.pt(jj));
      // ptContour.remove(f.pt(j));
      ptContour.remove(ptContour.ptEnd());
 
      ptCollector.addPointsFrom(ptContour);
    }
 
    contourLines.add(ptCollector);
  }
 
 
  // VERTICALES
 
  int nodesPerLevel = contourLines.line(0).numOfPts();
 
  for (int j = 0; j<nodesPerLevel; j++){
    if(j%3!=0){
      Pts ptCollector = new Pts(); // Where I store all points
      for (int i = 0; i<contourLines.numOfLines(); i++){
        Pts a = contourLines.line(i);
        // Pts b = (Pts) contourLines.parent(i + 1);
        ptCollector.add(a.pt( (j+1*i)%nodesPerLevel));
      }
      verticales.add(ptCollector);
    }
  }
 
 
  // WINDOWS
 
  RenderPtsLine redLines = new RenderPtsLine(new AColor(75,0,0));
  RenderPtsLine hedLines = new RenderPtsLine(new AColor(40,0,0));
  Param degree = new Param(1/.5f);
 
  for (int i = 1; i<verticales.lines.size(); i += 2){
    Pts a = verticales.lines.get(i);
    Pts b = verticales.lines.get( (i+1)%verticales.lines.size());
 
    for (int j = 0; j<a.numOfPts()-1; j++){
 
 
      Pts c = new Pts();
 
      if(Anar.rnd(10)>5){
        c.add(a.pt(j));
        c.add(b.pt(j+1));
      }
      else{
        c.add(a.pt(j+1));
        c.add(b.pt(j));
      }
      c.render = redLines;
 
      if(Anar.rnd(10)>5)
        windows.add(c);
 
 
      Pts k = new PtsMid(a.pt(j),b.pt(j+1),4);
      Pts l = new PtsMid(b.pt(j),a.pt(j+1),4);
 
      Pts m = new Pts();
      m.add(k.pt(1));
      m.add(k.pt(k.numOfPts()-2));
      m.render = redLines;
 
      if(Anar.rnd(10)>5)
        windows.add(m);
 
      Pts n = new Pts();
      n.add(l.pt(1));
      n.add(l.pt(l.numOfPts()-2));
      n.render = redLines;
 
      if(Anar.rnd(10)>5)
        windows.add(n);
 
 
      Pts e = new Pts();
 
      // e.add(a.pt(j));
      // e.add(a.pt(j+1));
      // e.add(b.pt(j+1));
      // e.add(b.pt(j));
      e.add(l.pt(1));
      e.add(k.pt(1));
      e.add(l.pt(l.numOfPts()-2));
      e.add(k.pt(k.numOfPts()-2));
 
 
      CSpline f = new CSpline(e,degree);
      f.closedMode = true;
      f.mode = CSpline.NEXT;
 
      // f.render = hedLines;
 
      if(Anar.rnd(10)>5)
        windows.add(f);
 
    }
  }
 
 
  Anar.camTarget(myObj);
  mySliders = new Sliders(myObj);
  println(myObj.parentList());
  println(myObj.primitiveToString( -1));
}
 
 
void draw(){
  background(200);
  myObj.draw();
  verticales.draw();
  // contourLines.draw();
  windows.draw();
 
  mySliders.draw();
}
 
 
 
 



screenshots