mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Fixed texturing and coloring in OBJ loading (PShape3D)
This commit is contained in:
@@ -56,9 +56,8 @@ import processing.core.PShape3D.VertexGroup;
|
||||
* By Andres Colubri
|
||||
*
|
||||
* TODO: Comment A3D, PShape3D and PTexture,
|
||||
* TODO: Check lighting and materials, specially in PShape3D..
|
||||
* TODO: Check lighting and materials.
|
||||
* TODO: Revise triangulator (issues are particularly apparent when tesselating SVG shapes).
|
||||
* TODO: Optimize Vertex Array rendering on real N1 hardware.
|
||||
*/
|
||||
public class PGraphicsAndroid3D extends PGraphics {
|
||||
public SurfaceHolder holder;
|
||||
@@ -456,7 +455,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
|
||||
protected void drawScreenTexture() {
|
||||
// TODO: try using glDrawTexiOES
|
||||
// TODO: try using glDrawTexiOES maybe?
|
||||
tint(255);
|
||||
fill(255);
|
||||
int w = 256;
|
||||
@@ -3652,7 +3651,7 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
|
||||
/**
|
||||
* Switches off all lights, but keeps lighting enabled..
|
||||
* Switches off all lights, but keeps lighting enabled.
|
||||
* TODO: discuss if this method is needed.
|
||||
*/
|
||||
public void resetLights() {
|
||||
|
||||
@@ -100,7 +100,6 @@ public class PShape3D extends PShape implements PConstants {
|
||||
}
|
||||
|
||||
|
||||
// TODO: Properly debug OBJ loading. Particuarly when loading textured materials.
|
||||
public PShape3D(PApplet parent, String filename, int mode) {
|
||||
this.parent = parent;
|
||||
a3d = (PGraphicsAndroid3D)parent.g;
|
||||
@@ -1313,7 +1312,7 @@ public class PShape3D extends PShape implements PConstants {
|
||||
* the data already stored in it by copying to the beginning of the
|
||||
* new buffers.
|
||||
*
|
||||
* TODO: Test!.
|
||||
* TODO: Test!
|
||||
*
|
||||
*/
|
||||
public void resize(int numVert) {
|
||||
@@ -2187,6 +2186,15 @@ public class PShape3D extends PShape implements PConstants {
|
||||
protected void recordOBJ(ArrayList<PVector> vertices, ArrayList<PVector> normals, ArrayList<PVector> textures, ArrayList<OBJFace> faces, ArrayList<OBJMaterial> materials) {
|
||||
int mtlIdxCur = -1;
|
||||
OBJMaterial mtl = null;
|
||||
|
||||
// Using normal mode for texture coordinates (i.e.: normalized between 0 and 1).
|
||||
int tMode0 = a3d.textureMode;
|
||||
a3d.textureMode = NORMAL;
|
||||
|
||||
// Using RGB mode for coloring.
|
||||
int cMode0 = a3d.colorMode;
|
||||
a3d.colorMode = RGB;
|
||||
|
||||
a3d.beginShapeRecorderImpl();
|
||||
for (int i = 0; i < faces.size(); i++) {
|
||||
OBJFace face = (OBJFace) faces.get(i);
|
||||
@@ -2202,6 +2210,11 @@ public class PShape3D extends PShape implements PConstants {
|
||||
a3d.ambient(mtl.ka.x * 255.0f, mtl.ka.y * 255.0f, mtl.ka.z * 255.0f);
|
||||
a3d.fill(mtl.kd.x * 255.0f, mtl.kd.y * 255.0f, mtl.kd.z * 255.0f, mtl.d * 255.0f);
|
||||
a3d.shininess(mtl.ns);
|
||||
|
||||
if (mtl.kdMap != null) {
|
||||
// If current material is textured, then tinting the texture using the diffuse color.
|
||||
a3d.tint(mtl.kd.x * 255.0f, mtl.kd.y * 255.0f, mtl.kd.z * 255.0f, mtl.d * 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// Recording current face.
|
||||
@@ -2272,6 +2285,9 @@ public class PShape3D extends PShape implements PConstants {
|
||||
xmax = ymax = zmax = -10000;
|
||||
|
||||
a3d.endShapeRecorderImpl(this);
|
||||
|
||||
a3d.textureMode = tMode0;
|
||||
a3d.colorMode = cMode0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ import java.nio.*;
|
||||
* By Andres Colubri
|
||||
* TODO: Finish integration with PImage
|
||||
* TODO: Revise updating mechanism (what happens when the pixels change in the PImage, etc).
|
||||
* TODO: Find alternative for FOBs or how to expose FBO functionality in N1 and other EGL2 phones.
|
||||
* TODO:
|
||||
* TODO: Find alternative for FOBs or how to expose FBO functionality in N1 and other EGL2 phones.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PTexture implements PConstants {
|
||||
|
||||
Reference in New Issue
Block a user