| .. | .. |
|---|
| 4428 | 4428 | } |
|---|
| 4429 | 4429 | } |
|---|
| 4430 | 4430 | |
|---|
| 4431 | | - void CullVertex(javax.media.opengl.GL gl, boolean shadow) |
|---|
| 4431 | + void CullVertex(javax.media.opengl.GL glNOTUSED, boolean shadowNOTUSED) |
|---|
| 4432 | 4432 | { |
|---|
| 4433 | 4433 | CameraPane.glu.gluProject(vect5.x,vect5.y,vect5.z, |
|---|
| 4434 | 4434 | CameraPane.tempmat,0, CameraPane.tempmat2,0, |
|---|
| .. | .. |
|---|
| 191 | 191 | |
|---|
| 192 | 192 | /// INTERFACE |
|---|
| 193 | 193 | |
|---|
| 194 | + public javax.media.opengl.GL GetGL0() |
|---|
| 195 | + { |
|---|
| 196 | + return null; |
|---|
| 197 | + } |
|---|
| 198 | + |
|---|
| 199 | + public int GenList() |
|---|
| 200 | + { |
|---|
| 201 | + javax.media.opengl.GL gl = GetGL(); |
|---|
| 202 | + return gl.glGenLists(1); |
|---|
| 203 | + } |
|---|
| 204 | + |
|---|
| 205 | + public void NewList(int id) |
|---|
| 206 | + { |
|---|
| 207 | + javax.media.opengl.GL gl = GetGL(); |
|---|
| 208 | + gl.glNewList(id, gl.GL_COMPILE); //_AND_EXECUTE); |
|---|
| 209 | + } |
|---|
| 210 | + |
|---|
| 211 | + public void CallList(int id) |
|---|
| 212 | + { |
|---|
| 213 | + javax.media.opengl.GL gl = GetGL(); |
|---|
| 214 | + gl.glCallList(id); |
|---|
| 215 | + } |
|---|
| 216 | + |
|---|
| 217 | + public void EndList() |
|---|
| 218 | + { |
|---|
| 219 | + javax.media.opengl.GL gl = GetGL(); |
|---|
| 220 | + gl.glEndList(); |
|---|
| 221 | + } |
|---|
| 222 | + |
|---|
| 194 | 223 | public boolean IsBoxMode() |
|---|
| 195 | 224 | { |
|---|
| 196 | 225 | return BOXMODE; |
|---|
| .. | .. |
|---|
| 1059 | 1088 | gl.glMatrixMode(gl.GL_MODELVIEW); |
|---|
| 1060 | 1089 | } |
|---|
| 1061 | 1090 | |
|---|
| 1091 | + public void DrawBox(cVector min, cVector max) |
|---|
| 1092 | + { |
|---|
| 1093 | + javax.media.opengl.GL gl = GetGL(); |
|---|
| 1094 | + gl.glBegin(gl.GL_LINES); |
|---|
| 1095 | + |
|---|
| 1096 | + gl.glVertex3d(min.x, min.y, min.z); |
|---|
| 1097 | + gl.glVertex3d(min.x, min.y, max.z); |
|---|
| 1098 | + gl.glVertex3d(min.x, min.y, min.z); |
|---|
| 1099 | + gl.glVertex3d(min.x, max.y, min.z); |
|---|
| 1100 | + gl.glVertex3d(min.x, min.y, min.z); |
|---|
| 1101 | + gl.glVertex3d(max.x, min.y, min.z); |
|---|
| 1102 | + |
|---|
| 1103 | + gl.glVertex3d(max.x, max.y, max.z); |
|---|
| 1104 | + gl.glVertex3d(min.x, max.y, max.z); |
|---|
| 1105 | + gl.glVertex3d(max.x, max.y, max.z); |
|---|
| 1106 | + gl.glVertex3d(max.x, min.y, max.z); |
|---|
| 1107 | + gl.glVertex3d(max.x, max.y, max.z); |
|---|
| 1108 | + gl.glVertex3d(max.x, max.y, min.z); |
|---|
| 1109 | + |
|---|
| 1110 | + gl.glEnd(); |
|---|
| 1111 | + } |
|---|
| 1112 | + |
|---|
| 1113 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
|---|
| 1114 | + { |
|---|
| 1115 | + int[] strips = bRep.getRawIndices(); |
|---|
| 1116 | + |
|---|
| 1117 | + javax.media.opengl.GL gl = GetGL(); |
|---|
| 1118 | + |
|---|
| 1119 | + // TRIANGLE STRIP ARRAY |
|---|
| 1120 | + if (bRep.trimmed) |
|---|
| 1121 | + { |
|---|
| 1122 | + float[] v = bRep.getRawVertices(); |
|---|
| 1123 | + float[] n = bRep.getRawNormals(); |
|---|
| 1124 | + float[] c = bRep.getRawColors(); |
|---|
| 1125 | + float[] uv = bRep.getRawUVMap(); |
|---|
| 1126 | + |
|---|
| 1127 | + int count2 = 0; |
|---|
| 1128 | + int count3 = 0; |
|---|
| 1129 | + |
|---|
| 1130 | + if (n.length > 0) |
|---|
| 1131 | + { |
|---|
| 1132 | + for (int i = 0; i < strips.length; i++) |
|---|
| 1133 | + { |
|---|
| 1134 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
|---|
| 1135 | + |
|---|
| 1136 | + /* |
|---|
| 1137 | + boolean locked = false; |
|---|
| 1138 | + float eps = 0.1f; |
|---|
| 1139 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
|---|
| 1140 | + |
|---|
| 1141 | + int dot = 0; |
|---|
| 1142 | + |
|---|
| 1143 | + if ((dot&1) == 0) |
|---|
| 1144 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
|---|
| 1145 | + |
|---|
| 1146 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
|---|
| 1147 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
|---|
| 1148 | + else |
|---|
| 1149 | + { |
|---|
| 1150 | + locked = true; |
|---|
| 1151 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
|---|
| 1152 | + } |
|---|
| 1153 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
|---|
| 1154 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
|---|
| 1155 | + if (hasnorm) |
|---|
| 1156 | + { |
|---|
| 1157 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
|---|
| 1158 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
|---|
| 1159 | + } |
|---|
| 1160 | + |
|---|
| 1161 | + if ((dot&4) == 0) |
|---|
| 1162 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
|---|
| 1163 | + |
|---|
| 1164 | + if (wrap || !locked && (dot&8) != 0) |
|---|
| 1165 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
|---|
| 1166 | + else |
|---|
| 1167 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
|---|
| 1168 | + |
|---|
| 1169 | + f.dot = dot; |
|---|
| 1170 | + */ |
|---|
| 1171 | + |
|---|
| 1172 | + if (!selectmode) |
|---|
| 1173 | + { |
|---|
| 1174 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
|---|
| 1175 | + { |
|---|
| 1176 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
|---|
| 1177 | + } else |
|---|
| 1178 | + { |
|---|
| 1179 | + gl.glNormal3f(0, 0, 1); |
|---|
| 1180 | + } |
|---|
| 1181 | + |
|---|
| 1182 | + if (c != null) |
|---|
| 1183 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
|---|
| 1184 | + { |
|---|
| 1185 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
|---|
| 1186 | + } |
|---|
| 1187 | + } |
|---|
| 1188 | + if (flipV) |
|---|
| 1189 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
|---|
| 1190 | + else |
|---|
| 1191 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
|---|
| 1192 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
|---|
| 1193 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
|---|
| 1194 | + |
|---|
| 1195 | + count2 += 2; |
|---|
| 1196 | + count3 += 3; |
|---|
| 1197 | + if (!selectmode) |
|---|
| 1198 | + { |
|---|
| 1199 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
|---|
| 1200 | + { |
|---|
| 1201 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
|---|
| 1202 | + } else |
|---|
| 1203 | + { |
|---|
| 1204 | + gl.glNormal3f(0, 0, 1); |
|---|
| 1205 | + } |
|---|
| 1206 | + if (c != null) |
|---|
| 1207 | + { |
|---|
| 1208 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
|---|
| 1209 | + } |
|---|
| 1210 | + } |
|---|
| 1211 | + if (flipV) |
|---|
| 1212 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
|---|
| 1213 | + else |
|---|
| 1214 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
|---|
| 1215 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
|---|
| 1216 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
|---|
| 1217 | + |
|---|
| 1218 | + count2 += 2; |
|---|
| 1219 | + count3 += 3; |
|---|
| 1220 | + for (int j = 0; j < strips[i] - 2; j++) |
|---|
| 1221 | + { |
|---|
| 1222 | + //gl.glTexCoord2d(...); |
|---|
| 1223 | + if (!selectmode) |
|---|
| 1224 | + { |
|---|
| 1225 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
|---|
| 1226 | + { |
|---|
| 1227 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
|---|
| 1228 | + } else |
|---|
| 1229 | + { |
|---|
| 1230 | + gl.glNormal3f(0, 0, 1); |
|---|
| 1231 | + } |
|---|
| 1232 | + if (c != null) |
|---|
| 1233 | + { |
|---|
| 1234 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
|---|
| 1235 | + } |
|---|
| 1236 | + } |
|---|
| 1237 | + |
|---|
| 1238 | + if (flipV) |
|---|
| 1239 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
|---|
| 1240 | + else |
|---|
| 1241 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
|---|
| 1242 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
|---|
| 1243 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
|---|
| 1244 | + count2 += 2; |
|---|
| 1245 | + count3 += 3; |
|---|
| 1246 | + } |
|---|
| 1247 | + |
|---|
| 1248 | + gl.glEnd(); |
|---|
| 1249 | + } |
|---|
| 1250 | + } |
|---|
| 1251 | + |
|---|
| 1252 | + assert count3 == v.length; |
|---|
| 1253 | + } |
|---|
| 1254 | + else // !trimmed |
|---|
| 1255 | + { |
|---|
| 1256 | + int count = 0; |
|---|
| 1257 | + for (int i = 0; i < strips.length; i++) |
|---|
| 1258 | + { |
|---|
| 1259 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
|---|
| 1260 | + |
|---|
| 1261 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
|---|
| 1262 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
|---|
| 1263 | + |
|---|
| 1264 | + drawVertex(gl, p, flipV, selectmode); |
|---|
| 1265 | + drawVertex(gl, q, flipV, selectmode); |
|---|
| 1266 | + |
|---|
| 1267 | + for (int j = 0; j < strips[i] - 2; j++) |
|---|
| 1268 | + { |
|---|
| 1269 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
|---|
| 1270 | + |
|---|
| 1271 | + // if (j%2 == 0) |
|---|
| 1272 | + // drawFace(p, q, r, display, null); |
|---|
| 1273 | + // else |
|---|
| 1274 | + // drawFace(p, r, q, display, null); |
|---|
| 1275 | + |
|---|
| 1276 | + // p = q; |
|---|
| 1277 | + // q = r; |
|---|
| 1278 | + drawVertex(gl, r, flipV, selectmode); |
|---|
| 1279 | + } |
|---|
| 1280 | + |
|---|
| 1281 | + gl.glEnd(); |
|---|
| 1282 | + } |
|---|
| 1283 | + } |
|---|
| 1284 | + } |
|---|
| 1285 | + |
|---|
| 1286 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
|---|
| 1287 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
|---|
| 1288 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
|---|
| 1289 | + |
|---|
| 1290 | + public void DrawDynamicMesh(cMesh mesh) |
|---|
| 1291 | + { |
|---|
| 1292 | + GL gl = GetGL(); // getGL(); |
|---|
| 1293 | + |
|---|
| 1294 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
|---|
| 1295 | + |
|---|
| 1296 | + gl.glDisable(gl.GL_LIGHTING); |
|---|
| 1297 | + |
|---|
| 1298 | + gl.glLineWidth(1); |
|---|
| 1299 | + gl.glColor3f(1,1,1); |
|---|
| 1300 | + gl.glBegin(gl.GL_LINES); |
|---|
| 1301 | + double scale = 0; |
|---|
| 1302 | + int count = 0; |
|---|
| 1303 | + for (int s=0; s<Phys.allSprings.size(); s++) |
|---|
| 1304 | + { |
|---|
| 1305 | + cSpring.Spring spring = Phys.allSprings.get(s); |
|---|
| 1306 | + if(s == 0) |
|---|
| 1307 | + { |
|---|
| 1308 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
|---|
| 1309 | + } |
|---|
| 1310 | + if (mesh.showsprings) |
|---|
| 1311 | + { |
|---|
| 1312 | + temp.set(spring.a.position); |
|---|
| 1313 | + temp.add(spring.b.position); |
|---|
| 1314 | + temp.mul(0.5); |
|---|
| 1315 | + temp2.set(spring.a.position); |
|---|
| 1316 | + temp2.sub(spring.b.position); |
|---|
| 1317 | + temp2.mul(spring.restLength/2); |
|---|
| 1318 | + temp.sub(temp2); |
|---|
| 1319 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
|---|
| 1320 | + temp.add(temp2); |
|---|
| 1321 | + temp.add(temp2); |
|---|
| 1322 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
|---|
| 1323 | + } |
|---|
| 1324 | + |
|---|
| 1325 | + if (spring.isHandle) |
|---|
| 1326 | + continue; |
|---|
| 1327 | + |
|---|
| 1328 | + //if (scale < spring.restLength) |
|---|
| 1329 | + scale += spring.restLength; |
|---|
| 1330 | + count++; |
|---|
| 1331 | + } |
|---|
| 1332 | + gl.glEnd(); |
|---|
| 1333 | + |
|---|
| 1334 | + if (count == 0) |
|---|
| 1335 | + scale = 0.01; |
|---|
| 1336 | + else |
|---|
| 1337 | + scale /= count * 3; |
|---|
| 1338 | + |
|---|
| 1339 | + //scale = 0.25; |
|---|
| 1340 | + |
|---|
| 1341 | + if (mesh.ShowInfo()) |
|---|
| 1342 | + { |
|---|
| 1343 | + gl.glLineWidth(4); |
|---|
| 1344 | + for (int s=0; s<Phys.allNodes.size(); s++) |
|---|
| 1345 | + { |
|---|
| 1346 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
|---|
| 1347 | + if (node.mass == 0) |
|---|
| 1348 | + continue; |
|---|
| 1349 | + |
|---|
| 1350 | + int i = node.springs==null?-1:node.springs.size(); |
|---|
| 1351 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
|---|
| 1352 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
|---|
| 1353 | + //temp.normalize(); |
|---|
| 1354 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
|---|
| 1355 | + gl.glBegin(gl.GL_LINES); |
|---|
| 1356 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
|---|
| 1357 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
|---|
| 1358 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
|---|
| 1359 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
|---|
| 1360 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
|---|
| 1361 | + gl.glEnd(); |
|---|
| 1362 | + } |
|---|
| 1363 | + |
|---|
| 1364 | + gl.glLineWidth(8); |
|---|
| 1365 | + for (int s=0; s<Phys.allNodes.size(); s++) |
|---|
| 1366 | + { |
|---|
| 1367 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
|---|
| 1368 | + |
|---|
| 1369 | + if (node.springs != null) |
|---|
| 1370 | + { |
|---|
| 1371 | + for (int i=0; i<node.springs.size(); i+=1) |
|---|
| 1372 | + { |
|---|
| 1373 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
|---|
| 1374 | + |
|---|
| 1375 | + int c = i+1; |
|---|
| 1376 | + // c = node.springs.get(i).nbcopies; |
|---|
| 1377 | + |
|---|
| 1378 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
|---|
| 1379 | + gl.glBegin(gl.GL_LINES); |
|---|
| 1380 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
|---|
| 1381 | + 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); |
|---|
| 1382 | + gl.glEnd(); |
|---|
| 1383 | + } |
|---|
| 1384 | + } |
|---|
| 1385 | + } |
|---|
| 1386 | + |
|---|
| 1387 | + gl.glLineWidth(1); |
|---|
| 1388 | + } |
|---|
| 1389 | + |
|---|
| 1390 | + gl.glEnable(gl.GL_LIGHTING); |
|---|
| 1391 | + } |
|---|
| 1392 | + |
|---|
| 1062 | 1393 | /// INTERFACE |
|---|
| 1394 | + |
|---|
| 1395 | + public void StartTriangles() |
|---|
| 1396 | + { |
|---|
| 1397 | + javax.media.opengl.GL gl = GetGL(); |
|---|
| 1398 | + gl.glBegin(gl.GL_TRIANGLES); |
|---|
| 1399 | + } |
|---|
| 1400 | + |
|---|
| 1401 | + public void EndTriangles() |
|---|
| 1402 | + { |
|---|
| 1403 | + GetGL().glEnd(); |
|---|
| 1404 | + } |
|---|
| 1405 | + |
|---|
| 1406 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
|---|
| 1407 | + { |
|---|
| 1408 | + if (!selectmode) |
|---|
| 1409 | + { |
|---|
| 1410 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
|---|
| 1411 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
|---|
| 1412 | + |
|---|
| 1413 | + if (flipV) |
|---|
| 1414 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
|---|
| 1415 | + else |
|---|
| 1416 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
|---|
| 1417 | + } |
|---|
| 1418 | + |
|---|
| 1419 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
|---|
| 1420 | + } |
|---|
| 1063 | 1421 | |
|---|
| 1064 | 1422 | void SetColor(Object3D obj, Vertex p0) |
|---|
| 1065 | 1423 | { |
|---|
| .. | .. |
|---|
| 16695 | 17053 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
|---|
| 16696 | 17054 | // Depth buffer format |
|---|
| 16697 | 17055 | //private int depth_format; |
|---|
| 16698 | | - static public void NextIndex(Object3D o, GL gl) |
|---|
| 17056 | + |
|---|
| 17057 | + public void NextIndex() |
|---|
| 16699 | 17058 | { |
|---|
| 16700 | 17059 | indexcount+=16; |
|---|
| 16701 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
|---|
| 17060 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
|---|
| 16702 | 17061 | //objects[indexcount] = o; |
|---|
| 16703 | 17062 | //System.out.println("indexcount = " + indexcount); |
|---|
| 16704 | 17063 | } |
|---|
| .. | .. |
|---|
| 142 | 142 | |
|---|
| 143 | 143 | //System.out.println("shape="+shape+" type="+BroadphaseNativeTypes.forValue(shape.getShapeType())); |
|---|
| 144 | 144 | |
|---|
| 145 | | - GL gl = display.GetGL(); |
|---|
| 145 | + GL gl = display.GetGL0(); |
|---|
| 146 | 146 | |
|---|
| 147 | 147 | gl.glPushMatrix(); |
|---|
| 148 | 148 | trans.getOpenGLMatrix(glMat); |
|---|
| .. | .. |
|---|
| 552 | 552 | |
|---|
| 553 | 553 | static public void drawSphere(iCameraPane display, float radius, int slices, int stacks) |
|---|
| 554 | 554 | { |
|---|
| 555 | | - GL gl = display.GetGL(); |
|---|
| 555 | + GL gl = display.GetGL0(); |
|---|
| 556 | 556 | |
|---|
| 557 | 557 | sphereKey.radius = radius; |
|---|
| 558 | 558 | Integer glList = sphereDisplayLists.get(sphereKey); |
|---|
| .. | .. |
|---|
| 624 | 624 | |
|---|
| 625 | 625 | static public void drawCylinder(iCameraPane display, float radius, float halfHeight, int upAxis) |
|---|
| 626 | 626 | { |
|---|
| 627 | | - GL gl = display.GetGL(); |
|---|
| 627 | + GL gl = display.GetGL0(); |
|---|
| 628 | 628 | |
|---|
| 629 | 629 | gl.glPushMatrix(); |
|---|
| 630 | 630 | switch (upAxis) |
|---|
| .. | .. |
|---|
| 330 | 330 | e.printStackTrace(); |
|---|
| 331 | 331 | } |
|---|
| 332 | 332 | |
|---|
| 333 | | - display.GetGL().glPushMatrix(); |
|---|
| 333 | + //display.GetGL().glPushMatrix(); |
|---|
| 334 | + display.PushMatrix(LA.Identity, 1); |
|---|
| 334 | 335 | Vector3f v = ragdolls.get(0).bodies[0].worldTransform.origin; |
|---|
| 335 | 336 | // display.GetGL().glTranslatef(-v.x,0,-v.z); |
|---|
| 336 | 337 | |
|---|
| 337 | 338 | super.DrawNode(display, root, selected); |
|---|
| 338 | | - display.GetGL().glPopMatrix(); |
|---|
| 339 | + //display.GetGL().glPopMatrix(); |
|---|
| 340 | + display.PopMatrix(LA.Identity); |
|---|
| 339 | 341 | |
|---|
| 340 | 342 | // assert(bRep != null); |
|---|
| 341 | 343 | |
|---|
| .. | .. |
|---|
| 453 | 455 | |
|---|
| 454 | 456 | public void renderme(iCameraPane display) |
|---|
| 455 | 457 | { |
|---|
| 456 | | - GL gl = display!=null?display.GetGL():null; |
|---|
| 458 | + GL gl = display!=null?display.GetGL0():null; |
|---|
| 457 | 459 | |
|---|
| 458 | 460 | // gl0 = gl; |
|---|
| 459 | 461 | if (GetDynamicsWorld() != null) |
|---|
| .. | .. |
|---|
| 798 | 800 | |
|---|
| 799 | 801 | public void drawCube(iCameraPane display, float extent) |
|---|
| 800 | 802 | { |
|---|
| 801 | | - GL gl = display.GetGL(); |
|---|
| 803 | + GL gl = display.GetGL0(); |
|---|
| 802 | 804 | |
|---|
| 803 | 805 | extent = extent * 0.5f; |
|---|
| 804 | 806 | |
|---|
| .. | .. |
|---|
| 1524 | 1526 | |
|---|
| 1525 | 1527 | public void drawSphere(iCameraPane display, float radius, int slices, int stacks) |
|---|
| 1526 | 1528 | { |
|---|
| 1527 | | - GL gl = display.GetGL(); |
|---|
| 1529 | + GL gl = display.GetGL0(); |
|---|
| 1528 | 1530 | |
|---|
| 1529 | 1531 | sphereKey.radius = radius; |
|---|
| 1530 | 1532 | Integer glList = sphereDisplayLists.get(sphereKey); |
|---|
| .. | .. |
|---|
| 1596 | 1598 | |
|---|
| 1597 | 1599 | public void drawCylinder(iCameraPane display, float radius, float halfHeight, int upAxis) |
|---|
| 1598 | 1600 | { |
|---|
| 1599 | | - GL gl = display.GetGL(); |
|---|
| 1601 | + GL gl = display.GetGL0(); |
|---|
| 1600 | 1602 | |
|---|
| 1601 | 1603 | gl.glPushMatrix(); |
|---|
| 1602 | 1604 | switch (upAxis) |
|---|
| .. | .. |
|---|
| 623 | 623 | private static int indxr[] = new int[4]; |
|---|
| 624 | 624 | private static int indxc[] = new int[4]; |
|---|
| 625 | 625 | |
|---|
| 626 | + static double[][] Identity = new double[4][4]; |
|---|
| 626 | 627 | |
|---|
| 627 | 628 | static int SIZE = 0; // 65536*64; |
|---|
| 628 | 629 | |
|---|
| .. | .. |
|---|
| 638 | 639 | costable[i] = Math.cos(PI2 * i/SIZE); |
|---|
| 639 | 640 | sintable[i] = Math.sin(PI2 * i*i/SIZE/SIZE); |
|---|
| 640 | 641 | } |
|---|
| 642 | + |
|---|
| 643 | + LA.matIdentity(Identity); |
|---|
| 641 | 644 | } |
|---|
| 642 | 645 | |
|---|
| 643 | 646 | static double cos(double x0) |
|---|
| .. | .. |
|---|
| 160 | 160 | // debug stuff |
|---|
| 161 | 161 | if (false) // bRep.averagepoints != null) |
|---|
| 162 | 162 | { |
|---|
| 163 | | - javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 164 | | - |
|---|
| 165 | | - gl.glColor3f(1, 0, 0); |
|---|
| 166 | | - //gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
|---|
| 167 | | - //gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
|---|
| 168 | | - |
|---|
| 169 | | - for (int i=0; i<NumGeometries(GetObject()); i++) |
|---|
| 170 | | - { |
|---|
| 171 | | - int i3 = i*3; |
|---|
| 172 | | - |
|---|
| 173 | | - float off = 0.005f; |
|---|
| 174 | | - |
|---|
| 175 | | - gl.glBegin(gl.GL_LINES); |
|---|
| 176 | | - gl.glVertex3d(bRep.averagepoints[i3]-off, bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]); |
|---|
| 177 | | - gl.glVertex3d(bRep.averagepoints[i3]+off, bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]); |
|---|
| 178 | | - gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1]-off, bRep.averagepoints[i3+2]); |
|---|
| 179 | | - gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1]+off, bRep.averagepoints[i3+2]); |
|---|
| 180 | | - gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]-off); |
|---|
| 181 | | - gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]+off); |
|---|
| 182 | | - gl.glEnd(); |
|---|
| 183 | | - } |
|---|
| 163 | +// javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 164 | +// |
|---|
| 165 | +// gl.glColor3f(1, 0, 0); |
|---|
| 166 | +// //gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
|---|
| 167 | +// //gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
|---|
| 168 | +// |
|---|
| 169 | +// for (int i=0; i<NumGeometries(GetObject()); i++) |
|---|
| 170 | +// { |
|---|
| 171 | +// int i3 = i*3; |
|---|
| 172 | +// |
|---|
| 173 | +// float off = 0.005f; |
|---|
| 174 | +// |
|---|
| 175 | +// gl.glBegin(gl.GL_LINES); |
|---|
| 176 | +// gl.glVertex3d(bRep.averagepoints[i3]-off, bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]); |
|---|
| 177 | +// gl.glVertex3d(bRep.averagepoints[i3]+off, bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]); |
|---|
| 178 | +// gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1]-off, bRep.averagepoints[i3+2]); |
|---|
| 179 | +// gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1]+off, bRep.averagepoints[i3+2]); |
|---|
| 180 | +// gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]-off); |
|---|
| 181 | +// gl.glVertex3d(bRep.averagepoints[i3], bRep.averagepoints[i3+1], bRep.averagepoints[i3+2]+off); |
|---|
| 182 | +// gl.glEnd(); |
|---|
| 183 | +// } |
|---|
| 184 | 184 | } |
|---|
| 185 | 185 | } |
|---|
| 186 | 186 | |
|---|
| .. | .. |
|---|
| 398 | 398 | |
|---|
| 399 | 399 | public void drawCube(iCameraPane display, float extent) |
|---|
| 400 | 400 | { |
|---|
| 401 | | - GL gl = display.GetGL(); |
|---|
| 401 | + GL gl = display.GetGL0(); |
|---|
| 402 | 402 | |
|---|
| 403 | 403 | extent = extent * 0.5f; |
|---|
| 404 | 404 | |
|---|
| .. | .. |
|---|
| 5 | 5 | import java.util.Vector; |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | import javax.media.j3d.Transform3D; |
|---|
| 8 | +import javax.media.opengl.GL; |
|---|
| 8 | 9 | import javax.vecmath.Vector3d; |
|---|
| 9 | 10 | |
|---|
| 10 | 11 | import javax.imageio.ImageIO; |
|---|
| .. | .. |
|---|
| 5371 | 5372 | return; |
|---|
| 5372 | 5373 | } |
|---|
| 5373 | 5374 | |
|---|
| 5374 | | - javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 5375 | + //javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 5375 | 5376 | |
|---|
| 5376 | 5377 | /* |
|---|
| 5377 | 5378 | if (touched) |
|---|
| .. | .. |
|---|
| 5423 | 5424 | //if (displaylist == -1 && usecalllists) |
|---|
| 5424 | 5425 | if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
|---|
| 5425 | 5426 | { |
|---|
| 5426 | | - bRep.displaylist = gl.glGenLists(1); |
|---|
| 5427 | + bRep.displaylist = display.GenList(); |
|---|
| 5427 | 5428 | assert(bRep.displaylist != 0); |
|---|
| 5428 | 5429 | // System.err.println("glGenLists: " + bRep.displaylist + " for " + this); |
|---|
| 5429 | 5430 | //System.out.println("\tgen list " + list); |
|---|
| .. | .. |
|---|
| 5435 | 5436 | if (usecalllists) |
|---|
| 5436 | 5437 | { |
|---|
| 5437 | 5438 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
|---|
| 5438 | | - gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE); |
|---|
| 5439 | + display.NewList(bRep.displaylist); |
|---|
| 5439 | 5440 | } |
|---|
| 5441 | + |
|---|
| 5440 | 5442 | CallList(display, root, selected, blocked); |
|---|
| 5443 | + |
|---|
| 5441 | 5444 | // compiled = true; |
|---|
| 5442 | 5445 | if (usecalllists) |
|---|
| 5443 | 5446 | { |
|---|
| 5444 | 5447 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
|---|
| 5445 | | - gl.glEndList(); |
|---|
| 5448 | + display.EndList(); |
|---|
| 5446 | 5449 | } |
|---|
| 5447 | 5450 | //gl.glDrawBuffer(gl.GL_BACK); |
|---|
| 5448 | 5451 | // XXX touched = false; |
|---|
| .. | .. |
|---|
| 5490 | 5493 | if (display.DrawMode() == iCameraPane.SHADOW) |
|---|
| 5491 | 5494 | { |
|---|
| 5492 | 5495 | if (!link2master // tricky to cull in shadow mode. |
|---|
| 5493 | | - && GetBRep().FrustumCull(this, gl, display.LightCamera(), true)) |
|---|
| 5496 | + && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
|---|
| 5494 | 5497 | { |
|---|
| 5495 | 5498 | //System.out.print("CULLED"); |
|---|
| 5496 | 5499 | culled = true; |
|---|
| .. | .. |
|---|
| 5498 | 5501 | } |
|---|
| 5499 | 5502 | else |
|---|
| 5500 | 5503 | //GetBRep().getBounds(v0, v1, this); |
|---|
| 5501 | | - if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false)) |
|---|
| 5504 | + if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false)) |
|---|
| 5502 | 5505 | culled = true; |
|---|
| 5503 | 5506 | |
|---|
| 5504 | 5507 | // LA.xformPos(v0, display.renderCamera.toScreen, v0); |
|---|
| .. | .. |
|---|
| 5538 | 5541 | { |
|---|
| 5539 | 5542 | if (GetBRep() != null) |
|---|
| 5540 | 5543 | { |
|---|
| 5541 | | - CameraPane.NextIndex(this, gl); |
|---|
| 5544 | + display.NextIndex(); |
|---|
| 5542 | 5545 | // vertex color conflict : gl.glCallList(list); |
|---|
| 5543 | 5546 | DrawNode(display, root, selected); |
|---|
| 5544 | 5547 | if (this instanceof BezierPatch) |
|---|
| .. | .. |
|---|
| 5595 | 5598 | |
|---|
| 5596 | 5599 | // System.err.println("glCallList: " + bRep.displaylist + " for " + this); |
|---|
| 5597 | 5600 | assert(bRep.displaylist != 0); |
|---|
| 5598 | | - gl.glCallList(bRep.displaylist); |
|---|
| 5601 | + display.CallList(bRep.displaylist); |
|---|
| 5599 | 5602 | // june 2013 drawSelf(display, root, selected); |
|---|
| 5600 | 5603 | } |
|---|
| 5601 | 5604 | } |
|---|
| .. | .. |
|---|
| 5897 | 5900 | |
|---|
| 5898 | 5901 | // bRep.lock = true; |
|---|
| 5899 | 5902 | |
|---|
| 5900 | | - javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 5903 | + //javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 5901 | 5904 | |
|---|
| 5902 | 5905 | if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
|---|
| 5903 | 5906 | { |
|---|
| .. | .. |
|---|
| 5914 | 5917 | |
|---|
| 5915 | 5918 | bRep.getMinMax(min, max, 100); |
|---|
| 5916 | 5919 | |
|---|
| 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(); |
|---|
| 5920 | + display.DrawBox(min, max); |
|---|
| 5934 | 5921 | |
|---|
| 5935 | 5922 | return; |
|---|
| 5936 | 5923 | } |
|---|
| .. | .. |
|---|
| 5984 | 5971 | new Exception().printStackTrace(); |
|---|
| 5985 | 5972 | return; |
|---|
| 5986 | 5973 | } |
|---|
| 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 | | - } |
|---|
| 5974 | + |
|---|
| 5975 | + display.DrawGeometry(bRep, flipV, selectmode); |
|---|
| 6153 | 5976 | } else // catch (Error e) |
|---|
| 6154 | 5977 | { |
|---|
| 6155 | 5978 | // TRIANGLE ARRAY |
|---|
| 6156 | 5979 | if (IsOpaque()) // Static()) |
|---|
| 6157 | 5980 | { |
|---|
| 6158 | | - gl.glBegin(gl.GL_TRIANGLES); |
|---|
| 5981 | + display.StartTriangles(); |
|---|
| 6159 | 5982 | int facecount = bRep.FaceCount(); |
|---|
| 6160 | 5983 | for (int i = 0; i < facecount; i++) |
|---|
| 6161 | 5984 | { |
|---|
| .. | .. |
|---|
| 6220 | 6043 | |
|---|
| 6221 | 6044 | display.DrawFace(this, p, q, r, face); |
|---|
| 6222 | 6045 | } |
|---|
| 6223 | | - gl.glEnd(); |
|---|
| 6046 | + display.EndTriangles(); |
|---|
| 6224 | 6047 | } |
|---|
| 6225 | 6048 | else |
|---|
| 6226 | 6049 | { |
|---|
| .. | .. |
|---|
| 6249 | 6072 | //System.out.println("SORT"); |
|---|
| 6250 | 6073 | |
|---|
| 6251 | 6074 | java.util.Arrays.sort(facescompare); |
|---|
| 6252 | | - |
|---|
| 6253 | | - gl.glBegin(gl.GL_TRIANGLES); |
|---|
| 6075 | + |
|---|
| 6076 | + display.StartTriangles(); |
|---|
| 6254 | 6077 | for (int i = 0; i < facecount; i++) |
|---|
| 6255 | 6078 | { |
|---|
| 6256 | 6079 | Face face = bRep.GetFace(facescompare[i].index); |
|---|
| .. | .. |
|---|
| 6264 | 6087 | |
|---|
| 6265 | 6088 | display.DrawFace(this, p, q, r, face); |
|---|
| 6266 | 6089 | } |
|---|
| 6267 | | - gl.glEnd(); |
|---|
| 6090 | + display.EndTriangles(); |
|---|
| 6268 | 6091 | } |
|---|
| 6269 | 6092 | |
|---|
| 6270 | 6093 | if (false) // live && support != null && support.bRep != null) // debug weights |
|---|
| 6271 | 6094 | { |
|---|
| 6095 | + /* |
|---|
| 6272 | 6096 | gl.glDisable(gl.GL_LIGHTING); |
|---|
| 6273 | 6097 | float[] colorV = new float[3]; |
|---|
| 6274 | 6098 | |
|---|
| .. | .. |
|---|
| 6347 | 6171 | // gl.glEnd(); |
|---|
| 6348 | 6172 | } |
|---|
| 6349 | 6173 | } |
|---|
| 6174 | + */ |
|---|
| 6350 | 6175 | } |
|---|
| 6351 | 6176 | } |
|---|
| 6352 | 6177 | |
|---|
| .. | .. |
|---|
| 6405 | 6230 | void Print(Vertex v) |
|---|
| 6406 | 6231 | { |
|---|
| 6407 | 6232 | //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); |
|---|
| 6424 | 6233 | } |
|---|
| 6425 | 6234 | |
|---|
| 6426 | 6235 | void drawSelf(ClickInfo info, int level, boolean select) |
|---|
| .. | .. |
|---|
| 529 | 529 | public void renderme0(iCameraPane display) |
|---|
| 530 | 530 | { |
|---|
| 531 | 531 | //updateCamera(); |
|---|
| 532 | | - GL gl = display.GetGL(); |
|---|
| 532 | + GL gl = display.GetGL0(); |
|---|
| 533 | 533 | |
|---|
| 534 | 534 | if (dynamicsWorld != null) { |
|---|
| 535 | 535 | int numObjects = dynamicsWorld.getNumCollisionObjects(); |
|---|
| .. | .. |
|---|
| 49 | 49 | { |
|---|
| 50 | 50 | cStatic.point7.set(stack.peek()); |
|---|
| 51 | 51 | /**/ |
|---|
| 52 | | - javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 52 | + //javax.media.opengl.GL gl = display.GetGL(); |
|---|
| 53 | 53 | |
|---|
| 54 | 54 | //gl.glBegin(gl.GL_LINES); |
|---|
| 55 | 55 | //gl.glVertex3d(stack.peek().x, stack.peek().y, stack.peek().z); |
|---|
| .. | .. |
|---|
| 1 | 1 | import java.util.Hashtable; |
|---|
| 2 | 2 | |
|---|
| 3 | | -import javax.media.opengl.GL; |
|---|
| 3 | +//import javax.media.opengl.GL; |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | public class cMesh extends cSpring |
|---|
| 6 | 6 | { |
|---|
| .. | .. |
|---|
| 78 | 78 | |
|---|
| 79 | 79 | live = true; |
|---|
| 80 | 80 | } |
|---|
| 81 | | - |
|---|
| 81 | + |
|---|
| 82 | 82 | Object3D deepCopy() |
|---|
| 83 | 83 | { |
|---|
| 84 | 84 | /* |
|---|
| .. | .. |
|---|
| 545 | 545 | |
|---|
| 546 | 546 | if(/*showsprings &&*/ Phys != null) |
|---|
| 547 | 547 | { |
|---|
| 548 | | - GL gl = display.GetGL(); // getGL(); |
|---|
| 549 | | - |
|---|
| 550 | | - gl.glDisable(gl.GL_LIGHTING); |
|---|
| 551 | | - |
|---|
| 552 | | - gl.glLineWidth(1); |
|---|
| 553 | | - gl.glColor3f(1,1,1); |
|---|
| 554 | | - gl.glBegin(gl.GL_LINES); |
|---|
| 555 | | - double scale = 0; |
|---|
| 556 | | - int count = 0; |
|---|
| 557 | | - for (int s=0; s<Phys.allSprings.size(); s++) |
|---|
| 558 | | - { |
|---|
| 559 | | - Spring spring = Phys.allSprings.get(s); |
|---|
| 560 | | - if(s == 0) |
|---|
| 561 | | - { |
|---|
| 562 | | - //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
|---|
| 563 | | - } |
|---|
| 564 | | - if (showsprings) |
|---|
| 565 | | - { |
|---|
| 566 | | - temp.set(spring.a.position); |
|---|
| 567 | | - temp.add(spring.b.position); |
|---|
| 568 | | - temp.mul(0.5); |
|---|
| 569 | | - temp2.set(spring.a.position); |
|---|
| 570 | | - temp2.sub(spring.b.position); |
|---|
| 571 | | - temp2.mul(spring.restLength/2); |
|---|
| 572 | | - temp.sub(temp2); |
|---|
| 573 | | - gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
|---|
| 574 | | - temp.add(temp2); |
|---|
| 575 | | - temp.add(temp2); |
|---|
| 576 | | - gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
|---|
| 577 | | - } |
|---|
| 578 | | - |
|---|
| 579 | | - if (spring.isHandle) |
|---|
| 580 | | - continue; |
|---|
| 581 | | - |
|---|
| 582 | | - //if (scale < spring.restLength) |
|---|
| 583 | | - scale += spring.restLength; |
|---|
| 584 | | - count++; |
|---|
| 585 | | - } |
|---|
| 586 | | - gl.glEnd(); |
|---|
| 587 | | - |
|---|
| 588 | | - if (count == 0) |
|---|
| 589 | | - scale = 0.01; |
|---|
| 590 | | - else |
|---|
| 591 | | - scale /= count * 3; |
|---|
| 592 | | - |
|---|
| 593 | | - //scale = 0.25; |
|---|
| 594 | | - |
|---|
| 595 | | - if (ShowInfo()) |
|---|
| 596 | | - { |
|---|
| 597 | | - gl.glLineWidth(4); |
|---|
| 598 | | - for (int s=0; s<Phys.allNodes.size(); s++) |
|---|
| 599 | | - { |
|---|
| 600 | | - DynamicNode node = Phys.allNodes.get(s); |
|---|
| 601 | | - if (node.mass == 0) |
|---|
| 602 | | - continue; |
|---|
| 603 | | - |
|---|
| 604 | | - int i = node.springs==null?-1:node.springs.size(); |
|---|
| 605 | | - gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
|---|
| 606 | | - //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
|---|
| 607 | | - //temp.normalize(); |
|---|
| 608 | | - //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
|---|
| 609 | | - gl.glBegin(gl.GL_LINES); |
|---|
| 610 | | - gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
|---|
| 611 | | - //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
|---|
| 612 | | - gl.glVertex3d(node.position.x + bRep.GetVertex(s).norm.x*scale, |
|---|
| 613 | | - node.position.y + bRep.GetVertex(s).norm.y*scale, |
|---|
| 614 | | - node.position.z + bRep.GetVertex(s).norm.z*scale); |
|---|
| 615 | | - gl.glEnd(); |
|---|
| 616 | | - } |
|---|
| 617 | | - |
|---|
| 618 | | - gl.glLineWidth(8); |
|---|
| 619 | | - for (int s=0; s<Phys.allNodes.size(); s++) |
|---|
| 620 | | - { |
|---|
| 621 | | - DynamicNode node = Phys.allNodes.get(s); |
|---|
| 622 | | - |
|---|
| 623 | | - if (node.springs != null) |
|---|
| 624 | | - { |
|---|
| 625 | | - for (int i=0; i<node.springs.size(); i+=1) |
|---|
| 626 | | - { |
|---|
| 627 | | - DynamicNode f = node.springs.get(i).GetOther(node); |
|---|
| 628 | | - |
|---|
| 629 | | - int c = i+1; |
|---|
| 630 | | - // c = node.springs.get(i).nbcopies; |
|---|
| 631 | | - |
|---|
| 632 | | - gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
|---|
| 633 | | - gl.glBegin(gl.GL_LINES); |
|---|
| 634 | | - gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
|---|
| 635 | | - 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); |
|---|
| 636 | | - gl.glEnd(); |
|---|
| 637 | | - } |
|---|
| 638 | | - } |
|---|
| 639 | | - } |
|---|
| 640 | | - |
|---|
| 641 | | - gl.glLineWidth(1); |
|---|
| 642 | | - } |
|---|
| 643 | | - |
|---|
| 644 | | - gl.glEnable(gl.GL_LIGHTING); |
|---|
| 548 | + display.DrawDynamicMesh(this); |
|---|
| 645 | 549 | } |
|---|
| 646 | 550 | |
|---|
| 647 | 551 | if (live && Globals.isLIVE() && display.DrawMode() == CameraPane.DEFAULT) |
|---|
| .. | .. |
|---|
| 565 | 565 | // } |
|---|
| 566 | 566 | |
|---|
| 567 | 567 | //new Exception().printStackTrace(); |
|---|
| 568 | | - GL gl = display.GetGL(); // getGL(); |
|---|
| 568 | + GL gl = display.GetGL0(); // getGL(); |
|---|
| 569 | 569 | |
|---|
| 570 | 570 | //gl.glDisable(GL.GL_LIGHTING); |
|---|
| 571 | 571 | |
|---|
| .. | .. |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | boolean IsFrozen(); |
|---|
| 26 | 26 | |
|---|
| 27 | | - javax.media.opengl.GL GetGL(); |
|---|
| 27 | + javax.media.opengl.GL GetGL0(); |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | // Currently in Globals |
|---|
| 30 | 30 | int DrawMode(); |
|---|
| .. | .. |
|---|
| 60 | 60 | |
|---|
| 61 | 61 | void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face); |
|---|
| 62 | 62 | |
|---|
| 63 | + void DrawBox(cVector min, cVector max); |
|---|
| 64 | + |
|---|
| 65 | + void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode); |
|---|
| 66 | + |
|---|
| 67 | + void DrawDynamicMesh(cMesh c); |
|---|
| 68 | + |
|---|
| 69 | + void StartTriangles(); |
|---|
| 70 | + void EndTriangles(); |
|---|
| 71 | + |
|---|
| 72 | + int GenList(); |
|---|
| 73 | + void NewList(int id); |
|---|
| 74 | + void CallList(int id); |
|---|
| 75 | + void EndList(); |
|---|
| 76 | + |
|---|
| 77 | + void NextIndex(); |
|---|
| 78 | + |
|---|
| 63 | 79 | void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate); |
|---|
| 64 | 80 | |
|---|
| 65 | 81 | void PrepOcclusion(BoundaryRep br, double[][] transform); |
|---|