.. | .. |
---|
56 | 56 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 57 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 58 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 59 | |
---|
62 | 60 | boolean DISPLAYTEXT = false; |
---|
63 | 61 | //boolean REDUCETEXTURE = true; |
---|
.. | .. |
---|
92 | 90 | |
---|
93 | 91 | static int tickcount = 0; // slow pose issue |
---|
94 | 92 | |
---|
| 93 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 94 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 95 | static boolean BOXMODE = false; |
---|
96 | 96 | static boolean IMAGEFLIP = false; |
---|
97 | 97 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 106 | static boolean OEIL = true; |
---|
107 | 107 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 108 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 109 | +static boolean SWITCH = true; // false; |
---|
110 | 110 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 111 | static boolean PAINTMODE = false; |
---|
112 | 112 | |
---|
.. | .. |
---|
150 | 150 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 151 | } |
---|
152 | 152 | |
---|
| 153 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 154 | + |
---|
153 | 155 | void SetAsGLRenderer(boolean b) |
---|
154 | 156 | { |
---|
155 | 157 | isRenderer = b; |
---|
.. | .. |
---|
191 | 193 | |
---|
192 | 194 | /// INTERFACE |
---|
193 | 195 | |
---|
| 196 | + public javax.media.opengl.GL GetGL0() |
---|
| 197 | + { |
---|
| 198 | + return null; |
---|
| 199 | + } |
---|
| 200 | + |
---|
| 201 | + public int GenList() |
---|
| 202 | + { |
---|
| 203 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 204 | + return gl.glGenLists(1); |
---|
| 205 | + } |
---|
| 206 | + |
---|
| 207 | + public void NewList(int id) |
---|
| 208 | + { |
---|
| 209 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 210 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 211 | + } |
---|
| 212 | + |
---|
| 213 | + public void CallList(int id) |
---|
| 214 | + { |
---|
| 215 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 216 | + gl.glCallList(id); |
---|
| 217 | + } |
---|
| 218 | + |
---|
| 219 | + public void EndList() |
---|
| 220 | + { |
---|
| 221 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 222 | + gl.glEndList(); |
---|
| 223 | + } |
---|
| 224 | + |
---|
194 | 225 | public boolean IsBoxMode() |
---|
195 | 226 | { |
---|
196 | 227 | return BOXMODE; |
---|
| 228 | + } |
---|
| 229 | + |
---|
| 230 | + public boolean IsZoomBoxMode() |
---|
| 231 | + { |
---|
| 232 | + return ZOOMBOXMODE; |
---|
197 | 233 | } |
---|
198 | 234 | |
---|
199 | 235 | public void ClearDepth() |
---|
.. | .. |
---|
428 | 464 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
429 | 465 | { |
---|
430 | 466 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
431 | | - 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 | + ; |
---|
432 | 470 | if (!hasnorm) |
---|
433 | 471 | { |
---|
434 | | - // System.out.println("FUCK!!"); |
---|
| 472 | + // System.out.println("Mesh normal"); |
---|
435 | 473 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
436 | 474 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
437 | 475 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1059 | 1097 | gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
1060 | 1098 | } |
---|
1061 | 1099 | |
---|
| 1100 | + public void DrawBox(cVector min, cVector max) |
---|
| 1101 | + { |
---|
| 1102 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1103 | + gl.glBegin(gl.GL_LINES); |
---|
| 1104 | + |
---|
| 1105 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1106 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1107 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1108 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1109 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1110 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1111 | + |
---|
| 1112 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1113 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1114 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1115 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1116 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1117 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1118 | + |
---|
| 1119 | + gl.glEnd(); |
---|
| 1120 | + } |
---|
| 1121 | + |
---|
| 1122 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1123 | + { |
---|
| 1124 | + int[] strips = bRep.getRawIndices(); |
---|
| 1125 | + |
---|
| 1126 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1127 | + |
---|
| 1128 | + // TRIANGLE STRIP ARRAY |
---|
| 1129 | + if (bRep.trimmed) |
---|
| 1130 | + { |
---|
| 1131 | + float[] v = bRep.getRawVertices(); |
---|
| 1132 | + float[] n = bRep.getRawNormals(); |
---|
| 1133 | + float[] c = bRep.getRawColors(); |
---|
| 1134 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1135 | + |
---|
| 1136 | + int count2 = 0; |
---|
| 1137 | + int count3 = 0; |
---|
| 1138 | + |
---|
| 1139 | + if (n.length > 0) |
---|
| 1140 | + { |
---|
| 1141 | + for (int i = 0; i < strips.length; i++) |
---|
| 1142 | + { |
---|
| 1143 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1144 | + |
---|
| 1145 | + /* |
---|
| 1146 | + boolean locked = false; |
---|
| 1147 | + float eps = 0.1f; |
---|
| 1148 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1149 | + |
---|
| 1150 | + int dot = 0; |
---|
| 1151 | + |
---|
| 1152 | + if ((dot&1) == 0) |
---|
| 1153 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1154 | + |
---|
| 1155 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1156 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1157 | + else |
---|
| 1158 | + { |
---|
| 1159 | + locked = true; |
---|
| 1160 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1161 | + } |
---|
| 1162 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1163 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1164 | + if (hasnorm) |
---|
| 1165 | + { |
---|
| 1166 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1167 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1168 | + } |
---|
| 1169 | + |
---|
| 1170 | + if ((dot&4) == 0) |
---|
| 1171 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1172 | + |
---|
| 1173 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1174 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1175 | + else |
---|
| 1176 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1177 | + |
---|
| 1178 | + f.dot = dot; |
---|
| 1179 | + */ |
---|
| 1180 | + |
---|
| 1181 | + if (!selectmode) |
---|
| 1182 | + { |
---|
| 1183 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1184 | + { |
---|
| 1185 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1186 | + } else |
---|
| 1187 | + { |
---|
| 1188 | + gl.glNormal3f(0, 0, 1); |
---|
| 1189 | + } |
---|
| 1190 | + |
---|
| 1191 | + if (c != null) |
---|
| 1192 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1193 | + { |
---|
| 1194 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1195 | + } |
---|
| 1196 | + } |
---|
| 1197 | + |
---|
| 1198 | + if (flipV) |
---|
| 1199 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1200 | + else |
---|
| 1201 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1202 | + |
---|
| 1203 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1204 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1205 | + |
---|
| 1206 | + count2 += 2; |
---|
| 1207 | + count3 += 3; |
---|
| 1208 | + if (!selectmode) |
---|
| 1209 | + { |
---|
| 1210 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1211 | + { |
---|
| 1212 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1213 | + } else |
---|
| 1214 | + { |
---|
| 1215 | + gl.glNormal3f(0, 0, 1); |
---|
| 1216 | + } |
---|
| 1217 | + if (c != null) |
---|
| 1218 | + { |
---|
| 1219 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1220 | + } |
---|
| 1221 | + } |
---|
| 1222 | + |
---|
| 1223 | + if (flipV) |
---|
| 1224 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1225 | + else |
---|
| 1226 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1227 | + |
---|
| 1228 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1229 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1230 | + |
---|
| 1231 | + count2 += 2; |
---|
| 1232 | + count3 += 3; |
---|
| 1233 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1234 | + { |
---|
| 1235 | + //gl.glTexCoord2d(...); |
---|
| 1236 | + if (!selectmode) |
---|
| 1237 | + { |
---|
| 1238 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1239 | + { |
---|
| 1240 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1241 | + } else |
---|
| 1242 | + { |
---|
| 1243 | + gl.glNormal3f(0, 0, 1); |
---|
| 1244 | + } |
---|
| 1245 | + if (c != null) |
---|
| 1246 | + { |
---|
| 1247 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1248 | + } |
---|
| 1249 | + } |
---|
| 1250 | + |
---|
| 1251 | + if (flipV) |
---|
| 1252 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1253 | + else |
---|
| 1254 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1255 | + |
---|
| 1256 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1257 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1258 | + |
---|
| 1259 | + count2 += 2; |
---|
| 1260 | + count3 += 3; |
---|
| 1261 | + } |
---|
| 1262 | + |
---|
| 1263 | + gl.glEnd(); |
---|
| 1264 | + } |
---|
| 1265 | + } |
---|
| 1266 | + |
---|
| 1267 | + assert count3 == v.length; |
---|
| 1268 | + } |
---|
| 1269 | + else // !trimmed |
---|
| 1270 | + { |
---|
| 1271 | + int count = 0; |
---|
| 1272 | + for (int i = 0; i < strips.length; i++) |
---|
| 1273 | + { |
---|
| 1274 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1275 | + |
---|
| 1276 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1277 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1278 | + |
---|
| 1279 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1280 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1281 | + |
---|
| 1282 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1283 | + { |
---|
| 1284 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1285 | + |
---|
| 1286 | + // if (j%2 == 0) |
---|
| 1287 | + // drawFace(p, q, r, display, null); |
---|
| 1288 | + // else |
---|
| 1289 | + // drawFace(p, r, q, display, null); |
---|
| 1290 | + |
---|
| 1291 | + // p = q; |
---|
| 1292 | + // q = r; |
---|
| 1293 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1294 | + } |
---|
| 1295 | + |
---|
| 1296 | + gl.glEnd(); |
---|
| 1297 | + } |
---|
| 1298 | + } |
---|
| 1299 | + } |
---|
| 1300 | + |
---|
| 1301 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1302 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1303 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1304 | + |
---|
| 1305 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1306 | + { |
---|
| 1307 | + GL gl = GetGL(); // getGL(); |
---|
| 1308 | + |
---|
| 1309 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1310 | + |
---|
| 1311 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1312 | + |
---|
| 1313 | + gl.glLineWidth(1); |
---|
| 1314 | + gl.glColor3f(1,1,1); |
---|
| 1315 | + gl.glBegin(gl.GL_LINES); |
---|
| 1316 | + double scale = 0; |
---|
| 1317 | + int count = 0; |
---|
| 1318 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1319 | + { |
---|
| 1320 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1321 | + if(s == 0) |
---|
| 1322 | + { |
---|
| 1323 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1324 | + } |
---|
| 1325 | + if (mesh.showsprings) |
---|
| 1326 | + { |
---|
| 1327 | + temp.set(spring.a.position); |
---|
| 1328 | + temp.add(spring.b.position); |
---|
| 1329 | + temp.mul(0.5); |
---|
| 1330 | + temp2.set(spring.a.position); |
---|
| 1331 | + temp2.sub(spring.b.position); |
---|
| 1332 | + temp2.mul(spring.restLength/2); |
---|
| 1333 | + temp.sub(temp2); |
---|
| 1334 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1335 | + temp.add(temp2); |
---|
| 1336 | + temp.add(temp2); |
---|
| 1337 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1338 | + } |
---|
| 1339 | + |
---|
| 1340 | + if (spring.isHandle) |
---|
| 1341 | + continue; |
---|
| 1342 | + |
---|
| 1343 | + //if (scale < spring.restLength) |
---|
| 1344 | + scale += spring.restLength; |
---|
| 1345 | + count++; |
---|
| 1346 | + } |
---|
| 1347 | + gl.glEnd(); |
---|
| 1348 | + |
---|
| 1349 | + if (count == 0) |
---|
| 1350 | + scale = 0.01; |
---|
| 1351 | + else |
---|
| 1352 | + scale /= count * 3; |
---|
| 1353 | + |
---|
| 1354 | + //scale = 0.25; |
---|
| 1355 | + |
---|
| 1356 | + if (mesh.ShowInfo()) |
---|
| 1357 | + { |
---|
| 1358 | + gl.glLineWidth(4); |
---|
| 1359 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1360 | + { |
---|
| 1361 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1362 | + if (node.mass == 0) |
---|
| 1363 | + continue; |
---|
| 1364 | + |
---|
| 1365 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1366 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1367 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1368 | + //temp.normalize(); |
---|
| 1369 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1370 | + gl.glBegin(gl.GL_LINES); |
---|
| 1371 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1372 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1373 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1374 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1375 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1376 | + gl.glEnd(); |
---|
| 1377 | + } |
---|
| 1378 | + |
---|
| 1379 | + gl.glLineWidth(8); |
---|
| 1380 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1381 | + { |
---|
| 1382 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1383 | + |
---|
| 1384 | + if (node.springs != null) |
---|
| 1385 | + { |
---|
| 1386 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1387 | + { |
---|
| 1388 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1389 | + |
---|
| 1390 | + int c = i+1; |
---|
| 1391 | + // c = node.springs.get(i).nbcopies; |
---|
| 1392 | + |
---|
| 1393 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1394 | + gl.glBegin(gl.GL_LINES); |
---|
| 1395 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1396 | + gl.glVertex3d(f.position.x/3+node.position.x*2/3, f.position.y/3+node.position.y*2/3, f.position.z/3+node.position.z*2/3); |
---|
| 1397 | + gl.glEnd(); |
---|
| 1398 | + } |
---|
| 1399 | + } |
---|
| 1400 | + } |
---|
| 1401 | + |
---|
| 1402 | + gl.glLineWidth(1); |
---|
| 1403 | + } |
---|
| 1404 | + |
---|
| 1405 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1406 | + } |
---|
| 1407 | + |
---|
1062 | 1408 | /// INTERFACE |
---|
| 1409 | + |
---|
| 1410 | + public void StartTriangles() |
---|
| 1411 | + { |
---|
| 1412 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1413 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1414 | + } |
---|
| 1415 | + |
---|
| 1416 | + public void EndTriangles() |
---|
| 1417 | + { |
---|
| 1418 | + GetGL().glEnd(); |
---|
| 1419 | + } |
---|
| 1420 | + |
---|
| 1421 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1422 | + { |
---|
| 1423 | + if (!selectmode) |
---|
| 1424 | + { |
---|
| 1425 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1426 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1427 | + |
---|
| 1428 | + if (flipV) |
---|
| 1429 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1430 | + else |
---|
| 1431 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1432 | + } |
---|
| 1433 | + |
---|
| 1434 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1435 | + } |
---|
1063 | 1436 | |
---|
1064 | 1437 | void SetColor(Object3D obj, Vertex p0) |
---|
1065 | 1438 | { |
---|
.. | .. |
---|
1254 | 1627 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
1255 | 1628 | if (!material.multiply) |
---|
1256 | 1629 | { |
---|
1257 | | - display.color = color; |
---|
| 1630 | + display.color = material.color; |
---|
1258 | 1631 | display.saturation = material.modulation; |
---|
1259 | 1632 | } |
---|
1260 | 1633 | else |
---|
1261 | 1634 | { |
---|
1262 | | - display.color *= color*2; |
---|
| 1635 | + display.color *= material.color*2; |
---|
1263 | 1636 | display.saturation *= material.modulation*2; |
---|
1264 | 1637 | } |
---|
1265 | 1638 | |
---|
1266 | 1639 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
1267 | 1640 | |
---|
1268 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1641 | + float[] colorV = Grafreed.colorV; |
---|
1269 | 1642 | |
---|
1270 | 1643 | /**/ |
---|
1271 | 1644 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
1525 | 1898 | void PushMatrix(double[][] matrix) |
---|
1526 | 1899 | { |
---|
1527 | 1900 | // GrafreeD.tracein(matrix); |
---|
1528 | | - PushMatrix(matrix,1); |
---|
| 1901 | + PushMatrix(matrix, 1); |
---|
1529 | 1902 | } |
---|
1530 | 1903 | |
---|
1531 | 1904 | void PushMatrix() |
---|
.. | .. |
---|
1777 | 2150 | System.err.println("LIVE = " + Globals.isLIVE()); |
---|
1778 | 2151 | |
---|
1779 | 2152 | if (!Globals.isLIVE()) // save sound |
---|
1780 | | - GrafreeD.savesound = true; // wav.save(); |
---|
| 2153 | + Grafreed.savesound = true; // wav.save(); |
---|
1781 | 2154 | // else |
---|
1782 | 2155 | repaint(); // start loop // may 2013 |
---|
1783 | 2156 | } |
---|
.. | .. |
---|
1810 | 2183 | public void ToggleBoxMode() |
---|
1811 | 2184 | { |
---|
1812 | 2185 | BOXMODE ^= true; |
---|
| 2186 | + } |
---|
| 2187 | + |
---|
| 2188 | + public void ToggleZoomBoxMode() |
---|
| 2189 | + { |
---|
| 2190 | + ZOOMBOXMODE ^= true; |
---|
1813 | 2191 | } |
---|
1814 | 2192 | |
---|
1815 | 2193 | public void ToggleSmoothFocus() |
---|
.. | .. |
---|
1897 | 2275 | LOOKAT ^= true; |
---|
1898 | 2276 | } |
---|
1899 | 2277 | |
---|
1900 | | - void ToggleRandom() |
---|
| 2278 | + void ToggleSwitch() |
---|
1901 | 2279 | { |
---|
1902 | | - RANDOM ^= true; |
---|
| 2280 | + SWITCH ^= true; |
---|
1903 | 2281 | } |
---|
1904 | 2282 | |
---|
1905 | 2283 | void ToggleHandles() |
---|
.. | .. |
---|
2006 | 2384 | { |
---|
2007 | 2385 | return currentGL; |
---|
2008 | 2386 | } |
---|
2009 | | - |
---|
| 2387 | + |
---|
2010 | 2388 | /**/ |
---|
2011 | 2389 | class CacheTexture |
---|
2012 | 2390 | { |
---|
.. | .. |
---|
3838 | 4216 | |
---|
3839 | 4217 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
3840 | 4218 | { |
---|
| 4219 | + new Exception().printStackTrace(); |
---|
3841 | 4220 | System.exit(0); |
---|
3842 | 4221 | com.sun.opengl.util.texture.Texture texture = null; |
---|
3843 | 4222 | |
---|
.. | .. |
---|
7550 | 7929 | ReleaseTexture(pigment, false); |
---|
7551 | 7930 | } |
---|
7552 | 7931 | |
---|
| 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 | + |
---|
7553 | 7990 | void ReleaseTexture(String tex, boolean bump) |
---|
7554 | 7991 | { |
---|
7555 | 7992 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
.. | .. |
---|
7653 | 8090 | } |
---|
7654 | 8091 | } |
---|
7655 | 8092 | |
---|
7656 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8093 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
7657 | 8094 | { |
---|
7658 | 8095 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7659 | 8096 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7698 | 8135 | return; // true; |
---|
7699 | 8136 | } |
---|
7700 | 8137 | |
---|
7701 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 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); |
---|
| 8203 | + } |
---|
| 8204 | + |
---|
| 8205 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8206 | + |
---|
| 8207 | + private boolean FileExists(String tex) |
---|
| 8208 | + { |
---|
| 8209 | + if (missingTextures.contains(tex)) |
---|
| 8210 | + { |
---|
| 8211 | + return false; |
---|
| 8212 | + } |
---|
| 8213 | + |
---|
| 8214 | + boolean fileExists = new File(tex).exists(); |
---|
| 8215 | + |
---|
| 8216 | + if (!fileExists) |
---|
| 8217 | + { |
---|
| 8218 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8219 | + missingTextures.add(tex); |
---|
| 8220 | + } |
---|
| 8221 | + |
---|
| 8222 | + return fileExists; |
---|
| 8223 | + } |
---|
| 8224 | + |
---|
| 8225 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
7702 | 8226 | { |
---|
7703 | 8227 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7704 | 8228 | |
---|
.. | .. |
---|
7706 | 8230 | { |
---|
7707 | 8231 | String texname = tex; |
---|
7708 | 8232 | |
---|
7709 | | - String[] split = tex.split("Textures"); |
---|
7710 | | - if (split.length > 1) |
---|
7711 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
7712 | | - else |
---|
7713 | | - if (!texname.startsWith("/")) |
---|
7714 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8233 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8234 | + |
---|
| 8235 | +// String[] split = tex.split("Textures"); |
---|
| 8236 | +// if (split.length > 1) |
---|
| 8237 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8238 | +// else |
---|
| 8239 | +// if (!texname.startsWith("/")) |
---|
| 8240 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8241 | + if (!FileExists(tex)) |
---|
| 8242 | + { |
---|
| 8243 | + texname = fallbackTextureName; |
---|
| 8244 | + } |
---|
7715 | 8245 | |
---|
7716 | 8246 | if (CACHETEXTURE) |
---|
7717 | 8247 | texture = textures.get(texname); // TEXTURE CACHE |
---|
.. | .. |
---|
7780 | 8310 | } |
---|
7781 | 8311 | |
---|
7782 | 8312 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
7783 | | - if (!new File(cachename).exists()) |
---|
| 8313 | + if (!FileExists(cachename)) |
---|
7784 | 8314 | cachename = texname; |
---|
7785 | 8315 | else |
---|
7786 | 8316 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7802 | 8332 | } |
---|
7803 | 8333 | |
---|
7804 | 8334 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
7805 | | - if (!new File(cachename).exists()) |
---|
| 8335 | + if (!FileExists(cachename)) |
---|
7806 | 8336 | cachename = texname; |
---|
7807 | 8337 | else |
---|
7808 | 8338 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
7811 | 8341 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
7812 | 8342 | |
---|
7813 | 8343 | |
---|
7814 | | - if (texturedata != null) |
---|
| 8344 | + if (texturedata == null) |
---|
| 8345 | + throw new Exception(); |
---|
| 8346 | + |
---|
7815 | 8347 | texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
7816 | 8348 | //texture = GetTexture(tex, bump); |
---|
7817 | 8349 | } |
---|
.. | .. |
---|
7933 | 8465 | return texture; |
---|
7934 | 8466 | } |
---|
7935 | 8467 | |
---|
7936 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8468 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
7937 | 8469 | { |
---|
7938 | 8470 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7939 | 8471 | |
---|
.. | .. |
---|
7951 | 8483 | return texture!=null?texture.texture:null; |
---|
7952 | 8484 | } |
---|
7953 | 8485 | |
---|
7954 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8486 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
7955 | 8487 | { |
---|
7956 | 8488 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7957 | 8489 | |
---|
7958 | 8490 | return texture!=null?texture.texturedata:null; |
---|
7959 | 8491 | } |
---|
7960 | 8492 | |
---|
7961 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8493 | + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
7962 | 8494 | { |
---|
7963 | 8495 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
7964 | 8496 | { |
---|
.. | .. |
---|
8935 | 9467 | assert (parentcam != renderCamera); |
---|
8936 | 9468 | |
---|
8937 | 9469 | if (renderCamera != lightCamera) |
---|
8938 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8939 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9470 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9471 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
8940 | 9472 | |
---|
8941 | 9473 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
8942 | 9474 | |
---|
.. | .. |
---|
8951 | 9483 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
8952 | 9484 | |
---|
8953 | 9485 | if (renderCamera != lightCamera) |
---|
8954 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
8955 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9486 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9487 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
8956 | 9488 | |
---|
8957 | 9489 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
8958 | 9490 | |
---|
.. | .. |
---|
9024 | 9556 | //gl.glFlush(); |
---|
9025 | 9557 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
9026 | 9558 | |
---|
9027 | | - if (ANIMATION && ABORTED) |
---|
| 9559 | + if (Globals.ANIMATION && ABORTED) |
---|
9028 | 9560 | { |
---|
9029 | 9561 | System.err.println(" ABORTED FRAME"); |
---|
9030 | 9562 | break; |
---|
.. | .. |
---|
9054 | 9586 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
9055 | 9587 | |
---|
9056 | 9588 | // save image |
---|
9057 | | - if (ANIMATION && !ABORTED) |
---|
| 9589 | + if (Globals.ANIMATION && !ABORTED) |
---|
9058 | 9590 | { |
---|
9059 | 9591 | VPwidth = viewport[2]; |
---|
9060 | 9592 | VPheight = viewport[3]; |
---|
.. | .. |
---|
9165 | 9697 | |
---|
9166 | 9698 | // imagecount++; |
---|
9167 | 9699 | |
---|
9168 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9700 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
9169 | 9701 | |
---|
9170 | 9702 | if (!BOXMODE) |
---|
9171 | 9703 | { |
---|
9172 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9704 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
9173 | 9705 | } |
---|
9174 | 9706 | |
---|
9175 | 9707 | if (!BOXMODE) |
---|
.. | .. |
---|
9207 | 9739 | ABORTED = false; |
---|
9208 | 9740 | } |
---|
9209 | 9741 | else |
---|
9210 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9742 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9211 | 9743 | |
---|
9212 | 9744 | if (false) |
---|
9213 | 9745 | { |
---|
.. | .. |
---|
9870 | 10402 | |
---|
9871 | 10403 | public void display(GLAutoDrawable drawable) |
---|
9872 | 10404 | { |
---|
9873 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10405 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
9874 | 10406 | { |
---|
9875 | | - GrafreeD.wav.save(); |
---|
9876 | | - GrafreeD.savesound = false; |
---|
9877 | | - GrafreeD.hassound = false; |
---|
| 10407 | + Grafreed.wav.save(); |
---|
| 10408 | + Grafreed.savesound = false; |
---|
| 10409 | + Grafreed.hassound = false; |
---|
9878 | 10410 | } |
---|
9879 | 10411 | // if (DEBUG_SELECTION) |
---|
9880 | 10412 | // { |
---|
.. | .. |
---|
10004 | 10536 | Object3D theobject = object; |
---|
10005 | 10537 | Object3D theparent = object.parent; |
---|
10006 | 10538 | object.parent = null; |
---|
10007 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10539 | + object = (Object3D)Grafreed.clone(object); |
---|
10008 | 10540 | object.Stripify(); |
---|
10009 | 10541 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10010 | 10542 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10017 | 10549 | ambientOcclusion = false; |
---|
10018 | 10550 | } |
---|
10019 | 10551 | |
---|
10020 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10552 | + if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10021 | 10553 | { |
---|
10022 | 10554 | //if (RENDERSHADOW) // ? |
---|
10023 | 10555 | if (!IsFrozen()) |
---|
10024 | 10556 | { |
---|
10025 | 10557 | // dec 2012 |
---|
10026 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10558 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10027 | 10559 | { |
---|
10028 | 10560 | Globals.framecount++; |
---|
10029 | 10561 | shadowbuffer.display(); |
---|
.. | .. |
---|
10150 | 10682 | |
---|
10151 | 10683 | // if (parentcam != renderCamera) // not a light |
---|
10152 | 10684 | if (cam != lightCamera) |
---|
10153 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10154 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10685 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10686 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10155 | 10687 | |
---|
10156 | 10688 | for (int j = 0; j < 4; j++) |
---|
10157 | 10689 | { |
---|
.. | .. |
---|
10165 | 10697 | |
---|
10166 | 10698 | // if (parentcam != renderCamera) // not a light |
---|
10167 | 10699 | if (cam != lightCamera) |
---|
10168 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10169 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10700 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10701 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10170 | 10702 | |
---|
10171 | 10703 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10172 | 10704 | |
---|
.. | .. |
---|
10425 | 10957 | // Bump noise |
---|
10426 | 10958 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10427 | 10959 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10428 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10960 | + |
---|
| 10961 | + try |
---|
| 10962 | + { |
---|
| 10963 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 10964 | + } |
---|
| 10965 | + catch (Exception e) |
---|
| 10966 | + { |
---|
| 10967 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 10968 | + } |
---|
| 10969 | + |
---|
10429 | 10970 | |
---|
10430 | 10971 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10431 | 10972 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10550 | 11091 | System.err.println("parentcam != renderCamera"); |
---|
10551 | 11092 | |
---|
10552 | 11093 | // if (cam != lightCamera) |
---|
10553 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10554 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11094 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11095 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10555 | 11096 | } |
---|
10556 | 11097 | |
---|
10557 | 11098 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10572 | 11113 | if (true) // TODO |
---|
10573 | 11114 | { |
---|
10574 | 11115 | if (cam != lightCamera) |
---|
10575 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10576 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11116 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11117 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10577 | 11118 | } |
---|
10578 | 11119 | |
---|
10579 | 11120 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
10889 | 11430 | { |
---|
10890 | 11431 | renderpass++; |
---|
10891 | 11432 | // System.out.println("Draw object... "); |
---|
| 11433 | + STEP = 1; |
---|
10892 | 11434 | if (FAST) // in case there is no script |
---|
10893 | | - STEP = 16; |
---|
| 11435 | + STEP = 8; |
---|
| 11436 | + |
---|
| 11437 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11438 | + { |
---|
| 11439 | + STEP *= 4; |
---|
| 11440 | + } |
---|
10894 | 11441 | |
---|
10895 | 11442 | //object.FullInvariants(); |
---|
10896 | 11443 | |
---|
.. | .. |
---|
10904 | 11451 | e.printStackTrace(); |
---|
10905 | 11452 | } |
---|
10906 | 11453 | |
---|
10907 | | - if (GrafreeD.RENDERME > 0) |
---|
10908 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11454 | + if (Grafreed.RENDERME > 0) |
---|
| 11455 | + Grafreed.RENDERME--; // mechante magouille |
---|
10909 | 11456 | |
---|
10910 | 11457 | Globals.ONESTEP = false; |
---|
10911 | 11458 | } |
---|
.. | .. |
---|
10975 | 11522 | |
---|
10976 | 11523 | usedtextures.clear(); |
---|
10977 | 11524 | |
---|
10978 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11525 | + try |
---|
| 11526 | + { |
---|
| 11527 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11528 | + } |
---|
| 11529 | + catch (Exception e) |
---|
| 11530 | + { |
---|
| 11531 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11532 | + } |
---|
10979 | 11533 | } |
---|
10980 | 11534 | //System.out.println("--> " + stackdepth); |
---|
10981 | 11535 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11066 | 11620 | if (checker != null && DrawMode() == DEFAULT) |
---|
11067 | 11621 | { |
---|
11068 | 11622 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11069 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11623 | + try |
---|
| 11624 | + { |
---|
| 11625 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11626 | + } |
---|
| 11627 | + catch (Exception e) |
---|
| 11628 | + { |
---|
| 11629 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11630 | + } |
---|
11070 | 11631 | // NEAREST |
---|
11071 | 11632 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11072 | 11633 | DrawChecker(gl); |
---|
.. | .. |
---|
11148 | 11709 | return; |
---|
11149 | 11710 | } |
---|
11150 | 11711 | |
---|
11151 | | - String string = obj.GetToolTip(); |
---|
| 11712 | + String string = obj.toString(); //.GetToolTip(); |
---|
11152 | 11713 | |
---|
11153 | 11714 | GL gl = GetGL(); |
---|
11154 | 11715 | |
---|
.. | .. |
---|
11465 | 12026 | //obj.TransformToWorld(light, light); |
---|
11466 | 12027 | for (int i = tp.size(); --i >= 0;) |
---|
11467 | 12028 | { |
---|
11468 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11469 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12029 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12030 | + LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
11470 | 12031 | } |
---|
11471 | 12032 | |
---|
11472 | 12033 | |
---|
.. | .. |
---|
11483 | 12044 | parentcam = cameras[0]; |
---|
11484 | 12045 | } |
---|
11485 | 12046 | |
---|
11486 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11487 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12047 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12048 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11488 | 12049 | |
---|
11489 | 12050 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11490 | 12051 | |
---|
.. | .. |
---|
12098 | 12659 | |
---|
12099 | 12660 | // display shadow only (bump == 0) |
---|
12100 | 12661 | "SUB temp.x, half.x, shadow.x;" + |
---|
12101 | | - "MOV temp.y, -params6.x;" + |
---|
12102 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12662 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12663 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12103 | 12664 | "SUB temp.y, one.x, temp.z;" + |
---|
12104 | 12665 | "MUL temp.x, temp.x, temp.y;" + |
---|
12105 | 12666 | "KIL temp.x;" + |
---|
.. | .. |
---|
12228 | 12789 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
12229 | 12790 | |
---|
12230 | 12791 | "SUB temp.x, one.x, ndotl.x;" + |
---|
12231 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
12232 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 12792 | + // Tuning for default skin |
---|
| 12793 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 12794 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 12795 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
12233 | 12796 | "MUL temp.x, temp.x, temp.y;" + |
---|
12234 | 12797 | |
---|
12235 | 12798 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12428 | 12991 | //once = true; |
---|
12429 | 12992 | } |
---|
12430 | 12993 | |
---|
12431 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 12994 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12432 | 12995 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12433 | 12996 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12434 | 12997 | |
---|
.. | .. |
---|
12561 | 13124 | |
---|
12562 | 13125 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12563 | 13126 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13127 | + |
---|
| 13128 | + // Compare fragment depth in light space with shadowmap. |
---|
12564 | 13129 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12565 | 13130 | "SGE temp.y, temp.x, zero.x;" + |
---|
12566 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13131 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13132 | + |
---|
| 13133 | + // Reverse comparison |
---|
12567 | 13134 | "SUB temp.x, one.x, temp.x;" + |
---|
12568 | 13135 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12569 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13136 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12570 | 13137 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12571 | 13138 | |
---|
12572 | 13139 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12580 | 13147 | // No shadow for backface |
---|
12581 | 13148 | "DP3 temp.x, normal, lightd;" + |
---|
12582 | 13149 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13150 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13151 | + |
---|
| 13152 | + // No shadow when out of frustrum |
---|
| 13153 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12583 | 13154 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12584 | 13155 | ""; |
---|
12585 | 13156 | } |
---|
.. | .. |
---|
13138 | 13709 | public void mousePressed(MouseEvent e) |
---|
13139 | 13710 | { |
---|
13140 | 13711 | //System.out.println("mousePressed: " + e); |
---|
13141 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13712 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13142 | 13713 | } |
---|
13143 | 13714 | |
---|
13144 | 13715 | static long prevtime = 0; |
---|
.. | .. |
---|
13165 | 13736 | |
---|
13166 | 13737 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
13167 | 13738 | |
---|
| 13739 | + if (BUTTONLESSWHEEL) |
---|
13168 | 13740 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
13169 | 13741 | { |
---|
13170 | 13742 | return; |
---|
.. | .. |
---|
13173 | 13745 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13174 | 13746 | |
---|
13175 | 13747 | // TIMER |
---|
13176 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 13748 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
13177 | 13749 | { |
---|
13178 | 13750 | keepboxmode = BOXMODE; |
---|
13179 | 13751 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
13213 | 13785 | // mode |= META; |
---|
13214 | 13786 | //} |
---|
13215 | 13787 | |
---|
13216 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
13217 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 13788 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 13789 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
13218 | 13790 | anchorX = ax; |
---|
13219 | 13791 | anchorY = ay; |
---|
13220 | 13792 | prevX = px; |
---|
.. | .. |
---|
13274 | 13846 | // wasliveok = true; |
---|
13275 | 13847 | // waslive = false; |
---|
13276 | 13848 | |
---|
| 13849 | + // May 2019 Forget it: |
---|
| 13850 | + if (true) |
---|
| 13851 | + return; |
---|
| 13852 | + |
---|
13277 | 13853 | // source == timer |
---|
13278 | 13854 | if (mouseDown) |
---|
13279 | 13855 | { |
---|
.. | .. |
---|
13312 | 13888 | |
---|
13313 | 13889 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13314 | 13890 | |
---|
13315 | | - void clickStart(int x, int y, int modifiers) |
---|
| 13891 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13316 | 13892 | { |
---|
13317 | 13893 | if (!wasliveok) |
---|
13318 | 13894 | return; |
---|
.. | .. |
---|
13329 | 13905 | // touched = true; // main DL |
---|
13330 | 13906 | if (isRenderer) |
---|
13331 | 13907 | { |
---|
13332 | | - SetMouseMode(modifiers); |
---|
| 13908 | + SetMouseMode(modifiers, modifiersex); |
---|
13333 | 13909 | } |
---|
13334 | 13910 | |
---|
13335 | 13911 | selectX = anchorX = x; |
---|
.. | .. |
---|
13342 | 13918 | clicked = true; |
---|
13343 | 13919 | hold = false; |
---|
13344 | 13920 | |
---|
13345 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 13921 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13346 | 13922 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13347 | 13923 | { |
---|
13348 | 13924 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13373 | 13949 | info.camera = renderCamera; |
---|
13374 | 13950 | info.x = x; |
---|
13375 | 13951 | info.y = y; |
---|
13376 | | - info.modifiers = modifiers; |
---|
| 13952 | + info.modifiers = modifiersex; |
---|
13377 | 13953 | editObj = object.doEditClick(info, 0); |
---|
13378 | 13954 | if (!editObj) |
---|
13379 | 13955 | { |
---|
.. | .. |
---|
13390 | 13966 | |
---|
13391 | 13967 | public void mouseDragged(MouseEvent e) |
---|
13392 | 13968 | { |
---|
| 13969 | + Globals.MOUSEDRAGGED = true; |
---|
| 13970 | + |
---|
| 13971 | + //System.out.println("mouseDragged: " + e); |
---|
13393 | 13972 | if (isRenderer) |
---|
13394 | 13973 | movingcamera = true; |
---|
| 13974 | + |
---|
13395 | 13975 | //if (drawing) |
---|
13396 | 13976 | //return; |
---|
13397 | | - //System.out.println("mouseDragged: " + e); |
---|
13398 | 13977 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
13399 | 13978 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13400 | 13979 | { |
---|
.. | .. |
---|
13402 | 13981 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13403 | 13982 | } |
---|
13404 | 13983 | else |
---|
13405 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13984 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13406 | 13985 | |
---|
13407 | 13986 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13408 | 13987 | } |
---|
.. | .. |
---|
13575 | 14154 | |
---|
13576 | 14155 | public void run() |
---|
13577 | 14156 | { |
---|
| 14157 | + new Exception().printStackTrace(); |
---|
13578 | 14158 | System.exit(0); |
---|
13579 | 14159 | for (;;) |
---|
13580 | 14160 | { |
---|
.. | .. |
---|
13638 | 14218 | { |
---|
13639 | 14219 | Globals.lighttouched = true; |
---|
13640 | 14220 | } |
---|
13641 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14221 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
13642 | 14222 | } |
---|
13643 | 14223 | //else |
---|
13644 | 14224 | } |
---|
.. | .. |
---|
13738 | 14318 | int X, Y; |
---|
13739 | 14319 | boolean SX, SY; |
---|
13740 | 14320 | |
---|
13741 | | - void drag(int x, int y, int modifiers) |
---|
| 14321 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
13742 | 14322 | { |
---|
13743 | 14323 | if (IsFrozen()) |
---|
13744 | 14324 | { |
---|
.. | .. |
---|
13747 | 14327 | |
---|
13748 | 14328 | drag = true; // NEW |
---|
13749 | 14329 | |
---|
13750 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14330 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
13751 | 14331 | |
---|
13752 | 14332 | X = x; |
---|
13753 | 14333 | Y = y; |
---|
13754 | 14334 | // floating state for animation |
---|
13755 | | - MODIFIERS = modifiers; |
---|
13756 | | - modifiers &= ~1024; |
---|
| 14335 | + MODIFIERS = modifiersex; |
---|
| 14336 | + modifiersex &= ~1024; |
---|
13757 | 14337 | if (false) // modifiers != 0) |
---|
13758 | 14338 | { |
---|
13759 | 14339 | //new Exception().printStackTrace(); |
---|
13760 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14340 | + System.out.println("mouseDragged: " + modifiersex); |
---|
13761 | 14341 | System.out.println("SHIFT = " + SHIFT); |
---|
13762 | 14342 | System.out.println("CONTROL = " + COMMAND); |
---|
13763 | 14343 | System.out.println("META = " + META); |
---|
.. | .. |
---|
13777 | 14357 | info.camera = renderCamera; |
---|
13778 | 14358 | info.x = x; |
---|
13779 | 14359 | info.y = y; |
---|
13780 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14360 | + object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
13781 | 14361 | } else |
---|
13782 | 14362 | { |
---|
13783 | 14363 | if (x < startX) |
---|
.. | .. |
---|
13929 | 14509 | public void mouseMoved(MouseEvent e) |
---|
13930 | 14510 | { |
---|
13931 | 14511 | //System.out.println("mouseMoved: " + e); |
---|
13932 | | - |
---|
13933 | 14512 | if (isRenderer) |
---|
13934 | 14513 | return; |
---|
13935 | 14514 | |
---|
.. | .. |
---|
13954 | 14533 | |
---|
13955 | 14534 | public void mouseReleased(MouseEvent e) |
---|
13956 | 14535 | { |
---|
| 14536 | + Globals.MOUSEDRAGGED = false; |
---|
| 14537 | + |
---|
13957 | 14538 | movingcamera = false; |
---|
| 14539 | + X = Y = 0; |
---|
13958 | 14540 | //System.out.println("mouseReleased: " + e); |
---|
13959 | 14541 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13960 | 14542 | } |
---|
.. | .. |
---|
13977 | 14559 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
13978 | 14560 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
13979 | 14561 | |
---|
13980 | | - if (control || command || IsFrozen()) |
---|
| 14562 | +// No delay if (control || command || IsFrozen()) |
---|
13981 | 14563 | timeout = true; |
---|
13982 | | - else |
---|
| 14564 | +// ?? May 2019 else |
---|
13983 | 14565 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
13984 | 14566 | mouseDown = false; |
---|
13985 | 14567 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
14089 | 14671 | System.out.println("keyReleased: " + e); |
---|
14090 | 14672 | } |
---|
14091 | 14673 | |
---|
14092 | | - void SetMouseMode(int modifiers) |
---|
| 14674 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
14093 | 14675 | { |
---|
14094 | 14676 | //System.out.println("SetMouseMode = " + modifiers); |
---|
14095 | 14677 | //modifiers &= ~1024; |
---|
.. | .. |
---|
14101 | 14683 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
14102 | 14684 | // return; |
---|
14103 | 14685 | //System.out.println("SetMode = " + modifiers); |
---|
14104 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14686 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
14105 | 14687 | { |
---|
14106 | 14688 | mouseMode |= ZOOM; |
---|
14107 | 14689 | } |
---|
14108 | 14690 | |
---|
14109 | 14691 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14110 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14692 | + if (capsLocked) // || (modifiers & META) == META) |
---|
14111 | 14693 | { |
---|
14112 | 14694 | mouseMode |= VR; // BACKFORTH; |
---|
14113 | 14695 | } |
---|
14114 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 14696 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
14115 | 14697 | { |
---|
14116 | 14698 | mouseMode |= SELECT; |
---|
14117 | 14699 | } |
---|
14118 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14700 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
14119 | 14701 | { |
---|
14120 | 14702 | mouseMode |= SELECT; |
---|
14121 | 14703 | } |
---|
14122 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14704 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14123 | 14705 | { |
---|
14124 | 14706 | mouseMode &= ~VR; |
---|
14125 | 14707 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14148 | 14730 | |
---|
14149 | 14731 | if (isRenderer) // |
---|
14150 | 14732 | { |
---|
14151 | | - SetMouseMode(modifiers); |
---|
| 14733 | + SetMouseMode(0, modifiers); |
---|
14152 | 14734 | } |
---|
14153 | 14735 | |
---|
14154 | 14736 | Globals.theRenderer.keyPressed(key); |
---|
.. | .. |
---|
14484 | 15066 | //RESIZETEXTURE ^= true; |
---|
14485 | 15067 | //break; |
---|
14486 | 15068 | case 'z': |
---|
14487 | | - RENDERSHADOW ^= true; |
---|
| 15069 | + Globals.RENDERSHADOW ^= true; |
---|
14488 | 15070 | Globals.lighttouched = true; |
---|
14489 | 15071 | repaint(); |
---|
14490 | 15072 | break; |
---|
.. | .. |
---|
14608 | 15190 | //mode = ROTATE; |
---|
14609 | 15191 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14610 | 15192 | { |
---|
14611 | | - SetMouseMode(modifiers); |
---|
| 15193 | + SetMouseMode(0, modifiers); |
---|
14612 | 15194 | } |
---|
14613 | 15195 | } |
---|
14614 | 15196 | |
---|
.. | .. |
---|
14742 | 15324 | |
---|
14743 | 15325 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14744 | 15326 | { |
---|
14745 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14746 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15327 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15328 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15329 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14747 | 15330 | { |
---|
14748 | 15331 | mouseMoved(e); |
---|
14749 | 15332 | } else |
---|
.. | .. |
---|
14773 | 15356 | |
---|
14774 | 15357 | void SelectParent() |
---|
14775 | 15358 | { |
---|
| 15359 | + new Exception().printStackTrace(); |
---|
14776 | 15360 | System.exit(0); |
---|
14777 | 15361 | Composite group = (Composite) object; |
---|
14778 | 15362 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
14796 | 15380 | |
---|
14797 | 15381 | void SelectChildren() |
---|
14798 | 15382 | { |
---|
| 15383 | + new Exception().printStackTrace(); |
---|
14799 | 15384 | System.exit(0); |
---|
14800 | 15385 | /* |
---|
14801 | 15386 | Composite group = (Composite) object; |
---|
.. | .. |
---|
14960 | 15545 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
14961 | 15546 | //Image img = CreateImage(width, height); |
---|
14962 | 15547 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15548 | + |
---|
14963 | 15549 | Graphics gr = g; // img.getGraphics(); |
---|
| 15550 | + |
---|
14964 | 15551 | if (!hasMarquee) |
---|
14965 | 15552 | { |
---|
14966 | 15553 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15058 | 15645 | if (!isRenderer) |
---|
15059 | 15646 | { |
---|
15060 | 15647 | object.drawEditHandles(info, 0); |
---|
| 15648 | + |
---|
| 15649 | + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15650 | + { |
---|
| 15651 | + switch (object.selection.get(0).hitSomething) |
---|
| 15652 | + { |
---|
| 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; |
---|
| 15662 | + } |
---|
| 15663 | + |
---|
| 15664 | + } |
---|
15061 | 15665 | } |
---|
15062 | 15666 | } |
---|
| 15667 | + |
---|
15063 | 15668 | if (isRenderer) |
---|
15064 | 15669 | { |
---|
15065 | 15670 | //gr.setColor(Color.black); |
---|
15066 | 15671 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15067 | 15672 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15068 | 15673 | } |
---|
| 15674 | + |
---|
15069 | 15675 | if (hasMarquee) |
---|
15070 | 15676 | { |
---|
15071 | 15677 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15178 | 15784 | public boolean mouseDown(Event evt, int x, int y) |
---|
15179 | 15785 | { |
---|
15180 | 15786 | System.out.println("mouseDown: " + evt); |
---|
| 15787 | + System.exit(0); |
---|
15181 | 15788 | /* |
---|
15182 | 15789 | locked = true; |
---|
15183 | 15790 | drag = false; |
---|
.. | .. |
---|
15221 | 15828 | { |
---|
15222 | 15829 | keyPressed(0, modifiers); |
---|
15223 | 15830 | } |
---|
15224 | | - clickStart(x, y, modifiers); |
---|
| 15831 | + // clickStart(x, y, modifiers); |
---|
15225 | 15832 | return true; |
---|
15226 | 15833 | } |
---|
15227 | 15834 | |
---|
.. | .. |
---|
15339 | 15946 | { |
---|
15340 | 15947 | keyReleased(0, 0); |
---|
15341 | 15948 | } |
---|
15342 | | - drag(x, y, modifiers); |
---|
| 15949 | + drag(x, y, 0, modifiers); |
---|
15343 | 15950 | return true; |
---|
15344 | 15951 | } |
---|
15345 | 15952 | |
---|
.. | .. |
---|
15471 | 16078 | Object3D object; |
---|
15472 | 16079 | static Object3D trackedobject; |
---|
15473 | 16080 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15474 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16081 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15475 | 16082 | /*static*/ Camera eyeCamera; |
---|
15476 | 16083 | /*static*/ Camera lightCamera; |
---|
15477 | 16084 | int cameracount; |
---|
.. | .. |
---|
15909 | 16516 | { |
---|
15910 | 16517 | if (!selection) |
---|
15911 | 16518 | { |
---|
| 16519 | + new Exception().printStackTrace(); |
---|
15912 | 16520 | System.exit(0); |
---|
15913 | 16521 | return; |
---|
15914 | 16522 | } |
---|
.. | .. |
---|
16036 | 16644 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
16037 | 16645 | } |
---|
16038 | 16646 | |
---|
16039 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16647 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16040 | 16648 | } |
---|
16041 | 16649 | } |
---|
16042 | 16650 | |
---|
16043 | 16651 | if (!movingcamera && !PAINTMODE) |
---|
16044 | 16652 | object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
16045 | 16653 | |
---|
16046 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16654 | + if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16047 | 16655 | { |
---|
16048 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16656 | + Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16049 | 16657 | |
---|
16050 | 16658 | Object3D group = new Object3D("inst" + paintcount++); |
---|
16051 | 16659 | |
---|
.. | .. |
---|
16201 | 16809 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16202 | 16810 | } |
---|
16203 | 16811 | |
---|
16204 | | - if (!RENDERSHADOW) |
---|
| 16812 | + if (!Globals.RENDERSHADOW) |
---|
16205 | 16813 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16206 | 16814 | |
---|
16207 | 16815 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16211 | 16819 | //gl.glColorMask(false, false, false, false); |
---|
16212 | 16820 | |
---|
16213 | 16821 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16214 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 16822 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16215 | 16823 | { |
---|
16216 | 16824 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16217 | 16825 | |
---|
.. | .. |
---|
16695 | 17303 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16696 | 17304 | // Depth buffer format |
---|
16697 | 17305 | //private int depth_format; |
---|
16698 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17306 | + |
---|
| 17307 | + public void NextIndex() |
---|
16699 | 17308 | { |
---|
16700 | 17309 | indexcount+=16; |
---|
16701 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17310 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16702 | 17311 | //objects[indexcount] = o; |
---|
16703 | 17312 | //System.out.println("indexcount = " + indexcount); |
---|
16704 | 17313 | } |
---|