Toxiclibs lighting
in
Contributed Library Questions
•
2 years ago
Hi!
I've been playing around with lighting in Toxiclibs, but am getting some low performance with the lighting of faces. Looking at the example below; the faces don't seem to be being lit smoothly as the cube moves. Is this something to do with the normals of the faces? I couldn't quite work out how to 'update' them (as you can see in the below (adapted from code by velvetkevorkian)).
Can anyone please advise as to how this may be possible?
______________________
www.systemarray.com
I've been playing around with lighting in Toxiclibs, but am getting some low performance with the lighting of faces. Looking at the example below; the faces don't seem to be being lit smoothly as the cube moves. Is this something to do with the normals of the faces? I couldn't quite work out how to 'update' them (as you can see in the below (adapted from code by velvetkevorkian)).
Can anyone please advise as to how this may be possible?
import processing.opengl.*;
import toxi.geom.*;
import toxi.geom.mesh.subdiv.*;
import toxi.geom.mesh.*;
import toxi.processing.*;
ToxiclibsSupport tox;
float rotx,roty= PI/4;
WETriangleMesh mesh;
void setup() {
size(700, 700, OPENGL);
tox= new ToxiclibsSupport(this);
buildMesh();
mesh.computeVertexNormals();
}
void draw() {
translate(width/2,height/2,0);
background(255);
fill(255,0,0);
strokeWeight(0.5);
stroke(0);
lights();
rotateX(rotx);
rotateY(roty);
tox.mesh(mesh, true, 0);
rotx+= 0.00510;
roty+= 0.00620;
mesh.computeFaceNormals();
mesh.computeVertexNormals();
}
void buildMesh() {
mesh=new WETriangleMesh();
toxi.geom.AABB b;
b=new toxi.geom.AABB(80);
b.toMesh(mesh);
}
______________________
www.systemarray.com
1