This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
MAYA=$(MAYA_LOCATION)
|
||||
|
||||
## Change this if you want to change the installation directory
|
||||
MAYA_PLUG_IN_PATH=/tmp
|
||||
MAYA_PLUG_IN_PATH=/usr/maya-plugins
|
||||
|
||||
## Change this if you want to change the name of the final plugin
|
||||
LIBRARY=mayaplugin.so
|
||||
@@ -31,14 +31,14 @@ BULLET_LIB=-L$(BULLET)/out/linux/optimize/libs -L$(BULLET)/src \
|
||||
-lGIMPACT -lGIMPACTUtils -lbulletdynamics \
|
||||
-lbulletmath -lbulletcollision -lbulletopenglsupport
|
||||
|
||||
GL_LIB=-lGL -lGLU -lglut -lGLEW
|
||||
GL_LIB=-lGL -lGLU
|
||||
|
||||
MAYA_INCLUDE=-I$(MAYA)/include
|
||||
MAYA_LIB=-L$(MAYA)/lib -lOpenMaya -lFoundation -lOpenMayaUI -lOpenMayaFX
|
||||
|
||||
SOURCES = pluginMain.cpp rigidBodyNode.cpp rigidBodyArrayNode.cpp collisionShapeNode.cpp \
|
||||
solver.cpp bt_solver.cpp dSolverNode.cpp dSolverCmd.cpp dRigidBodyCmd.cpp dRigidBodyArrayCmd.cpp \
|
||||
pdbIO.cpp
|
||||
pdbIO.cpp drawUtils.cpp
|
||||
|
||||
HEADERS = box_shape.h bt_sphere_shape.h dSolverNode.h rigid_body_impl.h \
|
||||
box_shape_impl.h collision_shape.h mathUtils.h rigidBodyNode.h \
|
||||
@@ -49,7 +49,7 @@ HEADERS = box_shape.h bt_sphere_shape.h dSolverNode.h
|
||||
bt_plane_shape.h dRigidBodyArrayCmd.h plane_shape_impl.h \
|
||||
bt_rigid_body.h dRigidBodyCmd.h rigidBodyArrayNode.h \
|
||||
bt_solver.h dSolverCmd.h rigid_body.h pdbIO.h \
|
||||
shared_ptr.h
|
||||
shared_ptr.h drawUtils.h
|
||||
|
||||
|
||||
INCLUDE_FLAGS= $(GL_INCLUDE) $(BULLET_INCLUDE) $(MAYA_INCLUDE)
|
||||
|
||||
@@ -26,6 +26,7 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
#define DYN_BT_BOX_SHAPE_H
|
||||
|
||||
#include "box_shape_impl.h"
|
||||
#include "drawUtils.h"
|
||||
|
||||
class bt_box_shape_t: public bt_collision_shape_t, public box_shape_impl_t
|
||||
{
|
||||
@@ -37,9 +38,9 @@ public:
|
||||
|
||||
glScalef(2 * e.x(), 2 * e.y(), 2 * e.z());
|
||||
if(draw_style & collision_shape_t::kDSSolid) {
|
||||
glutSolidCube(1.0);
|
||||
solid_cube();
|
||||
} else {
|
||||
glutWireCube(1.0);
|
||||
wire_cube();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
#define DYN_BT_PLANE_SHAPE_H
|
||||
|
||||
#include "plane_shape_impl.h"
|
||||
#include "drawUtils.h"
|
||||
|
||||
class bt_plane_shape_t: public bt_collision_shape_t, public plane_shape_impl_t
|
||||
{
|
||||
@@ -35,9 +36,9 @@ public:
|
||||
glPushMatrix();
|
||||
glScalef(100.0, 0.001, 100.0);
|
||||
if(draw_style & collision_shape_t::kDSSolid) {
|
||||
glutSolidCube(1.0);
|
||||
solid_cube();
|
||||
} else {
|
||||
glutWireCube(1.0);
|
||||
wire_cube();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -25,22 +25,26 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
#ifndef DYN_BT_SPHERE_SHAPE_H
|
||||
#define DYN_BT_SPHERE_SHAPE_H
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include "sphere_shape_impl.h"
|
||||
#include "bt_collision_shape.h"
|
||||
#include "collision_shape.h"
|
||||
#include "drawUtils.h"
|
||||
|
||||
class bt_sphere_shape_t: public bt_collision_shape_t, public sphere_shape_impl_t
|
||||
{
|
||||
public:
|
||||
virtual void gl_draw(size_t draw_style) {
|
||||
btSphereShape *sphere_shape = static_cast<btSphereShape*>(shape());
|
||||
glPushMatrix();
|
||||
glScalef(sphere_shape->getRadius(), sphere_shape->getRadius(), sphere_shape->getRadius());
|
||||
if(draw_style & collision_shape_t::kDSSolid) {
|
||||
glutSolidSphere(sphere_shape->getRadius(), 10, 10);
|
||||
solid_sphere();
|
||||
} else {
|
||||
glutWireSphere(sphere_shape->getRadius(), 10, 10);
|
||||
wire_sphere();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
virtual void set_scale(vec3f const& s) {
|
||||
|
||||
@@ -22,8 +22,6 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
|
||||
//collisionShapeNode.cpp
|
||||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include <maya/MFnMessageAttribute.h>
|
||||
#include <maya/MFnNumericAttribute.h>
|
||||
#include <maya/MFnEnumAttribute.h>
|
||||
|
||||
@@ -139,7 +139,7 @@ dRigidBodyCmd::redoIt()
|
||||
m_dagModifier->doIt();
|
||||
}
|
||||
|
||||
MGlobal::select(parentObj, MGlobal::kReplaceList);
|
||||
// MGlobal::select(parentObj, MGlobal::kReplaceList);
|
||||
|
||||
setResult(MFnDependencyNode(dRigidBodyObj).name());
|
||||
|
||||
|
||||
159
Extras/MayaPlugin/drawUtils.cpp
Normal file
159
Extras/MayaPlugin/drawUtils.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
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>
|
||||
*/
|
||||
|
||||
//drawUtils.cpp
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
void wire_cube()
|
||||
{
|
||||
static GLuint dlist = 0;
|
||||
if(glIsList(dlist)) {
|
||||
glCallList(dlist);
|
||||
} else {
|
||||
dlist = glGenLists(1);
|
||||
glNewList(dlist, GL_COMPILE_AND_EXECUTE);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3f(-0.5f, -0.5, 0.5);
|
||||
glVertex3f(0.5f, -0.5, 0.5);
|
||||
glVertex3f(0.5f, 0.5, 0.5);
|
||||
glVertex3f(-0.5f, 0.5, 0.5);
|
||||
glVertex3f(-0.5f, -0.5, 0.5);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3f(-0.5f, -0.5, -0.5);
|
||||
glVertex3f(0.5f, -0.5, -0.5);
|
||||
glVertex3f(0.5f, 0.5, -0.5);
|
||||
glVertex3f(-0.5f, 0.5, -0.5);
|
||||
glVertex3f(-0.5f, -0.5, -0.5);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||
glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(-0.5f, 0.5f, -0.5f);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
void solid_cube()
|
||||
{
|
||||
static GLuint dlist = 0;
|
||||
if(glIsList(dlist)) {
|
||||
glCallList(dlist);
|
||||
} else {
|
||||
dlist = glGenLists(1);
|
||||
glNewList(dlist, GL_COMPILE_AND_EXECUTE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f(-1.0f, 0.0f, 0.0f);
|
||||
glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||
glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(-0.5f, 0.5f, -0.5f);
|
||||
|
||||
glNormal3f(0.0f, 1.0f, 0.0f);
|
||||
glVertex3f(-0.5f, 0.5f, -0.5f);
|
||||
glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
|
||||
glNormal3f(1.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
|
||||
glNormal3f(0.0f, -1.0f, 0.0f);
|
||||
glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||
|
||||
glNormal3f(1.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
|
||||
glNormal3f(0.0f, 0.0f, 1.0f);
|
||||
glVertex3f(-0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(0.5f, -0.5f, 0.5f);
|
||||
glVertex3f(0.5f, 0.5f, 0.5f);
|
||||
glVertex3f(-0.5f, 0.5f, 0.5f);
|
||||
|
||||
glNormal3f(0.0f, 0.0f, -1.0f);
|
||||
glVertex3f(0.5f, -0.5f, -0.5f);
|
||||
glVertex3f(-0.5f, -0.5f, -0.5f);
|
||||
glVertex3f(-0.5f, 0.5f, -0.5f);
|
||||
glVertex3f(0.5f, 0.5f, -0.5f);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
void wire_sphere()
|
||||
{
|
||||
static GLuint dlist = 0;
|
||||
if(glIsList(dlist)) {
|
||||
glCallList(dlist);
|
||||
} else {
|
||||
GLUquadricObj* quadric = gluNewQuadric();
|
||||
gluQuadricDrawStyle(quadric, GLU_LINE);
|
||||
|
||||
dlist = glGenLists(1);
|
||||
glNewList(dlist, GL_COMPILE_AND_EXECUTE);
|
||||
gluSphere(quadric, 1.0, 10, 10);
|
||||
glEndList();
|
||||
|
||||
gluDeleteQuadric(quadric);
|
||||
}
|
||||
}
|
||||
|
||||
void solid_sphere()
|
||||
{
|
||||
static GLuint dlist = 0;
|
||||
if(glIsList(dlist)) {
|
||||
glCallList(dlist);
|
||||
} else {
|
||||
GLUquadricObj* quadric = gluNewQuadric();
|
||||
gluQuadricDrawStyle(quadric, GLU_FILL);
|
||||
|
||||
dlist = glGenLists(1);
|
||||
glNewList(dlist, GL_COMPILE_AND_EXECUTE);
|
||||
gluSphere(quadric, 1.0, 10, 10);
|
||||
glEndList();
|
||||
|
||||
gluDeleteQuadric(quadric);
|
||||
}
|
||||
}
|
||||
33
Extras/MayaPlugin/drawUtils.h
Normal file
33
Extras/MayaPlugin/drawUtils.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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>
|
||||
*/
|
||||
|
||||
//drawUtils.h
|
||||
|
||||
#ifndef DYN_DRAW_UTILS_H
|
||||
#define DYN_DRAW_UTILS_H
|
||||
|
||||
void wire_cube();
|
||||
void solid_cube();
|
||||
void wire_sphere();
|
||||
void solid_sphere();
|
||||
|
||||
#endif
|
||||
@@ -21,8 +21,6 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
*/
|
||||
|
||||
//pluginMain.cpp
|
||||
|
||||
|
||||
#include <maya/MFnPlugin.h>
|
||||
#include <maya/MGlobal.h>
|
||||
#include <maya/MDGMessage.h>
|
||||
|
||||
@@ -22,8 +22,6 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
|
||||
//rigidBodyArrayNode.cpp
|
||||
|
||||
//#include <GL/glut.h>
|
||||
|
||||
#include <maya/MFnDependencyNode.h>
|
||||
#include <maya/MPlugArray.h>
|
||||
#include <maya/MFnMessageAttribute.h>
|
||||
|
||||
@@ -22,8 +22,6 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
|
||||
//rigidBodyNode.cpp
|
||||
|
||||
//#include <GL/glut.h>
|
||||
|
||||
#include <maya/MFnDependencyNode.h>
|
||||
#include <maya/MPlugArray.h>
|
||||
#include <maya/MFnMessageAttribute.h>
|
||||
|
||||
@@ -387,19 +387,23 @@ proc dynamicaUI_createRigidBody(int $active, int $collisionShapeType)
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
string $newBodies[];
|
||||
|
||||
//pick the selected object's transform only if we are creating a hull or a mesh
|
||||
if($collisionShapeType == 0 || $collisionShapeType == 1) {
|
||||
|
||||
for($i = 0; $i < size($selection) / 2; $i++) {
|
||||
|
||||
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");
|
||||
string $shapeTransforms[] = `listRelatives -parent $selection[$i * 2]`;
|
||||
if($selection[$i * 2 + 1] == "mesh") {
|
||||
connectAttr ($selection[$i * 2] + ".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")`;
|
||||
|
||||
@@ -408,13 +412,25 @@ proc dynamicaUI_createRigidBody(int $active, int $collisionShapeType)
|
||||
|
||||
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];
|
||||
$newBodies[$i] = $rigidBodyTransforms[0];
|
||||
}
|
||||
} else {
|
||||
string $rigidBodyNode = `dRigidBody`;
|
||||
string $collisionShapeNode = `createNode dCollisionShape`;
|
||||
connectAttr ($collisionShapeNode + ".outCollisionShape") ($rigidBodyNode + ".inCollisionShape");
|
||||
string $rigidBodyTransforms[] = `listRelatives -parent $rigidBodyNode`;
|
||||
|
||||
setAttr ($rigidBodyNode + ".active" ) $active;
|
||||
setAttr ($collisionShapeNode + ".type" ) $collisionShapeType;
|
||||
|
||||
$newBodies[0] = $rigidBodyTransforms[0];
|
||||
}
|
||||
|
||||
select -r $newBodies;
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createArrayUIdismissCB(string $button)
|
||||
|
||||
Reference in New Issue
Block a user