Changing materials on imported .obj PShapes
in
Programming Questions
•
6 months ago
Hi all,
I'm working on what should be a simple sketch, but I've run into a brick wall.
I have a scene made of several OBJ files representing several lamp objects, with simple cone shapes representing their light beams. I need to be able to set their color and intensity, to use a gradient bitmap as a transparency mask (which makes a nice falloff effect) - but I can't figure out how to do any of that for PShapes made of imported .obj files.
The problem I'm having is that all of the normal operations like tint() or texture() require that they be called in between the beginShape() and endShape() operations -- but for imported OBJ files there's only loadShape(), which happens all at once.
I've also tried using the SaitoOBJLoader library, which is supposed to handle that kind of thing, but its texture operators don't seem to work in Processing 2.0
Am I missing something obvious?
Thanks,
--David
Here's an example of a nonworking scene. It runs, but gives me the errors:
tint() can only be called between beginShape() and endShape()
texture() can only be called between beginShape() and endShape()
I'm working on what should be a simple sketch, but I've run into a brick wall.
I have a scene made of several OBJ files representing several lamp objects, with simple cone shapes representing their light beams. I need to be able to set their color and intensity, to use a gradient bitmap as a transparency mask (which makes a nice falloff effect) - but I can't figure out how to do any of that for PShapes made of imported .obj files.
The problem I'm having is that all of the normal operations like tint() or texture() require that they be called in between the beginShape() and endShape() operations -- but for imported OBJ files there's only loadShape(), which happens all at once.
I've also tried using the SaitoOBJLoader library, which is supposed to handle that kind of thing, but its texture operators don't seem to work in Processing 2.0
Am I missing something obvious?
Thanks,
--David
Here's an example of a nonworking scene. It runs, but gives me the errors:
tint() can only be called between beginShape() and endShape()
texture() can only be called between beginShape() and endShape()
- PShape s;
PImage tex;
void setup() {
size(800, 600, P3D);
s = loadShape("B03.obj");
tex = loadImage("lightGrad.jpg");
s.tint(255,0,0);
s.texture(tex);
}
void draw() {
background(204);
translate(width/2, height/2);
shape(s, 0, 0);
}
1