Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
CameraPane.java
....@@ -464,10 +464,12 @@
464464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465465 {
466466 //gl.glBegin(gl.GL_TRIANGLES);
467
- boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
468
+ // TEST LIVE NORMALS && !obj.dontselect
469
+ ;
468470 if (!hasnorm)
469471 {
470
- // System.out.println("FUCK!!");
472
+ // System.out.println("Mesh normal");
471473 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472474 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473475 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1194,12 @@
11921194 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931195 }
11941196 }
1197
+
11951198 if (flipV)
11961199 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971200 else
11981201 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1202
+
11991203 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001204 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011205
....@@ -1215,10 +1219,12 @@
12151219 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161220 }
12171221 }
1222
+
12181223 if (flipV)
12191224 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201225 else
12211226 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1227
+
12221228 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231229 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241230
....@@ -1246,8 +1252,10 @@
12461252 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471253 else
12481254 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1255
+
12491256 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501257 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1258
+
12511259 count2 += 2;
12521260 count3 += 3;
12531261 }
....@@ -1890,7 +1898,7 @@
18901898 void PushMatrix(double[][] matrix)
18911899 {
18921900 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
18941902 }
18951903
18961904 void PushMatrix()
....@@ -7921,6 +7929,64 @@
79217929 ReleaseTexture(pigment, false);
79227930 }
79237931
7932
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7933
+ {
7934
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7935
+ {
7936
+ return;
7937
+ }
7938
+
7939
+ if (tex == null)
7940
+ {
7941
+ ReleaseTexture(null, false);
7942
+ return;
7943
+ }
7944
+
7945
+ String pigment = Object3D.GetPigment(tex);
7946
+
7947
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7948
+ {
7949
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7950
+ // System.out.println("; bump = " + bump);
7951
+ }
7952
+
7953
+ if (pigment.equals(""))
7954
+ {
7955
+ pigment = null;
7956
+ }
7957
+
7958
+ ReleaseTexture(pigment, false);
7959
+ }
7960
+
7961
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7962
+ {
7963
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7964
+ {
7965
+ return;
7966
+ }
7967
+
7968
+ if (tex == null)
7969
+ {
7970
+ ReleaseTexture(null, true);
7971
+ return;
7972
+ }
7973
+
7974
+ String bump = Object3D.GetBump(tex);
7975
+
7976
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7977
+ {
7978
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7979
+ // System.out.println("; bump = " + bump);
7980
+ }
7981
+
7982
+ if (bump.equals(""))
7983
+ {
7984
+ bump = null;
7985
+ }
7986
+
7987
+ ReleaseTexture(bump, true);
7988
+ }
7989
+
79247990 void ReleaseTexture(String tex, boolean bump)
79257991 {
79267992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8067,6 +8133,73 @@
80678133 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
80688134
80698135 return; // true;
8136
+ }
8137
+
8138
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8139
+ {
8140
+ if (// DrawMode() != 0 || /*tex == null ||*/
8141
+ ambientOcclusion ) // || !textureon)
8142
+ {
8143
+ return; // false;
8144
+ }
8145
+
8146
+ if (tex == null)
8147
+ {
8148
+ BindTexture(null,false,resolution);
8149
+ return;
8150
+ }
8151
+
8152
+ String pigment = Object3D.GetPigment(tex);
8153
+
8154
+ usedtextures.put(pigment, pigment);
8155
+
8156
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8157
+ {
8158
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8159
+ // System.out.println("; bump = " + bump);
8160
+ }
8161
+
8162
+ if (pigment.equals(""))
8163
+ {
8164
+ pigment = null;
8165
+ }
8166
+
8167
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8168
+ BindTexture(pigment, false, resolution);
8169
+ }
8170
+
8171
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8172
+ {
8173
+ if (// DrawMode() != 0 || /*tex == null ||*/
8174
+ ambientOcclusion ) // || !textureon)
8175
+ {
8176
+ return; // false;
8177
+ }
8178
+
8179
+ if (tex == null)
8180
+ {
8181
+ BindTexture(null,true,resolution);
8182
+ return;
8183
+ }
8184
+
8185
+ String bump = Object3D.GetBump(tex);
8186
+
8187
+ usedtextures.put(bump, bump);
8188
+
8189
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8190
+ {
8191
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8192
+ // System.out.println("; bump = " + bump);
8193
+ }
8194
+
8195
+ if (bump.equals(""))
8196
+ {
8197
+ bump = null;
8198
+ }
8199
+
8200
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8201
+ BindTexture(bump, true, resolution);
8202
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
80708203 }
80718204
80728205 java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
....@@ -9335,7 +9468,7 @@
93359468
93369469 if (renderCamera != lightCamera)
93379470 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93399472
93409473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93419474
....@@ -9351,7 +9484,7 @@
93519484
93529485 if (renderCamera != lightCamera)
93539486 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93559488
93569489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93579490
....@@ -10550,7 +10683,7 @@
1055010683 // if (parentcam != renderCamera) // not a light
1055110684 if (cam != lightCamera)
1055210685 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
- LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1055410687
1055510688 for (int j = 0; j < 4; j++)
1055610689 {
....@@ -10565,7 +10698,7 @@
1056510698 // if (parentcam != renderCamera) // not a light
1056610699 if (cam != lightCamera)
1056710700 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
- LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1056910702
1057010703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1057110704
....@@ -10959,7 +11092,7 @@
1095911092
1096011093 // if (cam != lightCamera)
1096111094 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
- LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
11095
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1096311096 }
1096411097
1096511098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10981,7 +11114,7 @@
1098111114 {
1098211115 if (cam != lightCamera)
1098311116 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
- LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013
11117
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1098511118 }
1098611119
1098711120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11894,7 +12027,7 @@
1189412027 for (int i = tp.size(); --i >= 0;)
1189512028 {
1189612029 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11897
- LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
12030
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1189812031 }
1189912032
1190012033
....@@ -11912,7 +12045,7 @@
1191212045 }
1191312046
1191412047 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
- LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013
12048
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1191612049
1191712050 LA.xformPos(light, renderCamera.toScreen, light);
1191812051
....@@ -13833,6 +13966,8 @@
1383313966
1383413967 public void mouseDragged(MouseEvent e)
1383513968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
1383613971 //System.out.println("mouseDragged: " + e);
1383713972 if (isRenderer)
1383813973 movingcamera = true;
....@@ -14398,6 +14533,8 @@
1439814533
1439914534 public void mouseReleased(MouseEvent e)
1440014535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1440114538 movingcamera = false;
1440214539 X = Y = 0;
1440314540 //System.out.println("mouseReleased: " + e);
....@@ -15513,12 +15650,17 @@
1551315650 {
1551415651 switch (object.selection.get(0).hitSomething)
1551515652 {
15516
- case Object3D.hitCenter: gr.setColor(Color.pink); break;
15517
- case Object3D.hitRotate: gr.setColor(Color.green); break;
15518
- case Object3D.hitScale: gr.setColor(Color.cyan); break;
15653
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15654
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15655
+ break;
15656
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15657
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15658
+ break;
15659
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15660
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15661
+ break;
1551915662 }
1552015663
15521
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1552215664 }
1552315665 }
1552415666 }