Normand Briere
2019-05-05 d7bc8865056ea0d35df261e719f92e1422af7c6e
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -2299,6 +2300,7 @@
22992300 {
23002301 if (newWindow)
23012302 {
2303
+ new Exception().printStackTrace();
23022304 System.exit(0);
23032305 if (parent != null)
23042306 {
....@@ -2905,7 +2907,8 @@
29052907 {
29062908 if (bRep != null)
29072909 {
2908
- bRep.GenUV();
2910
+ bRep.GenUV(); //1);
2911
+ //bRep.UnfoldUV();
29092912 Touch();
29102913 }
29112914 }
....@@ -5156,10 +5159,34 @@
51565159
51575160 // System.out.println("Fullname = " + fullname);
51585161
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5162
+ // Does not work on Windows due to C:
5163
+// if (fullname.name.indexOf(":") == -1)
5164
+// return fullname.name;
5165
+//
5166
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615167
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5168
+ String[] split = fullname.name.split(":");
5169
+
5170
+ if (split.length == 0)
5171
+ {
5172
+ return "";
5173
+ }
5174
+
5175
+ if (split.length <= 2)
5176
+ {
5177
+ if (fullname.name.endsWith(":"))
5178
+ {
5179
+ // Windows
5180
+ return fullname.name.substring(0, fullname.name.length()-1);
5181
+ }
5182
+
5183
+ return split[0];
5184
+ }
5185
+
5186
+ // Windows
5187
+ assert(split.length == 4);
5188
+
5189
+ return split[0] + ":" + split[1];
51635190 }
51645191
51655192 static String GetBump(cTexture fullname)
....@@ -5168,10 +5195,38 @@
51685195 return "";
51695196
51705197 // System.out.println("Fullname = " + fullname);
5171
- if (fullname.name.indexOf(":") == -1)
5172
- return "";
5173
-
5174
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5198
+ // Does not work on Windows due to C:
5199
+// if (fullname.name.indexOf(":") == -1)
5200
+// return "";
5201
+//
5202
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5203
+ String[] split = fullname.name.split(":");
5204
+
5205
+ if (split.length == 0)
5206
+ {
5207
+ return "";
5208
+ }
5209
+
5210
+ if (split.length == 1)
5211
+ {
5212
+ return "";
5213
+ }
5214
+
5215
+ if (split.length == 2)
5216
+ {
5217
+ if (fullname.name.endsWith(":"))
5218
+ {
5219
+ // Windows
5220
+ return "";
5221
+ }
5222
+
5223
+ return split[1];
5224
+ }
5225
+
5226
+ // Windows
5227
+ assert(split.length == 4);
5228
+
5229
+ return split[2] + ":" + split[3];
51755230 }
51765231
51775232 String GetPigmentTexture()
....@@ -5245,7 +5300,7 @@
52455300 System.out.print("; textures = " + textures);
52465301 System.out.println("; usedtextures = " + usedtextures);
52475302
5248
- if (GetTextures() == null)
5303
+ if (GetTextures() == null) // What is that??
52495304 GetTextures().name = ":";
52505305
52515306 String texname = tex;
....@@ -5371,7 +5426,7 @@
53715426 return;
53725427 }
53735428
5374
- javax.media.opengl.GL gl = display.GetGL();
5429
+ //javax.media.opengl.GL gl = display.GetGL();
53755430
53765431 /*
53775432 if (touched)
....@@ -5423,7 +5478,7 @@
54235478 //if (displaylist == -1 && usecalllists)
54245479 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255480 {
5426
- bRep.displaylist = gl.glGenLists(1);
5481
+ bRep.displaylist = display.GenList();
54275482 assert(bRep.displaylist != 0);
54285483 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295484 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5490,16 @@
54355490 if (usecalllists)
54365491 {
54375492 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5493
+ display.NewList(bRep.displaylist);
54395494 }
5495
+
54405496 CallList(display, root, selected, blocked);
5497
+
54415498 // compiled = true;
54425499 if (usecalllists)
54435500 {
54445501 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5502
+ display.EndList();
54465503 }
54475504 //gl.glDrawBuffer(gl.GL_BACK);
54485505 // XXX touched = false;
....@@ -5490,7 +5547,7 @@
54905547 if (display.DrawMode() == iCameraPane.SHADOW)
54915548 {
54925549 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5550
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945551 {
54955552 //System.out.print("CULLED");
54965553 culled = true;
....@@ -5498,7 +5555,7 @@
54985555 }
54995556 else
55005557 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5558
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025559 culled = true;
55035560
55045561 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5595,7 @@
55385595 {
55395596 if (GetBRep() != null)
55405597 {
5541
- CameraPane.NextIndex(this, gl);
5598
+ display.NextIndex();
55425599 // vertex color conflict : gl.glCallList(list);
55435600 DrawNode(display, root, selected);
55445601 if (this instanceof BezierPatch)
....@@ -5595,7 +5652,7 @@
55955652
55965653 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55975654 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
5655
+ display.CallList(bRep.displaylist);
55995656 // june 2013 drawSelf(display, root, selected);
56005657 }
56015658 }
....@@ -5895,9 +5952,10 @@
58955952 return;
58965953 }
58975954
5955
+ //bRep.GenUV(1/material.diffuseness);
58985956 // bRep.lock = true;
58995957
5900
- javax.media.opengl.GL gl = display.GetGL();
5958
+ //javax.media.opengl.GL gl = display.GetGL();
59015959
59025960 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59035961 {
....@@ -5914,23 +5972,7 @@
59145972
59155973 bRep.getMinMax(min, max, 100);
59165974
5917
- gl.glBegin(gl.GL_LINES);
5918
-
5919
- gl.glVertex3d(min.x, min.y, min.z);
5920
- gl.glVertex3d(min.x, min.y, max.z);
5921
- gl.glVertex3d(min.x, min.y, min.z);
5922
- gl.glVertex3d(min.x, max.y, min.z);
5923
- gl.glVertex3d(min.x, min.y, min.z);
5924
- gl.glVertex3d(max.x, min.y, min.z);
5925
-
5926
- gl.glVertex3d(max.x, max.y, max.z);
5927
- gl.glVertex3d(min.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, max.y, max.z);
5929
- gl.glVertex3d(max.x, min.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, max.z);
5931
- gl.glVertex3d(max.x, max.y, min.z);
5932
-
5933
- gl.glEnd();
5975
+ display.DrawBox(min, max);
59345976
59355977 return;
59365978 }
....@@ -5984,178 +6026,14 @@
59846026 new Exception().printStackTrace();
59856027 return;
59866028 }
5987
-
5988
- // TRIANGLE STRIP ARRAY
5989
- if (bRep.trimmed)
5990
- {
5991
- float[] v = bRep.getRawVertices();
5992
- float[] n = bRep.getRawNormals();
5993
- float[] c = bRep.getRawColors();
5994
- float[] uv = bRep.getRawUVMap();
5995
-
5996
- int count2 = 0;
5997
- int count3 = 0;
5998
-
5999
- if (n.length > 0)
6000
- {
6001
- for (int i = 0; i < strips.length; i++)
6002
- {
6003
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6004
-
6005
- /*
6006
- boolean locked = false;
6007
- float eps = 0.1f;
6008
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6009
-
6010
- int dot = 0;
6011
-
6012
- if ((dot&1) == 0)
6013
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6014
-
6015
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6016
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6017
- else
6018
- {
6019
- locked = true;
6020
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6021
- }
6022
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6023
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6024
- if (hasnorm)
6025
- {
6026
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6027
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6028
- }
6029
-
6030
- if ((dot&4) == 0)
6031
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6032
-
6033
- if (wrap || !locked && (dot&8) != 0)
6034
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6035
- else
6036
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6037
-
6038
- f.dot = dot;
6039
- */
6040
-
6041
- if (!selectmode)
6042
- {
6043
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6044
- {
6045
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6046
- } else
6047
- {
6048
- gl.glNormal3f(0, 0, 1);
6049
- }
6050
-
6051
- if (c != null)
6052
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6053
- {
6054
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6055
- }
6056
- }
6057
- if (flipV)
6058
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6059
- else
6060
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6061
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6062
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6063
-
6064
- count2 += 2;
6065
- count3 += 3;
6066
- if (!selectmode)
6067
- {
6068
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6069
- {
6070
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6071
- } else
6072
- {
6073
- gl.glNormal3f(0, 0, 1);
6074
- }
6075
- if (c != null)
6076
- {
6077
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6078
- }
6079
- }
6080
- if (flipV)
6081
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6082
- else
6083
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6084
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6085
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6086
-
6087
- count2 += 2;
6088
- count3 += 3;
6089
- for (int j = 0; j < strips[i] - 2; j++)
6090
- {
6091
- //gl.glTexCoord2d(...);
6092
- if (!selectmode)
6093
- {
6094
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6095
- {
6096
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6097
- } else
6098
- {
6099
- gl.glNormal3f(0, 0, 1);
6100
- }
6101
- if (c != null)
6102
- {
6103
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6104
- }
6105
- }
6106
-
6107
- if (flipV)
6108
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6109
- else
6110
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6111
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6112
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6113
- count2 += 2;
6114
- count3 += 3;
6115
- }
6116
-
6117
- gl.glEnd();
6118
- }
6119
- }
6120
-
6121
- assert count3 == v.length;
6122
- }
6123
- else // !trimmed
6124
- {
6125
- int count = 0;
6126
- for (int i = 0; i < strips.length; i++)
6127
- {
6128
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6129
-
6130
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6131
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6132
-
6133
- drawVertex(gl, p, selectmode);
6134
- drawVertex(gl, q, selectmode);
6135
-
6136
- for (int j = 0; j < strips[i] - 2; j++)
6137
- {
6138
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6139
-
6140
-// if (j%2 == 0)
6141
-// drawFace(p, q, r, display, null);
6142
-// else
6143
-// drawFace(p, r, q, display, null);
6144
-
6145
-// p = q;
6146
-// q = r;
6147
- drawVertex(gl, r, selectmode);
6148
- }
6149
-
6150
- gl.glEnd();
6151
- }
6152
- }
6029
+
6030
+ display.DrawGeometry(bRep, flipV, selectmode);
61536031 } else // catch (Error e)
61546032 {
61556033 // TRIANGLE ARRAY
61566034 if (IsOpaque()) // Static())
61576035 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6036
+ display.StartTriangles();
61596037 int facecount = bRep.FaceCount();
61606038 for (int i = 0; i < facecount; i++)
61616039 {
....@@ -6220,7 +6098,7 @@
62206098
62216099 display.DrawFace(this, p, q, r, face);
62226100 }
6223
- gl.glEnd();
6101
+ display.EndTriangles();
62246102 }
62256103 else
62266104 {
....@@ -6249,8 +6127,8 @@
62496127 //System.out.println("SORT");
62506128
62516129 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6130
+
6131
+ display.StartTriangles();
62546132 for (int i = 0; i < facecount; i++)
62556133 {
62566134 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6142,12 @@
62646142
62656143 display.DrawFace(this, p, q, r, face);
62666144 }
6267
- gl.glEnd();
6145
+ display.EndTriangles();
62686146 }
62696147
62706148 if (false) // live && support != null && support.bRep != null) // debug weights
62716149 {
6150
+ /*
62726151 gl.glDisable(gl.GL_LIGHTING);
62736152 float[] colorV = new float[3];
62746153
....@@ -6347,6 +6226,7 @@
63476226 // gl.glEnd();
63486227 }
63496228 }
6229
+ */
63506230 }
63516231 }
63526232
....@@ -6405,22 +6285,6 @@
64056285 void Print(Vertex v)
64066286 {
64076287 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6408
- }
6409
-
6410
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6411
- {
6412
- if (!selectmode)
6413
- {
6414
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6415
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6416
-
6417
- if (flipV)
6418
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6419
- else
6420
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6421
- }
6422
-
6423
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64246288 }
64256289
64266290 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7566,6 +7430,7 @@
75667430 objectUI.closeUI();
75677431 if (editWindow != null)
75687432 {
7433
+ editWindow.ctrlPanel.FlushUI();
75697434 editWindow.refreshContents();
75707435 } // ? new
75717436 objectUI = null;