.. | .. |
---|
70 | 70 | */ |
---|
71 | 71 | public class TriMesh extends Geometry implements Serializable |
---|
72 | 72 | { |
---|
| 73 | + /** |
---|
| 74 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 75 | + * it's normals, colors, textures and vertices. |
---|
| 76 | + * |
---|
| 77 | + * @see Renderer#draw(TriMesh) |
---|
| 78 | + * @param tris |
---|
| 79 | + * the mesh to render. |
---|
| 80 | + */ |
---|
| 81 | + void DrawParticles(iCameraPane display, Object3D geo, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 82 | + { |
---|
| 83 | + display.DrawParticles(this, geo, selected, rotate); |
---|
| 84 | + } |
---|
| 85 | + |
---|
73 | 86 | static final long serialVersionUID = 0; |
---|
74 | 87 | |
---|
75 | 88 | boolean IsStatic() |
---|
76 | 89 | { |
---|
77 | 90 | return false; |
---|
78 | 91 | } |
---|
| 92 | + |
---|
79 | 93 | private static final Logger logger = Logger.getLogger(TriMesh.class.getName()); |
---|
| 94 | + |
---|
80 | 95 | // private static final long serialVersionUID = 2L; |
---|
81 | 96 | public enum Mode |
---|
82 | 97 | { |
---|
.. | .. |
---|
270 | 285 | |
---|
271 | 286 | float[] texmat = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; |
---|
272 | 287 | |
---|
273 | | - // super.DrawNode(...); |
---|
274 | | - /** |
---|
275 | | - * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
276 | | - * it's normals, colors, textures and vertices. |
---|
277 | | - * |
---|
278 | | - * @see Renderer#draw(TriMesh) |
---|
279 | | - * @param tris |
---|
280 | | - * the mesh to render. |
---|
281 | | - */ |
---|
282 | | - void DrawParticles(CameraPane display, Object3D geo, boolean selected, boolean rotate) // TriMesh tris) |
---|
283 | | - { |
---|
284 | | - float r = display.modelParams0[0]; |
---|
285 | | - float g = display.modelParams0[1]; |
---|
286 | | - float b = display.modelParams0[2]; |
---|
287 | | - float opacity = display.modelParams5[1]; |
---|
288 | | - |
---|
289 | | - //final GL gl = GLU.getCurrentGL(); |
---|
290 | | - GL gl = display.GetGL(); // getGL(); |
---|
291 | | - |
---|
292 | | - int v = vertBuf.capacity(); |
---|
293 | | - |
---|
294 | | - int count = 0; |
---|
295 | | - |
---|
296 | | - boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
297 | | - gl.glEnable(gl.GL_CULL_FACE); |
---|
298 | | - // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
299 | | - for (int i=0; i<v/3; i++) |
---|
300 | | - { |
---|
301 | | - int index3 = i*3; |
---|
302 | | - |
---|
303 | | - if (sizeBuf.get(index3+1) == 0) |
---|
304 | | - continue; |
---|
305 | | - |
---|
306 | | - count++; |
---|
307 | | - |
---|
308 | | - int index4 = i*4; |
---|
309 | | - |
---|
310 | | - float tx = vertBuf.get(index3); |
---|
311 | | - float ty = vertBuf.get(index3+1); |
---|
312 | | - float tz = vertBuf.get(index3+2); |
---|
313 | | - |
---|
314 | | - // if (tx == 0 && ty == 0 && tz == 0) |
---|
315 | | - // continue; |
---|
316 | | - |
---|
317 | | - gl.glMatrixMode(gl.GL_TEXTURE); |
---|
318 | | - gl.glPushMatrix(); |
---|
319 | | - texmat[12] = texmat[13] = texmat[14] = i; |
---|
320 | | - |
---|
321 | | - gl.glMultMatrixf(texmat, 0); |
---|
322 | | - |
---|
323 | | - gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
324 | | - gl.glPushMatrix(); |
---|
325 | | - |
---|
326 | | - gl.glTranslatef(tx,ty,tz); |
---|
327 | | - |
---|
328 | | - if (rotate) |
---|
329 | | - gl.glRotatef(i, 0, 1, 0); |
---|
330 | | - |
---|
331 | | - float size = sizeBuf.get(index3) / 100; |
---|
332 | | - gl.glScalef(size,size,size); |
---|
333 | | - |
---|
334 | | - float cr = colorBuf.get(index4); |
---|
335 | | - float cg = colorBuf.get(index4+1); |
---|
336 | | - float cb = colorBuf.get(index4+2); |
---|
337 | | - float ca = colorBuf.get(index4+3); |
---|
338 | | - |
---|
339 | | - display.modelParams0[0] = r * cr; |
---|
340 | | - display.modelParams0[1] = g * cg; |
---|
341 | | - display.modelParams0[2] = b * cb; |
---|
342 | | - |
---|
343 | | - display.modelParams5[1] = opacity * ca; |
---|
344 | | - |
---|
345 | | - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
346 | | - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
347 | | - |
---|
348 | | - RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
349 | | - RandomNode.globalseed2 = RandomNode.globalseed; |
---|
350 | | - |
---|
351 | | -// gl.glColor4f(cr,cg,cb,ca); |
---|
352 | | - // gl.glScalef(1024/16,1024/16,1024/16); |
---|
353 | | - geo.Draw/*Node*/(display,null,selected,false); // blocked |
---|
354 | | - // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
355 | | - //gl.glTranslatef(-tx,-ty,-tz); |
---|
356 | | - gl.glPopMatrix(); |
---|
357 | | - |
---|
358 | | - gl.glMatrixMode(gl.GL_TEXTURE); |
---|
359 | | - gl.glPopMatrix(); |
---|
360 | | - } |
---|
361 | | - // gl.glScalef(1024,1024,1024); |
---|
362 | | - if (!cf) |
---|
363 | | - gl.glDisable(gl.GL_CULL_FACE); |
---|
364 | | - |
---|
365 | | - display.modelParams0[0] = r; |
---|
366 | | - display.modelParams0[1] = g; |
---|
367 | | - display.modelParams0[2] = b; |
---|
368 | | - |
---|
369 | | - display.modelParams5[1] = opacity; |
---|
370 | | - |
---|
371 | | - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
372 | | - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
373 | | - |
---|
374 | | - gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
375 | | - |
---|
376 | | -// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
377 | | - if (true) |
---|
378 | | - return; |
---|
379 | | - |
---|
380 | | -//// if (!tris.predraw(this)) |
---|
381 | | -//// { |
---|
382 | | -//// return; |
---|
383 | | -//// } |
---|
384 | | -//// if (Debug.stats) |
---|
385 | | -//// { |
---|
386 | | -//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
387 | | -//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
388 | | -//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
389 | | -//// } |
---|
390 | | -//// |
---|
391 | | -//// if (tris.getDisplayListID() != -1) |
---|
392 | | -//// { |
---|
393 | | -//// renderDisplayList(tris); |
---|
394 | | -//// return; |
---|
395 | | -//// } |
---|
396 | | -//// |
---|
397 | | -//// if (!generatingDisplayList) |
---|
398 | | -//// { |
---|
399 | | -//// applyStates(tris.states, tris); |
---|
400 | | -//// } |
---|
401 | | -//// if (Debug.stats) |
---|
402 | | -//// { |
---|
403 | | -//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
404 | | -//// } |
---|
405 | | -//// boolean transformed = doTransforms(tris); |
---|
406 | | -// |
---|
407 | | -// int glMode = GL.GL_TRIANGLES; |
---|
408 | | -// switch (getMode()) |
---|
409 | | -// { |
---|
410 | | -// case Triangles: |
---|
411 | | -// glMode = GL.GL_TRIANGLES; |
---|
412 | | -// break; |
---|
413 | | -// case Strip: |
---|
414 | | -// glMode = GL.GL_TRIANGLE_STRIP; |
---|
415 | | -// break; |
---|
416 | | -// case Fan: |
---|
417 | | -// glMode = GL.GL_TRIANGLE_FAN; |
---|
418 | | -// break; |
---|
419 | | -// } |
---|
420 | | -// |
---|
421 | | -// if (!predrawGeometry(gl)) |
---|
422 | | -// { |
---|
423 | | -// // make sure only the necessary indices are sent through on old |
---|
424 | | -// // cards. |
---|
425 | | -// IntBuffer indices = this.getIndexBuffer(); |
---|
426 | | -// if (indices == null) |
---|
427 | | -// { |
---|
428 | | -// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
429 | | -// } else |
---|
430 | | -// { |
---|
431 | | -// indices.rewind(); |
---|
432 | | -// indices.limit(this.getMaxIndex()); |
---|
433 | | -// |
---|
434 | | -// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
435 | | -// |
---|
436 | | -// indices.clear(); |
---|
437 | | -// } |
---|
438 | | -// } else |
---|
439 | | -// { |
---|
440 | | -// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
441 | | -// GL.GL_UNSIGNED_INT, 0); |
---|
442 | | -// } |
---|
443 | | -// |
---|
444 | | -//// postdrawGeometry(tris); |
---|
445 | | -//// if (transformed) |
---|
446 | | -//// { |
---|
447 | | -//// undoTransforms(tris); |
---|
448 | | -//// } |
---|
449 | | -//// |
---|
450 | | -//// if (Debug.stats) |
---|
451 | | -//// { |
---|
452 | | -//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
453 | | -//// } |
---|
454 | | -//// tris.postdraw(this); |
---|
455 | | - } |
---|
456 | | - |
---|
457 | 288 | final boolean supportsVBO = false; |
---|
458 | 289 | private FloatBuffer prevVerts; |
---|
459 | 290 | |
---|