propane 3.3.1-java → 3.6.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -2
- data/.mvn/wrapper/MavenWrapperDownloader.java +117 -0
- data/.mvn/wrapper/maven-wrapper.properties +2 -3
- data/.travis.yml +9 -0
- data/CHANGELOG.md +17 -5
- data/Gemfile +2 -0
- data/README.md +17 -8
- data/Rakefile +16 -30
- data/bin/propane +3 -1
- data/lib/propane.rb +6 -4
- data/lib/propane/app.rb +20 -10
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +23 -24
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +21 -15
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +14 -6
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +28 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +6 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +7 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +4 -1
- data/mvnw +127 -51
- data/mvnw.cmd +182 -145
- data/pom.rb +53 -50
- data/pom.xml +17 -8
- data/propane.gemspec +13 -11
- data/src/main/java/monkstone/ColorUtil.java +13 -1
- data/src/main/java/monkstone/MathToolModule.java +253 -203
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +2 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +7 -6
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +11 -27
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +2164 -1661
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +280 -268
- data/src/main/java/processing/awt/PSurfaceAWT.java +942 -829
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +831 -824
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +229 -213
- data/src/main/java/processing/core/PImage.java +620 -318
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -409
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2888 -2652
- data/src/main/java/processing/core/PShapeOBJ.java +436 -415
- data/src/main/java/processing/core/PShapeSVG.java +1702 -1479
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -208
- data/src/main/java/processing/core/PVector.java +997 -965
- data/src/main/java/processing/core/ThinkDifferent.java +12 -17
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/dxf/RawDXF.java +404 -0
- data/src/main/java/processing/event/Event.java +87 -66
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +744 -0
- data/src/main/java/processing/net/Server.java +388 -0
- data/src/main/java/processing/opengl/FontTexture.java +289 -270
- data/src/main/java/processing/opengl/FrameBuffer.java +386 -364
- data/src/main/java/processing/opengl/LinePath.java +547 -500
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +3047 -2914
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +1266 -1257
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +33 -62
- metadata +54 -45
- data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
- data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
- data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
- data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
- data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
- data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
- data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
- data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
- data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
- data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
- data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
- data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
- data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
- data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
- data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
- data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
- data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
- data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
- data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
- data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -2,461 +2,482 @@ package processing.core;
|
|
2
2
|
|
3
3
|
import java.io.BufferedReader;
|
4
4
|
import java.io.File;
|
5
|
+
import java.io.IOException;
|
5
6
|
import java.util.ArrayList;
|
6
7
|
import java.util.HashMap;
|
7
8
|
import java.util.Map;
|
8
9
|
|
9
10
|
/**
|
10
|
-
* This class is not part of the Processing API and should not be used
|
11
|
-
* Instead, use loadShape() and methods like it, which will make
|
12
|
-
* class. Using this class directly will cause your code to break
|
13
|
-
* with future versions of Processing.
|
11
|
+
* This class is not part of the Processing API and should not be used
|
12
|
+
* directly. Instead, use loadShape() and methods like it, which will make
|
13
|
+
* use of this class. Using this class directly will cause your code to break
|
14
|
+
* when combined with future versions of Processing.
|
14
15
|
* <p>
|
15
16
|
* OBJ loading implemented using code from Saito's OBJLoader library:
|
16
|
-
* http://code.google.com/p/saitoobjloader/
|
17
|
+
* http://code.google.com/p/saitoobjloader/
|
18
|
+
* and OBJReader from Ahmet Kizilay
|
17
19
|
* http://www.openprocessing.org/visuals/?visualID=191
|
18
20
|
*
|
19
21
|
*/
|
20
22
|
public class PShapeOBJ extends PShape {
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
/**
|
25
|
+
* Initializes a new OBJ Object with the given filename.
|
26
|
+
* @param parent
|
27
|
+
* @param filename
|
28
|
+
*/
|
29
|
+
public PShapeOBJ(PApplet parent, String filename) {
|
30
|
+
this(parent, parent.createReader(filename), getBasePath(parent, filename));
|
31
|
+
}
|
32
|
+
|
33
|
+
public PShapeOBJ(PApplet parent, BufferedReader reader) {
|
34
|
+
this(parent, reader, "");
|
35
|
+
}
|
36
|
+
|
37
|
+
public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) {
|
38
|
+
ArrayList<OBJFace> faces = new ArrayList<>();
|
39
|
+
ArrayList<OBJMaterial> materials = new ArrayList<>();
|
40
|
+
ArrayList<PVector> coords = new ArrayList<>();
|
41
|
+
ArrayList<PVector> normals = new ArrayList<>();
|
42
|
+
ArrayList<PVector> texcoords = new ArrayList<>();
|
43
|
+
parseOBJ(parent, basePath, reader,
|
44
|
+
faces, materials, coords, normals, texcoords);
|
45
|
+
|
46
|
+
// The OBJ geometry is stored with each face in a separate child shape.
|
47
|
+
parent = null;
|
48
|
+
family = GROUP;
|
49
|
+
addChildren(faces, materials, coords, normals, texcoords);
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
protected PShapeOBJ(OBJFace face, OBJMaterial mtl,
|
54
|
+
ArrayList<PVector> coords,
|
55
|
+
ArrayList<PVector> normals,
|
56
|
+
ArrayList<PVector> texcoords) {
|
57
|
+
family = GEOMETRY;
|
58
|
+
switch (face.vertIdx.size()) {
|
59
|
+
case 3:
|
60
|
+
kind = TRIANGLES;
|
61
|
+
break;
|
62
|
+
case 4:
|
63
|
+
kind = QUADS;
|
64
|
+
break;
|
65
|
+
default:
|
66
|
+
kind = POLYGON;
|
67
|
+
break;
|
27
68
|
}
|
28
69
|
|
29
|
-
|
30
|
-
|
70
|
+
stroke = false;
|
71
|
+
fill = true;
|
72
|
+
|
73
|
+
// Setting material properties for the new face
|
74
|
+
fillColor = rgbaValue(mtl.kd);
|
75
|
+
ambientColor = rgbaValue(mtl.ka);
|
76
|
+
specularColor = rgbaValue(mtl.ks);
|
77
|
+
shininess = mtl.ns;
|
78
|
+
if (mtl.kdMap != null) {
|
79
|
+
// If current material is textured, then tinting the texture using the
|
80
|
+
// diffuse color.
|
81
|
+
tintColor = rgbaValue(mtl.kd, mtl.d);
|
31
82
|
}
|
32
83
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
ArrayList<PVector> texcoords = new ArrayList<PVector>();
|
39
|
-
parseOBJ(parent, basePath, reader,
|
40
|
-
faces, materials, coords, normals, texcoords);
|
41
|
-
|
42
|
-
// The OBJ geometry is stored with each face in a separate child shape.
|
43
|
-
parent = null;
|
44
|
-
family = GROUP;
|
45
|
-
addChildren(faces, materials, coords, normals, texcoords);
|
46
|
-
}
|
47
|
-
|
48
|
-
protected PShapeOBJ(OBJFace face, OBJMaterial mtl,
|
49
|
-
ArrayList<PVector> coords,
|
50
|
-
ArrayList<PVector> normals,
|
51
|
-
ArrayList<PVector> texcoords) {
|
52
|
-
family = GEOMETRY;
|
53
|
-
if (face.vertIdx.size() == 3) {
|
54
|
-
kind = TRIANGLES;
|
55
|
-
} else if (face.vertIdx.size() == 4) {
|
56
|
-
kind = QUADS;
|
57
|
-
} else {
|
58
|
-
kind = POLYGON;
|
59
|
-
}
|
60
|
-
|
61
|
-
stroke = false;
|
62
|
-
fill = true;
|
63
|
-
|
64
|
-
// Setting material properties for the new face
|
65
|
-
fillColor = rgbaValue(mtl.kd);
|
66
|
-
ambientColor = rgbaValue(mtl.ka);
|
67
|
-
specularColor = rgbaValue(mtl.ks);
|
68
|
-
shininess = mtl.ns;
|
69
|
-
if (mtl.kdMap != null) {
|
70
|
-
// If current material is textured, then tinting the texture using the
|
71
|
-
// diffuse color.
|
72
|
-
tintColor = rgbaValue(mtl.kd, mtl.d);
|
73
|
-
}
|
74
|
-
|
75
|
-
vertexCount = face.vertIdx.size();
|
76
|
-
vertices = new float[vertexCount][12];
|
77
|
-
for (int j = 0; j < face.vertIdx.size(); j++) {
|
78
|
-
int vertIdx, normIdx, texIdx;
|
79
|
-
PVector vert, norms, tex;
|
80
|
-
|
81
|
-
vert = norms = tex = null;
|
82
|
-
|
83
|
-
vertIdx = face.vertIdx.get(j).intValue() - 1;
|
84
|
-
vert = coords.get(vertIdx);
|
85
|
-
|
86
|
-
if (j < face.normIdx.size()) {
|
87
|
-
normIdx = face.normIdx.get(j).intValue() - 1;
|
88
|
-
if (-1 < normIdx) {
|
89
|
-
norms = normals.get(normIdx);
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
if (j < face.texIdx.size()) {
|
94
|
-
texIdx = face.texIdx.get(j).intValue() - 1;
|
95
|
-
if (-1 < texIdx) {
|
96
|
-
tex = texcoords.get(texIdx);
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
vertices[j][X] = vert.x;
|
101
|
-
vertices[j][Y] = vert.y;
|
102
|
-
vertices[j][Z] = vert.z;
|
84
|
+
vertexCount = face.vertIdx.size();
|
85
|
+
vertices = new float[vertexCount][12];
|
86
|
+
for (int j = 0; j < face.vertIdx.size(); j++){
|
87
|
+
int vertIdx, normIdx, texIdx;
|
88
|
+
PVector vert, norms, tex;
|
103
89
|
|
104
|
-
|
105
|
-
vertices[j][PGraphics.G] = mtl.kd.y;
|
106
|
-
vertices[j][PGraphics.B] = mtl.kd.z;
|
107
|
-
vertices[j][PGraphics.A] = 1;
|
90
|
+
vert = norms = tex = null;
|
108
91
|
|
109
|
-
|
110
|
-
|
111
|
-
vertices[j][PGraphics.NY] = norms.y;
|
112
|
-
vertices[j][PGraphics.NZ] = norms.z;
|
113
|
-
}
|
92
|
+
vertIdx = face.vertIdx.get(j) - 1;
|
93
|
+
vert = coords.get(vertIdx);
|
114
94
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
if (mtl != null && mtl.kdMap != null) {
|
121
|
-
image = mtl.kdMap;
|
122
|
-
}
|
95
|
+
if (j < face.normIdx.size()) {
|
96
|
+
normIdx = face.normIdx.get(j) - 1;
|
97
|
+
if (-1 < normIdx) {
|
98
|
+
norms = normals.get(normIdx);
|
123
99
|
}
|
124
|
-
|
100
|
+
}
|
125
101
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
ArrayList<PVector> texcoords) {
|
131
|
-
int mtlIdxCur = -1;
|
132
|
-
OBJMaterial mtl = null;
|
133
|
-
for (int i = 0; i < faces.size(); i++) {
|
134
|
-
OBJFace face = faces.get(i);
|
135
|
-
|
136
|
-
// Getting current material.
|
137
|
-
if (mtlIdxCur != face.matIdx || face.matIdx == -1) {
|
138
|
-
// To make sure that at least we get the default material
|
139
|
-
mtlIdxCur = PApplet.max(0, face.matIdx);
|
140
|
-
mtl = materials.get(mtlIdxCur);
|
141
|
-
}
|
142
|
-
|
143
|
-
// Creating child shape for current face.
|
144
|
-
PShape child = new PShapeOBJ(face, mtl, coords, normals, texcoords);
|
145
|
-
addChild(child);
|
102
|
+
if (j < face.texIdx.size()) {
|
103
|
+
texIdx = face.texIdx.get(j) - 1;
|
104
|
+
if (-1 < texIdx) {
|
105
|
+
tex = texcoords.get(texIdx);
|
146
106
|
}
|
107
|
+
}
|
108
|
+
|
109
|
+
vertices[j][X] = vert.x;
|
110
|
+
vertices[j][Y] = vert.y;
|
111
|
+
vertices[j][Z] = vert.z;
|
112
|
+
|
113
|
+
vertices[j][PGraphics.R] = mtl.kd.x;
|
114
|
+
vertices[j][PGraphics.G] = mtl.kd.y;
|
115
|
+
vertices[j][PGraphics.B] = mtl.kd.z;
|
116
|
+
vertices[j][PGraphics.A] = 1;
|
117
|
+
|
118
|
+
if (norms != null) {
|
119
|
+
vertices[j][PGraphics.NX] = norms.x;
|
120
|
+
vertices[j][PGraphics.NY] = norms.y;
|
121
|
+
vertices[j][PGraphics.NZ] = norms.z;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (tex != null) {
|
125
|
+
vertices[j][PGraphics.U] = tex.x;
|
126
|
+
vertices[j][PGraphics.V] = tex.y;
|
127
|
+
}
|
128
|
+
|
129
|
+
if (mtl != null && mtl.kdMap != null) {
|
130
|
+
image = mtl.kdMap;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
protected void addChildren(ArrayList<OBJFace> faces,
|
137
|
+
ArrayList<OBJMaterial> materials,
|
138
|
+
ArrayList<PVector> coords,
|
139
|
+
ArrayList<PVector> normals,
|
140
|
+
ArrayList<PVector> texcoords) {
|
141
|
+
int mtlIdxCur = -1;
|
142
|
+
OBJMaterial mtl = null;
|
143
|
+
for (int i = 0; i < faces.size(); i++) {
|
144
|
+
OBJFace face = faces.get(i);
|
145
|
+
|
146
|
+
// Getting current material.
|
147
|
+
if (mtlIdxCur != face.matIdx || face.matIdx == -1) {
|
148
|
+
// To make sure that at least we get the default material
|
149
|
+
mtlIdxCur = PApplet.max(0, face.matIdx);
|
150
|
+
mtl = materials.get(mtlIdxCur);
|
151
|
+
}
|
152
|
+
|
153
|
+
// Creating child shape for current face.
|
154
|
+
PShape child = new PShapeOBJ(face, mtl, coords, normals, texcoords);
|
155
|
+
addChild(child);
|
147
156
|
}
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
static protected void parseOBJ(PApplet parent, String path,
|
161
|
+
BufferedReader reader,
|
162
|
+
ArrayList<OBJFace> faces,
|
163
|
+
ArrayList<OBJMaterial> materials,
|
164
|
+
ArrayList<PVector> coords,
|
165
|
+
ArrayList<PVector> normals,
|
166
|
+
ArrayList<PVector> texcoords) {
|
167
|
+
Map<String, Integer> mtlTable = new HashMap<>();
|
168
|
+
int mtlIdxCur = -1;
|
169
|
+
boolean readv, readvn, readvt;
|
170
|
+
try {
|
171
|
+
|
172
|
+
readv = readvn = readvt = false;
|
173
|
+
String line;
|
174
|
+
String gname = "object";
|
175
|
+
while ((line = reader.readLine()) != null) {
|
176
|
+
// Parse the line.
|
177
|
+
line = line.trim();
|
178
|
+
if (line.equals("") || line.indexOf('#') == 0) {
|
179
|
+
// Empty line of comment, ignore line
|
180
|
+
continue;
|
181
|
+
}
|
148
182
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
183
|
+
// The below patch/hack comes from Carlos Tomas Marti and is a
|
184
|
+
// fix for single backslashes in Rhino obj files
|
185
|
+
|
186
|
+
// BEGINNING OF RHINO OBJ FILES HACK
|
187
|
+
// Statements can be broken in multiple lines using '\' at the
|
188
|
+
// end of a line.
|
189
|
+
// In regular expressions, the backslash is also an escape
|
190
|
+
// character.
|
191
|
+
// The regular expression \\ matches a single backslash. This
|
192
|
+
// regular expression as a Java string, becomes "\\\\".
|
193
|
+
// That's right: 4 backslashes to match a single one.
|
194
|
+
while (line.contains("\\")) {
|
195
|
+
line = line.split("\\\\")[0];
|
196
|
+
final String s = reader.readLine();
|
197
|
+
if (s != null)
|
198
|
+
line += s;
|
199
|
+
}
|
200
|
+
// END OF RHINO OBJ FILES HACK
|
201
|
+
|
202
|
+
String[] parts = line.split("\\s+");
|
203
|
+
// if not a blank line, process the line.
|
204
|
+
if (parts.length > 0) {
|
205
|
+
switch (parts[0]) {
|
206
|
+
case "v":
|
207
|
+
{
|
208
|
+
// vertex
|
209
|
+
PVector tempv = new PVector(Float.parseFloat(parts[1]),
|
210
|
+
Float.parseFloat(parts[2]),
|
211
|
+
Float.parseFloat(parts[3]));
|
212
|
+
coords.add(tempv);
|
213
|
+
readv = true;
|
214
|
+
break;
|
215
|
+
}
|
216
|
+
case "vn":
|
217
|
+
// normal
|
218
|
+
PVector tempn = new PVector(Float.parseFloat(parts[1]),
|
219
|
+
Float.parseFloat(parts[2]),
|
220
|
+
Float.parseFloat(parts[3]));
|
221
|
+
normals.add(tempn);
|
222
|
+
readvn = true;
|
223
|
+
break;
|
224
|
+
case "vt":
|
225
|
+
{
|
226
|
+
// uv, inverting v to take into account Processing's inverted Y axis
|
227
|
+
// with respect to OpenGL.
|
228
|
+
PVector tempv = new PVector(Float.parseFloat(parts[1]),
|
229
|
+
1 - Float.parseFloat(parts[2]));
|
230
|
+
texcoords.add(tempv);
|
231
|
+
readvt = true;
|
232
|
+
break;
|
233
|
+
}
|
234
|
+
// Object name is ignored, for now.
|
235
|
+
case "o":
|
236
|
+
break;
|
237
|
+
case "mtllib":
|
238
|
+
if (parts[1] != null) {
|
239
|
+
String fn = parts[1];
|
240
|
+
if (!fn.contains(File.separator) && !path.equals("")) {
|
241
|
+
// Relative file name, adding the base path.
|
242
|
+
fn = path + File.separator + fn;
|
243
|
+
}
|
244
|
+
BufferedReader mreader = parent.createReader(fn);
|
245
|
+
if (mreader != null) {
|
246
|
+
parseMTL(parent, fn, path, mreader, materials, mtlTable);
|
247
|
+
mreader.close();
|
170
248
|
}
|
249
|
+
} break;
|
250
|
+
case "g":
|
251
|
+
gname = 1 < parts.length ? parts[1] : "";
|
252
|
+
break;
|
253
|
+
case "usemtl":
|
254
|
+
// Getting index of current active material (will be applied on
|
255
|
+
// all subsequent faces).
|
256
|
+
if (parts[1] != null) {
|
257
|
+
String mtlname = parts[1];
|
258
|
+
if (mtlTable.containsKey(mtlname)) {
|
259
|
+
Integer tempInt = mtlTable.get(mtlname);
|
260
|
+
mtlIdxCur = tempInt;
|
261
|
+
} else {
|
262
|
+
mtlIdxCur = -1;
|
263
|
+
}
|
264
|
+
} break;
|
265
|
+
case "f":
|
266
|
+
// Face setting
|
267
|
+
OBJFace face = new OBJFace();
|
268
|
+
face.matIdx = mtlIdxCur;
|
269
|
+
face.name = gname;
|
270
|
+
for (int i = 1; i < parts.length; i++) {
|
271
|
+
String seg = parts[i];
|
272
|
+
|
273
|
+
if (seg.indexOf("/") > 0) {
|
274
|
+
String[] forder = seg.split("/");
|
275
|
+
|
276
|
+
if (forder.length > 2) {
|
277
|
+
// Getting vertex and texture and normal indexes.
|
278
|
+
if (forder[0].length() > 0 && readv) {
|
279
|
+
face.vertIdx.add(Integer.valueOf(forder[0]));
|
280
|
+
}
|
281
|
+
|
282
|
+
if (forder[1].length() > 0 && readvt) {
|
283
|
+
face.texIdx.add(Integer.valueOf(forder[1]));
|
284
|
+
}
|
171
285
|
|
172
|
-
|
173
|
-
|
174
|
-
// BEGINNING OF RHINO OBJ FILES HACK
|
175
|
-
// Statements can be broken in multiple lines using '\' at the
|
176
|
-
// end of a line.
|
177
|
-
// In regular expressions, the backslash is also an escape
|
178
|
-
// character.
|
179
|
-
// The regular expression \\ matches a single backslash. This
|
180
|
-
// regular expression as a Java string, becomes "\\\\".
|
181
|
-
// That's right: 4 backslashes to match a single one.
|
182
|
-
while (line.contains("\\")) {
|
183
|
-
line = line.split("\\\\")[0];
|
184
|
-
final String s = reader.readLine();
|
185
|
-
if (s != null) {
|
186
|
-
line += s;
|
286
|
+
if (forder[2].length() > 0 && readvn) {
|
287
|
+
face.normIdx.add(Integer.valueOf(forder[2]));
|
187
288
|
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
// if not a blank line, process the line.
|
193
|
-
if (parts.length > 0) {
|
194
|
-
if (parts[0].equals("v")) {
|
195
|
-
// vertex
|
196
|
-
PVector tempv = new PVector(Float.valueOf(parts[1]).floatValue(),
|
197
|
-
Float.valueOf(parts[2]).floatValue(),
|
198
|
-
Float.valueOf(parts[3]).floatValue());
|
199
|
-
coords.add(tempv);
|
200
|
-
readv = true;
|
201
|
-
} else if (parts[0].equals("vn")) {
|
202
|
-
// normal
|
203
|
-
PVector tempn = new PVector(Float.valueOf(parts[1]).floatValue(),
|
204
|
-
Float.valueOf(parts[2]).floatValue(),
|
205
|
-
Float.valueOf(parts[3]).floatValue());
|
206
|
-
normals.add(tempn);
|
207
|
-
readvn = true;
|
208
|
-
} else if (parts[0].equals("vt")) {
|
209
|
-
// uv, inverting v to take into account Processing's inverted Y axis
|
210
|
-
// with respect to OpenGL.
|
211
|
-
PVector tempv = new PVector(Float.valueOf(parts[1]).floatValue(),
|
212
|
-
1 - Float.valueOf(parts[2]).
|
213
|
-
floatValue());
|
214
|
-
texcoords.add(tempv);
|
215
|
-
readvt = true;
|
216
|
-
} else if (parts[0].equals("o")) {
|
217
|
-
// Object name is ignored, for now.
|
218
|
-
} else if (parts[0].equals("mtllib")) {
|
219
|
-
if (parts[1] != null) {
|
220
|
-
String fn = parts[1];
|
221
|
-
if (fn.indexOf(File.separator) == -1 && !path.equals("")) {
|
222
|
-
// Relative file name, adding the base path.
|
223
|
-
fn = path + File.separator + fn;
|
224
|
-
}
|
225
|
-
BufferedReader mreader = parent.createReader(fn);
|
226
|
-
if (mreader != null) {
|
227
|
-
parseMTL(parent, fn, path, mreader, materials, mtlTable);
|
228
|
-
mreader.close();
|
229
|
-
}
|
230
|
-
}
|
231
|
-
} else if (parts[0].equals("g")) {
|
232
|
-
gname = 1 < parts.length ? parts[1] : "";
|
233
|
-
} else if (parts[0].equals("usemtl")) {
|
234
|
-
// Getting index of current active material (will be applied on
|
235
|
-
// all subsequent faces).
|
236
|
-
if (parts[1] != null) {
|
237
|
-
String mtlname = parts[1];
|
238
|
-
if (mtlTable.containsKey(mtlname)) {
|
239
|
-
Integer tempInt = mtlTable.get(mtlname);
|
240
|
-
mtlIdxCur = tempInt.intValue();
|
241
|
-
} else {
|
242
|
-
mtlIdxCur = -1;
|
243
|
-
}
|
244
|
-
}
|
245
|
-
} else if (parts[0].equals("f")) {
|
246
|
-
// Face setting
|
247
|
-
OBJFace face = new OBJFace();
|
248
|
-
face.matIdx = mtlIdxCur;
|
249
|
-
face.name = gname;
|
250
|
-
|
251
|
-
for (int i = 1; i < parts.length; i++) {
|
252
|
-
String seg = parts[i];
|
253
|
-
|
254
|
-
if (seg.indexOf("/") > 0) {
|
255
|
-
String[] forder = seg.split("/");
|
256
|
-
|
257
|
-
if (forder.length > 2) {
|
258
|
-
// Getting vertex and texture and normal indexes.
|
259
|
-
if (forder[0].length() > 0 && readv) {
|
260
|
-
face.vertIdx.add(Integer.valueOf(forder[0]));
|
261
|
-
}
|
262
|
-
|
263
|
-
if (forder[1].length() > 0 && readvt) {
|
264
|
-
face.texIdx.add(Integer.valueOf(forder[1]));
|
265
|
-
}
|
266
|
-
|
267
|
-
if (forder[2].length() > 0 && readvn) {
|
268
|
-
face.normIdx.add(Integer.valueOf(forder[2]));
|
269
|
-
}
|
270
|
-
} else if (forder.length > 1) {
|
271
|
-
// Getting vertex and texture/normal indexes.
|
272
|
-
if (forder[0].length() > 0 && readv) {
|
273
|
-
face.vertIdx.add(Integer.valueOf(forder[0]));
|
274
|
-
}
|
275
|
-
|
276
|
-
if (forder[1].length() > 0) {
|
277
|
-
if (readvt) {
|
278
|
-
face.texIdx.add(Integer.valueOf(forder[1]));
|
279
|
-
} else if (readvn) {
|
280
|
-
face.normIdx.add(Integer.valueOf(forder[1]));
|
281
|
-
}
|
282
|
-
|
283
|
-
}
|
284
|
-
|
285
|
-
} else if (forder.length > 0) {
|
286
|
-
// Getting vertex index only.
|
287
|
-
if (forder[0].length() > 0 && readv) {
|
288
|
-
face.vertIdx.add(Integer.valueOf(forder[0]));
|
289
|
-
}
|
290
|
-
}
|
291
|
-
} else {
|
292
|
-
// Getting vertex index only.
|
293
|
-
if (seg.length() > 0 && readv) {
|
294
|
-
face.vertIdx.add(Integer.valueOf(seg));
|
295
|
-
}
|
296
|
-
}
|
297
|
-
}
|
298
|
-
|
299
|
-
faces.add(face);
|
289
|
+
} else if (forder.length > 1) {
|
290
|
+
// Getting vertex and texture/normal indexes.
|
291
|
+
if (forder[0].length() > 0 && readv) {
|
292
|
+
face.vertIdx.add(Integer.valueOf(forder[0]));
|
300
293
|
}
|
294
|
+
|
295
|
+
if (forder[1].length() > 0) {
|
296
|
+
if (readvt) {
|
297
|
+
face.texIdx.add(Integer.valueOf(forder[1]));
|
298
|
+
} else if (readvn) {
|
299
|
+
face.normIdx.add(Integer.valueOf(forder[1]));
|
300
|
+
}
|
301
|
+
|
302
|
+
}
|
303
|
+
|
304
|
+
} else if (forder.length > 0) {
|
305
|
+
// Getting vertex index only.
|
306
|
+
if (forder[0].length() > 0 && readv) {
|
307
|
+
face.vertIdx.add(Integer.valueOf(forder[0]));
|
308
|
+
}
|
309
|
+
}
|
310
|
+
} else {
|
311
|
+
// Getting vertex index only.
|
312
|
+
if (seg.length() > 0 && readv) {
|
313
|
+
face.vertIdx.add(Integer.valueOf(seg));
|
314
|
+
}
|
301
315
|
}
|
302
|
-
|
316
|
+
} faces.add(face);
|
317
|
+
break;
|
318
|
+
default:
|
319
|
+
break;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
303
323
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
324
|
+
if (materials.isEmpty()) {
|
325
|
+
// No materials definition so far. Adding one default material.
|
326
|
+
OBJMaterial defMtl = new OBJMaterial();
|
327
|
+
materials.add(defMtl);
|
328
|
+
}
|
309
329
|
|
310
|
-
|
311
|
-
e.printStackTrace();
|
312
|
-
}
|
330
|
+
} catch (IOException | NumberFormatException e) {
|
313
331
|
}
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
// Loading texture map.
|
339
|
-
String texname = parts[1];
|
340
|
-
if (texname.indexOf(File.separator) == -1 && !path.equals("")) {
|
341
|
-
// Relative file name, adding the base path.
|
342
|
-
texname = path + File.separator + texname;
|
343
|
-
}
|
344
|
-
|
345
|
-
File file = new File(parent.dataPath(texname));
|
346
|
-
if (file.exists()) {
|
347
|
-
currentMtl.kdMap = parent.loadImage(texname);
|
348
|
-
} else {
|
349
|
-
System.err.println("The texture map \"" + texname + "\" "
|
350
|
-
+ "in the materials definition file \"" + mtlfn + "\" "
|
351
|
-
+ "is missing or inaccessible, make sure "
|
352
|
-
+ "the URL is valid or that the file has been "
|
353
|
-
+ "added to your sketch and is readable.");
|
354
|
-
}
|
355
|
-
} else if (parts[0].equals("Ka") && parts.length > 3) {
|
356
|
-
// The ambient color of the material
|
357
|
-
currentMtl.ka.x = Float.valueOf(parts[1]).floatValue();
|
358
|
-
currentMtl.ka.y = Float.valueOf(parts[2]).floatValue();
|
359
|
-
currentMtl.ka.z = Float.valueOf(parts[3]).floatValue();
|
360
|
-
} else if (parts[0].equals("Kd") && parts.length > 3) {
|
361
|
-
// The diffuse color of the material
|
362
|
-
currentMtl.kd.x = Float.valueOf(parts[1]).floatValue();
|
363
|
-
currentMtl.kd.y = Float.valueOf(parts[2]).floatValue();
|
364
|
-
currentMtl.kd.z = Float.valueOf(parts[3]).floatValue();
|
365
|
-
} else if (parts[0].equals("Ks") && parts.length > 3) {
|
366
|
-
// The specular color weighted by the specular coefficient
|
367
|
-
currentMtl.ks.x = Float.valueOf(parts[1]).floatValue();
|
368
|
-
currentMtl.ks.y = Float.valueOf(parts[2]).floatValue();
|
369
|
-
currentMtl.ks.z = Float.valueOf(parts[3]).floatValue();
|
370
|
-
} else if ((parts[0].equals("d")
|
371
|
-
|| parts[0].equals("Tr")) && parts.length > 1) {
|
372
|
-
// Reading the alpha transparency.
|
373
|
-
currentMtl.d = Float.valueOf(parts[1]).floatValue();
|
374
|
-
} else if (parts[0].equals("Ns") && parts.length > 1) {
|
375
|
-
// The specular component of the Phong shading model
|
376
|
-
currentMtl.ns = Float.valueOf(parts[1]).floatValue();
|
377
|
-
}
|
378
|
-
}
|
379
|
-
}
|
332
|
+
}
|
333
|
+
|
334
|
+
|
335
|
+
static protected void parseMTL(PApplet parent, String mtlfn, String path,
|
336
|
+
BufferedReader reader,
|
337
|
+
ArrayList<OBJMaterial> materials,
|
338
|
+
Map<String, Integer> materialsHash) {
|
339
|
+
try {
|
340
|
+
String line;
|
341
|
+
OBJMaterial currentMtl = null;
|
342
|
+
while ((line = reader.readLine()) != null) {
|
343
|
+
// Parse the line
|
344
|
+
line = line.trim();
|
345
|
+
String[] parts = line.split("\\s+");
|
346
|
+
if (parts.length > 0) {
|
347
|
+
// Extract the material data.
|
348
|
+
if (parts[0].equals("newmtl")) {
|
349
|
+
// Starting new material.
|
350
|
+
String mtlname = parts[1];
|
351
|
+
currentMtl = addMaterial(mtlname, materials, materialsHash);
|
352
|
+
} else {
|
353
|
+
if (currentMtl == null) {
|
354
|
+
currentMtl = addMaterial("material" + materials.size(),
|
355
|
+
materials, materialsHash);
|
380
356
|
}
|
381
|
-
|
382
|
-
|
357
|
+
if (parts[0].equals("map_Kd") && parts.length > 1) {
|
358
|
+
// Loading texture map.
|
359
|
+
String texname = parts[1];
|
360
|
+
if (!texname.contains(File.separator) && !path.equals("")) {
|
361
|
+
// Relative file name, adding the base path.
|
362
|
+
texname = path + File.separator + texname;
|
363
|
+
}
|
364
|
+
|
365
|
+
File file = new File(parent.dataPath(texname));
|
366
|
+
if (file.exists()) {
|
367
|
+
currentMtl.kdMap = parent.loadImage(texname);
|
368
|
+
} else {
|
369
|
+
System.err.println("The texture map \"" + texname + "\" " +
|
370
|
+
"in the materials definition file \"" + mtlfn + "\" " +
|
371
|
+
"is missing or inaccessible, make sure " +
|
372
|
+
"the URL is valid or that the file has been " +
|
373
|
+
"added to your sketch and is readable.");
|
374
|
+
}
|
375
|
+
} else if (parts[0].equals("Ka") && parts.length > 3) {
|
376
|
+
// The ambient color of the material
|
377
|
+
currentMtl.ka.x = Float.parseFloat(parts[1]);
|
378
|
+
currentMtl.ka.y = Float.parseFloat(parts[2]);
|
379
|
+
currentMtl.ka.z = Float.parseFloat(parts[3]);
|
380
|
+
} else if (parts[0].equals("Kd") && parts.length > 3) {
|
381
|
+
// The diffuse color of the material
|
382
|
+
currentMtl.kd.x = Float.parseFloat(parts[1]);
|
383
|
+
currentMtl.kd.y = Float.parseFloat(parts[2]);
|
384
|
+
currentMtl.kd.z = Float.parseFloat(parts[3]);
|
385
|
+
} else if (parts[0].equals("Ks") && parts.length > 3) {
|
386
|
+
// The specular color weighted by the specular coefficient
|
387
|
+
currentMtl.ks.x = Float.parseFloat(parts[1]);
|
388
|
+
currentMtl.ks.y = Float.parseFloat(parts[2]);
|
389
|
+
currentMtl.ks.z = Float.parseFloat(parts[3]);
|
390
|
+
} else if ((parts[0].equals("d") ||
|
391
|
+
parts[0].equals("Tr")) && parts.length > 1) {
|
392
|
+
// Reading the alpha transparency.
|
393
|
+
currentMtl.d = Float.parseFloat(parts[1]);
|
394
|
+
} else if (parts[0].equals("Ns") && parts.length > 1) {
|
395
|
+
// The specular component of the Phong shading model
|
396
|
+
currentMtl.ns = Float.parseFloat(parts[1]);
|
397
|
+
}
|
398
|
+
}
|
383
399
|
}
|
400
|
+
}
|
401
|
+
} catch (IOException | NumberFormatException e) {
|
384
402
|
}
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
403
|
+
}
|
404
|
+
|
405
|
+
protected static OBJMaterial addMaterial(String mtlname,
|
406
|
+
ArrayList<OBJMaterial> materials,
|
407
|
+
Map<String, Integer> materialsHash) {
|
408
|
+
OBJMaterial currentMtl = new OBJMaterial(mtlname);
|
409
|
+
materialsHash.put(mtlname, materials.size());
|
410
|
+
materials.add(currentMtl);
|
411
|
+
return currentMtl;
|
412
|
+
}
|
413
|
+
|
414
|
+
protected static int rgbaValue(PVector color) {
|
415
|
+
return 0xFF000000 | ((int)(color.x * 255) << 16) |
|
416
|
+
((int)(color.y * 255) << 8) |
|
417
|
+
(int)(color.z * 255);
|
418
|
+
}
|
419
|
+
|
420
|
+
|
421
|
+
protected static int rgbaValue(PVector color, float alpha) {
|
422
|
+
return ((int)(alpha * 255) << 24) |
|
423
|
+
((int)(color.x * 255) << 16) |
|
424
|
+
((int)(color.y * 255) << 8) |
|
425
|
+
(int)(color.z * 255);
|
426
|
+
}
|
427
|
+
|
428
|
+
|
429
|
+
// Stores a face from an OBJ file
|
430
|
+
static protected class OBJFace {
|
431
|
+
ArrayList<Integer> vertIdx;
|
432
|
+
ArrayList<Integer> texIdx;
|
433
|
+
ArrayList<Integer> normIdx;
|
434
|
+
int matIdx;
|
435
|
+
String name;
|
436
|
+
|
437
|
+
OBJFace() {
|
438
|
+
vertIdx = new ArrayList<>();
|
439
|
+
texIdx = new ArrayList<>();
|
440
|
+
normIdx = new ArrayList<>();
|
441
|
+
matIdx = -1;
|
442
|
+
name = "";
|
393
443
|
}
|
444
|
+
}
|
394
445
|
|
395
|
-
protected static int rgbaValue(PVector color) {
|
396
|
-
return 0xFF000000 | ((int) (color.x * 255) << 16)
|
397
|
-
| ((int) (color.y * 255) << 8)
|
398
|
-
| (int) (color.z * 255);
|
399
|
-
}
|
400
446
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
447
|
+
static protected String getBasePath(PApplet parent, String filename) {
|
448
|
+
// Obtaining the path
|
449
|
+
File file = new File(parent.dataPath(filename));
|
450
|
+
if (!file.exists()) {
|
451
|
+
file = parent.sketchFile(filename);
|
406
452
|
}
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
453
|
+
String absolutePath = file.getAbsolutePath();
|
454
|
+
return absolutePath.substring(0,
|
455
|
+
absolutePath.lastIndexOf(File.separator));
|
456
|
+
}
|
457
|
+
|
458
|
+
|
459
|
+
// Stores a material defined in an MTL file.
|
460
|
+
static protected class OBJMaterial {
|
461
|
+
String name;
|
462
|
+
PVector ka;
|
463
|
+
PVector kd;
|
464
|
+
PVector ks;
|
465
|
+
float d;
|
466
|
+
float ns;
|
467
|
+
PImage kdMap;
|
468
|
+
|
469
|
+
OBJMaterial() {
|
470
|
+
this("default");
|
424
471
|
}
|
425
472
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
absolutePath.lastIndexOf(File.separator));
|
435
|
-
}
|
436
|
-
|
437
|
-
// Stores a material defined in an MTL file.
|
438
|
-
static protected class OBJMaterial {
|
439
|
-
|
440
|
-
String name;
|
441
|
-
PVector ka;
|
442
|
-
PVector kd;
|
443
|
-
PVector ks;
|
444
|
-
float d;
|
445
|
-
float ns;
|
446
|
-
PImage kdMap;
|
447
|
-
|
448
|
-
OBJMaterial() {
|
449
|
-
this("default");
|
450
|
-
}
|
451
|
-
|
452
|
-
OBJMaterial(String name) {
|
453
|
-
this.name = name;
|
454
|
-
ka = new PVector(0.5f, 0.5f, 0.5f);
|
455
|
-
kd = new PVector(0.5f, 0.5f, 0.5f);
|
456
|
-
ks = new PVector(0.5f, 0.5f, 0.5f);
|
457
|
-
d = 1.0f;
|
458
|
-
ns = 0.0f;
|
459
|
-
kdMap = null;
|
460
|
-
}
|
473
|
+
OBJMaterial(String name) {
|
474
|
+
this.name = name;
|
475
|
+
ka = new PVector(0.5f, 0.5f, 0.5f);
|
476
|
+
kd = new PVector(0.5f, 0.5f, 0.5f);
|
477
|
+
ks = new PVector(0.5f, 0.5f, 0.5f);
|
478
|
+
d = 1.0f;
|
479
|
+
ns = 0.0f;
|
480
|
+
kdMap = null;
|
461
481
|
}
|
482
|
+
}
|
462
483
|
}
|