.. | .. |
---|
22 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
23 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
24 | 24 | |
---|
| 25 | + // Use GetUUID for backward compatibility with null. |
---|
25 | 26 | private UUID uuid = UUID.randomUUID(); |
---|
26 | 27 | |
---|
27 | 28 | // TEMPORARY for mocap undo. No need to be transient. |
---|
.. | .. |
---|
29 | 30 | Object3D saveskeleton; |
---|
30 | 31 | // |
---|
31 | 32 | |
---|
32 | | - byte[] versions[] = new byte[100][]; |
---|
| 33 | + String skyboxname; |
---|
| 34 | + String skyboxext; |
---|
| 35 | + |
---|
| 36 | + Object3D versionlist[]; |
---|
33 | 37 | int versionindex = -1; |
---|
34 | 38 | |
---|
| 39 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 40 | + |
---|
35 | 41 | ScriptNode scriptnode; |
---|
36 | 42 | |
---|
37 | 43 | void InitOthers() |
---|
.. | .. |
---|
219 | 225 | // o.bRep.support = null; |
---|
220 | 226 | // } |
---|
221 | 227 | o.selection = this.selection; |
---|
| 228 | + o.versionlist = this.versionlist; |
---|
| 229 | + o.versionindex = this.versionindex; |
---|
222 | 230 | |
---|
223 | 231 | if (this.support != null) |
---|
224 | 232 | { |
---|
.. | .. |
---|
240 | 248 | // this.support = null; |
---|
241 | 249 | // this.fileparent = null; |
---|
242 | 250 | } |
---|
| 251 | + |
---|
| 252 | +// Object3D GetObject(java.util.UUID uuid) |
---|
| 253 | +// { |
---|
| 254 | +// if (this.uuid.equals(uuid)) |
---|
| 255 | +// return this; |
---|
| 256 | +// |
---|
| 257 | +// if (blockloop) |
---|
| 258 | +// return null; |
---|
| 259 | +// |
---|
| 260 | +// blockloop = true; |
---|
| 261 | +// |
---|
| 262 | +// for (int i=0; i<Size(); i++) |
---|
| 263 | +// { |
---|
| 264 | +// Object3D o = get(i).GetObject(uuid); |
---|
| 265 | +// |
---|
| 266 | +// if (o != null) |
---|
| 267 | +// return o; |
---|
| 268 | +// } |
---|
| 269 | +// |
---|
| 270 | +// blockloop = false; |
---|
| 271 | +// |
---|
| 272 | +// return null; |
---|
| 273 | +// } |
---|
243 | 274 | |
---|
244 | 275 | void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
245 | 276 | { |
---|
.. | .. |
---|
274 | 305 | } |
---|
275 | 306 | |
---|
276 | 307 | this.selection = o.selection; |
---|
| 308 | + |
---|
| 309 | + this.versionlist = o.versionlist; |
---|
| 310 | + this.versionindex = o.versionindex; |
---|
277 | 311 | // July 2019 if (this.bRep != null) |
---|
278 | 312 | // this.bRep.support = o.transientrep; |
---|
279 | 313 | // this.support = o.support; |
---|
.. | .. |
---|
421 | 455 | } |
---|
422 | 456 | |
---|
423 | 457 | boolean live = false; |
---|
| 458 | + transient boolean keepdontselect; |
---|
424 | 459 | boolean dontselect = false; |
---|
425 | 460 | boolean hide = false; |
---|
426 | 461 | boolean link2master = false; // performs reset support/master at each frame |
---|
.. | .. |
---|
1005 | 1040 | |
---|
1006 | 1041 | if (material == null || material.multiply) |
---|
1007 | 1042 | return true; |
---|
| 1043 | + |
---|
| 1044 | + if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
| 1045 | + return false; |
---|
1008 | 1046 | |
---|
1009 | 1047 | // Transparent objects are dynamic because we have to sort the triangles. |
---|
1010 | 1048 | return material.opacity > 0.99; |
---|
.. | .. |
---|
2432 | 2470 | else |
---|
2433 | 2471 | { |
---|
2434 | 2472 | //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2473 | + if (objectUI != null) |
---|
| 2474 | + ((ObjEditor)objectUI).pinButton.setSelected(pinned); |
---|
| 2475 | + else |
---|
| 2476 | + //new Exception().printStackTrace(); |
---|
| 2477 | + System.err.println("objectUI is null"); |
---|
2435 | 2478 | } |
---|
2436 | 2479 | } |
---|
2437 | 2480 | |
---|
.. | .. |
---|
2561 | 2604 | private static final int editSelf = 1; |
---|
2562 | 2605 | private static final int editChild = 2; |
---|
2563 | 2606 | |
---|
2564 | | - void drawEditHandles(ClickInfo info, int level) |
---|
| 2607 | + void drawEditHandles(//ClickInfo info, |
---|
| 2608 | + int level) |
---|
2565 | 2609 | { |
---|
2566 | 2610 | if (level == 0) |
---|
2567 | 2611 | { |
---|
.. | .. |
---|
2569 | 2613 | return; |
---|
2570 | 2614 | |
---|
2571 | 2615 | Object3D selectee; |
---|
2572 | | - for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1)) |
---|
| 2616 | + for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info, |
---|
| 2617 | + level + 1)) |
---|
2573 | 2618 | { |
---|
2574 | 2619 | selectee = (Object3D) e.nextElement(); |
---|
2575 | 2620 | } |
---|
.. | .. |
---|
2577 | 2622 | } else |
---|
2578 | 2623 | { |
---|
2579 | 2624 | //super. |
---|
2580 | | - drawEditHandles0(info, level + 1); |
---|
| 2625 | + drawEditHandles0(//info, |
---|
| 2626 | + level + 1); |
---|
2581 | 2627 | } |
---|
2582 | 2628 | } |
---|
2583 | 2629 | |
---|
2584 | | - boolean doEditClick(ClickInfo info, int level) |
---|
| 2630 | + boolean doEditClick(//ClickInfo info, |
---|
| 2631 | + int level) |
---|
2585 | 2632 | { |
---|
2586 | 2633 | doSomething = 0; |
---|
2587 | 2634 | if (level == 0) |
---|
2588 | 2635 | { |
---|
2589 | | - return doParentClick(info); |
---|
| 2636 | + return doParentClick(); //info); |
---|
2590 | 2637 | } |
---|
2591 | 2638 | if (//super. |
---|
2592 | | - doEditClick0(info, level)) |
---|
| 2639 | + doEditClick0(//info, |
---|
| 2640 | + level)) |
---|
2593 | 2641 | { |
---|
2594 | 2642 | doSomething = 1; |
---|
2595 | 2643 | return true; |
---|
.. | .. |
---|
2599 | 2647 | } |
---|
2600 | 2648 | } |
---|
2601 | 2649 | |
---|
2602 | | - boolean doParentClick(ClickInfo info) |
---|
| 2650 | + boolean doParentClick() //ClickInfo info) |
---|
2603 | 2651 | { |
---|
2604 | 2652 | if (selection == null) |
---|
2605 | 2653 | { |
---|
.. | .. |
---|
2612 | 2660 | for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();) |
---|
2613 | 2661 | { |
---|
2614 | 2662 | Object3D selectee = (Object3D) e.nextElement(); |
---|
2615 | | - if (selectee.doEditClick(info, 1)) |
---|
| 2663 | + if (selectee.doEditClick(//info, |
---|
| 2664 | + 1)) |
---|
2616 | 2665 | { |
---|
2617 | 2666 | childToDrag = selectee; |
---|
2618 | 2667 | doSomething = 2; |
---|
.. | .. |
---|
2624 | 2673 | return retval; |
---|
2625 | 2674 | } |
---|
2626 | 2675 | |
---|
2627 | | - void doEditDrag(ClickInfo info, boolean opposite) |
---|
| 2676 | + void doEditDrag(//ClickInfo clickInfo, |
---|
| 2677 | + boolean opposite) |
---|
2628 | 2678 | { |
---|
2629 | 2679 | switch (doSomething) |
---|
2630 | 2680 | { |
---|
2631 | 2681 | case 1: // '\001' |
---|
2632 | 2682 | //super. |
---|
2633 | | - doEditDrag0(info, opposite); |
---|
| 2683 | + doEditDrag0(//clickInfo, |
---|
| 2684 | + opposite); |
---|
2634 | 2685 | break; |
---|
2635 | 2686 | |
---|
2636 | 2687 | case 2: // '\002' |
---|
.. | .. |
---|
2643 | 2694 | { |
---|
2644 | 2695 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2645 | 2696 | //childToDrag.doEditDrag(info); |
---|
2646 | | - sel.doEditDrag(info, opposite); |
---|
| 2697 | + sel.doEditDrag(//clickInfo, |
---|
| 2698 | + opposite); |
---|
2647 | 2699 | } else |
---|
2648 | 2700 | { |
---|
2649 | 2701 | //super. |
---|
2650 | | - doEditDrag0(info, opposite); |
---|
| 2702 | + doEditDrag0(//clickInfo, |
---|
| 2703 | + opposite); |
---|
2651 | 2704 | } |
---|
2652 | 2705 | } |
---|
2653 | 2706 | break; |
---|
.. | .. |
---|
2665 | 2718 | { |
---|
2666 | 2719 | deselectAll(); |
---|
2667 | 2720 | } |
---|
| 2721 | + |
---|
| 2722 | + new Exception().printStackTrace(); |
---|
| 2723 | + |
---|
2668 | 2724 | ClickInfo newInfo = new ClickInfo(); |
---|
2669 | 2725 | newInfo.flags = info.flags; |
---|
2670 | 2726 | newInfo.bounds = info.bounds; |
---|
.. | .. |
---|
3112 | 3168 | { |
---|
3113 | 3169 | if (bRep != null) |
---|
3114 | 3170 | { |
---|
3115 | | - bRep.GenerateNormalsMINE(); |
---|
| 3171 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
3116 | 3172 | Touch(); |
---|
3117 | 3173 | } |
---|
3118 | 3174 | } |
---|
.. | .. |
---|
5415 | 5471 | blockloop = false; |
---|
5416 | 5472 | } |
---|
5417 | 5473 | |
---|
| 5474 | + void ResetSelectable() |
---|
| 5475 | + { |
---|
| 5476 | + if (blockloop) |
---|
| 5477 | + return; |
---|
| 5478 | + |
---|
| 5479 | + blockloop = true; |
---|
| 5480 | + |
---|
| 5481 | + keepdontselect = dontselect; |
---|
| 5482 | + dontselect = true; |
---|
| 5483 | + |
---|
| 5484 | + Object3D child; |
---|
| 5485 | + int nb = Size(); |
---|
| 5486 | + for (int i = 0; i < nb; i++) |
---|
| 5487 | + { |
---|
| 5488 | + child = (Object3D) get(i); |
---|
| 5489 | + if (child == null) |
---|
| 5490 | + continue; |
---|
| 5491 | + child.ResetSelectable(); |
---|
| 5492 | + } |
---|
| 5493 | + |
---|
| 5494 | + blockloop = false; |
---|
| 5495 | + } |
---|
| 5496 | + |
---|
| 5497 | + void RestoreSelectable() |
---|
| 5498 | + { |
---|
| 5499 | + if (blockloop) |
---|
| 5500 | + return; |
---|
| 5501 | + |
---|
| 5502 | + blockloop = true; |
---|
| 5503 | + |
---|
| 5504 | + dontselect = keepdontselect; |
---|
| 5505 | + |
---|
| 5506 | + Object3D child; |
---|
| 5507 | + int nb = Size(); |
---|
| 5508 | + for (int i = 0; i < nb; i++) |
---|
| 5509 | + { |
---|
| 5510 | + child = (Object3D) get(i); |
---|
| 5511 | + if (child == null) |
---|
| 5512 | + continue; |
---|
| 5513 | + child.RestoreSelectable(); |
---|
| 5514 | + } |
---|
| 5515 | + |
---|
| 5516 | + blockloop = false; |
---|
| 5517 | + } |
---|
| 5518 | + |
---|
5418 | 5519 | boolean IsSelected() |
---|
5419 | 5520 | { |
---|
5420 | 5521 | if (parent == null) |
---|
.. | .. |
---|
5475 | 5576 | if (fullname == null) |
---|
5476 | 5577 | return ""; |
---|
5477 | 5578 | |
---|
| 5579 | + if (fullname.pigment != null) |
---|
| 5580 | + { |
---|
| 5581 | + return fullname.pigment; |
---|
| 5582 | + } |
---|
| 5583 | + |
---|
5478 | 5584 | // System.out.println("Fullname = " + fullname); |
---|
5479 | 5585 | |
---|
5480 | 5586 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5487 | 5593 | |
---|
5488 | 5594 | if (split.length == 0) |
---|
5489 | 5595 | { |
---|
5490 | | - return ""; |
---|
| 5596 | + return fullname.pigment = ""; |
---|
5491 | 5597 | } |
---|
5492 | 5598 | |
---|
5493 | 5599 | if (split.length <= 2) |
---|
.. | .. |
---|
5495 | 5601 | if (fullname.name.endsWith(":")) |
---|
5496 | 5602 | { |
---|
5497 | 5603 | // Windows |
---|
5498 | | - return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5604 | + return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1); |
---|
5499 | 5605 | } |
---|
5500 | 5606 | |
---|
5501 | | - return split[0]; |
---|
| 5607 | + return fullname.pigment = split[0]; |
---|
5502 | 5608 | } |
---|
5503 | 5609 | |
---|
5504 | 5610 | // Windows |
---|
5505 | 5611 | assert(split.length == 4); |
---|
5506 | 5612 | |
---|
5507 | | - return split[0] + ":" + split[1]; |
---|
| 5613 | + return fullname.pigment = split[0] + ":" + split[1]; |
---|
5508 | 5614 | } |
---|
5509 | 5615 | |
---|
5510 | 5616 | static String GetBump(cTexture fullname) |
---|
5511 | 5617 | { |
---|
5512 | 5618 | if (fullname == null) |
---|
5513 | 5619 | return ""; |
---|
| 5620 | + |
---|
| 5621 | + if (fullname.bump != null) |
---|
| 5622 | + { |
---|
| 5623 | + return fullname.bump; |
---|
| 5624 | + } |
---|
5514 | 5625 | |
---|
5515 | 5626 | // System.out.println("Fullname = " + fullname); |
---|
5516 | 5627 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5522 | 5633 | |
---|
5523 | 5634 | if (split.length == 0) |
---|
5524 | 5635 | { |
---|
5525 | | - return ""; |
---|
| 5636 | + return fullname.bump = ""; |
---|
5526 | 5637 | } |
---|
5527 | 5638 | |
---|
5528 | 5639 | if (split.length == 1) |
---|
5529 | 5640 | { |
---|
5530 | | - return ""; |
---|
| 5641 | + return fullname.bump = ""; |
---|
5531 | 5642 | } |
---|
5532 | 5643 | |
---|
5533 | 5644 | if (split.length == 2) |
---|
.. | .. |
---|
5535 | 5646 | if (fullname.name.endsWith(":")) |
---|
5536 | 5647 | { |
---|
5537 | 5648 | // Windows |
---|
5538 | | - return ""; |
---|
| 5649 | + return fullname.bump = ""; |
---|
5539 | 5650 | } |
---|
5540 | 5651 | |
---|
5541 | | - return split[1]; |
---|
| 5652 | + return fullname.bump = split[1]; |
---|
5542 | 5653 | } |
---|
5543 | 5654 | |
---|
5544 | 5655 | // Windows |
---|
5545 | 5656 | assert(split.length == 4); |
---|
5546 | 5657 | |
---|
5547 | | - return split[2] + ":" + split[3]; |
---|
| 5658 | + return fullname.bump = split[2] + ":" + split[3]; |
---|
5548 | 5659 | } |
---|
5549 | 5660 | |
---|
5550 | 5661 | String GetPigmentTexture() |
---|
.. | .. |
---|
5627 | 5738 | texname = ""; |
---|
5628 | 5739 | |
---|
5629 | 5740 | GetTextures().name = texname + ":" + GetBump(GetTextures()); |
---|
| 5741 | + |
---|
| 5742 | + GetTextures().pigment = null; |
---|
| 5743 | + |
---|
5630 | 5744 | Touch(); |
---|
5631 | 5745 | } |
---|
5632 | 5746 | |
---|
.. | .. |
---|
5700 | 5814 | |
---|
5701 | 5815 | GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname; |
---|
5702 | 5816 | |
---|
| 5817 | + GetTextures().bump = null; |
---|
| 5818 | + |
---|
5703 | 5819 | Touch(); |
---|
5704 | 5820 | } |
---|
5705 | 5821 | |
---|
.. | .. |
---|
5720 | 5836 | |
---|
5721 | 5837 | blockloop = true; |
---|
5722 | 5838 | child.ResetBumpTexture(); |
---|
| 5839 | + blockloop = false; |
---|
| 5840 | + } |
---|
| 5841 | + } |
---|
| 5842 | + |
---|
| 5843 | + void EmbedTextures(boolean embed) |
---|
| 5844 | + { |
---|
| 5845 | + if (blockloop) |
---|
| 5846 | + return; |
---|
| 5847 | + |
---|
| 5848 | + //if (GetTextures() != null) |
---|
| 5849 | + if (embed) |
---|
| 5850 | + CameraPane.EmbedTextures(GetTextures()); |
---|
| 5851 | + else |
---|
| 5852 | + { |
---|
| 5853 | + GetTextures().pigmentdata = null; |
---|
| 5854 | + GetTextures().bumpdata = null; |
---|
| 5855 | + GetTextures().pw = 0; |
---|
| 5856 | + GetTextures().ph = 0; |
---|
| 5857 | + GetTextures().bw = 0; |
---|
| 5858 | + GetTextures().bh = 0; |
---|
| 5859 | + } |
---|
| 5860 | + |
---|
| 5861 | + int nb = Size(); |
---|
| 5862 | + for (int i = 0; i < nb; i++) |
---|
| 5863 | + { |
---|
| 5864 | + Object3D child = (Object3D) get(i); |
---|
| 5865 | + |
---|
| 5866 | + if (child == null) |
---|
| 5867 | + continue; |
---|
| 5868 | + |
---|
| 5869 | + blockloop = true; |
---|
| 5870 | + child.EmbedTextures(embed); |
---|
5723 | 5871 | blockloop = false; |
---|
5724 | 5872 | } |
---|
5725 | 5873 | } |
---|
.. | .. |
---|
5810 | 5958 | if (support != null) |
---|
5811 | 5959 | support = support; |
---|
5812 | 5960 | |
---|
5813 | | - //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5814 | | - boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5961 | + boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5962 | + //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5963 | + |
---|
| 5964 | + //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
5815 | 5965 | |
---|
5816 | 5966 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5817 | 5967 | { |
---|
.. | .. |
---|
5821 | 5971 | // usecalllists &= !(parent instanceof RandomNode); |
---|
5822 | 5972 | // usecalllists = false; |
---|
5823 | 5973 | |
---|
5824 | | - if (GetBRep() != null) |
---|
5825 | | - usecalllists = usecalllists; |
---|
| 5974 | + if (display.DrawMode() == display.SHADOW) |
---|
| 5975 | + //GetBRep() != null) |
---|
| 5976 | + usecalllists = !!usecalllists; |
---|
5826 | 5977 | //System.out.println("draw " + this); |
---|
5827 | 5978 | //new Exception().printStackTrace(); |
---|
5828 | 5979 | |
---|
.. | .. |
---|
5844 | 5995 | if (!(this instanceof Composite)) |
---|
5845 | 5996 | touched = false; |
---|
5846 | 5997 | //if (displaylist == -1 && usecalllists) |
---|
5847 | | - if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
| 5998 | + if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013 |
---|
5848 | 5999 | { |
---|
5849 | 6000 | bRep.displaylist = display.GenList(); |
---|
5850 | 6001 | assert(bRep.displaylist != 0); |
---|
.. | .. |
---|
5855 | 6006 | |
---|
5856 | 6007 | //System.out.println("\tnew list " + list); |
---|
5857 | 6008 | //gl.glDrawBuffer(gl.GL_NONE); |
---|
5858 | | - if (usecalllists) |
---|
| 6009 | + if (usecalllists && bRep.displaylist > 0) |
---|
5859 | 6010 | { |
---|
5860 | 6011 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5861 | 6012 | display.NewList(bRep.displaylist); |
---|
.. | .. |
---|
5864 | 6015 | CallList(display, root, selected, blocked); |
---|
5865 | 6016 | |
---|
5866 | 6017 | // compiled = true; |
---|
5867 | | - if (usecalllists) |
---|
| 6018 | + if (usecalllists && bRep.displaylist > 0) |
---|
5868 | 6019 | { |
---|
5869 | 6020 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5870 | 6021 | display.EndList(); |
---|
.. | .. |
---|
7215 | 7366 | } |
---|
7216 | 7367 | } |
---|
7217 | 7368 | |
---|
7218 | | - protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec) |
---|
| 7369 | + static ClickInfo clickInfo = new ClickInfo(); |
---|
| 7370 | + |
---|
| 7371 | + protected void calcHotSpot(cVector in, //ClickInfo clickInfo, |
---|
| 7372 | + Point outPt, Rectangle outRec) |
---|
7219 | 7373 | { |
---|
7220 | | - int hc = info.bounds.x + info.bounds.width / 2; |
---|
7221 | | - int vc = info.bounds.y + info.bounds.height / 2; |
---|
7222 | | - double[][] toscreen = info.toScreen; |
---|
| 7374 | + int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2; |
---|
| 7375 | + int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2; |
---|
| 7376 | + double[][] toscreen = clickInfo.toScreen; |
---|
7223 | 7377 | if (toscreen == null) |
---|
7224 | 7378 | { |
---|
7225 | | - toscreen = new Camera(info.camera.viewCode).toScreen; |
---|
| 7379 | + toscreen = new Camera(clickInfo.camera.viewCode).toScreen; |
---|
7226 | 7380 | } |
---|
7227 | 7381 | cVector vec = in; |
---|
7228 | 7382 | LA.xformPos(in, toscreen, in); |
---|
7229 | 7383 | //System.out.println("Distance = " + info.camera.Distance()); |
---|
7230 | | - vec.x *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
7231 | | - vec.y *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
| 7384 | + vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
| 7385 | + vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
7232 | 7386 | outPt.x = hc + (int) vec.x; |
---|
7233 | 7387 | outPt.y = vc - (int) vec.y; |
---|
7234 | 7388 | outRec.x = outPt.x - 3; |
---|
.. | .. |
---|
7236 | 7390 | outRec.width = outRec.height = 6; |
---|
7237 | 7391 | } |
---|
7238 | 7392 | |
---|
7239 | | - protected Rectangle calcHotSpot(cVector in, ClickInfo info) |
---|
| 7393 | + protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo |
---|
| 7394 | + ) |
---|
7240 | 7395 | { |
---|
7241 | 7396 | Point pt = new Point(0, 0); |
---|
7242 | 7397 | Rectangle rec = new Rectangle(); |
---|
7243 | | - calcHotSpot(in, info, pt, rec); |
---|
| 7398 | + calcHotSpot(in, //clickInfo, |
---|
| 7399 | + pt, rec); |
---|
7244 | 7400 | return rec; |
---|
7245 | 7401 | } |
---|
7246 | 7402 | |
---|
7247 | | - void drawEditHandles0(ClickInfo info, int level) |
---|
| 7403 | + void drawEditHandles0(//ClickInfo clickInfo, |
---|
| 7404 | + int level) |
---|
7248 | 7405 | { |
---|
7249 | 7406 | if (level == 0) |
---|
7250 | 7407 | { |
---|
.. | .. |
---|
7253 | 7410 | { |
---|
7254 | 7411 | cVector origin = new cVector(); |
---|
7255 | 7412 | //LA.xformPos(origin, toParent, origin); |
---|
7256 | | - Rectangle spot = calcHotSpot(origin, info); |
---|
| 7413 | + if (this.clickInfo == null) |
---|
| 7414 | + this.clickInfo = new ClickInfo(); |
---|
| 7415 | + |
---|
| 7416 | + Rectangle spot = calcHotSpot(origin); //, clickInfo); |
---|
7257 | 7417 | Rectangle boundary = new Rectangle(); |
---|
7258 | 7418 | boundary.x = spot.x - 30; |
---|
7259 | 7419 | boundary.y = spot.y - 30; |
---|
7260 | 7420 | boundary.width = spot.width + 60; |
---|
7261 | 7421 | boundary.height = spot.height + 60; |
---|
7262 | | - info.g.setColor(Color.red); |
---|
| 7422 | + clickInfo.g.setColor(Color.white); |
---|
7263 | 7423 | int spotw = spot.x + spot.width; |
---|
7264 | 7424 | int spoth = spot.y + spot.height; |
---|
7265 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7425 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7266 | 7426 | // if (CameraPane.Xmin > spot.x) |
---|
7267 | 7427 | // { |
---|
7268 | 7428 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7279 | 7439 | // { |
---|
7280 | 7440 | // CameraPane.Ymax = spoth; |
---|
7281 | 7441 | // } |
---|
7282 | | - spot.translate(32, 32); |
---|
7283 | | - spotw = spot.x + spot.width; |
---|
7284 | | - spoth = spot.y + spot.height; |
---|
7285 | | - info.g.setColor(Color.cyan); |
---|
7286 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7287 | 7442 | // if (CameraPane.Xmin > spot.x) |
---|
7288 | 7443 | // { |
---|
7289 | 7444 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7302 | 7457 | // } |
---|
7303 | 7458 | // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
7304 | 7459 | //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
7305 | | - spot.translate(0, -32); |
---|
7306 | | - info.g.setColor(Color.yellow); |
---|
7307 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7308 | | - info.g.setColor(Color.green); |
---|
| 7460 | + spot.translate(32, 0); |
---|
| 7461 | + clickInfo.g.setColor(Color.yellow); |
---|
| 7462 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7463 | + |
---|
| 7464 | + spot.translate(32, 64); |
---|
| 7465 | + spotw = spot.x + spot.width; |
---|
| 7466 | + spoth = spot.y + spot.height; |
---|
| 7467 | + clickInfo.g.setColor(Color.cyan); |
---|
| 7468 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7309 | 7469 | // if (CameraPane.Xmin > spot.x) |
---|
7310 | 7470 | // { |
---|
7311 | 7471 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7322 | 7482 | // { |
---|
7323 | 7483 | // CameraPane.Ymax = spoth; |
---|
7324 | 7484 | // } |
---|
7325 | | - info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY, |
---|
7326 | | - (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360); |
---|
| 7485 | + clickInfo.g.setColor(Color.green); |
---|
| 7486 | + clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, |
---|
| 7487 | + (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); |
---|
7327 | 7488 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
7328 | 7489 | // if (CameraPane.Xmin > boundary.x) |
---|
7329 | 7490 | // { |
---|
.. | .. |
---|
7345 | 7506 | } |
---|
7346 | 7507 | } |
---|
7347 | 7508 | |
---|
7348 | | - boolean doEditClick0(ClickInfo info, int level) |
---|
| 7509 | + boolean doEditClick0(//ClickInfo clickInfo, |
---|
| 7510 | + int level) |
---|
7349 | 7511 | { |
---|
7350 | 7512 | if (level == 0) |
---|
7351 | 7513 | { |
---|
.. | .. |
---|
7354 | 7516 | |
---|
7355 | 7517 | boolean retval = false; |
---|
7356 | 7518 | |
---|
7357 | | - startX = info.x; |
---|
7358 | | - startY = info.y; |
---|
| 7519 | + startX = clickInfo.x; |
---|
| 7520 | + startY = clickInfo.y; |
---|
7359 | 7521 | |
---|
7360 | 7522 | hitSomething = -1; |
---|
7361 | 7523 | cVector origin = new cVector(); |
---|
.. | .. |
---|
7365 | 7527 | { |
---|
7366 | 7528 | centerPt = new Point(0, 0); |
---|
7367 | 7529 | } |
---|
7368 | | - calcHotSpot(origin, info, centerPt, spot); |
---|
7369 | | - if (spot.contains(info.x, info.y)) |
---|
| 7530 | + calcHotSpot(origin, //info, |
---|
| 7531 | + centerPt, spot); |
---|
| 7532 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7370 | 7533 | { |
---|
7371 | 7534 | hitSomething = hitCenter; |
---|
7372 | 7535 | retval = true; |
---|
7373 | 7536 | } |
---|
7374 | 7537 | spot.translate(32, 0); |
---|
7375 | | - if (spot.contains(info.x, info.y)) |
---|
| 7538 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7376 | 7539 | { |
---|
7377 | 7540 | hitSomething = hitRotate; |
---|
7378 | 7541 | retval = true; |
---|
7379 | 7542 | } |
---|
7380 | 7543 | spot.translate(0, 32); |
---|
7381 | | - if (spot.contains(info.x, info.y)) |
---|
| 7544 | + spot.translate(32, 0); |
---|
| 7545 | + spot.translate(0, 32); |
---|
| 7546 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7382 | 7547 | { |
---|
7383 | 7548 | hitSomething = hitScale; |
---|
| 7549 | + |
---|
| 7550 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7551 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
| 7552 | + double sign = 1; |
---|
| 7553 | + if (hScale < 0) |
---|
| 7554 | + { |
---|
| 7555 | + sign = -1; |
---|
| 7556 | + } |
---|
| 7557 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
| 7558 | + if (hScale < 0.01) |
---|
| 7559 | + { |
---|
| 7560 | + //hScale = 0.01; |
---|
| 7561 | + } |
---|
| 7562 | + |
---|
| 7563 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
| 7564 | + sign = 1; |
---|
| 7565 | + if (vScale < 0) |
---|
| 7566 | + { |
---|
| 7567 | + sign = -1; |
---|
| 7568 | + } |
---|
| 7569 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
| 7570 | + if (vScale < 0.01) |
---|
| 7571 | + { |
---|
| 7572 | + //vScale = 0.01; |
---|
| 7573 | + } |
---|
| 7574 | + |
---|
| 7575 | + clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale); |
---|
| 7576 | + |
---|
7384 | 7577 | retval = true; |
---|
7385 | 7578 | } |
---|
7386 | 7579 | |
---|
.. | .. |
---|
7390 | 7583 | } |
---|
7391 | 7584 | |
---|
7392 | 7585 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7393 | | - modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
| 7586 | + modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7394 | 7587 | //System.out.println("modified = " + modified); |
---|
7395 | 7588 | //new Exception().printStackTrace(); |
---|
7396 | 7589 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7418 | 7611 | return true; |
---|
7419 | 7612 | } |
---|
7420 | 7613 | |
---|
7421 | | - void doEditDrag0(ClickInfo info, boolean opposite) |
---|
| 7614 | + void doEditDrag0(//ClickInfo info, |
---|
| 7615 | + boolean opposite) |
---|
7422 | 7616 | { |
---|
7423 | 7617 | if (hitSomething == 0) |
---|
7424 | 7618 | { |
---|
.. | .. |
---|
7432 | 7626 | |
---|
7433 | 7627 | //System.out.println("hitSomething = " + hitSomething); |
---|
7434 | 7628 | |
---|
7435 | | - double scale = 0.005f * info.camera.Distance(); |
---|
| 7629 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
7436 | 7630 | |
---|
7437 | 7631 | cVector xlate = new cVector(); |
---|
7438 | 7632 | //cVector xlate2 = new cVector(); |
---|
.. | .. |
---|
7466 | 7660 | toParent[3][i] = xlate.get(i); |
---|
7467 | 7661 | LA.matInvert(toParent, fromParent); |
---|
7468 | 7662 | */ |
---|
7469 | | - cVector delta = LA.newVector(0, 0, startY - info.y); |
---|
7470 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7663 | + cVector delta = LA.newVector(0, 0, startY - clickInfo.y); |
---|
| 7664 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7471 | 7665 | |
---|
7472 | 7666 | LA.matCopy(startMat, toParent); |
---|
7473 | 7667 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7476 | 7670 | } else |
---|
7477 | 7671 | { |
---|
7478 | 7672 | //LA.xformDir(delta, info.camera.fromScreen, delta); |
---|
7479 | | - cVector up = new cVector(info.camera.up); |
---|
| 7673 | + cVector up = new cVector(clickInfo.camera.up); |
---|
7480 | 7674 | cVector away = new cVector(); |
---|
7481 | 7675 | //cVector right2 = new cVector(); |
---|
7482 | 7676 | //LA.vecCross(up, cVector.Z, right); |
---|
.. | .. |
---|
7493 | 7687 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7494 | 7688 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7495 | 7689 | LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7496 | | - LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
| 7690 | + LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away); |
---|
7497 | 7691 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7498 | 7692 | LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7499 | 7693 | //LA.vecCross(up, cVector.Z, right2); |
---|
7500 | 7694 | |
---|
7501 | | - cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
| 7695 | + cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0); |
---|
7502 | 7696 | |
---|
7503 | 7697 | //System.out.println("DELTA0 = " + delta); |
---|
7504 | 7698 | //System.out.println("AWAY = " + info.camera.away); |
---|
7505 | 7699 | //System.out.println("UP = " + info.camera.up); |
---|
7506 | 7700 | if (away.z > 0) |
---|
7507 | 7701 | { |
---|
7508 | | - if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
| 7702 | + if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
7509 | 7703 | { |
---|
7510 | 7704 | delta.x = -delta.x; |
---|
7511 | 7705 | } else |
---|
.. | .. |
---|
7520 | 7714 | //System.out.println("DELTA1 = " + delta); |
---|
7521 | 7715 | LA.xformDir(delta, ClickInfo.matbuffer, delta); |
---|
7522 | 7716 | //System.out.println("DELTA2 = " + delta); |
---|
7523 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7717 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7524 | 7718 | LA.matCopy(startMat, toParent); |
---|
7525 | 7719 | //System.out.println("DELTA3 = " + delta); |
---|
7526 | 7720 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7530 | 7724 | break; |
---|
7531 | 7725 | |
---|
7532 | 7726 | case hitRotate: // rotate |
---|
7533 | | - int dx = info.x - centerPt.x; |
---|
7534 | | - int dy = -(info.y - centerPt.y); |
---|
| 7727 | + int dx = clickInfo.x - centerPt.x; |
---|
| 7728 | + int dy = -(clickInfo.y - centerPt.y); |
---|
7535 | 7729 | double angle = (double) Math.atan2(dx, dy); |
---|
7536 | 7730 | angle = -(1.570796 - angle); |
---|
7537 | 7731 | |
---|
.. | .. |
---|
7554 | 7748 | } |
---|
7555 | 7749 | /**/ |
---|
7556 | 7750 | |
---|
7557 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7751 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7558 | 7752 | { |
---|
7559 | 7753 | case 1: // '\001' |
---|
7560 | 7754 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7581 | 7775 | break; |
---|
7582 | 7776 | |
---|
7583 | 7777 | case hitScale: // scale |
---|
7584 | | - double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7778 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
7585 | 7779 | double sign = 1; |
---|
7586 | 7780 | if (hScale < 0) |
---|
7587 | 7781 | { |
---|
.. | .. |
---|
7593 | 7787 | //hScale = 0.01; |
---|
7594 | 7788 | } |
---|
7595 | 7789 | |
---|
7596 | | - double vScale = (double) (info.y - centerPt.y) / 32; |
---|
| 7790 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
7597 | 7791 | sign = 1; |
---|
7598 | 7792 | if (vScale < 0) |
---|
7599 | 7793 | { |
---|
.. | .. |
---|
7604 | 7798 | { |
---|
7605 | 7799 | //vScale = 0.01; |
---|
7606 | 7800 | } |
---|
| 7801 | + |
---|
7607 | 7802 | LA.matCopy(startMat, toParent); |
---|
7608 | 7803 | /**/ |
---|
7609 | 7804 | for (int i = 0; i < 3; i++) |
---|
.. | .. |
---|
7613 | 7808 | } |
---|
7614 | 7809 | /**/ |
---|
7615 | 7810 | |
---|
7616 | | - double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7811 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale; |
---|
7617 | 7812 | |
---|
7618 | 7813 | if (totalScale < 0.01) |
---|
7619 | 7814 | { |
---|
7620 | 7815 | totalScale = 0.01; |
---|
7621 | 7816 | } |
---|
7622 | 7817 | |
---|
7623 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7818 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7624 | 7819 | { |
---|
7625 | 7820 | case 3: // '\001' |
---|
7626 | 7821 | if (modified || opposite) |
---|
7627 | 7822 | { |
---|
| 7823 | + if (modified && opposite) |
---|
| 7824 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 7825 | + else |
---|
7628 | 7826 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7629 | | - LA.matScale(toParent, totalScale, 1, 1); |
---|
| 7827 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7630 | 7828 | } // vScale, 1); |
---|
7631 | 7829 | else |
---|
7632 | 7830 | { |
---|
7633 | 7831 | // EXCEPTION! |
---|
7634 | | - LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 7832 | + LA.matScale(toParent, 1, totalScale, totalScale); |
---|
7635 | 7833 | } // vScale, 1); |
---|
7636 | 7834 | break; |
---|
7637 | 7835 | |
---|
7638 | 7836 | case 2: // '\002' |
---|
7639 | 7837 | if (modified || opposite) |
---|
7640 | 7838 | { |
---|
7641 | | - //LA.matScale(toParent, hScale, 1, vScale); |
---|
7642 | | - LA.matScale(toParent, 1, totalScale, 1); |
---|
| 7839 | + if (modified && opposite) |
---|
| 7840 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 7841 | + else |
---|
| 7842 | + //LA.matScale(toParent, hScale, 1, vScale); |
---|
| 7843 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7643 | 7844 | } else |
---|
7644 | 7845 | { |
---|
7645 | 7846 | LA.matScale(toParent, totalScale, 1, totalScale); |
---|
.. | .. |
---|
7649 | 7850 | case 1: // '\003' |
---|
7650 | 7851 | if (modified || opposite) |
---|
7651 | 7852 | { |
---|
7652 | | - //LA.matScale(toParent, hScale, vScale, 1); |
---|
7653 | | - LA.matScale(toParent, 1, 1, totalScale); |
---|
| 7853 | + if (modified && opposite) |
---|
| 7854 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 7855 | + else |
---|
| 7856 | + //LA.matScale(toParent, hScale, vScale, 1); |
---|
| 7857 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7654 | 7858 | } else |
---|
7655 | 7859 | { |
---|
7656 | 7860 | LA.matScale(toParent, totalScale, totalScale, 1); |
---|
.. | .. |
---|
7687 | 7891 | } // NEW ... |
---|
7688 | 7892 | |
---|
7689 | 7893 | |
---|
7690 | | - info.pane.repaint(); |
---|
| 7894 | + clickInfo.pane.repaint(); |
---|
7691 | 7895 | } |
---|
7692 | 7896 | |
---|
7693 | 7897 | boolean overflow = false; |
---|