Normand Briere
2019-04-22 c60a1ad4f6aa4904e80280586b440a584b5ff061
CameraPane.java
....@@ -192,6 +192,11 @@
192192
193193 /// INTERFACE
194194
195
+ public boolean IsBoxMode()
196
+ {
197
+ return BOXMODE;
198
+ }
199
+
195200 public void ClearDepth()
196201 {
197202 GetGL().glClear(GetGL().GL_DEPTH_BUFFER_BIT);
....@@ -566,6 +571,195 @@
566571 }
567572 }
568573
574
+ /**
575
+ * <code>draw</code> renders a <code>TriMesh</code> object including
576
+ * it's normals, colors, textures and vertices.
577
+ *
578
+ * @see Renderer#draw(TriMesh)
579
+ * @param tris
580
+ * the mesh to render.
581
+ */
582
+ public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris)
583
+ {
584
+ CameraPane display = this;
585
+
586
+ float r = display.modelParams0[0];
587
+ float g = display.modelParams0[1];
588
+ float b = display.modelParams0[2];
589
+ float opacity = display.modelParams5[1];
590
+
591
+ //final GL gl = GLU.getCurrentGL();
592
+ GL gl = display.GetGL(); // getGL();
593
+
594
+ FloatBuffer vertBuf = geo.vertBuf;
595
+
596
+ int v = vertBuf.capacity();
597
+
598
+ int count = 0;
599
+
600
+ boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
601
+ gl.glEnable(gl.GL_CULL_FACE);
602
+ // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024);
603
+ for (int i=0; i<v/3; i++)
604
+ {
605
+ int index3 = i*3;
606
+
607
+ if (geo.sizeBuf.get(index3+1) == 0)
608
+ continue;
609
+
610
+ count++;
611
+
612
+ int index4 = i*4;
613
+
614
+ float tx = vertBuf.get(index3);
615
+ float ty = vertBuf.get(index3+1);
616
+ float tz = vertBuf.get(index3+2);
617
+
618
+ // if (tx == 0 && ty == 0 && tz == 0)
619
+ // continue;
620
+
621
+ gl.glMatrixMode(gl.GL_TEXTURE);
622
+ gl.glPushMatrix();
623
+
624
+ float[] texmat = geo.texmat;
625
+ texmat[12] = texmat[13] = texmat[14] = i;
626
+
627
+ gl.glMultMatrixf(texmat, 0);
628
+
629
+ gl.glMatrixMode(gl.GL_MODELVIEW);
630
+ gl.glPushMatrix();
631
+
632
+ gl.glTranslatef(tx,ty,tz);
633
+
634
+ if (rotate)
635
+ gl.glRotatef(i, 0, 1, 0);
636
+
637
+ float size = geo.sizeBuf.get(index3) / 100;
638
+ gl.glScalef(size,size,size);
639
+
640
+ float cr = geo.colorBuf.get(index4);
641
+ float cg = geo.colorBuf.get(index4+1);
642
+ float cb = geo.colorBuf.get(index4+2);
643
+ float ca = geo.colorBuf.get(index4+3);
644
+
645
+ display.modelParams0[0] = r * cr;
646
+ display.modelParams0[1] = g * cg;
647
+ display.modelParams0[2] = b * cb;
648
+
649
+ display.modelParams5[1] = opacity * ca;
650
+
651
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
652
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
653
+
654
+ RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i;
655
+ RandomNode.globalseed2 = RandomNode.globalseed;
656
+
657
+// gl.glColor4f(cr,cg,cb,ca);
658
+ // gl.glScalef(1024/16,1024/16,1024/16);
659
+ shape.Draw/*Node*/(display,null,selected,false); // blocked
660
+ // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
661
+ //gl.glTranslatef(-tx,-ty,-tz);
662
+ gl.glPopMatrix();
663
+
664
+ gl.glMatrixMode(gl.GL_TEXTURE);
665
+ gl.glPopMatrix();
666
+ }
667
+ // gl.glScalef(1024,1024,1024);
668
+ if (!cf)
669
+ gl.glDisable(gl.GL_CULL_FACE);
670
+
671
+ display.modelParams0[0] = r;
672
+ display.modelParams0[1] = g;
673
+ display.modelParams0[2] = b;
674
+
675
+ display.modelParams5[1] = opacity;
676
+
677
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
678
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
679
+
680
+ gl.glMatrixMode(gl.GL_MODELVIEW);
681
+
682
+// System.err.println("total = " + v/3 + "; displayed = " + count);
683
+ if (true)
684
+ return;
685
+
686
+//// if (!tris.predraw(this))
687
+//// {
688
+//// return;
689
+//// }
690
+//// if (Debug.stats)
691
+//// {
692
+//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount());
693
+//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount());
694
+//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1);
695
+//// }
696
+////
697
+//// if (tris.getDisplayListID() != -1)
698
+//// {
699
+//// renderDisplayList(tris);
700
+//// return;
701
+//// }
702
+////
703
+//// if (!generatingDisplayList)
704
+//// {
705
+//// applyStates(tris.states, tris);
706
+//// }
707
+//// if (Debug.stats)
708
+//// {
709
+//// StatCollector.startStat(StatType.STAT_RENDER_TIMER);
710
+//// }
711
+//// boolean transformed = doTransforms(tris);
712
+//
713
+// int glMode = GL.GL_TRIANGLES;
714
+// switch (getMode())
715
+// {
716
+// case Triangles:
717
+// glMode = GL.GL_TRIANGLES;
718
+// break;
719
+// case Strip:
720
+// glMode = GL.GL_TRIANGLE_STRIP;
721
+// break;
722
+// case Fan:
723
+// glMode = GL.GL_TRIANGLE_FAN;
724
+// break;
725
+// }
726
+//
727
+// if (!predrawGeometry(gl))
728
+// {
729
+// // make sure only the necessary indices are sent through on old
730
+// // cards.
731
+// IntBuffer indices = this.getIndexBuffer();
732
+// if (indices == null)
733
+// {
734
+// logger.severe("missing indices on geometry object: " + this.toString());
735
+// } else
736
+// {
737
+// indices.rewind();
738
+// indices.limit(this.getMaxIndex());
739
+//
740
+// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT
741
+//
742
+// indices.clear();
743
+// }
744
+// } else
745
+// {
746
+// gl.glDrawElements(glMode, this.getIndexBuffer().limit(),
747
+// GL.GL_UNSIGNED_INT, 0);
748
+// }
749
+//
750
+//// postdrawGeometry(tris);
751
+//// if (transformed)
752
+//// {
753
+//// undoTransforms(tris);
754
+//// }
755
+////
756
+//// if (Debug.stats)
757
+//// {
758
+//// StatCollector.endStat(StatType.STAT_RENDER_TIMER);
759
+//// }
760
+//// tris.postdraw(this);
761
+ }
762
+
569763 /// INTERFACE
570764
571765 void SetColor(Object3D obj, Vertex p0)