Hi,
I have a strange problem. I am using "Sunflow" render and it renders files when geometry is not rotated with peasy cam.
I added the script and all the files I am using. SKETCH FILES
PLEASE HELP ME.
Try to render geomtery when you open the script and other render when you rotate camera.
To render you have to press "r".
I have a strange problem. I am using "Sunflow" render and it renders files when geometry is not rotated with peasy cam.
I added the script and all the files I am using. SKETCH FILES
PLEASE HELP ME.
Try to render geomtery when you open the script and other render when you rotate camera.
To render you have to press "r".
- /*SunflowAPIAPI and OpenGL
Press s to subdivide mesh, r to render through SunflowAPIAPI
*/
import peasy.*;
import processing.opengl.*;
import toxi.geom.*;
import toxi.geom.mesh.subdiv.*;
import toxi.geom.mesh.*;
import toxi.processing.*;
import java.awt.Color;
SunflowAPIAPI sunflow ;
ToxiclibsSupport tox;
PeasyCam cam;
float[] vertices;
int[] triangles;
int rad=250;
WETriangleMesh mesh;
void setup() {
size(700, 700, OPENGL);
tox= new ToxiclibsSupport(this);
cam= new PeasyCam(this, 500);
buildMesh();
}
void draw() {
background(255);
fill(255);
strokeWeight(0.5);
stroke(0);
lights();
tox.mesh(mesh, true, 0);
}
void buildMesh() {
mesh=new WETriangleMesh();
toxi.geom.Sphere s;
s=new toxi.geom.Sphere(rad);
s.toMesh(mesh, 15);
}
void render() { //converts the TriangleMesh to the arrays required by SunflowAPIAPI
vertices = mesh.getUniqueVerticesAsArray();
triangles = mesh.getFacesAsArray();
}
void keyPressed() {
if(key=='s') {
SubdivisionStrategy subdiv=new NormalDisplacementSubdivision(0.45f);
mesh.subdivide(subdiv,10);
println("done");
}
if(key=='r') {
render();
rayTrace();
}
}
void rayTrace() {
sunflow = new SunflowAPIAPI();
sunflow.setWidth(width);
sunflow.setHeight(height);
sunflow.setPointLight("myPointLight", new Point3(0, 0, 0), new Color(255, 255, 255));
float[] lookAt= cam.getLookAt();
float[] pos=cam.getPosition();
sunflow.setCameraTarget(lookAt[0], lookAt[1], lookAt[2]);
sunflow.setCameraPosition(pos[0], pos[1], pos[2]);
sunflow.setCameraUp(0, -1, 0);
sunflow.setThinlensCamera("thinLensCamera", 50f, (float)width/height);
sunflow.drawPlane("sky", new Point3(0,-rad*2,0), new Vector3(0,-1,0));
sunflow.setAmbientOcclusionShader("occlusion", new Color(1f, 1f, 1f), new Color(0, 0, 0), 32, 500);
sunflow.drawPlane("ground", new Point3(0,rad,0), new Vector3(0,1,0));
sunflow.drawMesh("myMesh", vertices, triangles);
sunflow.setPathTracingGIEngine(32);
sunflow.render(false, sketchPath + "/"+frameCount+".png");
}
1