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:   RecursivMoucharabieh00bUltraSimple.pde
   JAVA Download:   RecursivMoucharabieh00bUltraSimple.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
 */
 
 
Anar      goo;
 
// Sliders parameters;
 
Pt        a, b, c, d;
 
Obj       obj;
Sliders   mySlider;
 
Param     z, zMin;
Param     div;
Param     zero;
 
 
Translate t;
MirrorZ   m;
 
int       nIteration = 0;
 
void setup(){
    size(800,400,OPENGL);
  Anar.init(this);
 
  Scene.autoSeek = false;
 
  initForm();
}
 
void initForm(){
  div = new Param(3,2,10);
 
  t = new Translate(Anar.Pt(0,0,20));
  m = new MirrorZ();
 
  a = Anar.Pt( -60, -60);
  b = Anar.Pt(60, -60);
  c = Anar.Pt(60,60);
  d = Anar.Pt( -60,60);
 
  reset();
}
 
void reset(){
  obj = new Obj();
 
  Face f = new Face();
  f.add(a);
  f.add(b);
  f.add(c);
  f.add(d);
  obj.add(f);
 
  nIteration = 0;
 
  mySlider = new Sliders(obj);
}
 
 
void recursivIteration(){
 
  nIteration++;
  println(nIteration);
 
  Obj newObj = new Obj();
 
  for (int mm = 0; mm<obj.numOfFaces(); mm++){
    Face f = obj.face(mm);
 
    Obj hLines = new Obj();
 
    // subdivide horizontal and vertical edges
    Pts vEdge = new PtsMid(f.pt(0),f.pt(1),div);
    Pts hEdge = new PtsMid(f.pt(0),f.pt(3),div);
 
    Pt vDelta = (PtDER)vEdge.pt(0).minus(vEdge.pt(1));
 
    // translate horizontal line
    for (int i = 0; i<vEdge.numOfPts(); i++){
      Pts hCopy = new Pts(hEdge,new Translate(vDelta));
      hLines.add(hEdge);
      hEdge = hCopy;
    }
 
    Obj front = new Obj();
    Obj back = new Obj();
    for (int i = 0; i<hLines.numOfLines()-1; i++){
 
      if(i!=0){
        front.add(new Pts(hLines.line(i),t));
        // Transform tm = t;
        // tm.apply(m);
        // back.add(new Pts(hLines.line(i), tm));
      }
      else{
        front.add(hLines);
        // back.add(hLines);
      }
    }
 
    newObj.add(front);
    newObj.add(back);
    newObj.add(hLines);
 
    for (int i = 0; i<hLines.numOfLines()-1; i++){
 
 
      // create faces according to checkboard
      for (int j = i%2; j<hEdge.numOfPts()-1; j = j+2){
        Face newFace = new Face();
        newFace.add(front.line(i).pt(j));
        newFace.add(front.line(i+1).pt(j));
        newFace.add(front.line(i+1).pt(j+1));
        newFace.add(front.line(i).pt(j+1));
 
        newObj.add(newFace);
      }
 
      // for (int j=(i+1)%2; j<hEdge.numOfPts()-1; j=j+2) {
      // Face newFace = new Face();
      // newFace.add(back.line(i).pt(j));
      // newFace.add(back.line(i+1).pt(j));
      // newFace.add(back.line(i+1).pt(j+1));
      // newFace.add(back.line(i).pt(j+1));
      //    	        
      // newObj.add(newFace);
      // }
 
 
    }
 
  }
 
  obj = newObj;
 
  Anar.camTarget(obj);
  mySlider = new Sliders(obj);
}
 
 
void draw(){
  background(153);
 
  // ParametricValue v = parameters.get(0);
  // v.set(v.get()+ random(10)-5);
 
 
  obj.draw();
  mySlider.draw();
}
 
 
void keyPressed(){
 
  switch(key){
    case 'q':
      recursivIteration();
    break;
    case ' ':
      reset();
    break;
 
  }
}
 
 
 



screenshots