I'm very much looking forward to playing with the new renderer. I can see lots of possibilities coming up :)
My light situation is a little odd. The only one that I can get to look any good (so that it shows the actual edges and surfaces) is the spotlight. I used the same technique as in the GLLights example.
It's just that when you hold the mouse in one position, and the cube looks well illuminated, as it rotates, it's almost as though the light rotates with it! Is that possible? (push and popMatrix didn't seem to make a difference)
I've been trying to decipher what's going on and can't get to the bottom of it.
Thanks for all the heads up on all this.
I've posted the code below if you're interested:-
- import processing.opengl.*;
import codeanticode.glgraphics.*;
GLModel cube;
int numvertex= 24;
float rotx = PI/4;
float roty = PI/4;
float lightX, lightY, lightZ;
void setup()
{
size(640, 480, GLConstants.GLGRAPHICS);
background(255);
frameRate( 55 );
cube = new GLModel(this, numvertex, QUADS, GLModel.STREAM);
cube.initColors();
cube.beginUpdateVertices();
// Front face
cube.setLineWidth(108);
cube.updateVertex(0, -100, -100, +100);
cube.updateVertex(1, +100, -100, +100);
cube.updateVertex(2, +100, +100, +100);
cube.updateVertex(3, -100, +100, +100);
// Back face
cube.updateVertex(4, -100, -100, -100);
cube.updateVertex(5, +100, -100, -100);
cube.updateVertex(6, +100, +100, -100);
cube.updateVertex(7, -100, +100, -100);
// Rigth face
cube.updateVertex(8, +100, -100, +100);
cube.updateVertex(9, +100, -100, -100);
cube.updateVertex(10, +100, +100, -100);
cube.updateVertex(11, +100, +100, +100);
// Left face
cube.updateVertex(12, -100, -100, +100);
cube.updateVertex(13, -100, -100, -100);
cube.updateVertex(14, -100, +100, -100);
cube.updateVertex(15, -100, +100, +100);
// Top face
cube.updateVertex(16, +100, +100, +100);
cube.updateVertex(17, +100, +100, -100);
cube.updateVertex(18, -100, +100, -100);
cube.updateVertex(19, -100, +100, +100);
// Bottom face
cube.updateVertex(20, +100, -100, +100);
cube.updateVertex(21, +100, -100, -100);
cube.updateVertex(22, -100, -100, -100);
cube.updateVertex(23, -100, -100, +100);
cube.endUpdateVertices();
cube.beginUpdateColors();
for (int i = 0; i < numvertex; i++) {
cube.updateColor(i, 211,203,203, 300);
}
cube.endUpdateColors();
cube.setTint(255);
}
void draw()
{
lightX = mouseX;
lightY = mouseY;
lightZ = -10.5;
background(255);
GLGraphics renderer = (GLGraphics)g;
renderer.beginGL();
float dirX = width/2 - lightX;
float dirY = height/2 - lightY;
float dirZ = 0 - lightZ;
float n = sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
dirX /= n;
dirY /= n;
dirZ /= n;
pushMatrix();
spotLight(255, 255, 255, lightX, lightY, lightZ, dirX, dirY, dirZ, PI/2, 0.1);
popMatrix();
translate(width/2,height/2, -250);
rotateX(rotx);
rotateY(roty);
renderer.model(cube);
renderer.endGL();
roty+=0.0058;
rotx+=0.0059;
}
______________________
www.systemarray.com