
PDE Download: Test02eScreenSpace.pde
JAVA Download: Test02eScreenSpace.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;
Face f;
Obj myObj = new Obj();
Obj contourLines = new Obj();
Obj verticales = new Obj();
Sliders mySliders;
void setup(){
size(800,400,OPENGL);
Anar.init(this);
initForm();
Pts.globalRender = new RenderPtsLine();
Anar.drawAxis(true);
Scene.myOpenGLBackground = true;
}
void initForm(){
f = new Square(100);
Transform t = new Transform();
t.translate(0,0,10);
t.scale(0.98f,0.95f,1);
t.rotateZ(.1f);
int numberOfNodes = 50;
for (int i = 0; i<20; 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));
ptCollector.addPointsFrom(ptContour);
}
contourLines.add(ptCollector);
}
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 = (Pts)contourLines.line(i);
// Pts b = (Pts) contourLines.parent(i + 1);
ptCollector.add(a.pt( (j+2*i)%nodesPerLevel));
}
verticales.add(ptCollector);
}
}
// Assign a render to contourLines
contourLines.render = new RenderObjPts();
verticales.render = new RenderObjPts();
println(myObj.primitiveToString( -1));
Anar.camTarget(myObj);
mySliders = new Sliders(myObj);
}
void draw(){
background(200);
myObj.draw();
// contourLines.draw();
verticales.draw();
Anar.scene.actualView.draw();
mySliders.draw();
//
// fill(0,0,255);
// pushMatrix();
// translate(Anar.camera.actualView.targetX,Anar.camera.actualView.targetY,Anar.camera.actualView.targetZ);
// rotateY(-Anar.camera.actualView.rotateY);
// rotateZ(-Anar.camera.actualView.rotateZ);
// scale(-Anar.camera.actualView.scale);
// rotateZ(-Anar.camera.actualView.rotateZ);
// rotateY(-Anar.camera.actualView.rotateY);
//
//
//
//
// ellipse(width/2,height/2,100,100);
// ellipse(0,height,100,100);
// ellipse(width,0,100,100);
// ellipse(0,0,100,100);
// ellipse(width,height,100,100);
// popMatrix();
//
//
//
// PMatrix3D p = this.g.camera;
Anar.scene.screenDrawBegin();
int sz = 20;
ellipse(width/2,height/2,sz,sz);
ellipse(0,height,sz,sz);
ellipse(width,0,sz,sz);
ellipse(0,0,sz,sz);
ellipse(width,height,sz,sz);;
Anar.scene.screenDrawEnd();
}
void keyPressed(){
switch(key){
case 'p':
Scene.autoSeek = false;
break;
case 'a':
Group export = new Group();
export.add(myObj);
export.add(verticales);
Autolisp.export(export,this);
break;
case 'r':
RhinoScript.export(myObj,this);
break;
case 's':
SketchUpRuby.export(myObj,this);
break;
}
}

|