SpaceNavigator SE will not work in Maya 2009

Questions and answers about 3Dconnexion devices on macOS.

Moderator: Moderators

Post Reply
thennek
Posts: 6
Joined: Mon Jan 26, 2009 10:50 am

SpaceNavigator SE will not work in Maya 2009

Post by thennek »

I called Tech support twice and I still cannot get Maya to recognize the SE device. I originally ran Maya 2008 and the device worked fine. I then Uninstalled Maya 2008 and Installed 2009. When it did not work, I uninstalled the SE device and removed the old 2008 scripts folder. After re-installing the SE device as directed by tech support and reading the forums, I did the following:

1. I copied MagellanStartup.mel, C3DxMapping.mel, C3DxControlPanel.mel, C3DxButtonEditor.mel
from
Users/Shared/Autodesk/maya/scripts (which was created by a fresh SE driver install)
to
Users/Shared/Autodesk/maya/2009/scripts

2. I also copied 3DxCube_24x24,xpm, 3DxCube_26x26.xpm, 3DxCube_30x30.xpm, 3DxHelp_24x24.xpm, 3DxHelp_30x30.xpm, 3DxLogo_200x90.bmp

from
Users/Shared/Autodesk/maya/icons (which was created by a fresh SE driver install)
to
Users/Shared/Autodesk/maya/2009/icons

I followed this reasoning by reading this link:
viewtopic.php?t=2469

HOWEVER, the readme file that was sent to me by support says the following:

IMPORTANT:
----------

* Manual Installation
Copy the Melscripts to the "scripts\startup" sub-directory of Maya,
and the bitmap files to the Maya "icons" directory.
Copy 3DxMaya.mll to "bin\plug-ins"
Copy the 3DxHelp directory to "docs\ext"

BUT the only 3DxHelp files I could find have a .xpm extension, all the other files in the docs folder of Maya are .htm or .txt files so I am not quite sure if I manually put the 3DxHelp_24x24.xpm, 3DxHelp_30x30.xpm in the correct directory.

3. Lastly, I still get the following error:
// Error: Cannot find procedure "_3DxOnDeviceChanged". // when I try to enable this in the plugin folder of Maya. Please note that Google Earth works fine and I was also able to get the demo to work from the system preferences
flomotan
Moderator
Moderator
Posts: 287
Joined: Mon Jan 08, 2007 3:37 pm

Post by flomotan »

I would suggest doing a reinstall of the 3Dconnexion driver so that all the files are placed in their proper location.

Please try the following:
- Use the latest 3DxMacWare driver which is version 1.5.6

- Since you already have the driver installed, run the driver uninstall from /Applications/Utilities/Uninstall 3Dconnexion Driver.app

- The uninstall will not remove the maya plugin files as those were manually copied. Remove all of these files manually.

- Ensure there are no other 3Dconnexion maya scripts anywhere else on your machine.

- Install the driver. Once this completes, the following files should be installed for Maya:

In /Users/Shared/Autodesk/maya/scripts
C3DxButtonEditor.mel
C3DxControlPanel.mel
C3DxMapping.mel
MagellanStartup.mel
usersetup.mel

In /Users/Shared/Autodesk/maya/icons
3DxCube_*.xpm (3 files)
3DxHelp_*.xpm (2 files)
3DxLogo_200x90.bmp

In /Users/Shared/Autodesk/maya/2009/plug-ins
3DxMaya.bundle

These files should be present and the only ones on your machine. No duplicates of these files should be in any other folder.

- Start maya. Look at the MEL console window and monitor any errors.

- If you can't get movement from your 3d mouse, type 'MagellanStartup;' on your MEL script console

Please report any errors shown on the console
thennek
Posts: 6
Joined: Mon Jan 26, 2009 10:50 am

Post by thennek »

Forgive me if I do not understand, but I have two questions:

1.By MEL script console do you mean the Mel script editor?

2. When I look in the plug in manager the 3DxMaya.bundle is not loaded do I need to check the load & auto load boxes?
thennek
Posts: 6
Joined: Mon Jan 26, 2009 10:50 am

Post by thennek »

I follow your steps for installing the driver and when I move the mouse I get no movement but I get the following:


// Copyright (C) 2003 - 2007 3Dconnexion,
// a Logitech Company
//
// The information in this file is provided for the exclusive use of the
// licensees of 3Dconnexion Such users have the right to use, modify,
// and incorporate this code into other products for purposes authorized
// by the 3Dconnexion license agreement, without fee.
//
// 3DCONNEXION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
// EVENT SHALL 3DCONNEXION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
//
// 3Dconnexion wants to thank Konstantin Roggatz for his contribution to the original script
//
// MODIFY THIS SCRIPT AT YOUR OWN RISK
//
//
// Description:
// MagellanStartup()
// Start the Magellan support. Must be called at Startup of Maya.
// MagellanMoveModeToggle()
// Toggle between world, object and fly mode. Connected to UserButton1
// MagellanOptionWindowToggle()
// Toggle the option window on and off. Connected to userButton2
// MagellanCameraRotationModeToggle()
// Toggle between different rotation center (screen, world, object, camera). Connected to UserButton3
// MagellanCameraModeToggle()
// Toggle between rolling on/off. Connected to UserButton4
// MagellanRelativeObjectModeToggle()
// Toggle between screen or world axis for manipulation . Connected to UserButton5
// MagellanViewFit()
// Moves the objects to the center of the screen (viewFit -all). Connected to UserButton6
// MagellanCallback(tx, ty, tz, rx, ry, rz)
// Activated on any change of the input device. Just calls MagellanEvent()
// MagellanEvent(tx, ty, tz, rx, ry, rz)
// Handles keyFrame and undo issues.
// MagellanMove(tx, ty, tz, rx, ry, rz)
// Does the actual transformations
// Finalize (BOOL)
// Part of the undo/redo workaround
//
// Installation (the setup-routine does this automatically):
// - Install 3Dconnexions Windows Driver "3DxWare".
// - Put the "MagellanStartup.mel" into"MAYA_LOCATION\scripts\startup" folder.
// - Put the supplied "usersetup.mel" in the same directory or edit the existing script
// to include "MagellanStartup;".
//
// Open the 3Dconnexion option window:
// Open the Button mapping tab and expand the folder "Application Function". Assign "Button1", ..,
// "Button5" to any buttons of the device in order to get access to the toggle functions described above.
// Set the remaining buttons to the desired functions like "Dominant axis", "High/Low sensitivity"
// according to your individual preferences
// Save the settings in an arbitrary filename (e.g. "Maya"). This setting file will be automatically loaded
// whenever the 3DxWare driver is running and the Maya-application receives the focus.
//
// This Script is designed for Maya to be in the "Y-Axis Up" mode. For Z-Axis Up mode, modify by hand!
//
///////////////////////////////////////////////////////////////////////////////////////////////
// History
//
// $Id:$
//
// V1.6.0 First 3Dconnexion version
// New Features True object and scene movement.
// True camera rolling on/off
// World manipulation
// World and screen rotation centre
// Fit to view
// 3DxWare keyboard macros
// V1.6.2 MSB Fixed the issues with numerous events needing to be undone to get back to original position
// Known issue: Redo does not work (correctly)
// V1.6.3 MSB Fixed the view movement being undone by ctrl-z. View movements can only be undone/
// redone using previous/next view, irrespective of the setting of the journal option.
// V1.6.4 MSB Disable object movement as we have no fix momentarily for the redo issue. Also undoing object
// movement also undoes a following view movement
// V1.6.5 MSB Fixed the undo/redo movement issue. Works for single and multi-selection objects.
// Fixed the issue that the 3Dx bmps are not found if 3DxWare is not running
// V1.6.6 MSB Fixed an issue that view movements were getting undone with ctrl-z after the movement mode
// was toggled.
// V1.6.7 MSB Zoom/z-axis sensitivity is now a function of the view z-axis position.
// V1.6.8 MSB Fixes:
// If the user deletes the MagellanShelfButton it never is recreated. Instead of using an
// optionvar to determine if the shelfbutton exists. We now search the shelfs for buttons
// which activate the GUI. If none exist one is created.
// Moving the worldspace with the device set to worldspace coordinates and rolling off caused
// a gimbal lock effect.
// V1.6.9 MSB Fixes:
// Reworked the rotations relative to the screen with rolling off, so that the direction of
// rotation of the world is correct and uses device Rz input when appropriate
// V1.6.10 MSB Added readme file.
// V1.7.1 MSB Added support for Z-UpAxis
// V1.7.2 MSB Fix "error - object not found: Toolbutton1". Fix "error - object not found Persp1Shape"
// V1.8.1 MSB Fix "No valid objects supplied to 'xform' command.". Fix: Control settings not persistent
// across sessions.
// V1.8.2 MSB Fix: selected components could not be moved. This may unfix the "No valid objects supplied
// to 'xform' command." bug. Fix: When components where moved, their position jumped when the
// device was released.
// V1.8.3 MSB Fix the "No valid objects supplied to 'xform' command." bug. There is no really good fix
// for this. This fix uses the exception handling to catch the error. According to Alias
// the error/warning message should not be issued, but unfortunately it is. So that this is not
// too annoying the selection is only recalculated on the first non-zero 3dx event.
// V1.8.4 MSB Changed default settings to disable rolling, move camera and scene/object center
// Fix: After Freeze Transform (makeIdentity command) rotation pivot was set to (0,0,0).
// V2.0.5 MSB Merge of V1.8.4 and V2.0.4 alpha
// New GUI with features of other DCC plugins
// Buttonmapping has been added
// V2.0.6 MSB Fixed issue with OK button size in buttonmapping. Added Defaults button
// V2.1.1 MSB Changed algorithm for rotation center to use bounding box in when components are selectioned
// V2.1.2 MSB Intermediate fix for Linux version; Made MagellanEvent() global and changed name of Button event
// V2.1.3 MSB Added support for user marking menus. The marking menus need to be mappable to hotkeys
// The menu is only active once and needs to be reactivated if required again.
// V2.1.4 MSB Removed ShowHotbox and HideHotbox commands from the button mapping.
// Added Rescan button to buttonmapping dialog so that user does not need to restart maya
// when new commands are made available to the hotkey editor
// V2.1.5 MSB Fix: catchQuiet is a new command to V5, and leads to errors in V4.5. Script now uses the older
// catch for versions previous to V5.
// V2.1.6 MSB Change: Altered the algorithm for determining the center of rotation.
// Objects that are tranforms use the rotation pivot. All others use the translation returned
// by xform as this does not seem to be affected by Freeze and Reset Transformation.
// The bounding box is now only used as a last resort. This will now allow rotation around
// joint etc. pivots
// Fix variable definition for $error was missing in GetRotationPivot()
// V2.2.1 MSB New: Button mapping editor. Appearance is very similar to the hotkey editor.
// The selected command can be dragged and dropped to the button mapping on windows
// or assigned using the popupmenus in the button mapping window/command list
// Changed shelf icon format to xpm to support linux.
// V2.2.2 MSB Removed MagellanToggleHotbox command in linux version as this freezes the the driver
// V2.3.1 MSB New: Added support for motion capture. To activate set autoKeyFrame on in the maya GUI
// select the objects to move and check 'Enable Autokey Animation' in the 3Dconnexion GUI.
// Moving the objects will cause keys to be dropped at a rate of 2 per second.
// V3.0.1 MSB New: Added support for 3DxWare V5. This version requires the 3DxMaya.mll plug-in
// Added multiple button mapping configurations for 3DxWare V5
// Added new commands:
// - TopView, RightView, LeftView, FrontView.
// When executed in an orthographic view changes that view to the new view.
// When executed in 3DView (or with 3DView Lock on) changes the orientation of the view. With no selection the centre
// of interest remains unchanged with nothing selected. With a selction the centre of interest is moved to the
// selected object.
// Using 3DxMaya.mll results in the following improvements:
// - Full support for Hotbox and Marking menus
// - Full support for all device buttons (this is no longer limited to the 9 magellan device buttons).
// - Motion events do not appear in the script edito
// - 3DxWare functions can be mapped to buttons in the Button Mapping Editor
// Depreciated:
// - Buttonmappings saved with earlier version are deleted.
// Known Issues:
// - Motion capture only functions correctly if the rotation pivot remains at the center of the moved object as
// Maya does not record the the position of the pivot when storing keyframes
// V3.0.2 MSB New: Added '3D Control' to Main menu
// New: Added Control Panel Icon to statusline
// Renamed Commands from say MagellanTopView to xTopView
// New icons for shelf and logo
// Synchronised button editor to look and behave similar to other dcc app plugins
// V3.0.5 MSB General rework of code
// Added Button assignment synchronisation with 3DxWare
// Added Help button to status line
// Added 3D control shelf
// Fixed: Switching between left/right view in perspective nolonger causes obejct to wonder off
// Fixed: Rotation and Translation speeds can be moved with the button
// V3.0.6 MSB No changes
// V3.0.7 MSB Set Button 6 in the first default mapping for new devices to help
// Added dialog box to allow users to rename mappings
// V3.0.8 MSB Updated help
// V3.0.9 MSB Updated help to 3.10
// V3.0.10 MSB Changed help command
// V3.0.11 MSB Fix [1733] Button mapping defaults for SpacePilot L,R,T,F are swapped.
// Fix [1737] Help not available with Spaceball attached. Help only available with SpacePilot attached.
// Fix [1738] Fit button cannot be reprogrammed.
// V3.1.0 MSB Added specific button mapping defaults for SpaceMouse, SpaceTraveler and Spaceball with
// FrameSelectedInAllViews mapped to buttons 8 for the former two and button C for the latter.
// V3.1.1 MSB Added _3DxOnDriverFunctionsChanged callback
// Fix [3881] Creating/Editing macros in 3dxware causes parts of the buttonmapping to disappear.
// Fix [3761] Maya plug-in does not load if shelf is not visible
// Fix [3789] Translation velocity not dependent on zoom factor
// V3.2.0 MSB Added support for maya 8.0 beta 3 win32 and x64 versions
// V3.3.0 MSB Added mapping defaults for SpaceNavigator and SpaceExplorer
// Changed the SpaceTraveler defaults to match those of SpaceNavigator
// V3.3.1 MSB Added support for maya 8
// V3.3.2 MSB Fix [4094] Incorrect button mapping for ST
// Changed mapping for SpaceTraveler and SpaceNavigator from 'Toggle Object Movement' to 'Panel'
// Fix [4096] Button reset to empty if no any saved button mapping. The original button
// assignments are now initialized to the default setting.
// v3.3.3 msb Removed assignments to SpacePilot Help
// v3.4.0 msb Added support for maya 8.5
// Changed shelf tab name to 'Navigation' as '3D Control' is not a valid name.
// v3.4.1 msb Fix [4307] 3DxMaya isn't loaded in Maya 8.5 x64 (JP/EN)
// Fix [4308] Wrong 3DxMaya version displayed
// v3.5.0 msb
// v3.5.1 msb Fix [4575] 'delete' button enabled but does not function when in a default config
// Fix [4576] Inconsistent mapping of SE '2D' button
// v3.5.2 msb Fix [4666] Maya Auto Key causes time line to increase when navigating with 3D device
// v3.5.3 msb Fix [4675] Rearrangement of shelf-tabs does not take effect after restart
// v3.5.4 msb Added refresh -cv to make object movement smoother
// Added workaround for 3dxmaya plug-ins with mini api
// Implemented enhancment [4729] Cannot navigate lights when looking through them
// v3.5.5 msb Fix macOS: 3Dconnexion control panel window is too wide
// Fix macOS: Logo is not centered in panel window
// Removed resizable attribute from control panel window
// Removed help buttons when no help is available
// Do not attach to internal maya device on windows or mac
// Adjusted width of the columns for mapping combox to display 'mapping' text in one
// line on mac OS
// Always call _3DxOnDeviceChanged() during initialization if plug-in loaded
// v3.6.0 msb Fix [4776] Error: MagellanStartup.mel: line 402: No valid objects supplied to 'xform' command
// The catchQuiet was not supressing the error messages
// Fix [4804] 3DxMaya duplicates buttons in toolbar (Maya 2009)
// Fix [4805] Left and Right View commands show opposite views in perspective
// Fix [4806] 3Dconnexion toolbar remains with empty icons after removing 3DxMaya
// Simply do not create the shelf
//
//
// Known Issues:
// 1) The original view orientation cannot be reached using previous view if the very first view
// movement is made using the 3Dconnexion device. To get back to the starting view use the
// 'default home' menu item.
// 2) It is not possible to change the up axis in Linux. This must stay as the default configuration
// 3) Motion capture only functions correctly if the rotation pivot remains at the center of the moved object as
// Maya does not record the the position of the pivot when storing keyframes


global string $gsz3DxScriptVersion = "Version 3.6.0";


// set the initial states here. some variables will be overwritten by the stored user preferences

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Local procedures
proc SetDefaultParameters()
{
global string $gMagellanMoveMode;
global string $gMagellanRotationMode;
global int $gMagellanFlyMode;
global int $gMagellanDisableRoll;
global int $gMagellan3DViewLock;
global int $gMagellanObjectControl;
global int $gMagellanDominantAxis;
global int $gMagellanReferenceAxis;
global float $gMagellanDeviceTranslationSensitivity;
global float $gMagellanDeviceRotationSensitivity;
global int $gbMagellanYAxisUp;
global float $gMagellanTranslationScale;
global float $gMagellanRotationScale;
global int $gMagellanEventsSinceLastKey;
global int $gbMagellanEnableMotionCapture;

$gMagellanMoveMode = "moveCamera";
$gMagellanRotationMode = "coScene";
$gMagellanFlyMode = true;
$gMagellanDisableRoll = true;
$gMagellan3DViewLock = false;
$gMagellanObjectControl = false;
$gMagellanDominantAxis = false;
$gMagellanReferenceAxis = false;
$gMagellanDeviceTranslationSensitivity = 3.0;
$gMagellanDeviceRotationSensitivity = 8.0;
$gbMagellanYAxisUp = true;
$gMagellanTranslationScale = 1.0;
$gMagellanRotationScale = 1.0;
$gMagellanEventsSinceLastKey = 0;;
$gbMagellanEnableMotionCapture = false;
}


proc DominantAxisFilter (float $axis[])
{
global int $gMagellanDominantAxis;
global int $gMagellanFlyMode;

if ($gMagellanDominantAxis)
{
if (!$gMagellanFlyMode)
{
$axis[0]=0;
$axis[1]=0;
}
int $index;
int $maxIndex = 0;
float $maxValue = abs($axis[0]);
for ($index=1; $index<6>$maxValue)
{
$axis[$maxIndex]=0;
$maxIndex=$index;
$maxValue = abs($axis[$index]);
}
else
$axis[$index] = 0;
}
}
}

proc GetObjectPivot (float $centerOfRotation[], string $object)
{
global int $gMagellanCatchQuiet;

if (`objectType $object` == "transform")
{
int $error;
if ($gMagellanCatchQuiet)
$error = catchQuiet($centerOfRotation = `xform -q -ws -rp $object`);
else
$error = catch($centerOfRotation = `xform -q -ws -rp $object`);
}
else
{
int $error;
if ($gMagellanCatchQuiet)
$error = catchQuiet($centerOfRotation = `xform -q -ws -t $object`);
else
$error = catch($centerOfRotation = `xform -q -ws -t $object`);

if ($error)
{
// Last resort: use the bounding box of the complete selection
float $boundingBox[6];
if ($gMagellanCatchQuiet)
$error = catchQuiet($boundingBox = `xform -q -ws -bb`);
else
$error = catch($boundingBox = `xform -q -ws -bb`);

if (!$error)
{
$centerOfRotation[0] = ($boundingBox[0]+$boundingBox[3])/2;
$centerOfRotation[1] = ($boundingBox[1]+$boundingBox[4])/2;
$centerOfRotation[2] = ($boundingBox[2]+$boundingBox[5])/2;
}
}
}
}


proc GetRotationPivot (float $centerOfRotation[], string $cameraTrans)
{
global int $gMagellanCatchQuiet;
global int $gMagellanFlyMode;
global string $gMagellanRotationMode;
global string $gMagellanActiveMoveMode;
global string $gMagellanSelectedNodes[];

int $selectionCount=size($gMagellanSelectedNodes);
string $selection ="";

if ($selectionCount>0)
$selection=$gMagellanSelectedNodes[$selectionCount-1];

if ($gMagellanActiveMoveMode == "moveObject")
{
GetObjectPivot ($centerOfRotation, $selection);
}
else
{
if (!$gMagellanFlyMode)
{
$centerOfRotation = `camera -q -worldCenterOfInterest $cameraTrans`;
}
else
{
// Set the centre of rotation
switch ($gMagellanRotationMode)
{
case "coFocal":
$centerOfRotation = `camera -q -worldCenterOfInterest $cameraTrans`;
break;

case "coScene":
$centerOfRotation = {0.0, 0.0 , 0.0};
if ((`objExists $selection`) &&
($selection != "") &&
($selection != "|"))
{
GetObjectPivot($centerOfRotation, $selection);
}
break;

case "coCamera":
$centerOfRotation = `xform -q -ws -rp $cameraTrans`;
break;
}
}
}
}

proc int GetSelectedNodes(string $selectedNodes[])
{
global int $gMagellanCatchQuiet;

int $selectedNodeCount=0;
int $currentNodeCount;
global string $gCurrentSelection[];

clear $selectedNodes;
clear $gCurrentSelection;


$gCurrentSelection = `ls -long -selection`;
$currentNodeCount = size($gCurrentSelection);

while ($currentNodeCount > 0)
{
// Fix [4776] The catchQuiet was not supressing the error messages
// So try the objectType command instead
if (!`objectType -isType "transform" $gCurrentSelection[0]`)
{
$gCurrentSelection = `listTransforms "-long $gCurrentSelection"`;
$currentNodeCount = size($gCurrentSelection);
}
else
{
break;
}
}
$selectedNodes = $gCurrentSelection;
clear $gCurrentSelection;
$selectedNodeCount = size($selectedNodes);

return $selectedNodeCount;
}

proc float GetTargetDistance (string $camera, string $selection)
{
global string $gMagellanActiveMoveMode;
global string $gMagellanRotationMode;
global int $gMagellanFlyMode;

float $targetDistance;
float $objectPivot[3];
float $cameraPivot[3];

if ($gMagellanActiveMoveMode == "moveObject")
{
$objectPivot = `xform -q -ws -rp $selection`;
$cameraPivot = `xform -q -ws -rp $camera`;
$cameraPivot[0] -= $objectPivot[0];
$cameraPivot[1] -= $objectPivot[1];
$cameraPivot[2] -= $objectPivot[2];

$targetDistance = mag (<<cameraPivot>>);
}
else
{
if (!$gMagellanFlyMode)
{
$targetDistance = `camera -q -coi $camera`;
}
else
{
// Set the centre of rotation
switch ($gMagellanRotationMode)
{

case "coScene":
$cameraPivot = `xform -q -ws -rp $camera`;
$targetDistance = mag (<<cameraPivot>>);
break;

case "coCamera":
case "coFocal":
default:
$targetDistance = `camera -q -coi $camera`;
break;
}
}
}
return $targetDistance;
}

proc FinalizeUndo (int $bIsFinalize)
{
global float $gT[16];
global string $gMagellanSelectedNodes[];

if ($bIsFinalize)
{
if (size($gMagellanSelectedNodes) != 0)
{
// Only do this if the undo is off (otherwise a waste of time)
if (!`undoInfo -query -state`)
{
float $transform[16];
float $rotationPivot[3];
int $offset = 0;
string $selection;
for ($selection in $gMagellanSelectedNodes)
{
if (`objExists $selection`)
{
$transform = `xform -q -ws -m $selection`;
$rotationPivot = `xform -q -ws -rp $selection`;

// Undo the whole string of megallan actions
xform -ws -m $gT[$offset+0] $gT[$offset+1] $gT[$offset+2] $gT[$offset+3]
$gT[$offset+4] $gT[$offset+5] $gT[$offset+6] $gT[$offset+7]
$gT[$offset+8] $gT[$offset+9] $gT[$offset+10] $gT[$offset+11]
$gT[$offset+12] $gT[$offset+13] $gT[$offset+14] $gT[$offset+15]
$selection;

xform -ws -rp $gT[$offset+16] $gT[$offset+17] $gT[$offset+18]
$selection;

// switch the undo on change the attributes back and then switch it back off
undoInfo -swf true;

xform -ws -m $transform[0] $transform[1] $transform[2] $transform[3]
$transform[4] $transform[5] $transform[6] $transform[7]
$transform[8] $transform[9] $transform[10] $transform[11]
$transform[12] $transform[13] $transform[14] $transform[15]
$selection;

xform -ws -rp $rotationPivot[0] $rotationPivot[1] $rotationPivot[2]
$selection;

undoInfo -swf false;
}

$offset+=19;
}
}
}
}
// free memory
clear $gT;
}

proc InitializeUndo ()
{
global float $gT[16];
global string $gMagellanSelectedNodes[];

// Store the transform of the selected object(s)
string $selection;
int $offset=0;
float $transform[19];

clear $gT;

for ($selection in $gMagellanSelectedNodes)
{
if (`objExists $selection`)
{
$transform = `xform -q -ws -m $selection`;
int $i;
for ($i=0; $i<16; $i++)
{
$gT[$offset+$i] = $transform[$i];
}
$transform = `xform -q -ws -rp $selection`;
for ($i=0; $i<3; $i++)
{
$gT[$offset+16+$i] = $transform[$i];
}
}

$offset+=19;
}
}

proc IncrementTimeLine(float $fMilliSec)
{
string $currentTimeUnit = `currentUnit -q -time`;
float $currentTime = `currentTime -q`;


float $fMilliSecToTime = 0.024;
switch ($currentTimeUnit)
{
case "film":
$fMilliSecToTime = 0.024;
break;
case "game":
$fMilliSecToTime = 0.015;
break;
case "pal":
$fMilliSecToTime = 0.025;
break;
case "ntsc":
$fMilliSecToTime = 0.030;
break;
case "show":
$fMilliSecToTime = 0.048;
break;
case "palf":
$fMilliSecToTime = 0.050;
break;
case "ntscf":
$fMilliSecToTime = 0.060;
break;
case "millisec":
$fMilliSecToTime = 1;
break;
case "sec":
$fMilliSecToTime = 0.001;
break;
case "min":
$fMilliSecToTime = 0.001/60;
break;
case "hour":
$fMilliSecToTime = 0.001/3600;
break;
default:
$fMilliSecToTime = `substitute "fps" $currentTimeUnit ""`;
$fMilliSecToTime/=1000;
break;
}

if ($fMilliSecToTime <= 0)
$fMilliSecToTime = 0.024;

float $fDeltaTime = $fMilliSec * $fMilliSecToTime;
$currentTime += $fDeltaTime;
currentTime $currentTime;
}



proc LoadUserPreferences()
{
global string $gMagellanMoveMode;
global string $gMagellanRotationMode;
global int $gMagellanDisableRoll;
global int $gMagellanReferenceAxis;
global int $gMagellanFlyMode;
global int $gMagellan3DViewLock;
global int $gMagellanObjectControl;
global int $gMagellanDominantAxis;
global float $gMagellanTranslationScale;
global float $gMagellanRotationScale;

if (`optionVar -exists "MagellanMoveMode"`)
{
$gMagellanMoveMode = `optionVar -q "MagellanMoveMode"`;
}
if (`optionVar -exists "MagellanRotationMode"`)
{
$gMagellanRotationMode = `optionVar -q "MagellanRotationMode"`;
}
if (`optionVar -exists "MagellanFlyMode"`)
{
$gMagellanFlyMode = `optionVar -q "MagellanFlyMode"`;
}
if (`optionVar -exists "Magellan3DViewLock"`)
{
$gMagellan3DViewLock = `optionVar -q "Magellan3DViewLock"`;
}
if (`optionVar -exists "MagellanDisableRoll"`)
{
$gMagellanDisableRoll = `optionVar -q "MagellanDisableRoll"`;
}
if (`optionVar -exists "MagellanObjectControl"`)
{
$gMagellanObjectControl = `optionVar -q "MagellanObjectControl"`;
}
if (`optionVar -exists "MagellanDominantAxis"`)
{
$gMagellanDominantAxis = `optionVar -q "MagellanDominantAxis"`;
}
if (`optionVar -exists "MagellanReferenceAxis"`)
{
$gMagellanReferenceAxis = `optionVar -q "MagellanReferenceAxis"`;
}
if (`optionVar -exists "MagellanTranslationScale"`)
{
$gMagellanTranslationScale = `optionVar -q "MagellanTranslationScale"`;
}
if (`optionVar -exists "MagellanRotationScale"`)
{
$gMagellanRotationScale = `optionVar -q "MagellanRotationScale"`;
}
}


global string $gMagellanActiveCamera;
global string $gMagellanLast3DCamera="persp";
global string $gMagellanMoveMode = "moveCamera";
global string $gMagellanRotationMode = "coScene";
global int $gMagellanFlyMode = true;
global int $gMagellanDisableRoll = true;
global int $gMagellan3DViewLock = false;
global int $gMagellanObjectControl = false;
global int $gMagellanDominantAxis = false;
global int $gMagellanReferenceAxis = false;
global int $gMagellanHotBoxVisible = false;
global float $gMagellanDeviceTranslationSensitivity = 3.0;
global float $gMagellanDeviceRotationSensitivity = 8.0;
global int $gbMagellanYAxisUp = true;
global float $gMagellanTranslationScale = 1.0;
global float $gMagellanRotationScale = 1.0;
global int $gbIsPreviousZeroEvent = true;
global int $gbIsChangedAutoKeyframeState = false;
global string $gCurrentSelection[];
global string $gMagellanSelectedNodes[];
global string $gMagellanActiveMoveMode;
global int $gMagellanCatchQuiet=false;
global int $gMagellanEventsSinceLastKey;
global int $gbMagellanEnableMotionCapture;
global int $gMagellanMinSliderPosition = -8;
global int $gMagellanMaxSliderPosition = 8;

proc string GetActiveCamera ()
{
global int $gMagellan3DViewLock;
global string $gMagellanActiveCamera;
global string $gMagellanLastCamera;
global string $gMagellanLast3DCamera;

// get the camera of the active view
// if the active view is not a 3d view, then just take the last camera

if (!`objExists $gMagellanLast3DCamera`)
$gMagellanLast3DCamera = "persp";

if (!`objExists $gMagellanLastCamera`)
$gMagellanLastCamera = $gMagellanLast3DCamera;


string $p = `getPanel -withFocus`;
string $t = `getPanel -typeOf $p`;
if ($t == "modelPanel")
{
string $camera[];
$camera[0] = `modelPanel -q -camera $p`;
while (`objExists $camera[0]` && !`objectType -isType "transform" $camera[0]`)
{
$camera = `listRelatives -p $camera[0]`;
}
if (`objExists $camera[0]`)
{
$gMagellanActiveCamera = $camera[0];
$gMagellanLastCamera = $gMagellanActiveCamera;
}
else
$gMagellanActiveCamera = $gMagellanLastCamera;
}
else
$gMagellanActiveCamera = $gMagellanLastCamera;


int $cameraIsOrthographic = `camera -q -orthographic $gMagellanActiveCamera`;
if (!$cameraIsOrthographic)
{
$gMagellanLast3DCamera = $gMagellanActiveCamera;
}
else if ($gMagellan3DViewLock)
{
$gMagellanActiveCamera = $gMagellanLast3DCamera;
$cameraIsOrthographic = false;
}

return $gMagellanActiveCamera;
}

proc MagellanMove(float $tx, float $ty, float $tz, float $rx, float $ry, float $rz)
{
// This procedure does the actual object view transform
// Orientation is to move the object: The default 3Dconnexion orientation

global string $gMagellanSelectedNodes[];
global string $gMagellanActiveMoveMode;
global string $gMagellanRotationMode;
global int $gMagellanFlyMode;
global int $gMagellanDisableRoll;
global int $gMagellanReferenceAxis;

float $centerOfRotation[3];
float $pivotX, $pivotY, $pivotZ;
float $cameraPosition[3];
float $cameraDistance;

float $averageDistance = 50.0;
float $adjustTransSpeed;

int $bYAxisUp;
string $ax = `upAxis -q -ax`;
if ($ax == "z")
$bYAxisUp = false;
else
$bYAxisUp = true;

// get the camera of the active view
// if the active view is not a 3d view, then just take the last camera

string $camera = GetActiveCamera();
int $cameraIsOrthographic = `camera -q -orthographic $camera`;

// check if camera or object shall be moved
if ($gMagellanActiveMoveMode != "moveObject")
{

// for orthographic views things are different
if ($cameraIsOrthographic)
{
// Fix [3789] Translation velocity not dependent on zoom factor
$adjustTransSpeed = `camera -q -ow $camera` / 50;

$tx*=$adjustTransSpeed;
$ty*=$adjustTransSpeed;

// track moves the camera right/left, up/down
track -right $tx $camera;
track -up $ty $camera;
// dolly is moving the camera in or out
dolly -relative -orthoScale (1 + ($tz / 50) ) $camera;
}
else
{
// Make translation speed independent on distance
// $cameraPosition = `xform -q -os -t $camera`;
// $adjustTransSpeed = abs($cameraPosition[2]) / $averageDistance;
$adjustTransSpeed = GetTargetDistance($camera, $gMagellanSelectedNodes[0]) / $averageDistance;
if ($adjustTransSpeed <0>= 90)
$rx = -$rx;

rotate -p $centerOfRotation[0] $centerOfRotation[1] $centerOfRotation[2] -relative -eu -os $rx $dry 0 $camera;

xform -p true -rotateOrder $rotOrder $camera;
}
else
{
// Change to yxz order (because we want rY to be constant)
xform -p true -rotateOrder yxz $camera;

float $cameraR[3];
$cameraR = `xform -q -worldSpace -rotation $camera`;


// adjust to the currently set angular unit
if ((`currentUnit -q -angle` == "deg"))
{
$cameraR[0] = `deg_to_rad($cameraR[0])`;
$cameraR[1] = `deg_to_rad($cameraR[1])`;
$cameraR[2] = `deg_to_rad($cameraR[2])`;
}

// calculate the world space coordinate changes for rotation
float $sinX = sin($cameraR[0]);
float $sinY = sin($cameraR[1]);
float $cosX = cos($cameraR[0]);
float $cosY = cos($cameraR[1]);

float $zaxis[3];
$zaxis[0] = -$cosX * $sinY;
$zaxis[1] = $sinX;
$zaxis[2]= $cosX * $cosY;

// Dot product of input vector with Z axis
float $drz = $rx * $zaxis[0] + $ry * $zaxis[1] + $rz * $zaxis[2];

// Ry flips between 0,+180 and -180 degrees which effectively changes the
// orientation of the x-axis
if (abs(rad_to_deg($cameraR[1])) >= 90)
$rx = -$rx;

rotate -p $centerOfRotation[0] $centerOfRotation[1] $centerOfRotation[2] -relative -eu -os $rx 0 $drz $camera;

xform -p true -rotateOrder $rotOrder $camera;
}

}
else
{
// Save the rotation order
$rotOrder = `xform -q -rotateOrder $camera`;

if ($bYAxisUp)
{
float $cameraR[3];

// Change to xyz order
xform -p true -rotateOrder xyz $camera;

$cameraR = `xform -q -ws -ro $camera`;
if ((`currentUnit -q -angle` != "deg"))
$cameraR[2] = `rad_to_deg($cameraR[2])`;
if (abs($cameraR[2]) >= 90)
$ry = -$ry;
$rz = 0;
}
else
{
float $cameraR[3];

// Change to xyz order
xform -p true -rotateOrder xzy $camera;

$cameraR = `xform -q -ws -ro $camera`;
if ((`currentUnit -q -angle` != "deg"))
$cameraR[1] = `rad_to_deg($cameraR[2])`;
if (abs($cameraR[1]) >= 90)
$rz = -$rz;
$ry = 0;
}

rotate -p $centerOfRotation[0] $centerOfRotation[1] $centerOfRotation[2] -relative -eu -ws $rx $ry $rz $camera;

xform -p true -rotateOrder $rotOrder $camera;
}
}

// Translate
if ($gMagellanFlyMode)
{
if (!$gMagellanReferenceAxis)
move -relative -os $tx $ty $tz $camera;
else
move -relative -ws $tx $ty $tz $camera;
}
else
{
float $distance = `camera -q -coi $camera`;
$distance += $tz;
if ($distance <0> 0)
{
if (`objExists $gMagellanSelectedNodes[0]`)
{
$selection = $gMagellanSelectedNodes[0];
}
}

// proceed only if an object for moving has been found
if (($selection != "") && ($selection != "|"))
{

// choose the view point or world axis for manipulating objects
if (!$gMagellanReferenceAxis)
{
// check if rolling is enabled
if ($gMagellanDisableRoll)
{
$rz = 0;
}

// view point axis mode

// in order to easily get the camera y rotation, we must convert to yxz rotation order
// but this must be changed back for compatability
$rotOrder = `xform -q -rotateOrder $camera`;
xform -p true -rotateOrder xyz $camera;
$cameraR = `xform -q -worldSpace -rotation $camera`;
$myCameraR[0] = $cameraR[0];
$myCameraR[1] = $cameraR[1];
$myCameraR[2] = $cameraR[2];

// Make translation speed independent on distance

$cameraPosition = `xform -q -ws -t $camera`;
$cameraWCI = `camera -q -worldCenterOfInterest $camera`;
$objectPosition = `xform -q -ws -t $selection`;
$distanceOW = abs($cameraPosition[0] - $objectPosition[0]) + abs($cameraPosition[1] - $objectPosition[1]) + abs($cameraPosition[2] - $objectPosition[2]);
$distanceOZ = abs($cameraWCI[0] - $objectPosition[0]) + abs($cameraWCI[1] - $objectPosition[1]) + abs($cameraWCI[2] - $objectPosition[2]);
if (abs($distanceOZ) > $cutPlane)
$distanceOZ = $cutPlane;
if (($cameraWCI[2] - $objectPosition[2]) > 0)
$distanceOZ = - $distanceOZ;
$adjustTransSpeed =$maxDistance / ($distanceOZ + $maxDistance);
if ($adjustTransSpeed <0> 1)
{
move -relative -worldSpace $dtx $dty $dtz;
if (($gMagellanRotationMode) == "coScene")
{
float $boundedBox[6];
float $cX = 0, $cY = 0, $cZ = 0;
int $iSelection;


for ($iSelection = 0; $iSelection <selectionCount>= 29)
{
if ($bPress)
{
int $lastButtonMapping = size($g3DxButtonMapping)-1;
if ($lastButtonMapping)
{
if (++$g3DxCurrentButtonMapping>$lastButtonMapping)
$g3DxCurrentButtonMapping=0;
C3DxMapping_LoadMapping();
if (`window -exists o3DxButtonEditor`)
C3DxButtonEditor_OnMappingChange();
}
}
}
}

global proc _3DxOnFitView (int $bPress)
{
if ($bPress)
MagellanViewFit();
}

global proc _3DxOn3DLock (int $bPress)
{
if ($bPress)
Magellan3DViewLockToggle();
}

global proc _3DxOnButtonEvent (int $button, int $bPress)
{
global string $g3DxCurrentButtonAssignment[];
if ($button > 0 && $button<=size($g3DxCurrentButtonAssignment))
{
if ($bPress)
eval $g3DxCurrentButtonAssignment[$button-1];

else if ($g3DxCurrentButtonAssignment[$button-1] == "ShowHotbox")
eval "HideHotbox";

else
{
string $hotkeyCommand = `substitute "_Press" $g3DxCurrentButtonAssignment[$button-1] "_Release"`;
if (($hotkeyCommand != $g3DxCurrentButtonAssignment[$button-1]) &&
(`runTimeCommand -q -exists $hotkeyCommand`))
eval $hotkeyCommand;
}
}
}

global proc _3DxOnMotionEvent (float $tx, float $ty, float $tz, float $rx, float $ry, float $rz)
{
MagellanEvent($tx, $ty, $tz, $rx, $ry, $rz);
//Debug print ($tx +" " +$ty +" " +$tz +" " +$rx +" " +$ry +" " +$rz +"\n");
}

global proc _3DxShowHelp ()
{
global int $gbMagellanIs3DxMaya;
global string $g3DxHelpFile;

if ($gbMagellanIs3DxMaya)
eval ("_3DxHelp $g3DxHelpFile");
else
showHelp -a $g3DxHelpFile;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// C3DxMainMenu
////////////////////////////////////////////////////////////////////////////////////////////////////
global proc C3DxMainMenu()
{
global string $gMagellanImage;
global string $g3DxHelpFile;

if (!`menu -exists o3DxMainMenu`)
{
menu
-parent "MayaWindow"
-label "3D Control"
-familyImage $gMagellanImage
-tearOff true
o3DxMainMenu;

menuItem
-label "Control Panel..."
-imageOverlayLabel "Panel"
-annotation "3Dx Control Panel"
-command "C3DxMainMenu_OnControlPanel";

menuItem
-label "Button Mapping Editor..."
-imageOverlayLabel "Map"
-annotation "Assign Commands to 3Dx Device Buttons"
-command "C3DxMainMenu_OnButtonEditor";

if ($g3DxHelpFile != "")
{
menuItem
-divider true;
menuItem
-label "Help..."
-imageOverlayLabel "Help"
-annotation "Help"
-command "C3DxMainMenu_OnHelp";
}

menuItem
-divider true;
menuItem
-label "www.3Dconnnexion.com"
-imageOverlayLabel "www"
-annotation "Visit 3Dconnexion Home Page"
-command "C3DxMainMenu_OnWWW";
}
}

global proc C3DxMainMenu_DestroyMenu()
{
if (`menu -exists o3DxMainMenu`)
deleteUI o3DxMainMenu;
}

global proc C3DxMainMenu_OnButtonEditor()
{
C3DxButtonEditor();
}

global proc C3DxMainMenu_OnControlPanel()
{
C3DxControlPanel();
C3DxControlPanel_ShowWindow();
}

global proc C3DxMainMenu_OnHelp()
{
_3DxShowHelp();
}

global proc C3DxMainMenu_OnWWW()
{
showHelp -absolute "http://www.3Dconnexion.com";
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// C3DxStatusLine
////////////////////////////////////////////////////////////////////////////////////////////////////
global proc C3DxStatusLine()
{
global string $gStatusLineForm;
global string $gMagellanIconPath;
global string $g3DxHelpFile;


if (`formLayout -exists o3DxStatusLine`)
deleteUI o3DxStatusLine;

if (`formLayout -exists $gStatusLineForm`)
{
if (`formLayout -exists o3DxStatusLineForm`)
deleteUI o3DxStatusLineForm;

string $statusLineChildren[] = `formLayout -q -ca $gStatusLineForm`;
if (size($statusLineChildren)==1)
{
string $statusLineChild = $gStatusLineForm+"|"+$statusLineChildren[0];

string $form;
string $contronPanelButton;
string $image1 = $gMagellanIconPath+"3DxCube_24x24.xpm";
string $image2 = $gMagellanIconPath+"3DxHelp_24x24.xpm";

setParent $gStatusLineForm;
formLayout o3DxStatusLine;

// Our buttons in the statusline
iconTextButton
-image1 $image1
-width 26
-height 26
-annotation ("Show the 3Dconnexion Control Panel")
-command ("C3DxStatusLine_OnControlPanel")
o3DxStatusLine_ControlPanelButton;

if ($g3DxHelpFile != "")
{
iconTextButton
-image1 $image2
-width 26
-height 26
-annotation ("Open the 3Dconnexion Help")
-command ("C3DxStatusLine_OnHelp")
o3DxStatusLine_HelpButton;

// The attachments
formLayout -edit
-attachForm o3DxStatusLine_ControlPanelButton top 1
-attachForm o3DxStatusLine_ControlPanelButton left 0
-attachNone o3DxStatusLine_ControlPanelButton bottom
-attachNone o3DxStatusLine_ControlPanelButton right

-attachForm o3DxStatusLine_HelpButton top 1
-attachControl o3DxStatusLine_HelpButton left 2 o3DxStatusLine_ControlPanelButton
-attachNone o3DxStatusLine_HelpButton bottom
-attachNone o3DxStatusLine_HelpButton right

o3DxStatusLine;
}
else
{
// The attachments
formLayout -edit
-attachForm o3DxStatusLine_ControlPanelButton top 1
-attachForm o3DxStatusLine_ControlPanelButton left 0
-attachNone o3DxStatusLine_ControlPanelButton bottom
-attachNone o3DxStatusLine_ControlPanelButton right
o3DxStatusLine;
}

// Edit the original status line parent form
formLayout -edit
-attachControl $statusLineChild right 0 o3DxStatusLine
-attachForm o3DxStatusLine top 0
-attachNone o3DxStatusLine left
-attachForm o3DxStatusLine bottom 0
-attachForm o3DxStatusLine right 0
$gStatusLineForm;
}
}
}

global proc C3DxStatusLine_Destroy()
{
if (`formLayout -exists o3DxStatusLine`)
deleteUI o3DxStatusLine;
}

global proc C3DxStatusLine_OnControlPanel()
{
C3DxControlPanel();
C3DxControlPanel_ShowWindow();
}

global proc C3DxStatusLine_OnHelp()
{
_3DxShowHelp();
}
thennek
Posts: 6
Joined: Mon Jan 26, 2009 10:50 am

Post by thennek »

I made sure that the plugin is loaded in the plugin manager and when I restart Maya and immediately the mel command line give me the following:

// Error: Cannot find procedure "_3DxOnMotionEvent".

I then tried to run MagellanStartup and it worked and I get the following:

// Warning: Move Scene //
// Warning: Rotate around center of Camera! //
// Warning: Fly mode on! //
// Warning: Rotation Scale 1 //
// Warning: Translation Scale 1 //


However, I restarted Maya to verify my findings and the device did not function. I again got the error:

// Error: Cannot find procedure "_3DxOnMotionEvent".

I then re-ran MagellanStartup and it worked!

I have one last question, how do I ensure that this script runs upon start up in Maya each time I launch Maya?
flomotan
Moderator
Moderator
Posts: 287
Joined: Mon Jan 08, 2007 3:37 pm

Post by flomotan »

The "usersetup.mel" script is designed to be loaded and executed automatically each time you start Maya. In that script is the command for MagellanStartup. So in theory (sorry, I hate to have to say that :-), you shouldn't have to ever type MagellanStartup.

Please observe your system and let me know if you always have to enter this command. It would mean that Maya is finding another usersetup.mel script somewhere else on your hard disk and executing that instead of the one in /Users/Shared/Autodesk/maya/scripts. Apple's Spotlight can useful in finding any duplicate usersetup.mel files
thennek
Posts: 6
Joined: Mon Jan 26, 2009 10:50 am

usersetup.mel

Post by thennek »

Okay! There is a usersetup.mel script in each of the following directories:

/Users/Shared/Autodesk/maya/scripts
This folder has all of the 3DConexxion scripts

/Users/Shared/Autodesk/maya/2009/scripts
This folder was installed by maya and has all of the other scripts in it.

Which one do I keep, every other thing that I install defaults to the /maya/2009/scripts directory except for the 3DConexxion script.

Any Ideas

It really would help if the next version of the 3DConexxion driver uninstalled the old stuff and put the its new scripts in the default maya/2009/scripts directory!
flomotan
Moderator
Moderator
Posts: 287
Joined: Mon Jan 08, 2007 3:37 pm

Post by flomotan »

For now what you can do is merge the contents of
/Users/Shared/Autodesk/maya/scripts

into
/Users/Shared/Autodesk/maya/2009/scripts

Be sure NOT to copy usersetup.mel over any existing usersetup.mel in your 2009/scripts folder. Instead, edit the existing 2009/scripts/usersetup.mel file and add the line

MagellanStartup;

at the end of the file. You can use TextEdit to change the file.
Post Reply