| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | //////////////////////////////////////////////////////////////////////// |
| 38 | // |
| 39 | // Description: |
| 40 | // This is the source file for the SoSpotLightDragger. |
| 41 | // This is a composite dragger which allows independent rotation, |
| 42 | // translation, and beam spread editting of a spot light. |
| 43 | // |
| 44 | // It is composed of an SoRotateSphericalDragger (for rotation), |
| 45 | // an SoDragPointDragger (for translation), and it creates its own projector |
| 46 | // handles mouse events for doing it's own dragging of the beam angle. |
| 47 | // |
| 48 | // The beam is editted by behaving like an SoRotateDiscDragger, but the |
| 49 | // plane of the disc is re-defined every time a drag is initiated. |
| 50 | // The plane always passes through the z axis and the selected point. |
| 51 | // When the rotation angle is determined, however, the beam is not rotated, |
| 52 | // but scaled so it looks like an opening or closing umbrella. This is done |
| 53 | // by scaling evenly in x and y, and a different amount in z, so the distance |
| 54 | // between the selected point and the origin remains constant. |
| 55 | // |
| 56 | //////////////////////////////////////////////////////////////////////// |
| 57 | |
| 58 | |
| 59 | #include <cstdio> |
| 60 | #include <cmath> |
| 61 | #include <Inventor/SbLinear.h>cxx . . $ `<file>/lib/database/include/Inventor/SbLinear.h`/ |
| 62 | #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/ |
| 63 | #include <Inventor/SoPath.h>cxx . . $ `<file>/lib/database/include/Inventor/SoPath.h`/ |
| 64 | #include <Inventor/projectors/SbPlaneProjector.h>cxx . . $ `<file>/lib/database/include/Inventor/projectors/SbPlaneProjector.h`/ |
| 65 | #include <Inventor/projectors/SbSphereSectionProjector.h>cxx . . $ `<file>/lib/database/include/Inventor/projectors/SbSphereSectionProjector.h`/ |
| 66 | #include <Inventor/sensors/SoFieldSensor.h>cxx . . $ `<file>/lib/database/include/Inventor/sensors/SoFieldSensor.h`/ |
| 67 | |
| 68 | #include <Inventor/nodes/SoMaterial.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoMaterial.h`/ |
| 69 | #include <Inventor/nodes/SoRotation.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoRotation.h`/ |
| 70 | #include <Inventor/nodes/SoScale.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoScale.h`/ |
| 71 | #include <Inventor/nodes/SoSeparator.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSeparator.h`/ |
| 72 | #include <Inventor/nodes/SoTransform.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoTransform.h`/ |
| 73 | #include <Inventor/nodes/SoTranslation.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoTranslation.h`/ |
| 74 | #include <Inventor/nodes/SoSpotLight.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSpotLight.h`/ |
| 75 | #include <Inventor/nodes/SoSwitch.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSwitch.h`/ |
| 76 | #include <Inventor/draggers/SoDragPointDragger.h>cxx . . $ `<file>/lib/interaction/include/Inventor/draggers/SoDragPointDragger.h`/ |
| 77 | #include <Inventor/draggers/SoRotateSphericalDragger.h>cxx . . $ `<file>/lib/interaction/include/Inventor/draggers/SoRotateSphericalDragger.h`/ |
| 78 | #include <Inventor/draggers/SoSpotLightDragger.h>cxx . . $ `<file>/lib/interaction/include/Inventor/draggers/SoSpotLightDragger.h`/ |
| 79 | |
| 80 | #include "geom/SoSpotLightDraggerGeom.h"cxx . . $ `<file>/lib/interaction/src/draggers/geom/SoSpotLightDraggerGeom.h`/ |
| 81 | |
| 82 | |
| 83 | SO_KIT_SOURCEcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:194:9`!(SoSpotLightDragger); |
| 84 | |
| 85 | //////////////////////////////////////////////////////////////////////// |
| 86 | // |
| 87 | // Description: |
| 88 | // Constructors. Each constructor calls constructorSub(), which |
| 89 | // does work that is common to each. |
| 90 | // |
| 91 | // Use: public |
| 92 | // |
| 93 | //////////////////////////////////////////////////////////////////////// |
| 94 | |
| 95 | // Default constructor. |
| 96 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::SoSpotLightDraggercxx . . $ SoSpotLightDragger#SoSpotLightDragger(49f6e7a06ebc5aa8).() |
| 97 | { |
| 98 | SO_KIT_CONSTRUCTORcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:254:9`!(SoSpotLightDragger); |
| 99 | |
| 100 | isBuiltIncxx . . $ SoFieldContainer#isBuiltIn. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 101 | |
| 102 | // This gives the dragger an overall material. It is edited by lightManips |
| 103 | // to make its dragger match the color of the light. Any materials within |
| 104 | // other parts will override this one. |
| 105 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(material, SoMaterial, |
| 106 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, topSeparator, geomSeparator,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 107 | |
| 108 | // The translator is kept under a separator along with a |
| 109 | // rotation that is maintained as the inverse to the rotation of the |
| 110 | // light. This means that using the rotator does not rotate the |
| 111 | // coordinate system that we translate the base of the dragger in. |
| 112 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(translatorSep, SoSeparator, |
| 113 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, topSeparator, geomSeparator,FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 114 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(translatorRotInv, SoRotation, |
| 115 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, translatorSep, ,FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 116 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(translator, SoDragPointDragger, |
| 117 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, translatorSep, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 118 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(rotator, SoRotateSphericalDragger, |
| 119 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, topSeparator, geomSeparator,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 120 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(beamSep, SoSeparator, |
| 121 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, topSeparator, geomSeparator,FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 122 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(beamPlacement, SoTranslation, |
| 123 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, beamSep, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 124 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(beamScale, SoScale, |
| 125 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, beamSep, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 126 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(beamSwitch, SoSwitch, |
| 127 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, beamSep, ,FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 128 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(beam, SoSeparator, |
| 129 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, beamSwitch, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 130 | SO_KIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:333:9`!(beamActive, SoSeparator, |
| 131 | TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, beamSwitch, ,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 132 | |
| 133 | // Read the default geometry for this dragger |
| 134 | if (SO_KIT_IS_FIRST_INSTANCEcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:258:9`!()) |
| 135 | readDefaultPartscxx . . $ SoInteractionKit#readDefaultParts(5e891a9f77bb0eff).( "spotLightDragger.iv", geomBuffercxx . . $ SoSpotLightDragger#geomBuffer., sizeof(geomBuffercxx . . $ SoSpotLightDragger#geomBuffer.) ); |
| 136 | SO_KIT_ADD_FIELDcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:261:9`!(rotation, (0.0, 0.0, 0.0, 1.0)); |
| 137 | SO_KIT_ADD_FIELDcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:261:9`!(translation, (0.0, 0.0, 0.0)); |
| 138 | SO_KIT_ADD_FIELDcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:261:9`!(angle, (1.0)); |
| 139 | |
| 140 | SO_KIT_INIT_INSTANCEcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoSubKit.h:546:9`!(); |
| 141 | |
| 142 | // Set the overall material. |
| 143 | // We need to use a copy of the resource, since the resource is shared |
| 144 | // by all manips but we are going to edit ours. |
| 145 | SoNodecxx . . $ SoNode# *resourceMtl |
| 146 | = SoNodecxx . . $ SoNode#::getByNamecxx . . $ SoNode#getByName(bf62e009e5fb797f).("spotLightOverallMaterial"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 147 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("material"cxx . . $ SbName#SbName(85c52e162fed56f9)., resourceMtl->copycxx . . $ SoNode#copy(fd675789997d09c2).() ); |
| 148 | |
| 149 | |
| 150 | // Create the simple draggers that comprise this dragger. |
| 151 | // This dragger employs 2 simple draggers: |
| 152 | // 1 DragpointDragger |
| 153 | // 1 RotateSphericalDragger |
| 154 | |
| 155 | SoDragPointDraggercxx . . $ SoDragPointDragger# *trD; |
| 156 | trD = SO_GET_ANY_PARTcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoBaseKit.h:424:9`!( this,"translator", SoDragPointDragger ); |
| 157 | |
| 158 | SoRotateSphericalDraggercxx . . $ SoRotateSphericalDragger# *roD; |
| 159 | roD = SO_GET_ANY_PARTcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoBaseKit.h:424:9`!( this, "rotator", SoRotateSphericalDragger ); |
| 160 | |
| 161 | // Create everything needed for the beam spreader. |
| 162 | // Create the parts. |
| 163 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("beam"cxx . . $ SbName#SbName(85c52e162fed56f9)., "spotLightBeam"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 164 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("beamActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., "spotLightBeamActive"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 165 | setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("beamPlacement"cxx . . $ SbName#SbName(85c52e162fed56f9)., "spotLightBeamPlacement"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 166 | |
| 167 | // Set the switch to 0... |
| 168 | SoNodecxx . . $ SoNode# *bs = getAnyPartcxx . . $ SoInteractionKit#getAnyPart(e7d7a7aae96def2f).("beamSwitch"cxx . . $ SbName#SbName(85c52e162fed56f9)., TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`! ); |
| 169 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).(bs, 0); |
| 170 | |
| 171 | // Create a plane projector for use in dragging. |
| 172 | planeProjcxx . . $ SoSpotLightDragger#planeProj. = new SbPlaneProjectorcxx . . $ SbPlaneProjector#(); |
| 173 | |
| 174 | addStartCallbackcxx . . $ SoDragger#addStartCallback(5d3f11b67c4aec04).( &SoSpotLightDraggercxx . . $ SoSpotLightDragger#::startCBcxx . . $ SoSpotLightDragger#startCB(7027446dc0b7318f). ); |
| 175 | addMotionCallbackcxx . . $ SoDragger#addMotionCallback(5d3f11b67c4aec04).( &SoSpotLightDraggercxx . . $ SoSpotLightDragger#::motionCBcxx . . $ SoSpotLightDragger#motionCB(7027446dc0b7318f). ); |
| 176 | addFinishCallbackcxx . . $ SoDragger#addFinishCallback(5d3f11b67c4aec04).( &SoSpotLightDraggercxx . . $ SoSpotLightDragger#::doneCBcxx . . $ SoSpotLightDragger#doneCB(7027446dc0b7318f). ); |
| 177 | |
| 178 | // Update the rotation and scale fields when the motionMatrix is set. |
| 179 | addValueChangedCallbackcxx . . $ SoDragger#addValueChangedCallback(5d3f11b67c4aec04).( &SoSpotLightDraggercxx . . $ SoSpotLightDragger#::valueChangedCBcxx . . $ SoSpotLightDragger#valueChangedCB(7027446dc0b7318f). ); |
| 180 | |
| 181 | // Updates the motionMatrix when the scaleFactor field is set. |
| 182 | rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor. |
| 183 | = new SoFieldSensorcxx . . $ SoFieldSensor#(&SoSpotLightDraggercxx . . $ SoSpotLightDragger#::fieldSensorCBcxx . . $ SoSpotLightDragger#fieldSensorCB(c8d298b3e215c027)., this); |
| 184 | rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.->setPrioritycxx . . $ SoDelayQueueSensor#setPriority(cb2f890c2fdad230).( 0 ); |
| 185 | |
| 186 | // Updates the motionMatrix when the translationFactor field is set. |
| 187 | translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor. |
| 188 | = new SoFieldSensorcxx . . $ SoFieldSensor#( &SoSpotLightDraggercxx . . $ SoSpotLightDragger#::fieldSensorCBcxx . . $ SoSpotLightDragger#fieldSensorCB(c8d298b3e215c027)., this); |
| 189 | translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.->setPrioritycxx . . $ SoDelayQueueSensor#setPriority(cb2f890c2fdad230).( 0 ); |
| 190 | |
| 191 | // Updates the motionMatrix when the scaleFactor field is set. |
| 192 | angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor. |
| 193 | = new SoFieldSensorcxx . . $ SoFieldSensor#( &SoSpotLightDraggercxx . . $ SoSpotLightDragger#::fieldSensorCBcxx . . $ SoSpotLightDragger#fieldSensorCB(c8d298b3e215c027)., this); |
| 194 | angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->setPrioritycxx . . $ SoDelayQueueSensor#setPriority(cb2f890c2fdad230).( 0 ); |
| 195 | |
| 196 | setUpConnectionscxx . . $ SoSpotLightDragger#setUpConnections(9b79fb6aee4c0440).( TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`! ); |
| 197 | } |
| 198 | |
| 199 | //////////////////////////////////////////////////////////////////////// |
| 200 | // |
| 201 | // Description: |
| 202 | // Destructor |
| 203 | // |
| 204 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::~cxx . . $ SoSpotLightDragger#`~SoSpotLightDragger`(49f6e7a06ebc5aa8).SoSpotLightDraggercxx . . $ SoSpotLightDragger#() |
| 205 | // |
| 206 | //////////////////////////////////////////////////////////////////////// |
| 207 | { |
| 208 | delete planeProjcxx . . $ SoSpotLightDragger#planeProj.; |
| 209 | if (rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor. ) |
| 210 | delete rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.; |
| 211 | if (translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor. ) |
| 212 | delete translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.; |
| 213 | if (angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor. ) |
| 214 | delete angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.; |
| 215 | } |
| 216 | |
| 217 | // detach/attach any sensors, callbacks, and/or field connections. |
| 218 | // Called by: start/end of SoBaseKit::readInstance |
| 219 | // and on new copy by: start/end of SoBaseKit::copy. |
| 220 | // Classes that redefine must call setUpConnections(TRUE,TRUE) |
| 221 | // at end of constructor. |
| 222 | // Returns the state of the node when this was called. |
| 223 | SbBoolcxx . . $ SbBool# |
| 224 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::setUpConnectionscxx . . $ SoSpotLightDragger#setUpConnections(9b79fb6aee4c0440).( SbBoolcxx . . $ SbBool# onOff, SbBoolcxx . . $ SbBool# doItAlways ) |
| 225 | { |
| 226 | if ( !doItAlways && connectionsSetUpcxx . . $ SoBaseKit#connectionsSetUp. == onOff) |
| 227 | return onOff; |
| 228 | |
| 229 | if ( onOff ) { |
| 230 | |
| 231 | // We connect AFTER base class. |
| 232 | SoDraggercxx . . $ SoDragger#::setUpConnectionscxx . . $ SoInteractionKit#setUpConnections(9b79fb6aee4c0440).( onOff, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 233 | |
| 234 | // Set default parts and add callbacks to child draggers. |
| 235 | SoDraggercxx . . $ SoDragger# *trD = (SoDraggercxx . . $ SoDragger# *) getAnyPartcxx . . $ SoInteractionKit#getAnyPart(e7d7a7aae96def2f).( "translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 236 | if (trD != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 237 | |
| 238 | // Set up the parts in the child dragger |
| 239 | SoNodecxx . . $ SoNode# *n; |
| 240 | n = SoNodecxx . . $ SoNode#::getByNamecxx . . $ SoNode#getByName(bf62e009e5fb797f).("spotLightTranslatorLineTranslator"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 241 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("xTranslator.translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 242 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("yTranslator.translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 243 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("zTranslator.translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 244 | |
| 245 | n = SoNodecxx . . $ SoNode#::getByNamecxx . . $ SoNode#getByName(bf62e009e5fb797f).( |
| 246 | "spotLightTranslatorLineTranslatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 247 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("xTranslator.translatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 248 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("yTranslator.translatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 249 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("zTranslator.translatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 250 | |
| 251 | n = SoNodecxx . . $ SoNode#::getByNamecxx . . $ SoNode#getByName(bf62e009e5fb797f).("spotLightTranslatorPlaneTranslator"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 252 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("yzTranslator.translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 253 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("xzTranslator.translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 254 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("xyTranslator.translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 255 | |
| 256 | n = SoNodecxx . . $ SoNode#::getByNamecxx . . $ SoNode#getByName(bf62e009e5fb797f).( |
| 257 | "spotLightTranslatorPlaneTranslatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 258 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("yzTranslator.translatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 259 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("xzTranslator.translatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 260 | trD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(9a61422242ad1ac7).("xyTranslator.translatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., n ); |
| 261 | |
| 262 | registerChildDraggercxx . . $ SoDragger#registerChildDragger(d47e389994d178b5).( trD ); |
| 263 | } |
| 264 | |
| 265 | SoRotateSphericalDraggercxx . . $ SoRotateSphericalDragger# *roD |
| 266 | = (SoRotateSphericalDraggercxx . . $ SoRotateSphericalDragger# *) getAnyPartcxx . . $ SoInteractionKit#getAnyPart(e7d7a7aae96def2f).( "rotator"cxx . . $ SbName#SbName(85c52e162fed56f9)., FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 267 | if (roD != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 268 | |
| 269 | // Give it a projector that moves freely in the radial direction. |
| 270 | // We need this because our geometry is just a little stick, not a |
| 271 | // big ol' ball |
| 272 | SbSphereSectionProjectorcxx . . $ SbSphereSectionProjector# *ssp = new SbSphereSectionProjectorcxx . . $ SbSphereSectionProjector#(); |
| 273 | ssp->setRadialFactorcxx . . $ SbSphereSectionProjector#setRadialFactor(9364e6e7bff7660).( 1.0 ); |
| 274 | roD->setProjectorcxx . . $ SoRotateSphericalDragger#setProjector(f3c84063bf68151a).(ssp); |
| 275 | |
| 276 | // Set up the parts in the child dragger |
| 277 | roD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("rotator"cxx . . $ SbName#SbName(85c52e162fed56f9)., |
| 278 | "spotLightRotatorRotator"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 279 | roD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("rotatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., |
| 280 | "spotLightRotatorRotatorActive"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 281 | roD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("feedback"cxx . . $ SbName#SbName(85c52e162fed56f9)., |
| 282 | "spotLightRotatorFeedback"cxx . . $ SbName#SbName(85c52e162fed56f9). ); |
| 283 | roD->setPartAsDefaultcxx . . $ SoInteractionKit#setPartAsDefault(91c97549ed5f0a6b).("feedbackActive"cxx . . $ SbName#SbName(85c52e162fed56f9)., |
| 284 | "spotLightRotatorFeedbackActive"cxx . . $ SbName#SbName(85c52e162fed56f9).); |
| 285 | |
| 286 | registerChildDraggercxx . . $ SoDragger#registerChildDragger(d47e389994d178b5).( roD ); |
| 287 | |
| 288 | } |
| 289 | |
| 290 | // Call the sensor CBs to make things are up-to-date. |
| 291 | fieldSensorCBcxx . . $ SoSpotLightDragger#fieldSensorCB(c8d298b3e215c027).( this, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ); |
| 292 | |
| 293 | // Connect the field sensors |
| 294 | if (rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).() != &rotationcxx . . $ SoSpotLightDragger#rotation.) |
| 295 | rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &rotationcxx . . $ SoSpotLightDragger#rotation. ); |
| 296 | if (translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).() != &translationcxx . . $ SoSpotLightDragger#translation.) |
| 297 | translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &translationcxx . . $ SoSpotLightDragger#translation. ); |
| 298 | if (angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).() != &anglecxx . . $ SoSpotLightDragger#angle.) |
| 299 | angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &anglecxx . . $ SoSpotLightDragger#angle. ); |
| 300 | } |
| 301 | else { |
| 302 | |
| 303 | // We disconnect BEFORE base class. |
| 304 | |
| 305 | // remove callbacks from the child draggers |
| 306 | SoDraggercxx . . $ SoDragger# *trD = (SoDraggercxx . . $ SoDragger# *) getAnyPartcxx . . $ SoInteractionKit#getAnyPart(e7d7a7aae96def2f).( "translator"cxx . . $ SbName#SbName(85c52e162fed56f9)., FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 307 | if (trD) |
| 308 | unregisterChildDraggercxx . . $ SoDragger#unregisterChildDragger(d47e389994d178b5).( trD ); |
| 309 | |
| 310 | SoDraggercxx . . $ SoDragger# *roD = (SoDraggercxx . . $ SoDragger# *) getAnyPartcxx . . $ SoInteractionKit#getAnyPart(e7d7a7aae96def2f).( "rotator"cxx . . $ SbName#SbName(85c52e162fed56f9)., FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 311 | if (roD) |
| 312 | unregisterChildDraggercxx . . $ SoDragger#unregisterChildDragger(d47e389994d178b5).( roD ); |
| 313 | |
| 314 | // Disconnect the field sensors. |
| 315 | if (rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).()) |
| 316 | rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 317 | if (translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).()) |
| 318 | translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 319 | if (angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->getAttachedFieldcxx . . $ SoFieldSensor#getAttachedField(c4a4d937024b6702).()) |
| 320 | angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 321 | |
| 322 | SoDraggercxx . . $ SoDragger#::setUpConnectionscxx . . $ SoInteractionKit#setUpConnections(9b79fb6aee4c0440).( onOff, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ); |
| 323 | } |
| 324 | |
| 325 | return !(connectionsSetUpcxx . . $ SoBaseKit#connectionsSetUp. = onOff); |
| 326 | } |
| 327 | |
| 328 | //////////////////////////////////////////////////////////////////////// |
| 329 | // |
| 330 | // Description: |
| 331 | // Calculates the fields of the beamScale, based on |
| 332 | // a beam spread angle. |
| 333 | // |
| 334 | // At the angle of 45 degrees, the scale is (1,1,1) |
| 335 | // A greater beam angle increases the scale in x and y equally, |
| 336 | // while decreasing the angle in z. |
| 337 | // A smaller beam angle decreases the scale in x and y equally, |
| 338 | // while increasing the angle in z. |
| 339 | // |
| 340 | // The equation for the relationship is: |
| 341 | // xScale = yScale = sin( beamAngle ); |
| 342 | // zScale = cos( beamAngle ); |
| 343 | // |
| 344 | // Angles are clamped to lie between 0 and 90 degrees. |
| 345 | // |
| 346 | // Use: protected |
| 347 | // |
| 348 | void |
| 349 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::setBeamScaleFromAnglecxx . . $ SoSpotLightDragger#setBeamScaleFromAngle(9364e6e7bff7660).( float beamAngle ) |
| 350 | // |
| 351 | //////////////////////////////////////////////////////////////////////// |
| 352 | { |
| 353 | float myNewAngle = beamAngle; |
| 354 | // This dragger clamps angle values to lie between 0 and PI/2 radians. |
| 355 | // But we will be more restrictive when we display, so that users |
| 356 | // can always (hopefully) hit the beam geometry. |
| 357 | #define TWO_AND_A_HALF_DEGREEScxx . . $ `lib/interaction/src/draggers/SoSpotLightDragger.c++:357:9`! 0.043633 |
| 358 | if ( beamAngle < TWO_AND_A_HALF_DEGREEScxx . . $ `lib/interaction/src/draggers/SoSpotLightDragger.c++:357:9`! ) |
| 359 | myNewAngle = TWO_AND_A_HALF_DEGREEScxx . . $ `lib/interaction/src/draggers/SoSpotLightDragger.c++:357:9`!; |
| 360 | #undef TWO_AND_A_HALF_DEGREEScxx . . $ `lib/interaction/src/draggers/SoSpotLightDragger.c++:357:9`! |
| 361 | if ( beamAngle > (M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / 2.0) ) |
| 362 | myNewAngle = (M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / 2.0); |
| 363 | |
| 364 | float myCos = cosf(myNewAngle); |
| 365 | float mySin = sinf(myNewAngle); |
| 366 | |
| 367 | if (myCos < getMinScalecxx . . $ SoDragger#getMinScale(9b8c9e39889c762c).()) |
| 368 | myCos = getMinScalecxx . . $ SoDragger#getMinScale(9b8c9e39889c762c).(); |
| 369 | |
| 370 | if (mySin < getMinScalecxx . . $ SoDragger#getMinScale(9b8c9e39889c762c).()) |
| 371 | mySin = getMinScalecxx . . $ SoDragger#getMinScale(9b8c9e39889c762c).(); |
| 372 | |
| 373 | SoScalecxx . . $ SoScale# *bs = (SoScalecxx . . $ SoScale# *) getAnyPartcxx . . $ SoInteractionKit#getAnyPart(e7d7a7aae96def2f).("beamScale"cxx . . $ SbName#SbName(85c52e162fed56f9).,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 374 | if (bs) { |
| 375 | SbVec3fcxx . . $ SbVec3f# newSFcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(mySin, mySin, myCos); |
| 376 | if ( bs->scaleFactorcxx . . $ SoScale#scaleFactor..getValuecxx . . $ SoSFVec3f#getValue(b5c384c15c94bb12).() !=cxx . . $ `operator!=`(648f52454fd9f27). newSF ) |
| 377 | bs->scaleFactorcxx . . $ SoScale#scaleFactor..setValuecxx . . $ SoSFVec3f#setValue(65a601b9d70571d6).( newSF ); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | //////////////////////////////////////////////////////////////////////// |
| 382 | // |
| 383 | // Description: |
| 384 | // Prepare for dragging the beam spreading piece. |
| 385 | // |
| 386 | // Use: private |
| 387 | // |
| 388 | void |
| 389 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::dragStartcxx . . $ SoSpotLightDragger#dragStart(49f6e7a06ebc5aa8).() |
| 390 | // |
| 391 | //////////////////////////////////////////////////////////////////////// |
| 392 | { |
| 393 | // We only perform dragging if we received the mouse-down. |
| 394 | // If there is an active child dragger, then we should just return. |
| 395 | if ( getActiveChildDraggercxx . . $ SoDragger#getActiveChildDragger(3997a91e8a2bc46d).() != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 396 | return; |
| 397 | |
| 398 | // Set the switch to 1... |
| 399 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( beamSwitchcxx . . $ SoSpotLightDragger#beamSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 1 ); |
| 400 | |
| 401 | // Establish the working space. |
| 402 | // Working space is space at end of "beamPlacement", (but before |
| 403 | // "beamScale"). |
| 404 | SbMatrixcxx . . $ SbMatrix# workSpaceToLocalcxx . . $ SbMatrix#SbMatrix(49f6e7a06ebc5aa8)., localToWorkSpacecxx . . $ SbMatrix#SbMatrix(49f6e7a06ebc5aa8).; |
| 405 | getPartToLocalMatrixcxx . . $ SoDragger#getPartToLocalMatrix(311231c517bf1a8f).("beamPlacement"cxx . . $ SbName#SbName(85c52e162fed56f9).,workSpaceToLocal,localToWorkSpace); |
| 406 | SbMatrixcxx . . $ SbMatrix# worldSpaceToWork = getWorldToLocalMatrixcxx . . $ SoDragger#getWorldToLocalMatrix(2db31fc6bbb60646).(); |
| 407 | worldSpaceToWork.multRightcxx . . $ SbMatrix#multRight(5bda0b2cfca989a9).( localToWorkSpace ); |
| 408 | |
| 409 | // Establish the projector plane in working space. |
| 410 | // The plane is defined by two points on the z axis and the selected point. |
| 411 | // If they are colinear or nearly so, then make the plane face the viewer. |
| 412 | SbVec3fcxx . . $ SbVec3f# p0cxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,0), p1cxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,1); |
| 413 | |
| 414 | SbVec3fcxx . . $ SbVec3f# startWorkSpaceHitPtcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 415 | worldSpaceToWork.multVecMatrixcxx . . $ SbMatrix#multVecMatrix(f4e74898890c8c54).(getWorldStartingPointcxx . . $ SoDragger#getWorldStartingPoint(42d43ea8522fe3bf).(), |
| 416 | startWorkSpaceHitPt); |
| 417 | SbVec3fcxx . . $ SbVec3f# p2 = startWorkSpaceHitPt; |
| 418 | p2.normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 419 | #define MAX_WORKABLE_ANGLE_COScxx . . $ `lib/interaction/src/draggers/SoSpotLightDragger.c++:419:9`! .98 |
| 420 | if (((p2 -cxx . . $ operator-(af63bf8d0639b76b). p0).dotcxx . . $ SbVec3f#dot(adcfb95606509c95).(p1 -cxx . . $ operator-(af63bf8d0639b76b). p0)) > MAX_WORKABLE_ANGLE_COScxx . . $ `lib/interaction/src/draggers/SoSpotLightDragger.c++:419:9`!) { |
| 421 | // Find a new p2. |
| 422 | SbVec3fcxx . . $ SbVec3f# worldProjDir = getViewVolumecxx . . $ SoDragger#getViewVolume(ee52a61c9e3934e6).().getProjectionDirectioncxx . . $ SbViewVolume#getProjectionDirection(b5c384c15c94bb12).(); |
| 423 | SbVec3fcxx . . $ SbVec3f# lclProjDircxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 424 | worldSpaceToWork.multDirMatrixcxx . . $ SbMatrix#multDirMatrix(f4e74898890c8c54).(worldProjDir,lclProjDir); |
| 425 | lclProjDir.normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 426 | lclProjDir *=cxx . . $ SbVec3f#`operator*=`(3aaca777b5795e29). -1.0; |
| 427 | SbVec3fcxx . . $ SbVec3f# otherVecInPlane = lclProjDir.crosscxx . . $ SbVec3f#cross(d67ad7d0c0b29ebb).( p1 -cxx . . $ operator-(af63bf8d0639b76b). p0 ); |
| 428 | p2 =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). (otherVecInPlane -cxx . . $ operator-(af63bf8d0639b76b). p0); |
| 429 | } |
| 430 | #undef MAX_WORKABLE_ANGLE_COScxx . . $ `lib/interaction/src/draggers/SoSpotLightDragger.c++:419:9`! |
| 431 | |
| 432 | SbPlanecxx . . $ SbPlane# wsPlanecxx . . $ SbPlane#SbPlane(aaa4bb24159b7e44).(p0, p1, p2); |
| 433 | |
| 434 | planeProjcxx . . $ SoSpotLightDragger#planeProj.->setPlanecxx . . $ SbPlaneProjector#setPlane(b57880e1f0abeb65).( wsPlane ); |
| 435 | } |
| 436 | |
| 437 | //////////////////////////////////////////////////////////////////////// |
| 438 | // |
| 439 | // Description: |
| 440 | // Set the beam angle based on the new hit to the planeProj |
| 441 | // |
| 442 | // Use: private |
| 443 | // |
| 444 | void |
| 445 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::dragcxx . . $ SoSpotLightDragger#drag(49f6e7a06ebc5aa8).() |
| 446 | // |
| 447 | //////////////////////////////////////////////////////////////////////// |
| 448 | { |
| 449 | // We only perform dragging if we received the mouse-down. |
| 450 | // If there is an active child dragger, then we should just return. |
| 451 | if ( getActiveChildDraggercxx . . $ SoDragger#getActiveChildDragger(3997a91e8a2bc46d).() != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 452 | return; |
| 453 | |
| 454 | // Establish the working space. |
| 455 | // Working space is space at end of "beamPlacement", (but before |
| 456 | // "beamScale"). |
| 457 | SbMatrixcxx . . $ SbMatrix# workSpaceToLocalcxx . . $ SbMatrix#SbMatrix(49f6e7a06ebc5aa8)., localToWorkSpacecxx . . $ SbMatrix#SbMatrix(49f6e7a06ebc5aa8).; |
| 458 | getPartToLocalMatrixcxx . . $ SoDragger#getPartToLocalMatrix(311231c517bf1a8f).("beamPlacement"cxx . . $ SbName#SbName(85c52e162fed56f9).,workSpaceToLocal,localToWorkSpace); |
| 459 | SbMatrixcxx . . $ SbMatrix# workSpaceToWorld = getLocalToWorldMatrixcxx . . $ SoDragger#getLocalToWorldMatrix(2db31fc6bbb60646).(); |
| 460 | workSpaceToWorld.multLeftcxx . . $ SbMatrix#multLeft(5bda0b2cfca989a9).( workSpaceToLocal ); |
| 461 | SbMatrixcxx . . $ SbMatrix# worldSpaceToWork = getWorldToLocalMatrixcxx . . $ SoDragger#getWorldToLocalMatrix(2db31fc6bbb60646).(); |
| 462 | worldSpaceToWork.multRightcxx . . $ SbMatrix#multRight(5bda0b2cfca989a9).( localToWorkSpace ); |
| 463 | |
| 464 | // Set the projector space and viewVolume. |
| 465 | planeProjcxx . . $ SoSpotLightDragger#planeProj.->setViewVolumecxx . . $ SbProjector#setViewVolume(187982bfa537c808).( getViewVolumecxx . . $ SoDragger#getViewVolume(ee52a61c9e3934e6).() ); |
| 466 | planeProjcxx . . $ SoSpotLightDragger#planeProj.->setWorkingSpacecxx . . $ SbProjector#setWorkingSpace(37d2f951b3ffd7a6).( workSpaceToWorld ); |
| 467 | |
| 468 | // Get newHitPt and startHitPt in workspace. |
| 469 | SbVec3fcxx . . $ SbVec3f# newHitPt |
| 470 | = planeProjcxx . . $ SoSpotLightDragger#planeProj.->projectcxx . . $ SbPlaneProjector#project(52e93d88cc4c3965).( getNormalizedLocaterPositioncxx . . $ SoDragger#getNormalizedLocaterPosition(e67d94fc922bbbd4).()); |
| 471 | SbVec3fcxx . . $ SbVec3f# startHitPtcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 472 | worldSpaceToWork.multVecMatrixcxx . . $ SbMatrix#multVecMatrix(f4e74898890c8c54).( getWorldStartingPointcxx . . $ SoDragger#getWorldStartingPoint(42d43ea8522fe3bf).(), startHitPt ); |
| 473 | |
| 474 | // Based on the position, determine the new beamAngle. |
| 475 | // Theta will be the angle between the minus z axis and the |
| 476 | // vector from (0,0,0) to newHitPt. |
| 477 | |
| 478 | // Normalize these and they become directions from (0,0,0) to hit points |
| 479 | newHitPt.normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 480 | startHitPt.normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 481 | // We also need this direction: |
| 482 | SbVec3fcxx . . $ SbVec3f# minusZcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,-1); |
| 483 | |
| 484 | // If we've gone 'out of bounds' let's figure out what to do... |
| 485 | // If newHitPt was in positive z, the angle will be > (PI/2) |
| 486 | SbBoolcxx . . $ SbBool# isPosZ = ( newHitPt[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).2] > 0.0 ); |
| 487 | |
| 488 | // If newHitPt and startHitPt are on opposite sides of the |
| 489 | // z axis within the projector plane, we've completely closed |
| 490 | // the 'umbrella' and gone to the other side, so we'll want to |
| 491 | // clamp the value at 0.0 |
| 492 | SbVec3fcxx . . $ SbVec3f# newCross = newHitPt.crosscxx . . $ SbVec3f#cross(d67ad7d0c0b29ebb).(minusZ); |
| 493 | SbVec3fcxx . . $ SbVec3f# startCross = startHitPt.crosscxx . . $ SbVec3f#cross(d67ad7d0c0b29ebb).(minusZ); |
| 494 | |
| 495 | SbBoolcxx . . $ SbBool# isNewOppositeStart = ( newCross.dotcxx . . $ SbVec3f#dot(adcfb95606509c95).(startCross) < 0.0 ); |
| 496 | |
| 497 | // Find theta |
| 498 | // Do different things depending on if we've gone out of bounds. |
| 499 | float curAngle = anglecxx . . $ SoSpotLightDragger#angle..getValuecxx . . $ SoSFFloat#getValue(5036dfe8d4170af2).(); |
| 500 | float theta; |
| 501 | |
| 502 | // If both conditions are violated, use the value closer to |
| 503 | // the current angle. |
| 504 | if ( isPosZ && isNewOppositeStart ) { |
| 505 | if ( fabs(curAngle - 0.0) < fabs((M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!/2.0) - curAngle) ) |
| 506 | theta = 0.0; |
| 507 | else |
| 508 | theta = M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / 2.0; |
| 509 | } |
| 510 | else if ( isPosZ ) { |
| 511 | theta = M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / 2.0; |
| 512 | } |
| 513 | else if ( isNewOppositeStart ) { |
| 514 | theta = 0.0; |
| 515 | } |
| 516 | else { |
| 517 | // we should be able to go unconstrained. |
| 518 | // Find angle between minusZ vector and newHitPt |
| 519 | |
| 520 | // Dot product of unit vectors is cosine of angle between them. |
| 521 | float thetaCos = minusZ.dotcxx . . $ SbVec3f#dot(adcfb95606509c95).( newHitPt ); |
| 522 | theta = acosf( thetaCos ); |
| 523 | |
| 524 | // clamp theta to lie between 0 and PI/2 |
| 525 | theta = (theta < 0.0) ? 0.0 : theta; |
| 526 | theta = (theta > (M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / 2.0)) ? (M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! / 2.0) : theta; |
| 527 | } |
| 528 | |
| 529 | // Now we've got a new angle. Set the beamScale appropriately, |
| 530 | // set the angle field, and call the special angle callbacks. |
| 531 | |
| 532 | setBeamScaleFromAnglecxx . . $ SoSpotLightDragger#setBeamScaleFromAngle(9364e6e7bff7660).(theta); |
| 533 | |
| 534 | angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); // Disconnect sensor |
| 535 | if ( curAngle != theta ) // Set field |
| 536 | anglecxx . . $ SoSpotLightDragger#angle. =cxx . . $ SoSFFloat#`operator=`(fbcf3211dfe1bfd1). theta; |
| 537 | angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &anglecxx . . $ SoSpotLightDragger#angle. ); // Reconnect sensor |
| 538 | |
| 539 | // Invoke the value changed callbacks. |
| 540 | // We must specifically do this since only calling setMotionMatrix() |
| 541 | // does it automatically. |
| 542 | valueChangedcxx . . $ SoDragger#valueChanged(49f6e7a06ebc5aa8).(); |
| 543 | } |
| 544 | |
| 545 | //////////////////////////////////////////////////////////////////////// |
| 546 | // |
| 547 | // Description: |
| 548 | // Rotate the spoLightDragger based on mouse motion. |
| 549 | // |
| 550 | // Use: private |
| 551 | // |
| 552 | void |
| 553 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::dragFinishcxx . . $ SoSpotLightDragger#dragFinish(49f6e7a06ebc5aa8).() |
| 554 | // |
| 555 | //////////////////////////////////////////////////////////////////////// |
| 556 | { |
| 557 | // We only perform dragging if we received the mouse-down. |
| 558 | // If there is an active child dragger, then we should just return. |
| 559 | if ( getActiveChildDraggercxx . . $ SoDragger#getActiveChildDragger(3997a91e8a2bc46d).() != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 560 | return; |
| 561 | |
| 562 | // Set the switches to 0... |
| 563 | setSwitchValuecxx . . $ SoInteractionKit#setSwitchValue(de18c6a3dadfdca6).( beamSwitchcxx . . $ SoSpotLightDragger#beamSwitch..getValuecxx . . $ SoSFNode#getValue(b794963b450d51b3).(), 0 ); |
| 564 | } |
| 565 | |
| 566 | //////////////////////////////////////////////////////////////////// |
| 567 | // Stubs for callbacks |
| 568 | //////////////////////////////////////////////////////////////////// |
| 569 | void |
| 570 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::startCBcxx . . $ SoSpotLightDragger#startCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 571 | { |
| 572 | SoSpotLightDraggercxx . . $ SoSpotLightDragger# *dl = (SoSpotLightDraggercxx . . $ SoSpotLightDragger# *) inDragger; |
| 573 | dl->dragStartcxx . . $ SoSpotLightDragger#dragStart(49f6e7a06ebc5aa8).(); |
| 574 | } |
| 575 | |
| 576 | void |
| 577 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::motionCBcxx . . $ SoSpotLightDragger#motionCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 578 | { |
| 579 | SoSpotLightDraggercxx . . $ SoSpotLightDragger# *dl = (SoSpotLightDraggercxx . . $ SoSpotLightDragger# *) inDragger; |
| 580 | dl->dragcxx . . $ SoSpotLightDragger#drag(49f6e7a06ebc5aa8).(); |
| 581 | } |
| 582 | |
| 583 | void |
| 584 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::doneCBcxx . . $ SoSpotLightDragger#doneCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 585 | { |
| 586 | SoSpotLightDraggercxx . . $ SoSpotLightDragger# *dl = (SoSpotLightDraggercxx . . $ SoSpotLightDragger# *) inDragger; |
| 587 | dl->dragFinishcxx . . $ SoSpotLightDragger#dragFinish(49f6e7a06ebc5aa8).(); |
| 588 | } |
| 589 | |
| 590 | |
| 591 | void |
| 592 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::valueChangedCBcxx . . $ SoSpotLightDragger#valueChangedCB(7027446dc0b7318f).( void *, SoDraggercxx . . $ SoDragger# *inDragger ) |
| 593 | { |
| 594 | SoSpotLightDraggercxx . . $ SoSpotLightDragger# *m = (SoSpotLightDraggercxx . . $ SoSpotLightDragger# *) inDragger; |
| 595 | SbMatrixcxx . . $ SbMatrix# motMat = m->getMotionMatrixcxx . . $ SoDragger#getMotionMatrix(c49c36ee78b0a89e).(); |
| 596 | |
| 597 | SbVec3fcxx . . $ SbVec3f# transcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8)., scalecxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 598 | SbRotationcxx . . $ SbRotation# rotcxx . . $ SbRotation#SbRotation(49f6e7a06ebc5aa8)., scaleOrientcxx . . $ SbRotation#SbRotation(49f6e7a06ebc5aa8).; |
| 599 | motMat.getTransformcxx . . $ SbMatrix#getTransform(3b351a08677bdc76).( trans, rot, scale, scaleOrient ); |
| 600 | |
| 601 | // Disconnect the field sensors |
| 602 | m->rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 603 | m->translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 604 | m->angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->detachcxx . . $ SoFieldSensor#detach(49f6e7a06ebc5aa8).(); |
| 605 | |
| 606 | if ( m->rotationcxx . . $ SoSpotLightDragger#rotation..getValuecxx . . $ SoSFRotation#getValue(cd68af149be99fa7).() !=cxx . . $ `operator!=`(63a2304dedfd8e48). rot ) |
| 607 | m->rotationcxx . . $ SoSpotLightDragger#rotation. =cxx . . $ SoSFRotation#`operator=`(a110af7e76887ee8). rot; |
| 608 | if ( m->translationcxx . . $ SoSpotLightDragger#translation..getValuecxx . . $ SoSFVec3f#getValue(b5c384c15c94bb12).() !=cxx . . $ `operator!=`(648f52454fd9f27). trans ) |
| 609 | m->translationcxx . . $ SoSpotLightDragger#translation. =cxx . . $ SoSFVec3f#`operator=`(861f7885f8980b32). trans; |
| 610 | |
| 611 | // Make the rotation inside the "translaterRotInv" be the inverse |
| 612 | // of the new rotation. |
| 613 | SbRotationcxx . . $ SbRotation# newInv = rot.inversecxx . . $ SbRotation#inverse(ab9eafb24c82872e).(); |
| 614 | SoRotationcxx . . $ SoRotation# *rotInv = (SoRotationcxx . . $ SoRotation# *) m->getAnyPartcxx . . $ SoInteractionKit#getAnyPart(e7d7a7aae96def2f).("translatorRotInv"cxx . . $ SbName#SbName(85c52e162fed56f9).,TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 615 | if (rotInv->rotationcxx . . $ SoRotation#rotation..getValuecxx . . $ SoSFRotation#getValue(cd68af149be99fa7).() !=cxx . . $ `operator!=`(63a2304dedfd8e48). newInv) |
| 616 | rotInv->rotationcxx . . $ SoRotation#rotation. =cxx . . $ SoSFRotation#`operator=`(a110af7e76887ee8). newInv; |
| 617 | |
| 618 | // Note: we do not need to do anything special for 'angle.' |
| 619 | // When the dragging routine changes the angle, it sets both |
| 620 | // the angle field and the internal tranform for us. |
| 621 | |
| 622 | // Reconnect the field sensors |
| 623 | m->rotFieldSensorcxx . . $ SoSpotLightDragger#rotFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &(m->rotationcxx . . $ SoSpotLightDragger#rotation.) ); |
| 624 | m->translFieldSensorcxx . . $ SoSpotLightDragger#translFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &(m->translationcxx . . $ SoSpotLightDragger#translation.) ); |
| 625 | m->angleFieldSensorcxx . . $ SoSpotLightDragger#angleFieldSensor.->attachcxx . . $ SoFieldSensor#attach(6a35cc9f7090653f).( &(m->anglecxx . . $ SoSpotLightDragger#angle.) ); |
| 626 | } |
| 627 | |
| 628 | void |
| 629 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::fieldSensorCBcxx . . $ SoSpotLightDragger#fieldSensorCB(c8d298b3e215c027).(void *inDragger, SoSensorcxx . . $ SoSensor# *inSensor ) |
| 630 | { |
| 631 | SoSpotLightDraggercxx . . $ SoSpotLightDragger# *dragger = (SoSpotLightDraggercxx . . $ SoSpotLightDragger# *) inDragger; |
| 632 | |
| 633 | SoFieldcxx . . $ SoField# *trigF = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 634 | if ( inSensor ) |
| 635 | trigF = ((SoDataSensorcxx . . $ SoDataSensor# *)inSensor)->getTriggerFieldcxx . . $ SoDataSensor#getTriggerField(c4a4d937024b6702).(); |
| 636 | |
| 637 | // If inSensor is NULL or the trigger field is NULL, we |
| 638 | // will do both the matrix and beam stuff, since we don't know what changed. |
| 639 | SbBoolcxx . . $ SbBool# doMatrix = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 640 | SbBoolcxx . . $ SbBool# doBeam = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 641 | |
| 642 | // But if this is invoked by a sensor with a trigger field, |
| 643 | // we can do different things if it was the angle |
| 644 | // or the rotation/translation fields that triggered. |
| 645 | if ( trigF ) { |
| 646 | |
| 647 | if ( trigF == &dragger->rotationcxx . . $ SoSpotLightDragger#rotation. || trigF == &dragger->translationcxx . . $ SoSpotLightDragger#translation. ) |
| 648 | doBeam = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 649 | |
| 650 | if ( trigF == &dragger->anglecxx . . $ SoSpotLightDragger#angle. ) |
| 651 | doMatrix = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 652 | } |
| 653 | |
| 654 | // Save the cut off angle, since it can get screwed up when the |
| 655 | // matrix on the dragger is set: |
| 656 | float myCutOff = dragger->anglecxx . . $ SoSpotLightDragger#angle..getValuecxx . . $ SoSFFloat#getValue(5036dfe8d4170af2).(); |
| 657 | |
| 658 | if ( doMatrix ) { |
| 659 | |
| 660 | SbMatrixcxx . . $ SbMatrix# motMat = dragger->getMotionMatrixcxx . . $ SoDragger#getMotionMatrix(c49c36ee78b0a89e).(); |
| 661 | dragger->workFieldsIntoTransformcxx . . $ SoDragger#workFieldsIntoTransform(ab60305a37435a6f).(motMat); |
| 662 | |
| 663 | dragger->setMotionMatrixcxx . . $ SoDragger#setMotionMatrix(37d2f951b3ffd7a6).(motMat); |
| 664 | } |
| 665 | |
| 666 | // Restore the cut off angle: |
| 667 | if (dragger->anglecxx . . $ SoSpotLightDragger#angle..getValuecxx . . $ SoSFFloat#getValue(5036dfe8d4170af2).() != myCutOff) |
| 668 | dragger->anglecxx . . $ SoSpotLightDragger#angle. =cxx . . $ SoSFFloat#`operator=`(fbcf3211dfe1bfd1). myCutOff; |
| 669 | |
| 670 | if ( doBeam ) { |
| 671 | |
| 672 | // This line is special work done for spotlights that is |
| 673 | // different from most other draggers. |
| 674 | dragger->setBeamScaleFromAnglecxx . . $ SoSpotLightDragger#setBeamScaleFromAngle(9364e6e7bff7660).( dragger->anglecxx . . $ SoSpotLightDragger#angle..getValuecxx . . $ SoSFFloat#getValue(5036dfe8d4170af2).() ); |
| 675 | |
| 676 | // We need to specifically tell the dragger to invoke the |
| 677 | // value changed callbacks, since only calling setMotionMatrix |
| 678 | // automatically does this. |
| 679 | if ( doMatrix == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ) |
| 680 | dragger->valueChangedcxx . . $ SoDragger#valueChanged(49f6e7a06ebc5aa8).(); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | void |
| 685 | SoSpotLightDraggercxx . . $ SoSpotLightDragger#::setDefaultOnNonWritingFieldscxx . . $ SoSpotLightDragger#setDefaultOnNonWritingFields(49f6e7a06ebc5aa8).() |
| 686 | { |
| 687 | // We don't write out angle if it has default value. |
| 688 | if ( ! (anglecxx . . $ SoSpotLightDragger#angle..isConnectedcxx . . $ SoField#isConnected(455f465bc33b4cdf).() && anglecxx . . $ SoSpotLightDragger#angle..isConnectionEnabledcxx . . $ SoField#isConnectionEnabled(455f465bc33b4cdf).()) |
| 689 | && anglecxx . . $ SoSpotLightDragger#angle..getValuecxx . . $ SoSFFloat#getValue(5036dfe8d4170af2).() == 1.0 ) |
| 690 | anglecxx . . $ SoSpotLightDragger#angle..setDefaultcxx . . $ SoField#setDefault(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 691 | |
| 692 | // These nodes may change after construction, but we still |
| 693 | // don't want to write them out. |
| 694 | translatorRotInvcxx . . $ SoSpotLightDragger#translatorRotInv..setDefaultcxx . . $ SoField#setDefault(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 695 | beamScalecxx . . $ SoSpotLightDragger#beamScale..setDefaultcxx . . $ SoField#setDefault(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 696 | |
| 697 | // Try not to write out the sub-draggers. |
| 698 | translatorcxx . . $ SoSpotLightDragger#translator..setDefaultcxx . . $ SoField#setDefault(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 699 | rotatorcxx . . $ SoSpotLightDragger#rotator..setDefaultcxx . . $ SoField#setDefault(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 700 | |
| 701 | // Call the base class... |
| 702 | SoDraggercxx . . $ SoDragger#::setDefaultOnNonWritingFieldscxx . . $ SoDragger#setDefaultOnNonWritingFields(49f6e7a06ebc5aa8).(); |
| 703 | } |