Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
.js switch weirdness

.js switch weirdness

2004-12-17       - By Matthias Worch

 Back
Reply:     1     2     3  

I'm seeing weird behavior in a jscript I wrote yesterday, but I can't
reproduce the problem in smaller test scripts. Maybe somebody has time
to dig through this little thing and tell me why the switch statement
at the end doesn't work? The script works anyway, but it irks me like
hell ;)

//==============================================================================
// toggleSelMode.js
// Matthias Worch - http://www.langsuyar.com
// Toggles between Point Select, Raycast Edge Select and Raycast Poly Select
// tools for speedy modelling. Bind to Tab or similar key :)
//==============================================================================

//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
// We're keeping track of the last mode in a blob that attaches to the scene
// root. Return blob's value (or create one if it doesn't exist)

function getCurrentSelMode()
{
       var e = new Enumerator( ActiveSceneRoot.Properties );
       var item;
       var currentSelMode;
       
       for( null; !e.atEnd(); e.moveNext() )
       {
               item = e.item();
               if( item.Type == "UserDataBlob" )
                       if( item.Name == "currentSelMode" )
                       {
                               // cache and return the current mode, advance
the index
                               currentSelMode = item.Value;
                               advanceSelMode( item );
                               return currentSelMode;
                       }
       }
       // Blob doesn't exist yet!
       var Blob = ActiveSceneRoot.AddProperty( "UserDataBlob", false,
"currentSelMode" );
       Blob.Value = "0";
       advanceSelMode( Blob );
       return 0;
}

//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
// Update blob's data with the next selection mode
function advanceSelMode( item )
{
       item.Value++;
       if( item.Value >= 3 )
               item.Value = 0;
       return;
}

//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
// toggle mode
function toggleSelMode( value )
{
       logMessage( value );

       // this if/else works
       if( value == 0 )
       {
                       ActivateVertexSelTool(null);
                       return;
       }
       else if( value == 1 )
       {
                       ActivateRaycastEdgeSelTool(null);
                       return;
       }
       else if( value == 2 )
       {
                       ActivateRaycastPolySelTool(null);
                       return;
       }

       // the switch version of this doesn't work
       /*
       switch( value )
       {
       case 0:
               ActivateVertexSelTool(null);
               break;
       case 1:
               ActivateRaycastEdgeSelTool(null);
               break;
       case 2:
               ActivateRaycastPolySelTool(null);
               break;
       Default:
               break;
       }
       */
}

//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
// main()

toggleSelMode( getCurrentSelMode() );





---
Unsubscribe? Mail Majordomo@(protected) with the following text in body:
unsubscribe xsi