.. | .. |
---|
86 | 86 | static boolean FULLSCREEN = false; |
---|
87 | 87 | static boolean SUPPORT = true; |
---|
88 | 88 | static boolean INERTIA = true; |
---|
89 | | -static boolean FAST = false; |
---|
| 89 | +static boolean FAST = true; // false; |
---|
90 | 90 | static boolean SLOWPOSE = false; |
---|
91 | 91 | static boolean FOOTCONTACT = true; |
---|
92 | 92 | |
---|
93 | 93 | static int tickcount = 0; // slow pose issue |
---|
94 | 94 | |
---|
| 95 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 96 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 97 | static boolean BOXMODE = false; |
---|
96 | 98 | static boolean IMAGEFLIP = false; |
---|
97 | 99 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
149 | 151 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 152 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 153 | } |
---|
152 | | - static CameraPane theRenderer; |
---|
153 | | - |
---|
| 154 | + |
---|
154 | 155 | void SetAsGLRenderer(boolean b) |
---|
155 | 156 | { |
---|
156 | 157 | isRenderer = b; |
---|
157 | | - theRenderer = this; |
---|
| 158 | + Globals.theRenderer = this; |
---|
158 | 159 | } |
---|
159 | 160 | |
---|
160 | 161 | CameraPane(Object3D o, Camera cam, boolean withcontext) |
---|
.. | .. |
---|
191 | 192 | } |
---|
192 | 193 | |
---|
193 | 194 | /// INTERFACE |
---|
| 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 | + |
---|
| 225 | + public boolean IsBoxMode() |
---|
| 226 | + { |
---|
| 227 | + return BOXMODE; |
---|
| 228 | + } |
---|
| 229 | + |
---|
| 230 | + public boolean IsZoomBoxMode() |
---|
| 231 | + { |
---|
| 232 | + return ZOOMBOXMODE; |
---|
| 233 | + } |
---|
194 | 234 | |
---|
195 | 235 | public void ClearDepth() |
---|
196 | 236 | { |
---|
.. | .. |
---|
231 | 271 | return this.ambientOcclusion; |
---|
232 | 272 | } |
---|
233 | 273 | |
---|
| 274 | + public boolean IsDebugSelection() |
---|
| 275 | + { |
---|
| 276 | + return DEBUG_SELECTION; |
---|
| 277 | + } |
---|
| 278 | + |
---|
234 | 279 | public boolean IsFrozen() |
---|
235 | 280 | { |
---|
236 | | - boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 281 | + boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection(); |
---|
237 | 282 | |
---|
238 | 283 | return !selectmode && cameracount == 0; // != 0; |
---|
239 | 284 | } |
---|
.. | .. |
---|
254 | 299 | return lightCamera; |
---|
255 | 300 | } |
---|
256 | 301 | |
---|
| 302 | + public Camera ManipCamera() |
---|
| 303 | + { |
---|
| 304 | + return manipCamera; |
---|
| 305 | + } |
---|
| 306 | + |
---|
257 | 307 | public Camera RenderCamera() |
---|
258 | 308 | { |
---|
259 | 309 | return renderCamera; |
---|
| 310 | + } |
---|
| 311 | + |
---|
| 312 | + public Camera[] Cameras() |
---|
| 313 | + { |
---|
| 314 | + return cameras; |
---|
260 | 315 | } |
---|
261 | 316 | |
---|
262 | 317 | public void PushMaterial(Object3D obj, boolean selected) |
---|
.. | .. |
---|
403 | 458 | |
---|
404 | 459 | javax.media.opengl.GL gl = display.GetGL(); |
---|
405 | 460 | |
---|
406 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 461 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
407 | 462 | |
---|
408 | 463 | //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
409 | 464 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
.. | .. |
---|
566 | 621 | } |
---|
567 | 622 | } |
---|
568 | 623 | |
---|
| 624 | + /** |
---|
| 625 | + * <code>draw</code> renders a <code>TriMesh</code> object including |
---|
| 626 | + * it's normals, colors, textures and vertices. |
---|
| 627 | + * |
---|
| 628 | + * @see Renderer#draw(TriMesh) |
---|
| 629 | + * @param tris |
---|
| 630 | + * the mesh to render. |
---|
| 631 | + */ |
---|
| 632 | + public void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate) // TriMesh tris) |
---|
| 633 | + { |
---|
| 634 | + CameraPane display = this; |
---|
| 635 | + |
---|
| 636 | + float r = display.modelParams0[0]; |
---|
| 637 | + float g = display.modelParams0[1]; |
---|
| 638 | + float b = display.modelParams0[2]; |
---|
| 639 | + float opacity = display.modelParams5[1]; |
---|
| 640 | + |
---|
| 641 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 642 | + GL gl = display.GetGL(); // getGL(); |
---|
| 643 | + |
---|
| 644 | + FloatBuffer vertBuf = geo.vertBuf; |
---|
| 645 | + |
---|
| 646 | + int v = vertBuf.capacity(); |
---|
| 647 | + |
---|
| 648 | + int count = 0; |
---|
| 649 | + |
---|
| 650 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 651 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 652 | + // gl.glScalef(1.0f/1024,1.0f/1024,1.0f/1024); |
---|
| 653 | + for (int i=0; i<v/3; i++) |
---|
| 654 | + { |
---|
| 655 | + int index3 = i*3; |
---|
| 656 | + |
---|
| 657 | + if (geo.sizeBuf.get(index3+1) == 0) |
---|
| 658 | + continue; |
---|
| 659 | + |
---|
| 660 | + count++; |
---|
| 661 | + |
---|
| 662 | + int index4 = i*4; |
---|
| 663 | + |
---|
| 664 | + float tx = vertBuf.get(index3); |
---|
| 665 | + float ty = vertBuf.get(index3+1); |
---|
| 666 | + float tz = vertBuf.get(index3+2); |
---|
| 667 | + |
---|
| 668 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 669 | + // continue; |
---|
| 670 | + |
---|
| 671 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 672 | + gl.glPushMatrix(); |
---|
| 673 | + |
---|
| 674 | + float[] texmat = geo.texmat; |
---|
| 675 | + texmat[12] = texmat[13] = texmat[14] = i; |
---|
| 676 | + |
---|
| 677 | + gl.glMultMatrixf(texmat, 0); |
---|
| 678 | + |
---|
| 679 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 680 | + gl.glPushMatrix(); |
---|
| 681 | + |
---|
| 682 | + gl.glTranslatef(tx,ty,tz); |
---|
| 683 | + |
---|
| 684 | + if (rotate) |
---|
| 685 | + gl.glRotatef(i, 0, 1, 0); |
---|
| 686 | + |
---|
| 687 | + float size = geo.sizeBuf.get(index3) / 100; |
---|
| 688 | + gl.glScalef(size,size,size); |
---|
| 689 | + |
---|
| 690 | + float cr = geo.colorBuf.get(index4); |
---|
| 691 | + float cg = geo.colorBuf.get(index4+1); |
---|
| 692 | + float cb = geo.colorBuf.get(index4+2); |
---|
| 693 | + float ca = geo.colorBuf.get(index4+3); |
---|
| 694 | + |
---|
| 695 | + display.modelParams0[0] = r * cr; |
---|
| 696 | + display.modelParams0[1] = g * cg; |
---|
| 697 | + display.modelParams0[2] = b * cb; |
---|
| 698 | + |
---|
| 699 | + display.modelParams5[1] = opacity * ca; |
---|
| 700 | + |
---|
| 701 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 702 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 703 | + |
---|
| 704 | + RandomNode.globalseed = (int)geo.sizeBuf.get(index3+2); // i; |
---|
| 705 | + RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 706 | + |
---|
| 707 | +// gl.glColor4f(cr,cg,cb,ca); |
---|
| 708 | + // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 709 | + shape.Draw/*Node*/(display,null,selected,false); // blocked |
---|
| 710 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 711 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 712 | + gl.glPopMatrix(); |
---|
| 713 | + |
---|
| 714 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 715 | + gl.glPopMatrix(); |
---|
| 716 | + } |
---|
| 717 | + // gl.glScalef(1024,1024,1024); |
---|
| 718 | + if (!cf) |
---|
| 719 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 720 | + |
---|
| 721 | + display.modelParams0[0] = r; |
---|
| 722 | + display.modelParams0[1] = g; |
---|
| 723 | + display.modelParams0[2] = b; |
---|
| 724 | + |
---|
| 725 | + display.modelParams5[1] = opacity; |
---|
| 726 | + |
---|
| 727 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 728 | + gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 729 | + |
---|
| 730 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 731 | + |
---|
| 732 | +// System.err.println("total = " + v/3 + "; displayed = " + count); |
---|
| 733 | + if (true) |
---|
| 734 | + return; |
---|
| 735 | + |
---|
| 736 | +//// if (!tris.predraw(this)) |
---|
| 737 | +//// { |
---|
| 738 | +//// return; |
---|
| 739 | +//// } |
---|
| 740 | +//// if (Debug.stats) |
---|
| 741 | +//// { |
---|
| 742 | +//// StatCollector.addStat(StatType.STAT_TRIANGLE_COUNT, tris.getTriangleCount()); |
---|
| 743 | +//// StatCollector.addStat(StatType.STAT_VERTEX_COUNT, tris.getVertexCount()); |
---|
| 744 | +//// StatCollector.addStat(StatType.STAT_GEOM_COUNT, 1); |
---|
| 745 | +//// } |
---|
| 746 | +//// |
---|
| 747 | +//// if (tris.getDisplayListID() != -1) |
---|
| 748 | +//// { |
---|
| 749 | +//// renderDisplayList(tris); |
---|
| 750 | +//// return; |
---|
| 751 | +//// } |
---|
| 752 | +//// |
---|
| 753 | +//// if (!generatingDisplayList) |
---|
| 754 | +//// { |
---|
| 755 | +//// applyStates(tris.states, tris); |
---|
| 756 | +//// } |
---|
| 757 | +//// if (Debug.stats) |
---|
| 758 | +//// { |
---|
| 759 | +//// StatCollector.startStat(StatType.STAT_RENDER_TIMER); |
---|
| 760 | +//// } |
---|
| 761 | +//// boolean transformed = doTransforms(tris); |
---|
| 762 | +// |
---|
| 763 | +// int glMode = GL.GL_TRIANGLES; |
---|
| 764 | +// switch (getMode()) |
---|
| 765 | +// { |
---|
| 766 | +// case Triangles: |
---|
| 767 | +// glMode = GL.GL_TRIANGLES; |
---|
| 768 | +// break; |
---|
| 769 | +// case Strip: |
---|
| 770 | +// glMode = GL.GL_TRIANGLE_STRIP; |
---|
| 771 | +// break; |
---|
| 772 | +// case Fan: |
---|
| 773 | +// glMode = GL.GL_TRIANGLE_FAN; |
---|
| 774 | +// break; |
---|
| 775 | +// } |
---|
| 776 | +// |
---|
| 777 | +// if (!predrawGeometry(gl)) |
---|
| 778 | +// { |
---|
| 779 | +// // make sure only the necessary indices are sent through on old |
---|
| 780 | +// // cards. |
---|
| 781 | +// IntBuffer indices = this.getIndexBuffer(); |
---|
| 782 | +// if (indices == null) |
---|
| 783 | +// { |
---|
| 784 | +// logger.severe("missing indices on geometry object: " + this.toString()); |
---|
| 785 | +// } else |
---|
| 786 | +// { |
---|
| 787 | +// indices.rewind(); |
---|
| 788 | +// indices.limit(this.getMaxIndex()); |
---|
| 789 | +// |
---|
| 790 | +// gl.glDrawElements(glMode, indices.limit(), GL.GL_UNSIGNED_INT, indices); // TODO Check <count> and assumed <type> of GL_UNSIGNED_INT |
---|
| 791 | +// |
---|
| 792 | +// indices.clear(); |
---|
| 793 | +// } |
---|
| 794 | +// } else |
---|
| 795 | +// { |
---|
| 796 | +// gl.glDrawElements(glMode, this.getIndexBuffer().limit(), |
---|
| 797 | +// GL.GL_UNSIGNED_INT, 0); |
---|
| 798 | +// } |
---|
| 799 | +// |
---|
| 800 | +//// postdrawGeometry(tris); |
---|
| 801 | +//// if (transformed) |
---|
| 802 | +//// { |
---|
| 803 | +//// undoTransforms(tris); |
---|
| 804 | +//// } |
---|
| 805 | +//// |
---|
| 806 | +//// if (Debug.stats) |
---|
| 807 | +//// { |
---|
| 808 | +//// StatCollector.endStat(StatType.STAT_RENDER_TIMER); |
---|
| 809 | +//// } |
---|
| 810 | +//// tris.postdraw(this); |
---|
| 811 | + } |
---|
| 812 | + |
---|
| 813 | + static Camera localcamera = new Camera(); |
---|
| 814 | + static cVector from = new cVector(); |
---|
| 815 | + static cVector to = new cVector(); |
---|
| 816 | + |
---|
| 817 | + public void PrepOcclusion(BoundaryRep br, double[][] transform) |
---|
| 818 | + { |
---|
| 819 | + CameraPane cp = this; |
---|
| 820 | + |
---|
| 821 | + Camera keep = cp.RenderCamera(); |
---|
| 822 | + cp.renderCamera = localcamera; |
---|
| 823 | + |
---|
| 824 | + if (br.trimmed) |
---|
| 825 | + { |
---|
| 826 | + float[] colors = new float[br.positions.length / 3]; |
---|
| 827 | + |
---|
| 828 | + int i3 = 0; |
---|
| 829 | + for (int i = 0; i < br.positions.length / 3; i++, i3 += 3) |
---|
| 830 | + { |
---|
| 831 | + if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0) |
---|
| 832 | + continue; |
---|
| 833 | + |
---|
| 834 | + from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]); |
---|
| 835 | + to.set(br.positions[i3] + br.normals[i3], |
---|
| 836 | + br.positions[i3 + 1] + br.normals[i3 + 1], |
---|
| 837 | + br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
| 838 | + LA.xformPos(from, transform, from); |
---|
| 839 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 840 | + localcamera.setAim(from, to); |
---|
| 841 | + |
---|
| 842 | + CameraPane.occlusionbuffer.display(); |
---|
| 843 | + |
---|
| 844 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 845 | + cp.display(); // debug |
---|
| 846 | + |
---|
| 847 | + colors[i] = cp.vertexOcclusion.r; |
---|
| 848 | + //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
| 849 | + //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
| 850 | + |
---|
| 851 | + if ((i % 100) == 0 && i != 0) |
---|
| 852 | + { |
---|
| 853 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 854 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 855 | + System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")"); |
---|
| 856 | + } |
---|
| 857 | + } |
---|
| 858 | + |
---|
| 859 | + br.colors = colors; |
---|
| 860 | + } |
---|
| 861 | + else |
---|
| 862 | + { |
---|
| 863 | + for (int i = 0; i < br.VertexCount(); i++) |
---|
| 864 | + { |
---|
| 865 | + Vertex v = br.GetVertex(i); |
---|
| 866 | + |
---|
| 867 | + if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
| 868 | + continue; |
---|
| 869 | + |
---|
| 870 | + from.set(v.x, v.y, v.z); |
---|
| 871 | + to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
| 872 | + LA.xformPos(from, transform, from); |
---|
| 873 | + LA.xformPos(to, transform, to); // RIGID ONLY |
---|
| 874 | + localcamera.setAim(from, to); |
---|
| 875 | + |
---|
| 876 | + CameraPane.occlusionbuffer.display(); |
---|
| 877 | + |
---|
| 878 | + if (CameraPane.DEBUG_OCCLUSION) |
---|
| 879 | + cp.display(); // debug |
---|
| 880 | + |
---|
| 881 | + v.AO = cp.vertexOcclusion.r; |
---|
| 882 | + |
---|
| 883 | + if ((i % 100) == 0 && i != 0) |
---|
| 884 | + { |
---|
| 885 | + Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
| 886 | + //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
| 887 | + System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")"); |
---|
| 888 | + } |
---|
| 889 | + } |
---|
| 890 | + } |
---|
| 891 | + |
---|
| 892 | + //System.out.println("done."); |
---|
| 893 | + |
---|
| 894 | + cp.renderCamera = keep; |
---|
| 895 | + } |
---|
| 896 | + |
---|
| 897 | + void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 898 | + { |
---|
| 899 | + CameraPane display = this; |
---|
| 900 | + pointFlow.CreateHT(); |
---|
| 901 | + |
---|
| 902 | + float r = display.modelParams0[0]; |
---|
| 903 | + float g = display.modelParams0[1]; |
---|
| 904 | + float b = display.modelParams0[2]; |
---|
| 905 | + float opacity = display.modelParams5[1]; |
---|
| 906 | + |
---|
| 907 | + //final GL gl = GLU.getCurrentGL(); |
---|
| 908 | + GL gl = display.GetGL(); // getGL(); |
---|
| 909 | + |
---|
| 910 | + int s = pointFlow.points.size(); |
---|
| 911 | + |
---|
| 912 | + boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE); |
---|
| 913 | + gl.glEnable(gl.GL_CULL_FACE); |
---|
| 914 | + |
---|
| 915 | + for (int i=s; --i>=0;) |
---|
| 916 | + //for (int i=0; i<s; i++) |
---|
| 917 | + { |
---|
| 918 | + cVector v = pointFlow.points.get(i); |
---|
| 919 | + |
---|
| 920 | + double mindist = Double.MAX_VALUE; |
---|
| 921 | + |
---|
| 922 | + double size = pointFlow.minimumSize; |
---|
| 923 | + |
---|
| 924 | + double distancenext = 0; |
---|
| 925 | + |
---|
| 926 | + if (i > 0) |
---|
| 927 | + { |
---|
| 928 | + cVector w = pointFlow.points.get(i-1); |
---|
| 929 | + |
---|
| 930 | + double dist = w.distance(v); |
---|
| 931 | + |
---|
| 932 | + distancenext = dist; |
---|
| 933 | + |
---|
| 934 | + if (mindist > dist) |
---|
| 935 | + { |
---|
| 936 | + mindist = dist; |
---|
| 937 | + size = mindist*pointFlow.resizefactor; |
---|
| 938 | + } |
---|
| 939 | + } |
---|
| 940 | + |
---|
| 941 | + if (i < s-1) |
---|
| 942 | + { |
---|
| 943 | + cVector w = pointFlow.points.get(i+1); |
---|
| 944 | + |
---|
| 945 | + double dist = w.distance(v); |
---|
| 946 | + |
---|
| 947 | + if (mindist > dist) |
---|
| 948 | + { |
---|
| 949 | + mindist = dist; |
---|
| 950 | + size = mindist*pointFlow.resizefactor; |
---|
| 951 | + } |
---|
| 952 | + } |
---|
| 953 | + |
---|
| 954 | + if (size < pointFlow.minimumSize) |
---|
| 955 | + size = pointFlow.minimumSize; |
---|
| 956 | + if (size > pointFlow.maximumSize) |
---|
| 957 | + size = pointFlow.maximumSize; |
---|
| 958 | + |
---|
| 959 | + double tx = v.x; |
---|
| 960 | + double ty = v.y; |
---|
| 961 | + double tz = v.z; |
---|
| 962 | + |
---|
| 963 | + // if (tx == 0 && ty == 0 && tz == 0) |
---|
| 964 | + // continue; |
---|
| 965 | + |
---|
| 966 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 967 | + gl.glPushMatrix(); |
---|
| 968 | + pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i; |
---|
| 969 | + |
---|
| 970 | + gl.glMultMatrixf(pointFlow.texmat, 0); |
---|
| 971 | + |
---|
| 972 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 973 | + gl.glPushMatrix(); |
---|
| 974 | + |
---|
| 975 | + gl.glTranslated(tx,ty,tz); |
---|
| 976 | + |
---|
| 977 | + gl.glScaled(size,size,size); |
---|
| 978 | + |
---|
| 979 | +// float cr = colorBuf.get(index4); |
---|
| 980 | +// float cg = colorBuf.get(index4+1); |
---|
| 981 | +// float cb = colorBuf.get(index4+2); |
---|
| 982 | +// float ca = colorBuf.get(index4+3); |
---|
| 983 | +// |
---|
| 984 | +// display.modelParams0[0] = r * cr; |
---|
| 985 | +// display.modelParams0[1] = g * cg; |
---|
| 986 | +// display.modelParams0[2] = b * cb; |
---|
| 987 | +// |
---|
| 988 | +// display.modelParams5[1] = opacity * ca; |
---|
| 989 | +// |
---|
| 990 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 991 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 992 | +// |
---|
| 993 | +// RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i; |
---|
| 994 | +// RandomNode.globalseed2 = RandomNode.globalseed; |
---|
| 995 | +// |
---|
| 996 | +//// gl.glColor4f(cr,cg,cb,ca); |
---|
| 997 | +// // gl.glScalef(1024/16,1024/16,1024/16); |
---|
| 998 | + pointFlow.geo.Draw/*Node*/(display,null,selected, blocked); |
---|
| 999 | + |
---|
| 1000 | + gl.glPopMatrix(); |
---|
| 1001 | + |
---|
| 1002 | + double step = size/4; // |
---|
| 1003 | + |
---|
| 1004 | + if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step) |
---|
| 1005 | + continue; |
---|
| 1006 | + |
---|
| 1007 | + int nbsteps = (int)(distancenext/step); |
---|
| 1008 | + |
---|
| 1009 | + step = distancenext/nbsteps; |
---|
| 1010 | + |
---|
| 1011 | + cVector next = pointFlow.points.get(i-1); |
---|
| 1012 | + |
---|
| 1013 | + tmp.set(next); |
---|
| 1014 | + tmp.sub(v); |
---|
| 1015 | + tmp.normalize(); |
---|
| 1016 | + tmp.mul(step); |
---|
| 1017 | + |
---|
| 1018 | + // calculate next size |
---|
| 1019 | + mindist = Double.MAX_VALUE; |
---|
| 1020 | + |
---|
| 1021 | + double nextsize = pointFlow.minimumSize; |
---|
| 1022 | + |
---|
| 1023 | + if (i > 1) |
---|
| 1024 | + { |
---|
| 1025 | + cVector w = pointFlow.points.get(i-2); |
---|
| 1026 | + |
---|
| 1027 | + double dist = w.distance(next); |
---|
| 1028 | + |
---|
| 1029 | + if (mindist > dist) |
---|
| 1030 | + { |
---|
| 1031 | + mindist = dist; |
---|
| 1032 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1033 | + } |
---|
| 1034 | + } |
---|
| 1035 | + |
---|
| 1036 | + double dist = v.distance(next); |
---|
| 1037 | + |
---|
| 1038 | + if (mindist > dist) |
---|
| 1039 | + { |
---|
| 1040 | + mindist = dist; |
---|
| 1041 | + nextsize = mindist*pointFlow.resizefactor; |
---|
| 1042 | + } |
---|
| 1043 | + |
---|
| 1044 | + if (nextsize < pointFlow.minimumSize) |
---|
| 1045 | + nextsize = pointFlow.minimumSize; |
---|
| 1046 | + if (nextsize > pointFlow.maximumSize) |
---|
| 1047 | + nextsize = pointFlow.maximumSize; |
---|
| 1048 | + // |
---|
| 1049 | + |
---|
| 1050 | + double count = 0; |
---|
| 1051 | + |
---|
| 1052 | + while (distancenext > 0.000000001) // step |
---|
| 1053 | + { |
---|
| 1054 | + gl.glPushMatrix(); |
---|
| 1055 | + |
---|
| 1056 | + gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count); |
---|
| 1057 | + |
---|
| 1058 | + double K = count/nbsteps; |
---|
| 1059 | + |
---|
| 1060 | + double intersize = K*nextsize + (1-K)*size; |
---|
| 1061 | + |
---|
| 1062 | + gl.glScaled(intersize,intersize,intersize); |
---|
| 1063 | + |
---|
| 1064 | + pointFlow.geo.Draw/*Node*/(display,null,selected,blocked); |
---|
| 1065 | + |
---|
| 1066 | + count++; |
---|
| 1067 | + |
---|
| 1068 | + distancenext -= step; |
---|
| 1069 | + |
---|
| 1070 | + gl.glPopMatrix(); |
---|
| 1071 | + } |
---|
| 1072 | + |
---|
| 1073 | + if (count != nbsteps) |
---|
| 1074 | + assert(count == nbsteps); |
---|
| 1075 | + |
---|
| 1076 | + // gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024); |
---|
| 1077 | + //gl.glTranslatef(-tx,-ty,-tz); |
---|
| 1078 | + |
---|
| 1079 | + gl.glMatrixMode(gl.GL_TEXTURE); |
---|
| 1080 | + gl.glPopMatrix(); |
---|
| 1081 | + } |
---|
| 1082 | + |
---|
| 1083 | + if (!cf) |
---|
| 1084 | + gl.glDisable(gl.GL_CULL_FACE); |
---|
| 1085 | + |
---|
| 1086 | +// display.modelParams0[0] = r; |
---|
| 1087 | +// display.modelParams0[1] = g; |
---|
| 1088 | +// display.modelParams0[2] = b; |
---|
| 1089 | +// |
---|
| 1090 | +// display.modelParams5[1] = opacity; |
---|
| 1091 | +// |
---|
| 1092 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0); |
---|
| 1093 | +// gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0); |
---|
| 1094 | + |
---|
| 1095 | + gl.glMatrixMode(gl.GL_MODELVIEW); |
---|
| 1096 | + } |
---|
| 1097 | + |
---|
| 1098 | + public void DrawBox(cVector min, cVector max) |
---|
| 1099 | + { |
---|
| 1100 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1101 | + gl.glBegin(gl.GL_LINES); |
---|
| 1102 | + |
---|
| 1103 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1104 | + gl.glVertex3d(min.x, min.y, max.z); |
---|
| 1105 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1106 | + gl.glVertex3d(min.x, max.y, min.z); |
---|
| 1107 | + gl.glVertex3d(min.x, min.y, min.z); |
---|
| 1108 | + gl.glVertex3d(max.x, min.y, min.z); |
---|
| 1109 | + |
---|
| 1110 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1111 | + gl.glVertex3d(min.x, max.y, max.z); |
---|
| 1112 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1113 | + gl.glVertex3d(max.x, min.y, max.z); |
---|
| 1114 | + gl.glVertex3d(max.x, max.y, max.z); |
---|
| 1115 | + gl.glVertex3d(max.x, max.y, min.z); |
---|
| 1116 | + |
---|
| 1117 | + gl.glEnd(); |
---|
| 1118 | + } |
---|
| 1119 | + |
---|
| 1120 | + public void DrawGeometry(BoundaryRep bRep, boolean flipV, boolean selectmode) |
---|
| 1121 | + { |
---|
| 1122 | + int[] strips = bRep.getRawIndices(); |
---|
| 1123 | + |
---|
| 1124 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1125 | + |
---|
| 1126 | + // TRIANGLE STRIP ARRAY |
---|
| 1127 | + if (bRep.trimmed) |
---|
| 1128 | + { |
---|
| 1129 | + float[] v = bRep.getRawVertices(); |
---|
| 1130 | + float[] n = bRep.getRawNormals(); |
---|
| 1131 | + float[] c = bRep.getRawColors(); |
---|
| 1132 | + float[] uv = bRep.getRawUVMap(); |
---|
| 1133 | + |
---|
| 1134 | + int count2 = 0; |
---|
| 1135 | + int count3 = 0; |
---|
| 1136 | + |
---|
| 1137 | + if (n.length > 0) |
---|
| 1138 | + { |
---|
| 1139 | + for (int i = 0; i < strips.length; i++) |
---|
| 1140 | + { |
---|
| 1141 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1142 | + |
---|
| 1143 | + /* |
---|
| 1144 | + boolean locked = false; |
---|
| 1145 | + float eps = 0.1f; |
---|
| 1146 | + boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
| 1147 | + |
---|
| 1148 | + int dot = 0; |
---|
| 1149 | + |
---|
| 1150 | + if ((dot&1) == 0) |
---|
| 1151 | + dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
| 1152 | + |
---|
| 1153 | + if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
| 1154 | + gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
| 1155 | + else |
---|
| 1156 | + { |
---|
| 1157 | + locked = true; |
---|
| 1158 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1159 | + } |
---|
| 1160 | + //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
| 1161 | + gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
| 1162 | + if (hasnorm) |
---|
| 1163 | + { |
---|
| 1164 | + //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
| 1165 | + gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
| 1166 | + } |
---|
| 1167 | + |
---|
| 1168 | + if ((dot&4) == 0) |
---|
| 1169 | + dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
| 1170 | + |
---|
| 1171 | + if (wrap || !locked && (dot&8) != 0) |
---|
| 1172 | + gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
| 1173 | + else |
---|
| 1174 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1175 | + |
---|
| 1176 | + f.dot = dot; |
---|
| 1177 | + */ |
---|
| 1178 | + |
---|
| 1179 | + if (!selectmode) |
---|
| 1180 | + { |
---|
| 1181 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1182 | + { |
---|
| 1183 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1184 | + } else |
---|
| 1185 | + { |
---|
| 1186 | + gl.glNormal3f(0, 0, 1); |
---|
| 1187 | + } |
---|
| 1188 | + |
---|
| 1189 | + if (c != null) |
---|
| 1190 | + //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
| 1191 | + { |
---|
| 1192 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1193 | + } |
---|
| 1194 | + } |
---|
| 1195 | + if (flipV) |
---|
| 1196 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1197 | + else |
---|
| 1198 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1199 | + //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1200 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1201 | + |
---|
| 1202 | + count2 += 2; |
---|
| 1203 | + count3 += 3; |
---|
| 1204 | + if (!selectmode) |
---|
| 1205 | + { |
---|
| 1206 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1207 | + { |
---|
| 1208 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1209 | + } else |
---|
| 1210 | + { |
---|
| 1211 | + gl.glNormal3f(0, 0, 1); |
---|
| 1212 | + } |
---|
| 1213 | + if (c != null) |
---|
| 1214 | + { |
---|
| 1215 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1216 | + } |
---|
| 1217 | + } |
---|
| 1218 | + if (flipV) |
---|
| 1219 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1220 | + else |
---|
| 1221 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1222 | + //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
| 1223 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1224 | + |
---|
| 1225 | + count2 += 2; |
---|
| 1226 | + count3 += 3; |
---|
| 1227 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1228 | + { |
---|
| 1229 | + //gl.glTexCoord2d(...); |
---|
| 1230 | + if (!selectmode) |
---|
| 1231 | + { |
---|
| 1232 | + if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
| 1233 | + { |
---|
| 1234 | + gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1235 | + } else |
---|
| 1236 | + { |
---|
| 1237 | + gl.glNormal3f(0, 0, 1); |
---|
| 1238 | + } |
---|
| 1239 | + if (c != null) |
---|
| 1240 | + { |
---|
| 1241 | + gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
| 1242 | + } |
---|
| 1243 | + } |
---|
| 1244 | + |
---|
| 1245 | + if (flipV) |
---|
| 1246 | + gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
| 1247 | + else |
---|
| 1248 | + gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1249 | + //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
| 1250 | + gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1251 | + count2 += 2; |
---|
| 1252 | + count3 += 3; |
---|
| 1253 | + } |
---|
| 1254 | + |
---|
| 1255 | + gl.glEnd(); |
---|
| 1256 | + } |
---|
| 1257 | + } |
---|
| 1258 | + |
---|
| 1259 | + assert count3 == v.length; |
---|
| 1260 | + } |
---|
| 1261 | + else // !trimmed |
---|
| 1262 | + { |
---|
| 1263 | + int count = 0; |
---|
| 1264 | + for (int i = 0; i < strips.length; i++) |
---|
| 1265 | + { |
---|
| 1266 | + gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
| 1267 | + |
---|
| 1268 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1269 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1270 | + |
---|
| 1271 | + drawVertex(gl, p, flipV, selectmode); |
---|
| 1272 | + drawVertex(gl, q, flipV, selectmode); |
---|
| 1273 | + |
---|
| 1274 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 1275 | + { |
---|
| 1276 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 1277 | + |
---|
| 1278 | + // if (j%2 == 0) |
---|
| 1279 | + // drawFace(p, q, r, display, null); |
---|
| 1280 | + // else |
---|
| 1281 | + // drawFace(p, r, q, display, null); |
---|
| 1282 | + |
---|
| 1283 | + // p = q; |
---|
| 1284 | + // q = r; |
---|
| 1285 | + drawVertex(gl, r, flipV, selectmode); |
---|
| 1286 | + } |
---|
| 1287 | + |
---|
| 1288 | + gl.glEnd(); |
---|
| 1289 | + } |
---|
| 1290 | + } |
---|
| 1291 | + } |
---|
| 1292 | + |
---|
| 1293 | + static cSpring.Point3D temp = new cSpring.Point3D(); |
---|
| 1294 | + static cSpring.Point3D temp2 = new cSpring.Point3D(); |
---|
| 1295 | + static cSpring.Point3D temp3 = new cSpring.Point3D(); |
---|
| 1296 | + |
---|
| 1297 | + public void DrawDynamicMesh(cMesh mesh) |
---|
| 1298 | + { |
---|
| 1299 | + GL gl = GetGL(); // getGL(); |
---|
| 1300 | + |
---|
| 1301 | + cSpring.PhysicsController3D Phys = mesh.Phys; |
---|
| 1302 | + |
---|
| 1303 | + gl.glDisable(gl.GL_LIGHTING); |
---|
| 1304 | + |
---|
| 1305 | + gl.glLineWidth(1); |
---|
| 1306 | + gl.glColor3f(1,1,1); |
---|
| 1307 | + gl.glBegin(gl.GL_LINES); |
---|
| 1308 | + double scale = 0; |
---|
| 1309 | + int count = 0; |
---|
| 1310 | + for (int s=0; s<Phys.allSprings.size(); s++) |
---|
| 1311 | + { |
---|
| 1312 | + cSpring.Spring spring = Phys.allSprings.get(s); |
---|
| 1313 | + if(s == 0) |
---|
| 1314 | + { |
---|
| 1315 | + //System.out.println(" spring : " + spring.a.position + "; " + spring.b.position); |
---|
| 1316 | + } |
---|
| 1317 | + if (mesh.showsprings) |
---|
| 1318 | + { |
---|
| 1319 | + temp.set(spring.a.position); |
---|
| 1320 | + temp.add(spring.b.position); |
---|
| 1321 | + temp.mul(0.5); |
---|
| 1322 | + temp2.set(spring.a.position); |
---|
| 1323 | + temp2.sub(spring.b.position); |
---|
| 1324 | + temp2.mul(spring.restLength/2); |
---|
| 1325 | + temp.sub(temp2); |
---|
| 1326 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1327 | + temp.add(temp2); |
---|
| 1328 | + temp.add(temp2); |
---|
| 1329 | + gl.glVertex3f((float)temp.x, (float)temp.y, (float)temp.z); |
---|
| 1330 | + } |
---|
| 1331 | + |
---|
| 1332 | + if (spring.isHandle) |
---|
| 1333 | + continue; |
---|
| 1334 | + |
---|
| 1335 | + //if (scale < spring.restLength) |
---|
| 1336 | + scale += spring.restLength; |
---|
| 1337 | + count++; |
---|
| 1338 | + } |
---|
| 1339 | + gl.glEnd(); |
---|
| 1340 | + |
---|
| 1341 | + if (count == 0) |
---|
| 1342 | + scale = 0.01; |
---|
| 1343 | + else |
---|
| 1344 | + scale /= count * 3; |
---|
| 1345 | + |
---|
| 1346 | + //scale = 0.25; |
---|
| 1347 | + |
---|
| 1348 | + if (mesh.ShowInfo()) |
---|
| 1349 | + { |
---|
| 1350 | + gl.glLineWidth(4); |
---|
| 1351 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1352 | + { |
---|
| 1353 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1354 | + if (node.mass == 0) |
---|
| 1355 | + continue; |
---|
| 1356 | + |
---|
| 1357 | + int i = node.springs==null?-1:node.springs.size(); |
---|
| 1358 | + gl.glColor3f((i>>2)&1,(i>>1)&1,i&1); |
---|
| 1359 | + //temp.set(node.springForce.x, node.springForce.y, node.springForce.z); |
---|
| 1360 | + //temp.normalize(); |
---|
| 1361 | + //gl.glColor3d((temp.x+1)/2, (temp.y+1)/2, (temp.z+1)/2); |
---|
| 1362 | + gl.glBegin(gl.GL_LINES); |
---|
| 1363 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1364 | + //gl.glVertex3d(node.position.x + node.normal.x*scale, node.position.y + node.normal.y*scale, node.position.z + node.normal.z*scale); |
---|
| 1365 | + gl.glVertex3d(node.position.x + mesh.bRep.GetVertex(s).norm.x*scale, |
---|
| 1366 | + node.position.y + mesh.bRep.GetVertex(s).norm.y*scale, |
---|
| 1367 | + node.position.z + mesh.bRep.GetVertex(s).norm.z*scale); |
---|
| 1368 | + gl.glEnd(); |
---|
| 1369 | + } |
---|
| 1370 | + |
---|
| 1371 | + gl.glLineWidth(8); |
---|
| 1372 | + for (int s=0; s<Phys.allNodes.size(); s++) |
---|
| 1373 | + { |
---|
| 1374 | + cSpring.DynamicNode node = Phys.allNodes.get(s); |
---|
| 1375 | + |
---|
| 1376 | + if (node.springs != null) |
---|
| 1377 | + { |
---|
| 1378 | + for (int i=0; i<node.springs.size(); i+=1) |
---|
| 1379 | + { |
---|
| 1380 | + cSpring.DynamicNode f = node.springs.get(i).GetOther(node); |
---|
| 1381 | + |
---|
| 1382 | + int c = i+1; |
---|
| 1383 | + // c = node.springs.get(i).nbcopies; |
---|
| 1384 | + |
---|
| 1385 | + gl.glColor3f((c>>2)&1,(c>>1)&1,c&1); |
---|
| 1386 | + gl.glBegin(gl.GL_LINES); |
---|
| 1387 | + gl.glVertex3d(node.position.x, node.position.y, node.position.z); |
---|
| 1388 | + 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); |
---|
| 1389 | + gl.glEnd(); |
---|
| 1390 | + } |
---|
| 1391 | + } |
---|
| 1392 | + } |
---|
| 1393 | + |
---|
| 1394 | + gl.glLineWidth(1); |
---|
| 1395 | + } |
---|
| 1396 | + |
---|
| 1397 | + gl.glEnable(gl.GL_LIGHTING); |
---|
| 1398 | + } |
---|
| 1399 | + |
---|
569 | 1400 | /// INTERFACE |
---|
| 1401 | + |
---|
| 1402 | + public void StartTriangles() |
---|
| 1403 | + { |
---|
| 1404 | + javax.media.opengl.GL gl = GetGL(); |
---|
| 1405 | + gl.glBegin(gl.GL_TRIANGLES); |
---|
| 1406 | + } |
---|
| 1407 | + |
---|
| 1408 | + public void EndTriangles() |
---|
| 1409 | + { |
---|
| 1410 | + GetGL().glEnd(); |
---|
| 1411 | + } |
---|
| 1412 | + |
---|
| 1413 | + void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean flipV, boolean selectmode) |
---|
| 1414 | + { |
---|
| 1415 | + if (!selectmode) |
---|
| 1416 | + { |
---|
| 1417 | + gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1418 | + gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
| 1419 | + |
---|
| 1420 | + if (flipV) |
---|
| 1421 | + gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
| 1422 | + else |
---|
| 1423 | + gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
| 1424 | + } |
---|
| 1425 | + |
---|
| 1426 | + gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
| 1427 | + } |
---|
570 | 1428 | |
---|
571 | 1429 | void SetColor(Object3D obj, Vertex p0) |
---|
572 | 1430 | { |
---|
.. | .. |
---|
761 | 1619 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
762 | 1620 | if (!material.multiply) |
---|
763 | 1621 | { |
---|
764 | | - display.color = color; |
---|
| 1622 | + display.color = material.color; |
---|
765 | 1623 | display.saturation = material.modulation; |
---|
766 | 1624 | } |
---|
767 | 1625 | else |
---|
768 | 1626 | { |
---|
769 | | - display.color *= color*2; |
---|
| 1627 | + display.color *= material.color*2; |
---|
770 | 1628 | display.saturation *= material.modulation*2; |
---|
771 | 1629 | } |
---|
772 | 1630 | |
---|
.. | .. |
---|
1129 | 1987 | |
---|
1130 | 1988 | static int camerachangeframe; |
---|
1131 | 1989 | |
---|
1132 | | - boolean SetCamera(Camera cam) |
---|
| 1990 | + public boolean SetCamera(Camera cam) |
---|
1133 | 1991 | { |
---|
1134 | 1992 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
1135 | 1993 | // return false; |
---|
.. | .. |
---|
1257 | 2115 | mainDL ^= true; |
---|
1258 | 2116 | } |
---|
1259 | 2117 | |
---|
1260 | | - void ToggleTexture() |
---|
| 2118 | + void ToggleFullScreen() |
---|
| 2119 | + { |
---|
| 2120 | + FULLSCREEN ^= true; |
---|
| 2121 | + } |
---|
| 2122 | + |
---|
| 2123 | + void ToggleCrowd() |
---|
| 2124 | + { |
---|
| 2125 | + Globals.CROWD ^= true; |
---|
| 2126 | + } |
---|
| 2127 | + |
---|
| 2128 | + void ToggleLocal() |
---|
| 2129 | + { |
---|
| 2130 | + LOCALTRANSFORM ^= true; |
---|
| 2131 | + } |
---|
| 2132 | + |
---|
| 2133 | + public void ToggleTexture() |
---|
1261 | 2134 | { |
---|
1262 | 2135 | textureon ^= true; |
---|
1263 | 2136 | } |
---|
1264 | 2137 | |
---|
1265 | | - void ToggleLive() |
---|
| 2138 | + public void ToggleLive() |
---|
1266 | 2139 | { |
---|
1267 | 2140 | Globals.setLIVE(Globals.isLIVE() ^ true); |
---|
1268 | 2141 | |
---|
.. | .. |
---|
1274 | 2147 | repaint(); // start loop // may 2013 |
---|
1275 | 2148 | } |
---|
1276 | 2149 | |
---|
1277 | | - void ToggleSupport() |
---|
| 2150 | + public void ToggleSupport() |
---|
1278 | 2151 | { |
---|
1279 | 2152 | SUPPORT ^= true; |
---|
1280 | 2153 | } |
---|
1281 | 2154 | |
---|
1282 | | - void ToggleAbort() |
---|
| 2155 | + public void ToggleAbort() |
---|
1283 | 2156 | { |
---|
1284 | 2157 | ABORTMODE ^= true; |
---|
1285 | 2158 | } |
---|
1286 | 2159 | |
---|
1287 | | - void ToggleFullScreen() |
---|
1288 | | - { |
---|
1289 | | - FULLSCREEN ^= true; |
---|
1290 | | - } |
---|
1291 | | - |
---|
1292 | | - void ToggleCrowd() |
---|
1293 | | - { |
---|
1294 | | - Globals.CROWD ^= true; |
---|
1295 | | - } |
---|
1296 | | - |
---|
1297 | | - void ToggleInertia() |
---|
| 2160 | + public void ToggleInertia() |
---|
1298 | 2161 | { |
---|
1299 | 2162 | INERTIA ^= true; |
---|
1300 | 2163 | } |
---|
1301 | 2164 | |
---|
1302 | | - void ToggleLocal() |
---|
1303 | | - { |
---|
1304 | | - LOCALTRANSFORM ^= true; |
---|
1305 | | - } |
---|
1306 | | - |
---|
1307 | | - void ToggleFast() |
---|
| 2165 | + public void ToggleFast() |
---|
1308 | 2166 | { |
---|
1309 | 2167 | FAST ^= true; |
---|
1310 | 2168 | } |
---|
1311 | 2169 | |
---|
1312 | | - void ToggleSlowPose() |
---|
| 2170 | + public void ToggleSlowPose() |
---|
1313 | 2171 | { |
---|
1314 | 2172 | SLOWPOSE ^= true; |
---|
1315 | 2173 | } |
---|
1316 | 2174 | |
---|
1317 | | - void ToggleFootContact() |
---|
1318 | | - { |
---|
1319 | | - FOOTCONTACT ^= true; |
---|
1320 | | - } |
---|
1321 | | - |
---|
1322 | | - void ToggleBoxMode() |
---|
| 2175 | + public void ToggleBoxMode() |
---|
1323 | 2176 | { |
---|
1324 | 2177 | BOXMODE ^= true; |
---|
1325 | 2178 | } |
---|
1326 | 2179 | |
---|
1327 | | - void ToggleSmoothFocus() |
---|
| 2180 | + public void ToggleZoomBoxMode() |
---|
| 2181 | + { |
---|
| 2182 | + ZOOMBOXMODE ^= true; |
---|
| 2183 | + } |
---|
| 2184 | + |
---|
| 2185 | + public void ToggleSmoothFocus() |
---|
1328 | 2186 | { |
---|
1329 | 2187 | SMOOTHFOCUS ^= true; |
---|
1330 | 2188 | } |
---|
1331 | 2189 | |
---|
1332 | | - void ToggleImageFlip() |
---|
| 2190 | + public void ToggleImageFlip() |
---|
1333 | 2191 | { |
---|
1334 | 2192 | IMAGEFLIP ^= true; |
---|
1335 | 2193 | } |
---|
1336 | 2194 | |
---|
1337 | | - void ToggleSpeakerMocap() |
---|
| 2195 | + public void ToggleSpeakerMocap() |
---|
1338 | 2196 | { |
---|
1339 | 2197 | SPEAKERMOCAP ^= true; |
---|
1340 | 2198 | } |
---|
1341 | 2199 | |
---|
1342 | | - void ToggleSpeakerCamera() |
---|
| 2200 | + public void ToggleSpeakerCamera() |
---|
1343 | 2201 | { |
---|
1344 | 2202 | SPEAKERCAMERA ^= true; |
---|
1345 | 2203 | } |
---|
1346 | 2204 | |
---|
1347 | | - void ToggleSpeakerFocus() |
---|
| 2205 | + public void ToggleSpeakerFocus() |
---|
1348 | 2206 | { |
---|
1349 | 2207 | SPEAKERFOCUS ^= true; |
---|
1350 | 2208 | } |
---|
1351 | 2209 | |
---|
1352 | | - void ToggleDebug() |
---|
1353 | | - { |
---|
1354 | | - DEBUG ^= true; |
---|
1355 | | - } |
---|
1356 | | - |
---|
1357 | | - void ToggleFrustum() |
---|
| 2210 | + public void ToggleFrustum() |
---|
1358 | 2211 | { |
---|
1359 | 2212 | FRUSTUM ^= true; |
---|
1360 | 2213 | } |
---|
1361 | 2214 | |
---|
1362 | | - void ToggleTrack() |
---|
| 2215 | + public void ToggleTrack() |
---|
1363 | 2216 | { |
---|
1364 | 2217 | TRACK ^= true; |
---|
1365 | 2218 | if (TRACK) |
---|
.. | .. |
---|
1378 | 2231 | repaint(); |
---|
1379 | 2232 | } |
---|
1380 | 2233 | |
---|
1381 | | - void ToggleTrackOnce() |
---|
| 2234 | + public void ToggleTrackOnce() |
---|
1382 | 2235 | { |
---|
1383 | 2236 | TRACKONCE ^= true; |
---|
1384 | 2237 | } |
---|
1385 | 2238 | |
---|
1386 | | - void ToggleShadowTrack() |
---|
| 2239 | + public void ToggleShadowTrack() |
---|
1387 | 2240 | { |
---|
1388 | 2241 | SHADOWTRACK ^= true; |
---|
1389 | 2242 | repaint(); |
---|
1390 | 2243 | } |
---|
1391 | 2244 | |
---|
1392 | | - void ToggleOeil() |
---|
| 2245 | + public void ToggleOeil() |
---|
1393 | 2246 | { |
---|
1394 | 2247 | OEIL ^= true; |
---|
1395 | 2248 | } |
---|
1396 | 2249 | |
---|
1397 | | - void ToggleOeilOnce() |
---|
| 2250 | + public void ToggleOeilOnce() |
---|
1398 | 2251 | { |
---|
1399 | 2252 | OEILONCE ^= true; |
---|
| 2253 | + } |
---|
| 2254 | + |
---|
| 2255 | + void ToggleFootContact() |
---|
| 2256 | + { |
---|
| 2257 | + FOOTCONTACT ^= true; |
---|
| 2258 | + } |
---|
| 2259 | + |
---|
| 2260 | + void ToggleDebug() |
---|
| 2261 | + { |
---|
| 2262 | + DEBUG ^= true; |
---|
1400 | 2263 | } |
---|
1401 | 2264 | |
---|
1402 | 2265 | void ToggleLookAt() |
---|
.. | .. |
---|
7458 | 8321 | return texture!=null?texture.texture:null; |
---|
7459 | 8322 | } |
---|
7460 | 8323 | |
---|
7461 | | - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8324 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
7462 | 8325 | { |
---|
7463 | 8326 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
7464 | 8327 | |
---|
.. | .. |
---|
10146 | 11009 | fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso |
---|
10147 | 11010 | //System.out.println("fragmentMode = " + fragmentMode); |
---|
10148 | 11011 | |
---|
10149 | | - if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION) |
---|
| 11012 | + if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection()) |
---|
10150 | 11013 | { |
---|
10151 | 11014 | /* |
---|
10152 | 11015 | if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING)) |
---|
.. | .. |
---|
10447 | 11310 | callist = gl.glGenLists(1); |
---|
10448 | 11311 | } |
---|
10449 | 11312 | |
---|
10450 | | - boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 11313 | + boolean selectmode = DrawMode() == SELECTION || IsDebugSelection(); |
---|
10451 | 11314 | |
---|
10452 | 11315 | boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown; |
---|
10453 | 11316 | |
---|
.. | .. |
---|
11884 | 12747 | "MUL final.y, fragment.texcoord[0].x, c256;" + |
---|
11885 | 12748 | "FLR final.x, final.y;" + |
---|
11886 | 12749 | "SUB final.y, final.y, final.x;" + |
---|
11887 | | - "MUL final.x, final.x, c256i;" + |
---|
| 12750 | + //"MUL final.x, final.x, c256i;" + |
---|
11888 | 12751 | "MOV final.z, zero.x;" + |
---|
11889 | 12752 | "MOV final.a, one.w;":"" |
---|
11890 | 12753 | ) + |
---|
.. | .. |
---|
11892 | 12755 | "MUL final.y, fragment.texcoord[0].y, c256;" + |
---|
11893 | 12756 | "FLR final.x, final.y;" + |
---|
11894 | 12757 | "SUB final.y, final.y, final.x;" + |
---|
11895 | | - "MUL final.x, final.x, c256i;" + |
---|
| 12758 | + //"MUL final.x, final.x, c256i;" + |
---|
11896 | 12759 | "MOV final.z, zero.x;" + |
---|
11897 | 12760 | "MOV final.a, one.w;":"" |
---|
11898 | 12761 | ) + |
---|
.. | .. |
---|
12672 | 13535 | |
---|
12673 | 13536 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
12674 | 13537 | |
---|
| 13538 | + if (BUTTONLESSWHEEL) |
---|
12675 | 13539 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
12676 | 13540 | { |
---|
12677 | 13541 | return; |
---|
.. | .. |
---|
12680 | 13544 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
12681 | 13545 | |
---|
12682 | 13546 | // TIMER |
---|
12683 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 13547 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
12684 | 13548 | { |
---|
12685 | 13549 | keepboxmode = BOXMODE; |
---|
12686 | 13550 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
12897 | 13761 | |
---|
12898 | 13762 | public void mouseDragged(MouseEvent e) |
---|
12899 | 13763 | { |
---|
| 13764 | + //System.out.println("mouseDragged: " + e); |
---|
12900 | 13765 | if (isRenderer) |
---|
12901 | 13766 | movingcamera = true; |
---|
12902 | 13767 | //if (drawing) |
---|
12903 | 13768 | //return; |
---|
12904 | | - //System.out.println("mouseDragged: " + e); |
---|
12905 | 13769 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
12906 | 13770 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
12907 | 13771 | { |
---|
.. | .. |
---|
12921 | 13785 | cVector tmp = new cVector(); |
---|
12922 | 13786 | cVector tmp2 = new cVector(); |
---|
12923 | 13787 | boolean isMoving; |
---|
| 13788 | + |
---|
| 13789 | + public cVector TargetLookAt() |
---|
| 13790 | + { |
---|
| 13791 | + return targetLookAt; |
---|
| 13792 | + } |
---|
12924 | 13793 | |
---|
12925 | 13794 | class PingThread extends Thread |
---|
12926 | 13795 | { |
---|
.. | .. |
---|
13431 | 14300 | public void mouseMoved(MouseEvent e) |
---|
13432 | 14301 | { |
---|
13433 | 14302 | //System.out.println("mouseMoved: " + e); |
---|
13434 | | - |
---|
13435 | 14303 | if (isRenderer) |
---|
13436 | 14304 | return; |
---|
13437 | 14305 | |
---|
.. | .. |
---|
13653 | 14521 | SetMouseMode(modifiers); |
---|
13654 | 14522 | } |
---|
13655 | 14523 | |
---|
13656 | | - theRenderer.keyPressed(key); |
---|
| 14524 | + Globals.theRenderer.keyPressed(key); |
---|
13657 | 14525 | } |
---|
13658 | 14526 | |
---|
13659 | 14527 | int kompactbit = 4; // power bit |
---|
.. | .. |
---|
13665 | 14533 | float SATPOW = 1; // 2; // 0.5f; |
---|
13666 | 14534 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
13667 | 14535 | |
---|
13668 | | - void keyPressed(int key) |
---|
| 14536 | + public void keyPressed(int key) |
---|
13669 | 14537 | { |
---|
13670 | 14538 | if (key >= '0' && key <= '5') |
---|
13671 | 14539 | clampbit = (key-'0'); |
---|
.. | .. |
---|
14102 | 14970 | } |
---|
14103 | 14971 | //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy); |
---|
14104 | 14972 | } |
---|
| 14973 | + |
---|
14105 | 14974 | static double OCCLUSIONBOOST = 1; // 0.5; |
---|
14106 | 14975 | |
---|
14107 | 14976 | void keyReleased(int key, int modifiers) |
---|
.. | .. |
---|
14113 | 14982 | } |
---|
14114 | 14983 | } |
---|
14115 | 14984 | |
---|
14116 | | - protected void processKeyEvent(KeyEvent e) |
---|
| 14985 | + public void processKeyEvent(KeyEvent e) |
---|
14117 | 14986 | { |
---|
14118 | 14987 | switch (e.getID()) |
---|
14119 | 14988 | { |
---|
.. | .. |
---|
14243 | 15112 | |
---|
14244 | 15113 | protected void processMouseMotionEvent(MouseEvent e) |
---|
14245 | 15114 | { |
---|
14246 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
14247 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15115 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15116 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15117 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
14248 | 15118 | { |
---|
14249 | 15119 | mouseMoved(e); |
---|
14250 | 15120 | } else |
---|
.. | .. |
---|
15772 | 16642 | |
---|
15773 | 16643 | class AntialiasBuffer implements GLEventListener |
---|
15774 | 16644 | { |
---|
15775 | | - |
---|
15776 | 16645 | CameraPane parent = null; |
---|
15777 | 16646 | |
---|
15778 | 16647 | AntialiasBuffer(CameraPane p) |
---|
.. | .. |
---|
16165 | 17034 | } |
---|
16166 | 17035 | } |
---|
16167 | 17036 | |
---|
16168 | | - static void DrawPoints(CameraPane cpane) |
---|
| 17037 | + static void DrawPoints(iCameraPane cpane) |
---|
16169 | 17038 | { |
---|
16170 | 17039 | for (int i=0; i<8; i++) // first and last are red |
---|
16171 | 17040 | { |
---|
.. | .. |
---|
16197 | 17066 | static IntBuffer textbuffer = null; // IntBuffer.allocate(TEXT_WIDTH*8*8 * TEXT_HEIGHT); |
---|
16198 | 17067 | // Depth buffer format |
---|
16199 | 17068 | //private int depth_format; |
---|
16200 | | - static public void NextIndex(Object3D o, GL gl) |
---|
| 17069 | + |
---|
| 17070 | + public void NextIndex() |
---|
16201 | 17071 | { |
---|
16202 | 17072 | indexcount+=16; |
---|
16203 | | - gl.glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
| 17073 | + GetGL().glColor3d(((indexcount >>> 16) & 255) / 255.0, ((indexcount >>> 8) & 255) / 255.0, ((indexcount) & 255) / 255.0); |
---|
16204 | 17074 | //objects[indexcount] = o; |
---|
16205 | 17075 | //System.out.println("indexcount = " + indexcount); |
---|
16206 | 17076 | } |
---|