.. | .. |
---|
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 | | - // TEMPORARY for mocap undo |
---|
28 | | - mocap.reader.BVHReader.BVHResult bvh; |
---|
29 | | - Object3D skeleton; |
---|
| 28 | + // TEMPORARY for mocap undo. No need to be transient. |
---|
| 29 | + mocap.reader.BVHReader.BVHResult savebvh; |
---|
| 30 | + Object3D saveskeleton; |
---|
30 | 31 | // |
---|
31 | 32 | |
---|
| 33 | + String skyboxname; |
---|
| 34 | + String skyboxext; |
---|
| 35 | + |
---|
| 36 | + Object3D versionlist[]; |
---|
| 37 | + int versionindex = -1; |
---|
| 38 | + |
---|
32 | 39 | ScriptNode scriptnode; |
---|
33 | 40 | |
---|
34 | 41 | void InitOthers() |
---|
.. | .. |
---|
170 | 177 | |
---|
171 | 178 | void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
172 | 179 | { |
---|
| 180 | + Object3D o; |
---|
| 181 | + |
---|
173 | 182 | if (hashtable.containsKey(GetUUID())) |
---|
174 | 183 | { |
---|
175 | | - Object3D o = hashtable.get(GetUUID()); |
---|
| 184 | + o = hashtable.get(GetUUID()); |
---|
176 | 185 | |
---|
177 | 186 | Grafreed.Assert(this.bRep == o.bRep); |
---|
178 | | - if (this.bRep != null) |
---|
179 | | - assert(this.bRep.support == o.transientrep); |
---|
| 187 | + //if (this.bRep != null) |
---|
| 188 | + // assert(this.bRep.support == o.transientrep); |
---|
| 189 | + if (this.support != null) |
---|
| 190 | + assert(this.support.bRep == o.transientrep); |
---|
| 191 | + } |
---|
| 192 | + else |
---|
| 193 | + { |
---|
| 194 | + o = new Object3D("copy of " + this.name); |
---|
180 | 195 | |
---|
181 | | - return; |
---|
| 196 | + hashtable.put(GetUUID(), o); |
---|
182 | 197 | } |
---|
183 | 198 | |
---|
184 | | - Object3D o = new Object3D("copy of " + this.name); |
---|
185 | | - |
---|
186 | | - hashtable.put(GetUUID(), o); |
---|
187 | | - |
---|
188 | | - for (int i=0; i<Size(); i++) |
---|
| 199 | + if (!blockloop) |
---|
189 | 200 | { |
---|
190 | | - get(i).ExtractBigData(hashtable); |
---|
| 201 | + blockloop = true; |
---|
| 202 | + |
---|
| 203 | + for (int i=0; i<Size(); i++) |
---|
| 204 | + { |
---|
| 205 | + get(i).ExtractBigData(hashtable); |
---|
| 206 | + } |
---|
| 207 | + |
---|
| 208 | + blockloop = false; |
---|
191 | 209 | } |
---|
192 | 210 | |
---|
193 | 211 | ExtractBigData(o); |
---|
.. | .. |
---|
195 | 213 | |
---|
196 | 214 | void ExtractBigData(Object3D o) |
---|
197 | 215 | { |
---|
| 216 | + if (o.bRep != null) |
---|
| 217 | + Grafreed.Assert(o.bRep == this.bRep); |
---|
| 218 | + |
---|
198 | 219 | o.bRep = this.bRep; |
---|
199 | | - if (this.bRep != null) |
---|
| 220 | +// July 2019 if (this.bRep != null) |
---|
| 221 | +// { |
---|
| 222 | +// o.transientrep = this.bRep.support; |
---|
| 223 | +// o.bRep.support = null; |
---|
| 224 | +// } |
---|
| 225 | + o.selection = this.selection; |
---|
| 226 | + o.versionlist = this.versionlist; |
---|
| 227 | + o.versionindex = this.versionindex; |
---|
| 228 | + |
---|
| 229 | + if (this.support != null) |
---|
200 | 230 | { |
---|
201 | | - o.transientrep = this.bRep.support; |
---|
202 | | - o.bRep.support = null; |
---|
| 231 | + if (o.transientrep != null) |
---|
| 232 | + Grafreed.Assert(o.transientrep == this.support.bRep); |
---|
| 233 | + |
---|
| 234 | + o.transientrep = this.support.bRep; |
---|
| 235 | + this.support.bRep = null; |
---|
203 | 236 | } |
---|
204 | 237 | |
---|
205 | 238 | // o.support = this.support; |
---|
.. | .. |
---|
214 | 247 | // this.fileparent = null; |
---|
215 | 248 | } |
---|
216 | 249 | |
---|
| 250 | +// Object3D GetObject(java.util.UUID uuid) |
---|
| 251 | +// { |
---|
| 252 | +// if (this.uuid.equals(uuid)) |
---|
| 253 | +// return this; |
---|
| 254 | +// |
---|
| 255 | +// if (blockloop) |
---|
| 256 | +// return null; |
---|
| 257 | +// |
---|
| 258 | +// blockloop = true; |
---|
| 259 | +// |
---|
| 260 | +// for (int i=0; i<Size(); i++) |
---|
| 261 | +// { |
---|
| 262 | +// Object3D o = get(i).GetObject(uuid); |
---|
| 263 | +// |
---|
| 264 | +// if (o != null) |
---|
| 265 | +// return o; |
---|
| 266 | +// } |
---|
| 267 | +// |
---|
| 268 | +// blockloop = false; |
---|
| 269 | +// |
---|
| 270 | +// return null; |
---|
| 271 | +// } |
---|
| 272 | + |
---|
217 | 273 | void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
218 | 274 | { |
---|
219 | 275 | if (!hashtable.containsKey(GetUUID())) |
---|
220 | 276 | return; |
---|
221 | 277 | |
---|
| 278 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 279 | + |
---|
| 280 | + RestoreBigData(o); |
---|
| 281 | + |
---|
222 | 282 | if (blockloop) |
---|
223 | 283 | return; |
---|
224 | 284 | |
---|
225 | 285 | blockloop = true; |
---|
226 | | - |
---|
227 | | - Object3D o = hashtable.get(GetUUID()); |
---|
228 | | - |
---|
229 | | - RestoreBigData(o); |
---|
230 | 286 | |
---|
231 | 287 | //hashtable.remove(GetUUID()); |
---|
232 | 288 | |
---|
.. | .. |
---|
241 | 297 | void RestoreBigData(Object3D o) |
---|
242 | 298 | { |
---|
243 | 299 | this.bRep = o.bRep; |
---|
244 | | - if (this.bRep != null) |
---|
245 | | - this.bRep.support = o.transientrep; |
---|
| 300 | + if (this.support != null && o.transientrep != null) |
---|
| 301 | + { |
---|
| 302 | + this.support.bRep = o.transientrep; |
---|
| 303 | + } |
---|
| 304 | + |
---|
| 305 | + this.selection = o.selection; |
---|
| 306 | + |
---|
| 307 | + this.versionlist = o.versionlist; |
---|
| 308 | + this.versionindex = o.versionindex; |
---|
| 309 | +// July 2019 if (this.bRep != null) |
---|
| 310 | +// this.bRep.support = o.transientrep; |
---|
246 | 311 | // this.support = o.support; |
---|
247 | 312 | // this.fileparent = o.fileparent; |
---|
248 | 313 | } |
---|
.. | .. |
---|
388 | 453 | } |
---|
389 | 454 | |
---|
390 | 455 | boolean live = false; |
---|
| 456 | + transient boolean keepdontselect; |
---|
391 | 457 | boolean dontselect = false; |
---|
392 | 458 | boolean hide = false; |
---|
393 | 459 | boolean link2master = false; // performs reset support/master at each frame |
---|
.. | .. |
---|
973 | 1039 | if (material == null || material.multiply) |
---|
974 | 1040 | return true; |
---|
975 | 1041 | |
---|
| 1042 | + if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
| 1043 | + return false; |
---|
| 1044 | + |
---|
976 | 1045 | // Transparent objects are dynamic because we have to sort the triangles. |
---|
977 | 1046 | return material.opacity > 0.99; |
---|
978 | 1047 | } |
---|
.. | .. |
---|
1374 | 1443 | toParent = LA.newMatrix(); |
---|
1375 | 1444 | fromParent = LA.newMatrix(); |
---|
1376 | 1445 | } |
---|
| 1446 | + |
---|
1377 | 1447 | LA.matCopy(other.toParent, toParent); |
---|
1378 | 1448 | LA.matCopy(other.fromParent, fromParent); |
---|
1379 | 1449 | |
---|
.. | .. |
---|
2527 | 2597 | private static final int editSelf = 1; |
---|
2528 | 2598 | private static final int editChild = 2; |
---|
2529 | 2599 | |
---|
2530 | | - void drawEditHandles(ClickInfo info, int level) |
---|
| 2600 | + void drawEditHandles(//ClickInfo info, |
---|
| 2601 | + int level) |
---|
2531 | 2602 | { |
---|
2532 | 2603 | if (level == 0) |
---|
2533 | 2604 | { |
---|
.. | .. |
---|
2535 | 2606 | return; |
---|
2536 | 2607 | |
---|
2537 | 2608 | Object3D selectee; |
---|
2538 | | - for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1)) |
---|
| 2609 | + for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info, |
---|
| 2610 | + level + 1)) |
---|
2539 | 2611 | { |
---|
2540 | 2612 | selectee = (Object3D) e.nextElement(); |
---|
2541 | 2613 | } |
---|
.. | .. |
---|
2543 | 2615 | } else |
---|
2544 | 2616 | { |
---|
2545 | 2617 | //super. |
---|
2546 | | - drawEditHandles0(info, level + 1); |
---|
| 2618 | + drawEditHandles0(//info, |
---|
| 2619 | + level + 1); |
---|
2547 | 2620 | } |
---|
2548 | 2621 | } |
---|
2549 | 2622 | |
---|
2550 | | - boolean doEditClick(ClickInfo info, int level) |
---|
| 2623 | + boolean doEditClick(//ClickInfo info, |
---|
| 2624 | + int level) |
---|
2551 | 2625 | { |
---|
2552 | 2626 | doSomething = 0; |
---|
2553 | 2627 | if (level == 0) |
---|
2554 | 2628 | { |
---|
2555 | | - return doParentClick(info); |
---|
| 2629 | + return doParentClick(); //info); |
---|
2556 | 2630 | } |
---|
2557 | 2631 | if (//super. |
---|
2558 | | - doEditClick0(info, level)) |
---|
| 2632 | + doEditClick0(//info, |
---|
| 2633 | + level)) |
---|
2559 | 2634 | { |
---|
2560 | 2635 | doSomething = 1; |
---|
2561 | 2636 | return true; |
---|
.. | .. |
---|
2565 | 2640 | } |
---|
2566 | 2641 | } |
---|
2567 | 2642 | |
---|
2568 | | - boolean doParentClick(ClickInfo info) |
---|
| 2643 | + boolean doParentClick() //ClickInfo info) |
---|
2569 | 2644 | { |
---|
2570 | 2645 | if (selection == null) |
---|
2571 | 2646 | { |
---|
.. | .. |
---|
2578 | 2653 | for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();) |
---|
2579 | 2654 | { |
---|
2580 | 2655 | Object3D selectee = (Object3D) e.nextElement(); |
---|
2581 | | - if (selectee.doEditClick(info, 1)) |
---|
| 2656 | + if (selectee.doEditClick(//info, |
---|
| 2657 | + 1)) |
---|
2582 | 2658 | { |
---|
2583 | 2659 | childToDrag = selectee; |
---|
2584 | 2660 | doSomething = 2; |
---|
.. | .. |
---|
2590 | 2666 | return retval; |
---|
2591 | 2667 | } |
---|
2592 | 2668 | |
---|
2593 | | - void doEditDrag(ClickInfo info, boolean opposite) |
---|
| 2669 | + void doEditDrag(//ClickInfo clickInfo, |
---|
| 2670 | + boolean opposite) |
---|
2594 | 2671 | { |
---|
2595 | 2672 | switch (doSomething) |
---|
2596 | 2673 | { |
---|
2597 | 2674 | case 1: // '\001' |
---|
2598 | 2675 | //super. |
---|
2599 | | - doEditDrag0(info, opposite); |
---|
| 2676 | + doEditDrag0(//clickInfo, |
---|
| 2677 | + opposite); |
---|
2600 | 2678 | break; |
---|
2601 | 2679 | |
---|
2602 | 2680 | case 2: // '\002' |
---|
.. | .. |
---|
2609 | 2687 | { |
---|
2610 | 2688 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2611 | 2689 | //childToDrag.doEditDrag(info); |
---|
2612 | | - sel.doEditDrag(info, opposite); |
---|
| 2690 | + sel.doEditDrag(//clickInfo, |
---|
| 2691 | + opposite); |
---|
2613 | 2692 | } else |
---|
2614 | 2693 | { |
---|
2615 | 2694 | //super. |
---|
2616 | | - doEditDrag0(info, opposite); |
---|
| 2695 | + doEditDrag0(//clickInfo, |
---|
| 2696 | + opposite); |
---|
2617 | 2697 | } |
---|
2618 | 2698 | } |
---|
2619 | 2699 | break; |
---|
.. | .. |
---|
2631 | 2711 | { |
---|
2632 | 2712 | deselectAll(); |
---|
2633 | 2713 | } |
---|
| 2714 | + |
---|
| 2715 | + new Exception().printStackTrace(); |
---|
| 2716 | + |
---|
2634 | 2717 | ClickInfo newInfo = new ClickInfo(); |
---|
2635 | 2718 | newInfo.flags = info.flags; |
---|
2636 | 2719 | newInfo.bounds = info.bounds; |
---|
.. | .. |
---|
3078 | 3161 | { |
---|
3079 | 3162 | if (bRep != null) |
---|
3080 | 3163 | { |
---|
3081 | | - bRep.GenerateNormalsMINE(); |
---|
| 3164 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
3082 | 3165 | Touch(); |
---|
3083 | 3166 | } |
---|
3084 | 3167 | } |
---|
.. | .. |
---|
5381 | 5464 | blockloop = false; |
---|
5382 | 5465 | } |
---|
5383 | 5466 | |
---|
| 5467 | + void ResetSelectable() |
---|
| 5468 | + { |
---|
| 5469 | + if (blockloop) |
---|
| 5470 | + return; |
---|
| 5471 | + |
---|
| 5472 | + blockloop = true; |
---|
| 5473 | + |
---|
| 5474 | + keepdontselect = dontselect; |
---|
| 5475 | + dontselect = true; |
---|
| 5476 | + |
---|
| 5477 | + Object3D child; |
---|
| 5478 | + int nb = Size(); |
---|
| 5479 | + for (int i = 0; i < nb; i++) |
---|
| 5480 | + { |
---|
| 5481 | + child = (Object3D) get(i); |
---|
| 5482 | + if (child == null) |
---|
| 5483 | + continue; |
---|
| 5484 | + child.ResetSelectable(); |
---|
| 5485 | + } |
---|
| 5486 | + |
---|
| 5487 | + blockloop = false; |
---|
| 5488 | + } |
---|
| 5489 | + |
---|
| 5490 | + void RestoreSelectable() |
---|
| 5491 | + { |
---|
| 5492 | + if (blockloop) |
---|
| 5493 | + return; |
---|
| 5494 | + |
---|
| 5495 | + blockloop = true; |
---|
| 5496 | + |
---|
| 5497 | + dontselect = keepdontselect; |
---|
| 5498 | + |
---|
| 5499 | + Object3D child; |
---|
| 5500 | + int nb = Size(); |
---|
| 5501 | + for (int i = 0; i < nb; i++) |
---|
| 5502 | + { |
---|
| 5503 | + child = (Object3D) get(i); |
---|
| 5504 | + if (child == null) |
---|
| 5505 | + continue; |
---|
| 5506 | + child.RestoreSelectable(); |
---|
| 5507 | + } |
---|
| 5508 | + |
---|
| 5509 | + blockloop = false; |
---|
| 5510 | + } |
---|
| 5511 | + |
---|
5384 | 5512 | boolean IsSelected() |
---|
5385 | 5513 | { |
---|
5386 | 5514 | if (parent == null) |
---|
.. | .. |
---|
5690 | 5818 | } |
---|
5691 | 5819 | } |
---|
5692 | 5820 | |
---|
| 5821 | + void EmbedTextures(boolean embed) |
---|
| 5822 | + { |
---|
| 5823 | + if (blockloop) |
---|
| 5824 | + return; |
---|
| 5825 | + |
---|
| 5826 | + //if (GetTextures() != null) |
---|
| 5827 | + if (embed) |
---|
| 5828 | + CameraPane.EmbedTextures(GetTextures()); |
---|
| 5829 | + else |
---|
| 5830 | + { |
---|
| 5831 | + GetTextures().pigmentdata = null; |
---|
| 5832 | + GetTextures().bumpdata = null; |
---|
| 5833 | + GetTextures().pw = 0; |
---|
| 5834 | + GetTextures().ph = 0; |
---|
| 5835 | + GetTextures().bw = 0; |
---|
| 5836 | + GetTextures().bh = 0; |
---|
| 5837 | + } |
---|
| 5838 | + |
---|
| 5839 | + int nb = Size(); |
---|
| 5840 | + for (int i = 0; i < nb; i++) |
---|
| 5841 | + { |
---|
| 5842 | + Object3D child = (Object3D) get(i); |
---|
| 5843 | + |
---|
| 5844 | + if (child == null) |
---|
| 5845 | + continue; |
---|
| 5846 | + |
---|
| 5847 | + blockloop = true; |
---|
| 5848 | + child.EmbedTextures(embed); |
---|
| 5849 | + blockloop = false; |
---|
| 5850 | + } |
---|
| 5851 | + } |
---|
| 5852 | + |
---|
5693 | 5853 | void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5694 | 5854 | { |
---|
5695 | 5855 | Draw(display, root, selected, blocked); |
---|
.. | .. |
---|
5776 | 5936 | if (support != null) |
---|
5777 | 5937 | support = support; |
---|
5778 | 5938 | |
---|
5779 | | - //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5780 | | - boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5939 | + boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5940 | + //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5941 | + |
---|
| 5942 | + //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
5781 | 5943 | |
---|
5782 | 5944 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5783 | 5945 | { |
---|
.. | .. |
---|
5787 | 5949 | // usecalllists &= !(parent instanceof RandomNode); |
---|
5788 | 5950 | // usecalllists = false; |
---|
5789 | 5951 | |
---|
5790 | | - if (GetBRep() != null) |
---|
5791 | | - usecalllists = usecalllists; |
---|
| 5952 | + if (display.DrawMode() == display.SHADOW) |
---|
| 5953 | + //GetBRep() != null) |
---|
| 5954 | + usecalllists = !!usecalllists; |
---|
5792 | 5955 | //System.out.println("draw " + this); |
---|
5793 | 5956 | //new Exception().printStackTrace(); |
---|
5794 | 5957 | |
---|
.. | .. |
---|
5810 | 5973 | if (!(this instanceof Composite)) |
---|
5811 | 5974 | touched = false; |
---|
5812 | 5975 | //if (displaylist == -1 && usecalllists) |
---|
5813 | | - if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
| 5976 | + if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013 |
---|
5814 | 5977 | { |
---|
5815 | 5978 | bRep.displaylist = display.GenList(); |
---|
5816 | 5979 | assert(bRep.displaylist != 0); |
---|
.. | .. |
---|
5821 | 5984 | |
---|
5822 | 5985 | //System.out.println("\tnew list " + list); |
---|
5823 | 5986 | //gl.glDrawBuffer(gl.GL_NONE); |
---|
5824 | | - if (usecalllists) |
---|
| 5987 | + if (usecalllists && bRep.displaylist > 0) |
---|
5825 | 5988 | { |
---|
5826 | 5989 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5827 | 5990 | display.NewList(bRep.displaylist); |
---|
.. | .. |
---|
5830 | 5993 | CallList(display, root, selected, blocked); |
---|
5831 | 5994 | |
---|
5832 | 5995 | // compiled = true; |
---|
5833 | | - if (usecalllists) |
---|
| 5996 | + if (usecalllists && bRep.displaylist > 0) |
---|
5834 | 5997 | { |
---|
5835 | 5998 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5836 | 5999 | display.EndList(); |
---|
.. | .. |
---|
7181 | 7344 | } |
---|
7182 | 7345 | } |
---|
7183 | 7346 | |
---|
7184 | | - protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec) |
---|
| 7347 | + static ClickInfo clickInfo = new ClickInfo(); |
---|
| 7348 | + |
---|
| 7349 | + protected void calcHotSpot(cVector in, //ClickInfo clickInfo, |
---|
| 7350 | + Point outPt, Rectangle outRec) |
---|
7185 | 7351 | { |
---|
7186 | | - int hc = info.bounds.x + info.bounds.width / 2; |
---|
7187 | | - int vc = info.bounds.y + info.bounds.height / 2; |
---|
7188 | | - double[][] toscreen = info.toScreen; |
---|
| 7352 | + int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2; |
---|
| 7353 | + int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2; |
---|
| 7354 | + double[][] toscreen = clickInfo.toScreen; |
---|
7189 | 7355 | if (toscreen == null) |
---|
7190 | 7356 | { |
---|
7191 | | - toscreen = new Camera(info.camera.viewCode).toScreen; |
---|
| 7357 | + toscreen = new Camera(clickInfo.camera.viewCode).toScreen; |
---|
7192 | 7358 | } |
---|
7193 | 7359 | cVector vec = in; |
---|
7194 | 7360 | LA.xformPos(in, toscreen, in); |
---|
7195 | 7361 | //System.out.println("Distance = " + info.camera.Distance()); |
---|
7196 | | - vec.x *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
7197 | | - vec.y *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
| 7362 | + vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
| 7363 | + vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
7198 | 7364 | outPt.x = hc + (int) vec.x; |
---|
7199 | 7365 | outPt.y = vc - (int) vec.y; |
---|
7200 | 7366 | outRec.x = outPt.x - 3; |
---|
.. | .. |
---|
7202 | 7368 | outRec.width = outRec.height = 6; |
---|
7203 | 7369 | } |
---|
7204 | 7370 | |
---|
7205 | | - protected Rectangle calcHotSpot(cVector in, ClickInfo info) |
---|
| 7371 | + protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo |
---|
| 7372 | + ) |
---|
7206 | 7373 | { |
---|
7207 | 7374 | Point pt = new Point(0, 0); |
---|
7208 | 7375 | Rectangle rec = new Rectangle(); |
---|
7209 | | - calcHotSpot(in, info, pt, rec); |
---|
| 7376 | + calcHotSpot(in, //clickInfo, |
---|
| 7377 | + pt, rec); |
---|
7210 | 7378 | return rec; |
---|
7211 | 7379 | } |
---|
7212 | 7380 | |
---|
7213 | | - void drawEditHandles0(ClickInfo info, int level) |
---|
| 7381 | + void drawEditHandles0(//ClickInfo clickInfo, |
---|
| 7382 | + int level) |
---|
7214 | 7383 | { |
---|
7215 | 7384 | if (level == 0) |
---|
7216 | 7385 | { |
---|
.. | .. |
---|
7219 | 7388 | { |
---|
7220 | 7389 | cVector origin = new cVector(); |
---|
7221 | 7390 | //LA.xformPos(origin, toParent, origin); |
---|
7222 | | - Rectangle spot = calcHotSpot(origin, info); |
---|
| 7391 | + if (this.clickInfo == null) |
---|
| 7392 | + this.clickInfo = new ClickInfo(); |
---|
| 7393 | + |
---|
| 7394 | + Rectangle spot = calcHotSpot(origin); //, clickInfo); |
---|
7223 | 7395 | Rectangle boundary = new Rectangle(); |
---|
7224 | 7396 | boundary.x = spot.x - 30; |
---|
7225 | 7397 | boundary.y = spot.y - 30; |
---|
7226 | 7398 | boundary.width = spot.width + 60; |
---|
7227 | 7399 | boundary.height = spot.height + 60; |
---|
7228 | | - info.g.setColor(Color.red); |
---|
| 7400 | + clickInfo.g.setColor(Color.red); |
---|
7229 | 7401 | int spotw = spot.x + spot.width; |
---|
7230 | 7402 | int spoth = spot.y + spot.height; |
---|
7231 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7403 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7232 | 7404 | // if (CameraPane.Xmin > spot.x) |
---|
7233 | 7405 | // { |
---|
7234 | 7406 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7248 | 7420 | spot.translate(32, 32); |
---|
7249 | 7421 | spotw = spot.x + spot.width; |
---|
7250 | 7422 | spoth = spot.y + spot.height; |
---|
7251 | | - info.g.setColor(Color.cyan); |
---|
7252 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7423 | + clickInfo.g.setColor(Color.cyan); |
---|
| 7424 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7253 | 7425 | // if (CameraPane.Xmin > spot.x) |
---|
7254 | 7426 | // { |
---|
7255 | 7427 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7269 | 7441 | // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
7270 | 7442 | //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
7271 | 7443 | spot.translate(0, -32); |
---|
7272 | | - info.g.setColor(Color.yellow); |
---|
7273 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7274 | | - info.g.setColor(Color.green); |
---|
| 7444 | + clickInfo.g.setColor(Color.yellow); |
---|
| 7445 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7446 | + clickInfo.g.setColor(Color.green); |
---|
7275 | 7447 | // if (CameraPane.Xmin > spot.x) |
---|
7276 | 7448 | // { |
---|
7277 | 7449 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7288 | 7460 | // { |
---|
7289 | 7461 | // CameraPane.Ymax = spoth; |
---|
7290 | 7462 | // } |
---|
7291 | | - info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY, |
---|
7292 | | - (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360); |
---|
| 7463 | + clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, |
---|
| 7464 | + (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); |
---|
7293 | 7465 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
7294 | 7466 | // if (CameraPane.Xmin > boundary.x) |
---|
7295 | 7467 | // { |
---|
.. | .. |
---|
7311 | 7483 | } |
---|
7312 | 7484 | } |
---|
7313 | 7485 | |
---|
7314 | | - boolean doEditClick0(ClickInfo info, int level) |
---|
| 7486 | + boolean doEditClick0(//ClickInfo clickInfo, |
---|
| 7487 | + int level) |
---|
7315 | 7488 | { |
---|
7316 | 7489 | if (level == 0) |
---|
7317 | 7490 | { |
---|
.. | .. |
---|
7320 | 7493 | |
---|
7321 | 7494 | boolean retval = false; |
---|
7322 | 7495 | |
---|
7323 | | - startX = info.x; |
---|
7324 | | - startY = info.y; |
---|
| 7496 | + startX = clickInfo.x; |
---|
| 7497 | + startY = clickInfo.y; |
---|
7325 | 7498 | |
---|
7326 | 7499 | hitSomething = -1; |
---|
7327 | 7500 | cVector origin = new cVector(); |
---|
.. | .. |
---|
7331 | 7504 | { |
---|
7332 | 7505 | centerPt = new Point(0, 0); |
---|
7333 | 7506 | } |
---|
7334 | | - calcHotSpot(origin, info, centerPt, spot); |
---|
7335 | | - if (spot.contains(info.x, info.y)) |
---|
| 7507 | + calcHotSpot(origin, //info, |
---|
| 7508 | + centerPt, spot); |
---|
| 7509 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7336 | 7510 | { |
---|
7337 | 7511 | hitSomething = hitCenter; |
---|
7338 | 7512 | retval = true; |
---|
7339 | 7513 | } |
---|
7340 | 7514 | spot.translate(32, 0); |
---|
7341 | | - if (spot.contains(info.x, info.y)) |
---|
| 7515 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7342 | 7516 | { |
---|
7343 | 7517 | hitSomething = hitRotate; |
---|
7344 | 7518 | retval = true; |
---|
7345 | 7519 | } |
---|
7346 | 7520 | spot.translate(0, 32); |
---|
7347 | | - if (spot.contains(info.x, info.y)) |
---|
| 7521 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7348 | 7522 | { |
---|
7349 | 7523 | hitSomething = hitScale; |
---|
| 7524 | + |
---|
| 7525 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7526 | + double hScale = (double) (clickInfo.x - centerPt.x) / 32; |
---|
| 7527 | + double sign = 1; |
---|
| 7528 | + if (hScale < 0) |
---|
| 7529 | + { |
---|
| 7530 | + sign = -1; |
---|
| 7531 | + } |
---|
| 7532 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
| 7533 | + if (hScale < 0.01) |
---|
| 7534 | + { |
---|
| 7535 | + //hScale = 0.01; |
---|
| 7536 | + } |
---|
| 7537 | + |
---|
| 7538 | + double vScale = (double) (clickInfo.y - centerPt.y) / 32; |
---|
| 7539 | + sign = 1; |
---|
| 7540 | + if (vScale < 0) |
---|
| 7541 | + { |
---|
| 7542 | + sign = -1; |
---|
| 7543 | + } |
---|
| 7544 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
| 7545 | + if (vScale < 0.01) |
---|
| 7546 | + { |
---|
| 7547 | + //vScale = 0.01; |
---|
| 7548 | + } |
---|
| 7549 | + |
---|
| 7550 | + clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale); |
---|
| 7551 | + |
---|
7350 | 7552 | retval = true; |
---|
7351 | 7553 | } |
---|
7352 | 7554 | |
---|
.. | .. |
---|
7356 | 7558 | } |
---|
7357 | 7559 | |
---|
7358 | 7560 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7359 | | - modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
| 7561 | + modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7360 | 7562 | //System.out.println("modified = " + modified); |
---|
7361 | 7563 | //new Exception().printStackTrace(); |
---|
7362 | 7564 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7384 | 7586 | return true; |
---|
7385 | 7587 | } |
---|
7386 | 7588 | |
---|
7387 | | - void doEditDrag0(ClickInfo info, boolean opposite) |
---|
| 7589 | + void doEditDrag0(//ClickInfo info, |
---|
| 7590 | + boolean opposite) |
---|
7388 | 7591 | { |
---|
7389 | 7592 | if (hitSomething == 0) |
---|
7390 | 7593 | { |
---|
.. | .. |
---|
7398 | 7601 | |
---|
7399 | 7602 | //System.out.println("hitSomething = " + hitSomething); |
---|
7400 | 7603 | |
---|
7401 | | - double scale = 0.005f * info.camera.Distance(); |
---|
| 7604 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
7402 | 7605 | |
---|
7403 | 7606 | cVector xlate = new cVector(); |
---|
7404 | 7607 | //cVector xlate2 = new cVector(); |
---|
.. | .. |
---|
7432 | 7635 | toParent[3][i] = xlate.get(i); |
---|
7433 | 7636 | LA.matInvert(toParent, fromParent); |
---|
7434 | 7637 | */ |
---|
7435 | | - cVector delta = LA.newVector(0, 0, startY - info.y); |
---|
7436 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7638 | + cVector delta = LA.newVector(0, 0, startY - clickInfo.y); |
---|
| 7639 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7437 | 7640 | |
---|
7438 | 7641 | LA.matCopy(startMat, toParent); |
---|
7439 | 7642 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7442 | 7645 | } else |
---|
7443 | 7646 | { |
---|
7444 | 7647 | //LA.xformDir(delta, info.camera.fromScreen, delta); |
---|
7445 | | - cVector up = new cVector(info.camera.up); |
---|
| 7648 | + cVector up = new cVector(clickInfo.camera.up); |
---|
7446 | 7649 | cVector away = new cVector(); |
---|
7447 | 7650 | //cVector right2 = new cVector(); |
---|
7448 | 7651 | //LA.vecCross(up, cVector.Z, right); |
---|
.. | .. |
---|
7459 | 7662 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7460 | 7663 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7461 | 7664 | LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7462 | | - LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
| 7665 | + LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away); |
---|
7463 | 7666 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7464 | 7667 | LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7465 | 7668 | //LA.vecCross(up, cVector.Z, right2); |
---|
7466 | 7669 | |
---|
7467 | | - cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
| 7670 | + cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0); |
---|
7468 | 7671 | |
---|
7469 | 7672 | //System.out.println("DELTA0 = " + delta); |
---|
7470 | 7673 | //System.out.println("AWAY = " + info.camera.away); |
---|
7471 | 7674 | //System.out.println("UP = " + info.camera.up); |
---|
7472 | 7675 | if (away.z > 0) |
---|
7473 | 7676 | { |
---|
7474 | | - if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
| 7677 | + if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
7475 | 7678 | { |
---|
7476 | 7679 | delta.x = -delta.x; |
---|
7477 | 7680 | } else |
---|
.. | .. |
---|
7486 | 7689 | //System.out.println("DELTA1 = " + delta); |
---|
7487 | 7690 | LA.xformDir(delta, ClickInfo.matbuffer, delta); |
---|
7488 | 7691 | //System.out.println("DELTA2 = " + delta); |
---|
7489 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7692 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7490 | 7693 | LA.matCopy(startMat, toParent); |
---|
7491 | 7694 | //System.out.println("DELTA3 = " + delta); |
---|
7492 | 7695 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7496 | 7699 | break; |
---|
7497 | 7700 | |
---|
7498 | 7701 | case hitRotate: // rotate |
---|
7499 | | - int dx = info.x - centerPt.x; |
---|
7500 | | - int dy = -(info.y - centerPt.y); |
---|
| 7702 | + int dx = clickInfo.x - centerPt.x; |
---|
| 7703 | + int dy = -(clickInfo.y - centerPt.y); |
---|
7501 | 7704 | double angle = (double) Math.atan2(dx, dy); |
---|
7502 | 7705 | angle = -(1.570796 - angle); |
---|
7503 | 7706 | |
---|
.. | .. |
---|
7520 | 7723 | } |
---|
7521 | 7724 | /**/ |
---|
7522 | 7725 | |
---|
7523 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7726 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7524 | 7727 | { |
---|
7525 | 7728 | case 1: // '\001' |
---|
7526 | 7729 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7547 | 7750 | break; |
---|
7548 | 7751 | |
---|
7549 | 7752 | case hitScale: // scale |
---|
7550 | | - double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7753 | + double hScale = (double) (clickInfo.x - centerPt.x) / 32; |
---|
7551 | 7754 | double sign = 1; |
---|
7552 | 7755 | if (hScale < 0) |
---|
7553 | 7756 | { |
---|
.. | .. |
---|
7559 | 7762 | //hScale = 0.01; |
---|
7560 | 7763 | } |
---|
7561 | 7764 | |
---|
7562 | | - double vScale = (double) (info.y - centerPt.y) / 32; |
---|
| 7765 | + double vScale = (double) (clickInfo.y - centerPt.y) / 32; |
---|
7563 | 7766 | sign = 1; |
---|
7564 | 7767 | if (vScale < 0) |
---|
7565 | 7768 | { |
---|
.. | .. |
---|
7570 | 7773 | { |
---|
7571 | 7774 | //vScale = 0.01; |
---|
7572 | 7775 | } |
---|
| 7776 | + |
---|
7573 | 7777 | LA.matCopy(startMat, toParent); |
---|
7574 | 7778 | /**/ |
---|
7575 | 7779 | for (int i = 0; i < 3; i++) |
---|
.. | .. |
---|
7579 | 7783 | } |
---|
7580 | 7784 | /**/ |
---|
7581 | 7785 | |
---|
7582 | | - double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7786 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale; |
---|
7583 | 7787 | |
---|
7584 | 7788 | if (totalScale < 0.01) |
---|
7585 | 7789 | { |
---|
7586 | 7790 | totalScale = 0.01; |
---|
7587 | 7791 | } |
---|
7588 | 7792 | |
---|
7589 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7793 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7590 | 7794 | { |
---|
7591 | 7795 | case 3: // '\001' |
---|
7592 | 7796 | if (modified || opposite) |
---|
.. | .. |
---|
7653 | 7857 | } // NEW ... |
---|
7654 | 7858 | |
---|
7655 | 7859 | |
---|
7656 | | - info.pane.repaint(); |
---|
| 7860 | + clickInfo.pane.repaint(); |
---|
7657 | 7861 | } |
---|
7658 | 7862 | |
---|
7659 | 7863 | boolean overflow = false; |
---|