First MayaPlugin, still need to fix the makefiles and get unique ids for
the Maya nodes. Got rid of boost dependencies. Cleaned up mvl library
This commit is contained in:
41
Extras/MayaPlugin/scripts/AEdCollisionShapeTemplate.mel
Normal file
41
Extras/MayaPlugin/scripts/AEdCollisionShapeTemplate.mel
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
Copyright (c) 2008 Walt Disney Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
*/
|
||||
|
||||
//AEdCollisionShapeTemplate.mel
|
||||
|
||||
global proc AEdCollisionShapeTemplate( string $nodeName )
|
||||
{
|
||||
|
||||
editorTemplate -beginScrollLayout;
|
||||
|
||||
editorTemplate -addControl inShape;
|
||||
editorTemplate -addControl outCollisionShape;
|
||||
editorTemplate -addControl type;
|
||||
editorTemplate -addControl scale;
|
||||
|
||||
AEdependNodeTemplate $nodeName;
|
||||
|
||||
editorTemplate -addExtraControls;
|
||||
editorTemplate -endScrollLayout;
|
||||
|
||||
}
|
||||
|
||||
89
Extras/MayaPlugin/scripts/AEdRigidBodyArrayTemplate.mel
Normal file
89
Extras/MayaPlugin/scripts/AEdRigidBodyArrayTemplate.mel
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
Copyright (c) 2008 Walt Disney Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
*/
|
||||
|
||||
//AEdRigidBodyArrayTemplate.mel
|
||||
|
||||
global proc AEdRigidBodyArrayTemplate( string $nodeName )
|
||||
{
|
||||
|
||||
editorTemplate -beginScrollLayout;
|
||||
|
||||
editorTemplate -addControl inCollisionShape;
|
||||
editorTemplate -addControl numBodies;
|
||||
editorTemplate -addControl active;
|
||||
editorTemplate -addControl mass;
|
||||
editorTemplate -addControl restitution;
|
||||
editorTemplate -addControl friction;
|
||||
editorTemplate -addControl linearDamping;
|
||||
editorTemplate -addControl angularDamping;
|
||||
|
||||
editorTemplate -beginLayout "Initial configuration" -collapse 1;
|
||||
editorTemplate -addControl initialPosition;
|
||||
editorTemplate -addControl initialRotation;
|
||||
editorTemplate -addControl initialVelocity;
|
||||
editorTemplate -addControl initialSpin;
|
||||
editorTemplate -endLayout;
|
||||
|
||||
editorTemplate -beginLayout "Current configuration" -collapse 1;
|
||||
editorTemplate -addControl position;
|
||||
editorTemplate -addControl rotation;
|
||||
editorTemplate -endLayout;
|
||||
|
||||
editorTemplate -beginLayout "File IO" -collapse 1;
|
||||
editorTemplate -addControl fileIO;
|
||||
editorTemplate -addControl files;
|
||||
editorTemplate -addControl positionAttribute;
|
||||
editorTemplate -addControl rotationAttribute;
|
||||
editorTemplate -endLayout;
|
||||
|
||||
editorTemplate -addControl solver;
|
||||
|
||||
editorTemplate -beginLayout (uiRes("m_AElocatorTemplate.kLocatorAttributes")) -collapse 1;
|
||||
AElocatorCommon $nodeName;
|
||||
editorTemplate -endLayout;
|
||||
|
||||
{
|
||||
editorTemplate -suppress "motionBlur";
|
||||
editorTemplate -suppress "visibleInReflections";
|
||||
editorTemplate -suppress "visibleInRefractions";
|
||||
editorTemplate -suppress "maxVisibilitySamplesOverride";
|
||||
editorTemplate -suppress "maxVisibilitySamples";
|
||||
editorTemplate -suppress "geometryAntialiasingOverride";
|
||||
editorTemplate -suppress "antialiasingLevel";
|
||||
editorTemplate -suppress "shadingSamplesOverride";
|
||||
editorTemplate -suppress "shadingSamples";
|
||||
editorTemplate -suppress "maxShadingSamples";
|
||||
editorTemplate -suppress "volumeSamplesOverride";
|
||||
editorTemplate -suppress "volumeSamples";
|
||||
editorTemplate -suppress "depthJitter";
|
||||
editorTemplate -suppress "ignoreSelfShadowing";
|
||||
editorTemplate -suppress "primaryVisibility";
|
||||
editorTemplate -suppress "compInstObjGroups";
|
||||
}
|
||||
|
||||
AEshapeTemplate $nodeName;
|
||||
|
||||
editorTemplate -addExtraControls;
|
||||
editorTemplate -endScrollLayout;
|
||||
|
||||
}
|
||||
|
||||
102
Extras/MayaPlugin/scripts/AEdRigidBodyTemplate.mel
Normal file
102
Extras/MayaPlugin/scripts/AEdRigidBodyTemplate.mel
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
Copyright (c) 2008 Walt Disney Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
*/
|
||||
|
||||
//AEdRigidBodyTemplate.mel
|
||||
|
||||
global proc AEdRigidBodyTemplate( string $nodeName )
|
||||
{
|
||||
|
||||
editorTemplate -beginScrollLayout;
|
||||
|
||||
/* editorTemplate -callCustom
|
||||
"AEgpufxLCtextureFiles 1"
|
||||
"AEgpufxLCtextureFiles 0"
|
||||
"textureFiles";
|
||||
editorTemplate -suppress "textureFiles";*/
|
||||
|
||||
editorTemplate -addControl inCollisionShape;
|
||||
editorTemplate -addControl active;
|
||||
editorTemplate -addControl mass;
|
||||
editorTemplate -addControl restitution;
|
||||
editorTemplate -addControl friction;
|
||||
editorTemplate -addControl linearDamping;
|
||||
editorTemplate -addControl angularDamping;
|
||||
|
||||
editorTemplate -beginLayout "Initial configuration" -collapse 0;
|
||||
editorTemplate -addControl initialPosition;
|
||||
editorTemplate -addControl initialRotation;
|
||||
editorTemplate -addControl initialVelocity;
|
||||
editorTemplate -addControl initialSpin;
|
||||
editorTemplate -endLayout;
|
||||
|
||||
editorTemplate -addControl solver;
|
||||
|
||||
editorTemplate -beginLayout (uiRes("m_AElocatorTemplate.kLocatorAttributes")) -collapse 1;
|
||||
AElocatorCommon $nodeName;
|
||||
editorTemplate -endLayout;
|
||||
|
||||
{
|
||||
editorTemplate -suppress "motionBlur";
|
||||
editorTemplate -suppress "visibleInReflections";
|
||||
editorTemplate -suppress "visibleInRefractions";
|
||||
editorTemplate -suppress "maxVisibilitySamplesOverride";
|
||||
editorTemplate -suppress "maxVisibilitySamples";
|
||||
editorTemplate -suppress "geometryAntialiasingOverride";
|
||||
editorTemplate -suppress "antialiasingLevel";
|
||||
editorTemplate -suppress "shadingSamplesOverride";
|
||||
editorTemplate -suppress "shadingSamples";
|
||||
editorTemplate -suppress "maxShadingSamples";
|
||||
editorTemplate -suppress "volumeSamplesOverride";
|
||||
editorTemplate -suppress "volumeSamples";
|
||||
editorTemplate -suppress "depthJitter";
|
||||
editorTemplate -suppress "ignoreSelfShadowing";
|
||||
editorTemplate -suppress "primaryVisibility";
|
||||
editorTemplate -suppress "compInstObjGroups";
|
||||
}
|
||||
|
||||
AEshapeTemplate $nodeName;
|
||||
|
||||
editorTemplate -addExtraControls;
|
||||
editorTemplate -endScrollLayout;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
global proc AEgpufxLCpdbFiles(int $create, string $node)
|
||||
{
|
||||
if ($create) {
|
||||
rowLayout -nc 3 -cw 3 57;
|
||||
{
|
||||
text -l "Pdb Files";
|
||||
textField -ann "Path to the pdb files" pdbFilesTF;
|
||||
button -l "Reload" -ann "Reload pdb files" reloadPdbFilesB;
|
||||
setParent ..;
|
||||
}
|
||||
}
|
||||
|
||||
connectControl pdbFilesTF $node;
|
||||
|
||||
// use dgdirty if we start using attributeAffects
|
||||
button -e -c ("string $attr = getAttr(\"" +$node +"\"); setAttr " + $node + " -type \"string\" \"\"; setAttr " + $node + " -type \"string\" $attr;") reloadPdbFilesB;
|
||||
}
|
||||
|
||||
*/
|
||||
50
Extras/MayaPlugin/scripts/AEdSolverTemplate.mel
Normal file
50
Extras/MayaPlugin/scripts/AEdSolverTemplate.mel
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
Copyright (c) 2008 Walt Disney Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
*/
|
||||
|
||||
//AEdSolverTemplate.mel
|
||||
|
||||
global proc AEdSolverTemplate( string $nodeName )
|
||||
{
|
||||
|
||||
editorTemplate -beginScrollLayout;
|
||||
|
||||
editorTemplate -addControl ssSolverType;
|
||||
|
||||
editorTemplate -addControl gravity;
|
||||
|
||||
editorTemplate -addControl substeps;
|
||||
|
||||
editorTemplate -addControl enabled;
|
||||
|
||||
editorTemplate -addControl splitImpulse;
|
||||
|
||||
editorTemplate -addControl startTime;
|
||||
|
||||
editorTemplate -addControl rigidBodies;
|
||||
|
||||
AEdependNodeTemplate $nodeName;
|
||||
|
||||
editorTemplate -addExtraControls;
|
||||
editorTemplate -endScrollLayout;
|
||||
|
||||
}
|
||||
|
||||
23
Extras/MayaPlugin/scripts/dynamica.mel
Normal file
23
Extras/MayaPlugin/scripts/dynamica.mel
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
Copyright (c) 2008 Walt Disney Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
*/
|
||||
|
||||
//dynamica.mel
|
||||
643
Extras/MayaPlugin/scripts/dynamicaUI.mel
Normal file
643
Extras/MayaPlugin/scripts/dynamicaUI.mel
Normal file
@@ -0,0 +1,643 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
Copyright (c) 2008 Walt Disney Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
*/
|
||||
|
||||
//dynamicaUI.mel
|
||||
|
||||
//
|
||||
global string $dynamicaUIWindow = "dynamicaUIWindow";
|
||||
|
||||
global proc dynamicaUI_initialize()
|
||||
{
|
||||
dynamicaUI_createShelfButton();
|
||||
|
||||
//add script jobs
|
||||
//scriptJob -e "SceneOpened" gpufxGUI_updateSettings;
|
||||
}
|
||||
|
||||
//main window
|
||||
global proc dynamicaUI_createWindow()
|
||||
{
|
||||
global string $dynamicaUIWindow;
|
||||
|
||||
//check if the window exists
|
||||
if ( `window -ex $dynamicaUIWindow` )
|
||||
{
|
||||
showWindow $dynamicaUIWindow;
|
||||
return;
|
||||
}
|
||||
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
$dynamicaUIWindow = `window -t "dynamica"`;
|
||||
|
||||
string $mainForm = `formLayout`;
|
||||
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
|
||||
|
||||
formLayout -e
|
||||
-attachForm $tabs "top" 0
|
||||
-attachForm $tabs "left" 0
|
||||
-attachForm $tabs "bottom" 0
|
||||
-attachForm $tabs "right" 0
|
||||
$mainForm;
|
||||
|
||||
|
||||
string $mainLayt = dynamicaUI_createMainTab();
|
||||
string $solverLayt = dynamicaUI_createSolverTab();
|
||||
|
||||
tabLayout -e -tabLabel $mainLayt "Create" -tabLabel $solverLayt "Solver" $tabs;
|
||||
|
||||
showWindow $dynamicaUIWindow;
|
||||
// window -e -wh 479 664 $dynamicaUIWindow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
global proc dynamicaUI_createShelfButton()
|
||||
{
|
||||
// The shelf we want to add the button to.
|
||||
string $shelf = "EfxToolsLumiere";
|
||||
|
||||
// The icon we want to use on the button.
|
||||
string $iconImage = "dynamica.xpm";
|
||||
|
||||
// Tle button label.
|
||||
string $iconBtnLabel = "dynamica";
|
||||
|
||||
// Specify the shelf as the parent for our tool button. If there
|
||||
// is no such shelf, we create it.
|
||||
//
|
||||
string $btnParent;
|
||||
if ( `shelfLayout -ex $shelf` )
|
||||
{
|
||||
$btnParent = $shelf;
|
||||
|
||||
// Check to see if the shelf already has the gpufx button. If so,
|
||||
// we want to delete it before we remake it so we don't end up with
|
||||
// duplicate buttons on the shelf.
|
||||
|
||||
string $existingShelfButtons[] = `shelfLayout -q -ca $shelf`;
|
||||
for ( $btn in $existingShelfButtons )
|
||||
if ( `shelfButton -q -l $btn` == $iconBtnLabel )
|
||||
deleteUI $btn;
|
||||
} else {
|
||||
// Create the shelf under the global shelf parent.
|
||||
global string $gShelfTopLevel;
|
||||
$btnParent = `shelfLayout -p $gShelfTopLevel $shelf`;
|
||||
}
|
||||
|
||||
// Make (or remake) the tool button.
|
||||
shelfButton -label $iconBtnLabel -image1 $iconImage
|
||||
-command "dynamicaUI_createWindow" -p $btnParent;
|
||||
|
||||
}
|
||||
|
||||
global proc string dynamicaUI_createSolverTab()
|
||||
{
|
||||
global string $dynamicaUI_STsolverType;
|
||||
global string $dynamicaUI_STgravityX;
|
||||
global string $dynamicaUI_STgravityY;
|
||||
global string $dynamicaUI_STgravityZ;
|
||||
global string $dynamicaUI_STenabled;
|
||||
global string $dynamicaUI_STsplitImpulse;
|
||||
global string $dynamicaUI_STsubsteps;
|
||||
|
||||
string $mainForm = `columnLayout -adj 1`;
|
||||
{
|
||||
string $solverTypeFrame = `frameLayout -collapsable false -label "Solver Type" -borderStyle "etchedIn"`;
|
||||
{
|
||||
rowLayout -nc 1 -adj 1 -cat 1 "left" 30;
|
||||
{
|
||||
int $solverType = `getAttr dSolver1.ssSolverType` + 1; // 1-based
|
||||
$dynamicaUI_STsolverType = `textScrollList -append "Bullet Physics" -append "Ageia PhysX" -append "Stanford PhysBAM"
|
||||
-selectIndexedItem $solverType
|
||||
-numberOfRows 1
|
||||
-sc dynamicaUI_STSolverTypeChanged`;
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
string $gravityFrame = `frameLayout -collapsable false -label "Gravity" -borderStyle "etchedIn"`;
|
||||
{
|
||||
rowLayout -nc 3 -cat 1 "both" 0 -cat 2 "both" 0 -cat 3 "both" 0 -cw3 50 50 50;
|
||||
{
|
||||
float $gravity[] = `getAttr dSolver1.gravity`;
|
||||
$dynamicaUI_STgravityX = `floatField -precision 3 -value $gravity[0] -changeCommand dynamicaUI_STgravityChanged`;
|
||||
$dynamicaUI_STgravityY = `floatField -precision 3 -value $gravity[1] -changeCommand dynamicaUI_STgravityChanged`;
|
||||
$dynamicaUI_STgravityZ = `floatField -precision 3 -value $gravity[2] -changeCommand dynamicaUI_STgravityChanged`;
|
||||
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
string $substepsFrame = `frameLayout -collapsable false -label "Substeps" -borderStyle "etchedIn"`;
|
||||
{
|
||||
rowLayout -nc 1 -cat 1 "both" 0 -cw1 50;
|
||||
{
|
||||
int $substeps = `getAttr dSolver1.substeps`;
|
||||
$dynamicaUI_STsubsteps = `intField -value $substeps -changeCommand dynamicaUI_STsubstepsChanged`;
|
||||
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
string $enabledFrame = `frameLayout -collapsable false -label "Solver State" -borderStyle "etchedIn"`;
|
||||
{
|
||||
rowLayout -nc 1 -adj 1 -cat 1 "left" 30;
|
||||
{
|
||||
int $enabled = `getAttr dSolver1.enabled`;
|
||||
$dynamicaUI_STenabled = `checkBox -label "Enabled" -value $enabled
|
||||
-cc dynamicaUI_STenabledChanged`;
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
string $splitImpulseFrame = `frameLayout -collapsable false -label "SplitImpulse" -borderStyle "etchedIn"`;
|
||||
{
|
||||
rowLayout -nc 1 -adj 1 -cat 1 "left" 30;
|
||||
{
|
||||
int $enabled = `getAttr dSolver1.splitImpulse`;
|
||||
$dynamicaUI_STsplitImpulse = `checkBox -label "Enabled" -value $enabled
|
||||
-cc dynamicaUI_STsplitImpulseChanged`;
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
|
||||
return $mainForm;
|
||||
}
|
||||
|
||||
global proc string dynamicaUI_createMainTab()
|
||||
{
|
||||
string $mainForm = `columnLayout -adj 1`;
|
||||
{
|
||||
frameLayout -collapsable true -label "Active Rigid Bodies" -borderStyle "in";
|
||||
{
|
||||
rowLayout -nc 5;
|
||||
{
|
||||
string $createActiveSphereRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Sphere"
|
||||
-width 100 -image1 "dynamicaCreateActiveSphereRB.xpm" -c ("dynamicaUI_createActiveSphereRB")
|
||||
-ann "Create an active sphere rigid body"`;
|
||||
|
||||
string $createActiveBoxRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Box"
|
||||
-width 100 -image1 "dynamicaCreateActiveBoxRB.xpm" -c ("dynamicaUI_createActiveBoxRB")
|
||||
-ann "Create an active box rigid body"`;
|
||||
|
||||
string $createActivePlaneRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Plane"
|
||||
-width 100 -image1 "dynamicaCreateActivePlaneRB.xpm" -c ("dynamicaUI_createActivePlaneRB")
|
||||
-ann "Create an active plane rigid body"`;
|
||||
|
||||
string $createActiveHullRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Hull"
|
||||
-width 100 -image1 "dynamicaCreateActiveHullRB.xpm" -c ("dynamicaUI_createActiveHullRB")
|
||||
-ann "Create an active hull rigid body"`;
|
||||
|
||||
string $createActiveMeshRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Mesh"
|
||||
-width 100 -image1 "dynamicaCreateActiveMeshRB.xpm" -c ("dynamicaUI_createActiveMeshRB")
|
||||
-ann "Create an active mesh rigid body"`;
|
||||
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
|
||||
frameLayout -collapsable true -label "Passive Rigid Bodies" -borderStyle "in";
|
||||
{
|
||||
rowLayout -nc 5;
|
||||
{
|
||||
string $createPassiveSphereRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Sphere"
|
||||
-width 100 -image1 "dynamicaCreatePassiveSphereRB.xpm" -c ("dynamicaUI_createPassiveSphereRB")
|
||||
-ann "Create an passive sphere rigid body"`;
|
||||
|
||||
string $createPassiveBoxRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Box"
|
||||
-width 100 -image1 "dynamicaCreatePassiveBoxRB.xpm" -c ("dynamicaUI_createPassiveBoxRB")
|
||||
-ann "Create an passive box rigid body"`;
|
||||
|
||||
string $createPassivePlaneRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Plane"
|
||||
-width 100 -image1 "dynamicaCreatePassivePlaneRB.xpm" -c ("dynamicaUI_createPassivePlaneRB")
|
||||
-ann "Create an passive plane rigid body"`;
|
||||
|
||||
string $createPassiveHullRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Hull"
|
||||
-width 100 -image1 "dynamicaCreatePassiveHullRB.xpm" -c ("dynamicaUI_createPassiveHullRB")
|
||||
-ann "Create an passive hull rigid body"`;
|
||||
|
||||
string $createPassiveMeshRBBtn = `iconTextButton -style "iconAndTextVertical" -label "Mesh"
|
||||
-width 100 -image1 "dynamicaCreatePassiveMeshRB.xpm" -c ("dynamicaUI_createPassiveMeshRB")
|
||||
-ann "Create an passive mesh rigid body"`;
|
||||
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
|
||||
|
||||
frameLayout -collapsable true -label "Active Rigid Body Arrays" -borderStyle "in";
|
||||
{
|
||||
rowLayout -nc 5;
|
||||
{
|
||||
string $createActiveSphereRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Sphere"
|
||||
-width 100 -image1 "dynamicaCreateActiveSphereRBArray.xpm" -c ("dynamicaUI_createActiveSphereRBArray")
|
||||
-ann "Create an active sphere rigid body array"`;
|
||||
|
||||
string $createActiveBoxRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Box"
|
||||
-width 100 -image1 "dynamicaCreateActiveBoxRBArray.xpm" -c ("dynamicaUI_createActiveBoxRBArray")
|
||||
-ann "Create an active box rigid body array"`;
|
||||
|
||||
string $createActivePlaneRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Plane"
|
||||
-width 100 -image1 "dynamicaCreateActivePlaneRBArray.xpm" -c ("dynamicaUI_createActivePlaneRBArray")
|
||||
-ann "Create an active plane rigid body array"`;
|
||||
|
||||
string $createActiveHullRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Hull"
|
||||
-width 100 -image1 "dynamicaCreateActiveHullRBArray.xpm" -c ("dynamicaUI_createActiveHullRBArray")
|
||||
-ann "Create an active hull rigid body array"`;
|
||||
|
||||
string $createActiveMeshRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Mesh"
|
||||
-width 100 -image1 "dynamicaCreateActiveMeshRBArray.xpm" -c ("dynamicaUI_createActiveMeshRBArray")
|
||||
-ann "Create an active mesh rigid body array"`;
|
||||
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
|
||||
frameLayout -collapsable true -label "Passive Rigid Body Arrays" -borderStyle "in";
|
||||
{
|
||||
rowLayout -nc 5;
|
||||
{
|
||||
string $createPassiveSphereRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Sphere"
|
||||
-width 100 -image1 "dynamicaCreatePassiveSphereRBArray.xpm" -c ("dynamicaUI_createPassiveSphereRBArray")
|
||||
-ann "Create an passive sphere rigid body array"`;
|
||||
|
||||
string $createPassiveBoxRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Box"
|
||||
-width 100 -image1 "dynamicaCreatePassiveBoxRBArray.xpm" -c ("dynamicaUI_createPassiveBoxRBArray")
|
||||
-ann "Create an passive box rigid body array"`;
|
||||
|
||||
string $createPassivePlaneRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Plane"
|
||||
-width 100 -image1 "dynamicaCreatePassivePlaneRBArray.xpm" -c ("dynamicaUI_createPassivePlaneRBArray")
|
||||
-ann "Create an passive plane rigid body array"`;
|
||||
|
||||
string $createPassiveHullRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Hull"
|
||||
-width 100 -image1 "dynamicaCreatePassiveHullRBArray.xpm" -c ("dynamicaUI_createPassiveHullRBArray")
|
||||
-ann "Create an passive hull rigid body array"`;
|
||||
|
||||
string $createPassiveMeshRBArrayBtn = `iconTextButton -style "iconAndTextVertical" -label "Mesh"
|
||||
-width 100 -image1 "dynamicaCreatePassiveMeshRBArray.xpm" -c ("dynamicaUI_createPassiveMeshRBArray")
|
||||
-ann "Create an passive mesh rigid body array"`;
|
||||
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
return $mainForm;
|
||||
}
|
||||
|
||||
global proc dynamicaUI_STSolverTypeChanged()
|
||||
{
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
global string $dynamicaUI_STsolverType;
|
||||
int $type[] = `textScrollList -q -selectIndexedItem $dynamicaUI_STsolverType`;
|
||||
$type[0] = $type[0] -1; //1-based
|
||||
setAttr dSolver1.ssSolverType $type[0];
|
||||
}
|
||||
|
||||
global proc dynamicaUI_STgravityChanged()
|
||||
{
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
global string $dynamicaUI_STgravityX;
|
||||
global string $dynamicaUI_STgravityY;
|
||||
global string $dynamicaUI_STgravityZ;
|
||||
|
||||
float $gx = `floatField -query -value $dynamicaUI_STgravityX`;
|
||||
float $gy = `floatField -query -value $dynamicaUI_STgravityY`;
|
||||
float $gz = `floatField -query -value $dynamicaUI_STgravityZ`;
|
||||
|
||||
setAttr dSolver1.gravity -type double3 $gx $gy $gz;
|
||||
|
||||
}
|
||||
|
||||
global proc dynamicaUI_STenabledChanged()
|
||||
{
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
global string $dynamicaUI_STenabled;
|
||||
|
||||
int $enabled = `checkBox -query -value $dynamicaUI_STenabled`;
|
||||
|
||||
setAttr dSolver1.enabled $enabled;
|
||||
|
||||
}
|
||||
|
||||
global proc dynamicaUI_STsplitImpulseChanged()
|
||||
{
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
global string $dynamicaUI_STsplitImpulse;
|
||||
|
||||
int $enabled = `checkBox -query -value $dynamicaUI_STsplitImpulse`;
|
||||
|
||||
setAttr dSolver1.splitImpulse $enabled;
|
||||
|
||||
}
|
||||
|
||||
global proc dynamicaUI_STsubstepsChanged()
|
||||
{
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
global string $dynamicaUI_STsubsteps;
|
||||
|
||||
int $substeps = `intField -query -value $dynamicaUI_STsubsteps`;
|
||||
|
||||
setAttr dSolver1.substeps $substeps;
|
||||
|
||||
}
|
||||
|
||||
proc dynamicaUI_createRigidBody(int $active, int $collisionShapeType)
|
||||
{
|
||||
string $selection[] = `ls -selection -dag -leaf -showType -type "geometry"`;
|
||||
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
string $rigidBodyNode = `dRigidBody`;
|
||||
string $collisionShapeNode = `createNode dCollisionShape`;
|
||||
connectAttr ($collisionShapeNode + ".outCollisionShape") ($rigidBodyNode + ".inCollisionShape");
|
||||
string $rigidBodyTransforms[] = `listRelatives -parent $rigidBodyNode`;
|
||||
|
||||
if(size($selection) != 0) {
|
||||
string $shapeTransforms[] = `listRelatives -parent $selection[0]`;
|
||||
if($selection[1] == "mesh") {
|
||||
connectAttr ($selection[0] + ".message") ($collisionShapeNode + ".inShape");
|
||||
hide $shapeTransforms[0];
|
||||
}
|
||||
//pick the selected object's transform only if we are creating a hull or a mesh
|
||||
if($collisionShapeType == 0 || $collisionShapeType == 1) {
|
||||
float $pos[]= `getAttr ($shapeTransforms[0] + ".translate")`;
|
||||
float $rot[]= `getAttr ($shapeTransforms[0] + ".rotate")`;
|
||||
|
||||
setAttr ($rigidBodyTransforms[0] + ".translate") -type double3 $pos[0] $pos[1] $pos[2];
|
||||
//setAttr ($rigidBodyNode + ".initialPosition") -type double3 $pos[0] $pos[1] $pos[2];
|
||||
|
||||
setAttr ($rigidBodyTransforms[0] + ".rotate") -type double3 $rot[0] $rot[1] $rot[2];
|
||||
// setAttr ($rigidBodyNode + ".initialRotation") -type double3 $rot[0] $rot[1] $rot[2];
|
||||
}
|
||||
}
|
||||
|
||||
setAttr ($rigidBodyNode + ".active" ) $active;
|
||||
setAttr ($collisionShapeNode + ".type" ) $collisionShapeType;
|
||||
|
||||
select -r $rigidBodyTransforms[0];
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createArrayUIdismissCB(string $button)
|
||||
{
|
||||
global string $dynamicaUI_createArrayUI_sizeCT;
|
||||
global string $dynamicaUI_createArrayUI_offsetCT;
|
||||
|
||||
global int $dynamicaUI_createArrayUI_size[];
|
||||
global float $dynamicaUI_createArrayUI_offset[];
|
||||
|
||||
$dynamicaUI_createArrayUI_size = `intFieldGrp -query -value $dynamicaUI_createArrayUI_sizeCT`;
|
||||
$dynamicaUI_createArrayUI_offset = `floatFieldGrp -query -value $dynamicaUI_createArrayUI_offsetCT`;
|
||||
layoutDialog -dismiss $button;
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createArrayUI()
|
||||
{
|
||||
global string $dynamicaUI_createArrayUI_sizeCT;
|
||||
global string $dynamicaUI_createArrayUI_offsetCT;
|
||||
|
||||
// Get the dialog's formLayout.
|
||||
string $form = `setParent -q`;
|
||||
|
||||
// layoutDialog's are not resizable, so hard code a size here,
|
||||
// to make sure all UI elements are visible.
|
||||
formLayout -e -width 350 $form;
|
||||
|
||||
string $b1 = `button -l "OK" -c "dynamicaUI_createArrayUIdismissCB(\"OK\")"`;
|
||||
string $b2 = `button -l "Cancel"-c "dynamicaUI_createArrayUIdismissCB(\"Cancel\")"`;
|
||||
|
||||
$dynamicaUI_createArrayUI_sizeCT = `intFieldGrp -columnAlign 1 "left" -adj 1 -numberOfFields 3 -label "Array Size" -v1 1 -v2 1 -v3 1`;
|
||||
$dynamicaUI_createArrayUI_offsetCT = `floatFieldGrp -columnAlign 1 "left" -adj 1 -numberOfFields 3 -label "Array Offset" -v1 2.0 -v2 2.0 -v3 2.0`;
|
||||
|
||||
formLayout -edit
|
||||
-attachForm $dynamicaUI_createArrayUI_sizeCT "top" 5
|
||||
-attachForm $dynamicaUI_createArrayUI_sizeCT "left" 5
|
||||
-attachNone $dynamicaUI_createArrayUI_sizeCT "bottom"
|
||||
-attachForm $dynamicaUI_createArrayUI_sizeCT "right" 5
|
||||
|
||||
-attachControl $dynamicaUI_createArrayUI_offsetCT "top" 5 $dynamicaUI_createArrayUI_sizeCT
|
||||
-attachForm $dynamicaUI_createArrayUI_offsetCT "left" 5
|
||||
-attachNone $dynamicaUI_createArrayUI_offsetCT "bottom"
|
||||
-attachForm $dynamicaUI_createArrayUI_offsetCT "right" 5
|
||||
|
||||
-attachControl $b1 "top" 5 $dynamicaUI_createArrayUI_offsetCT
|
||||
-attachForm $b1 "left" 5
|
||||
-attachNone $b1 "bottom"
|
||||
-attachPosition $b1 "right" 5 33
|
||||
|
||||
-attachControl $b2 "top" 5 $dynamicaUI_createArrayUI_offsetCT
|
||||
-attachPosition $b2 "left" 5 33
|
||||
-attachNone $b2 "bottom"
|
||||
-attachPosition $b2 "right" 5 66
|
||||
|
||||
$form;
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveRigidBody()
|
||||
{
|
||||
dynamicaUI_createRigidBody(true, 0);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveRigidBody()
|
||||
{
|
||||
dynamicaUI_createRigidBody(false, 0);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveSphereRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(true, 5);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveBoxRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(true, 4);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActivePlaneRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(true, 6);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveHullRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(true, 0);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveMeshRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(true, 1);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveSphereRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(false, 5);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveBoxRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(false, 4);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassivePlaneRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(false, 6);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveHullRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(false, 0);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveMeshRB()
|
||||
{
|
||||
dynamicaUI_createRigidBody(false, 1);
|
||||
}
|
||||
|
||||
proc dynamicaUI_createRigidBodyArray(int $active, int $collisionShapeType)
|
||||
{
|
||||
global int $dynamicaUI_createArrayUI_size[];
|
||||
global float $dynamicaUI_createArrayUI_offset[];
|
||||
|
||||
if(`layoutDialog -title "Create Rigid Body Array" -ui "dynamicaUI_createArrayUI"` == "OK") {
|
||||
string $selection[] = `ls -selection -dag -leaf -showType -type "geometry"`;
|
||||
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
string $rigidBodyArrayNode = `dRigidBodyArray`;
|
||||
string $collisionShapeNode = `createNode dCollisionShape`;
|
||||
connectAttr ($collisionShapeNode + ".outCollisionShape") ($rigidBodyArrayNode + ".inCollisionShape");
|
||||
string $rigidBodyTransforms[] = `listRelatives -parent $rigidBodyArrayNode`;
|
||||
|
||||
if(size($selection) != 0) {
|
||||
string $shapeTransforms[] = `listRelatives -parent $selection[0]`;
|
||||
if($selection[1] == "mesh") {
|
||||
connectAttr ($selection[0] + ".message") ($collisionShapeNode + ".inShape");
|
||||
hide $shapeTransforms[0];
|
||||
}
|
||||
}
|
||||
|
||||
setAttr ($rigidBodyArrayNode + ".active" ) $active;
|
||||
setAttr ($collisionShapeNode + ".type" ) $collisionShapeType;
|
||||
|
||||
select -r $rigidBodyTransforms[0];
|
||||
|
||||
int $size[]= $dynamicaUI_createArrayUI_size;
|
||||
float $off[]= $dynamicaUI_createArrayUI_offset;
|
||||
float $x0[];
|
||||
$x0[0] = -0.5 * $size[0] * $off[0];
|
||||
$x0[1] = -0.5 * $size[1] * $off[1];
|
||||
$x0[2] = -0.5 * $size[2] * $off[2];
|
||||
setAttr ($rigidBodyArrayNode + ".numBodies") ($size[0] * $size[1] * $size[2]);
|
||||
for($i = 0; $i < $size[0]; $i++) {
|
||||
for($j = 0; $j < $size[1]; $j++) {
|
||||
for($k = 0; $k < $size[2]; $k++) {
|
||||
setAttr ($rigidBodyArrayNode + ".initialPosition[" + string($i + $size[0] * $j + $size[0] * $size[1] * $k) + "]") ($x0[0] + $i * $off[0]) ($x0[1] + $j * $off[1]) ($x0[2] + $k * $off[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveSphereRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(true, 5);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveBoxRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(true, 4);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActivePlaneRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(true, 6);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveHullRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(true, 0);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createActiveMeshRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(true, 1);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveSphereRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(false, 5);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveBoxRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(false, 4);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassivePlaneRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(false, 6);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveHullRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(false, 0);
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createPassiveMeshRBArray()
|
||||
{
|
||||
dynamicaUI_createRigidBodyArray(false, 1);
|
||||
}
|
||||
|
||||
global proc dyn_demo1()
|
||||
{
|
||||
dynamicaUI_createActiveSphereRBArray();
|
||||
string $children[] = `listRelatives -shapes`;
|
||||
setAttr ($children[0] + ".numBodies") 1000;
|
||||
for($i = 0; $i < 10; $i++) {
|
||||
for($j = 0; $j < 10; $j++) {
|
||||
for($k = 0; $k < 10; $k++) {
|
||||
setAttr ($children[0] + ".initialPosition[" + string($i + 10 * $j + 100 * $k) + "]") ($i * 2) (10 + $k * 2) ($j * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user