Not able to use light with Shape(POINTS) - am i missing something ?
in
Contributed Library Questions
•
26 days ago
HI all,
I am a beginner in Processing. I am trying to play with my kinect and to simulate a light/shade effect on a body shape.
My first question is about the relation between stroke and light effect. I managed to get a shade effect on a sphere if there is noStroke(). Why the fact to set a stroke value makes the shade effect fail ?
pointLight(250, 250, 250, 0, 750, 1000);
noStroke();
//stroke(250.0,250.0,250.0); // with or without stroke
translate(0,0,500.0);
fill(250,250,250);
sphere(100);
My second question is about the 3D body shape obtained thanks to the Kinekt. I got the 3D body shape through some basic codes (proposed in SimpleOpenNI examples) :
beginShape(POINTS);
for(int y=0;y < context.depthHeight();y+=10)
{
for(int x=0;x < context.depthWidth();x+=10)
{
index = x + y * context.depthWidth();
if(depthMap[index] > 0)
{
// draw the projected point
realWorldPoint = context.depthMapRealWorld()[index];
point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);
}
}
}
endShape();
but the light has no effect on it. I have the intuition that is linked to the first question. Maybe a list of Points doesn't make a solid texture and so no light effect on it.
Could someone answer my two questions and give me some hints to produce a 3D body shape with a shade effect ?
Any recommended tutorial on the subject is much welcome as well :D !
Many thanks for your help.
Nexx Oko
import SimpleOpenNI.*;
import processing.opengl.*;
SimpleOpenNI context;
float zoomF =0.5f;
float rotX = radians(180); // by default rotate the hole scene 180deg around the x-axis,
// the data from openni comes upside down
float rotY = radians(0);
boolean autoCalib=true;
void setup()
{
size(1024,768,P3D); // strange, get drawing error in the cameraFrustum if i use P3D, in opengl there is no problem
context = new SimpleOpenNI(this);
if(context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}
frame.setResizable(true);
// disable mirror
context.setMirror(false);
// enable depthMap generation
context.enableDepth();
stroke(255,255,255);
smooth();
perspective(radians(45),
float(width)/float(height),
10,150000);
frameRate(80);
}
void draw()
{
context.update();
background(0,0,0);
// set the scene pos
translate(width/2, height/2, 0);
noStroke();
stroke(50.0,50.0,70.0);
rotateX(rotX);
rotateY(rotY);
scale(zoomF);
int[] depthMap = context.depthMap();
int index;
PVector realWorldPoint;
pointLight(250, 250, 250, 0, 750, 1000);
noStroke();
//stroke(250.0,250.0,250.0);
translate(0,0,500.0);
fill(250,250,250);
sphere(100);
stroke(250.0,250.0,250.0);
beginShape(POINTS);
for(int y=0;y < context.depthHeight();y+=10)
{
for(int x=0;x < context.depthWidth();x+=10)
{
index = x + y * context.depthWidth();
if(depthMap[index] > 0)
{
// draw the projected point
realWorldPoint = context.depthMapRealWorld()[index];
point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);
}
}
}
endShape();
}
I am a beginner in Processing. I am trying to play with my kinect and to simulate a light/shade effect on a body shape.
My first question is about the relation between stroke and light effect. I managed to get a shade effect on a sphere if there is noStroke(). Why the fact to set a stroke value makes the shade effect fail ?
pointLight(250, 250, 250, 0, 750, 1000);
noStroke();
//stroke(250.0,250.0,250.0); // with or without stroke
translate(0,0,500.0);
fill(250,250,250);
sphere(100);
My second question is about the 3D body shape obtained thanks to the Kinekt. I got the 3D body shape through some basic codes (proposed in SimpleOpenNI examples) :
beginShape(POINTS);
for(int y=0;y < context.depthHeight();y+=10)
{
for(int x=0;x < context.depthWidth();x+=10)
{
index = x + y * context.depthWidth();
if(depthMap[index] > 0)
{
// draw the projected point
realWorldPoint = context.depthMapRealWorld()[index];
point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);
}
}
}
endShape();
but the light has no effect on it. I have the intuition that is linked to the first question. Maybe a list of Points doesn't make a solid texture and so no light effect on it.
Could someone answer my two questions and give me some hints to produce a 3D body shape with a shade effect ?
Any recommended tutorial on the subject is much welcome as well :D !
Many thanks for your help.
Nexx Oko
import SimpleOpenNI.*;
import processing.opengl.*;
SimpleOpenNI context;
float zoomF =0.5f;
float rotX = radians(180); // by default rotate the hole scene 180deg around the x-axis,
// the data from openni comes upside down
float rotY = radians(0);
boolean autoCalib=true;
void setup()
{
size(1024,768,P3D); // strange, get drawing error in the cameraFrustum if i use P3D, in opengl there is no problem
context = new SimpleOpenNI(this);
if(context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}
frame.setResizable(true);
// disable mirror
context.setMirror(false);
// enable depthMap generation
context.enableDepth();
stroke(255,255,255);
smooth();
perspective(radians(45),
float(width)/float(height),
10,150000);
frameRate(80);
}
void draw()
{
context.update();
background(0,0,0);
// set the scene pos
translate(width/2, height/2, 0);
noStroke();
stroke(50.0,50.0,70.0);
rotateX(rotX);
rotateY(rotY);
scale(zoomF);
int[] depthMap = context.depthMap();
int index;
PVector realWorldPoint;
pointLight(250, 250, 250, 0, 750, 1000);
noStroke();
//stroke(250.0,250.0,250.0);
translate(0,0,500.0);
fill(250,250,250);
sphere(100);
stroke(250.0,250.0,250.0);
beginShape(POINTS);
for(int y=0;y < context.depthHeight();y+=10)
{
for(int x=0;x < context.depthWidth();x+=10)
{
index = x + y * context.depthWidth();
if(depthMap[index] > 0)
{
// draw the projected point
realWorldPoint = context.depthMapRealWorld()[index];
point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);
}
}
}
endShape();
}
1