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:
nicola.candussi
2008-08-25 15:11:33 +00:00
parent 07b577fd86
commit d78a46fea2
82 changed files with 11691 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
#Dynamica Makefile
CPP = g++412
LD = ld
CPPFLAGS = -DBits64_ -m64 -DUNIX -D_BOOL -DLINUX -DFUNCPROTO -D_GNU_SOURCE -DLINUX_64 -fPIC \
-fno-strict-aliasing -DREQUIRE_IOSTREAM -Wno-deprecated -Wall \
-Wno-multichar -Wno-comment -Wno-sign-compare -funsigned-char \
-Wno-reorder -fno-gnu-keywords -ftemplate-depth-25 -pthread \
-Wno-deprecated -fno-gnu-keywords \
-g
LDFLAGS =-Wl,-Bsymbolic -shared
LIBRARY=dynamica.so
ifdef DISNEY
#inside Disney
CPPFLAGS += -DINSIDE_DISNEY
MAYA_PLUG_IN_PATH=/tmp
BULLET=$(RP_bullet)
BULLET_INCLUDE=-I$(BULLET)/include
BULLET_LIB=-L$(BULLET)/lib \
-lGIMPACT -lGIMPACTUtils -lbulletdynamics \
-lbulletmath -lbulletcollision
GL_INCLUDE=-I$(RP_glut)/include -I$(RP_glew)/include
GL_LIB=-L$(RP_glut)/lib -L$(RP_glew)/lib -lGL -lGLU -lglut -lGLEW
else
#Nicola's
MAYA_PLUG_IN_PATH=/usr/maya-plugins
BULLET=/usr/bullet-2.70
BULLET_INCLUDE=-I$(BULLET)/src -I$(BULLET)/Extras/GIMPACT/include
BULLET_LIB=-L$(BULLET)/out/linux/optimize/libs \
-lGIMPACT -lGIMPACTUtils -lbulletdynamics \
-lbulletmath -lbulletcollision -lbulletopenglsupport
GL_LIB=-lGL -lGLU -lglut -lGLEW
endif
MAYA=$(MAYA_LOCATION)
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
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 \
bt_box_shape.h collision_shape_impl.h mayaUtils.h solver.h \
bt_collision_shape.h collisionShapeNode.h mesh_shape.h solver_impl.h \
bt_convex_hull_shape.h convex_hull_shape.h mesh_shape_impl.h sphere_shape.h \
bt_mesh_shape.h convex_hull_shape_impl.h plane_shape.h sphere_shape_impl.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
INCLUDE_FLAGS= $(GL_INCLUDE) $(BULLET_INCLUDE) $(MAYA_INCLUDE)
LIB_FLAGS=$(BULLET_LIB) $(MAYA_LIB) $(GL_LIB)
OBJECTS=$(SOURCES:.cpp=.o)
all: $(SOURCES) $(LIBRARY)
.cpp.o: $(SOURCES) $(HEADERS)
$(CPP) -c $< $(CPPFLAGS) $(INCLUDE_FLAGS) -o $@
$(OBJECTS): $(HEADERS)
$(LIBRARY): $(OBJECTS)
$(CPP) $(OBJECTS) $(LDFLAGS) $(LIB_FLAGS) -o $@
install: $(LIBRARY)
cp -f $(LIBRARY) $(MAYA_PLUG_IN_PATH)
cp -f scripts/*.mel $(MAYA_PLUG_IN_PATH)
cp -f icons/*.xpm $(MAYA_PLUG_IN_PATH)
clean:
rm -f *.o *.so

View File

@@ -0,0 +1,44 @@
/*
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>
*/
//box_shape.h
#ifndef DYN_BOX_SHAPE_H
#define DYN_BOX_SHAPE_H
#include "collision_shape.h"
#include "box_shape_impl.h"
class box_shape_t: public collision_shape_t
{
public:
//typedefs
typedef shared_ptr<box_shape_t> pointer;
protected:
friend class solver_t;
box_shape_t(collision_shape_impl_t* impl): collision_shape_t(impl) { }
};
#endif

View File

@@ -0,0 +1,39 @@
/*
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>
*/
//box_shape_impl.h
#ifndef DYN_BOX_SHAPE_IMPL_H
#define DYN_BOX_SHAPE_IMPL_H
#include "collision_shape_impl.h"
class box_shape_impl_t: public collision_shape_impl_t
{
public:
//typedefs
private:
};
#endif

View File

@@ -0,0 +1,94 @@
/*
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>
*/
//bt_box_shape.h
#ifndef DYN_BT_BOX_SHAPE_H
#define DYN_BT_BOX_SHAPE_H
#include "box_shape_impl.h"
class bt_box_shape_t: public bt_collision_shape_t, public box_shape_impl_t
{
public:
virtual void gl_draw(size_t draw_style) {
btBoxShape *box_shape = static_cast<btBoxShape*>(shape());
btVector3 const& e = box_shape->getHalfExtentsWithoutMargin();
glPushMatrix();
glScalef(2 * e.x(), 2 * e.y(), 2 * e.z());
if(draw_style & collision_shape_t::kDSSolid) {
glutSolidCube(1.0);
} else {
glutWireCube(1.0);
}
glPopMatrix();
}
virtual void set_scale(vec3f const& s) {
const btVector3& scale = shape()->getLocalScaling();
if(scale.x() != s[0] || scale.y() != s[1] || scale.z() != s[2]) {
shape()->setLocalScaling(btVector3(s[0], s[1], s[2]));
update();
}
}
virtual void get_scale(vec3f& s) {
const btVector3& scale = shape()->getLocalScaling();
s = vec3f(scale.x(), scale.y(), scale.z());
}
virtual float volume() { return m_volume; }
virtual vec3f const& local_inertia() { return m_local_inertia; }
virtual vec3f const& center() { return m_center; }
virtual quatf const& rotation() { return m_rotation; }
protected:
friend class bt_solver_t;
bt_box_shape_t(vec3f const& halfExtents):
bt_collision_shape_t()
{
set_shape(new btBoxShape(btVector3(halfExtents[0], halfExtents[0], halfExtents[0])));
update();
}
void update()
{
btBoxShape *box_shape = static_cast<btBoxShape*>(shape());
btVector3 e = 2 * box_shape->getHalfExtentsWithoutMargin();
m_volume = e.x() * e.y() * e.z();
m_center = vec3f(0, 0, 0);
m_rotation = qidentity<float>();
m_local_inertia = vec3f((e.y() * e.y() + e.z() * e.z()) / 12.0f,
(e.x() * e.x() + e.z() * e.z()) / 12.0f,
(e.x() * e.x() + e.y() * e.y()) / 12.0f);
}
private:
float m_volume;
vec3f m_center;
quatf m_rotation;
vec3f m_local_inertia;
};
#endif

View File

@@ -0,0 +1,51 @@
/*
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>
*/
//bt_collision_shape.h
#ifndef DYN_BT_COLLISION_SHAPE_H
#define DYN_BT_COLLISION_SHAPE_H
#include "btBulletCollisionCommon.h"
#include "btBulletDynamicsCommon.h"
class bt_collision_shape_t
{
public:
protected:
friend class bt_solver_t;
bt_collision_shape_t() { }
btCollisionShape* shape() { return m_shape.get(); }
void set_shape(btCollisionShape *shape) { return m_shape.reset(shape); }
public:
friend class bt_rigid_body_t;
virtual ~bt_collision_shape_t() { }
private:
shared_ptr<btCollisionShape> m_shape;
};
#endif

View File

@@ -0,0 +1,138 @@
/*
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>
*/
//bt_convex_hull_shape.h
#ifndef DYN_BT_CONVEX_HULL_SHAPE_H
#define DYN_BT_CONVEX_HULL_SHAPE_H
#include <vector>
#include "convex_hull_shape_impl.h"
#include "bt_collision_shape.h"
class bt_convex_hull_shape_t: public bt_collision_shape_t, public convex_hull_shape_impl_t
{
public:
virtual void gl_draw(size_t draw_style) {
if(m_vertices.empty() || m_indices.empty()) return;
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if(draw_style & collision_shape_t::kDSSolid) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
} else {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
glVertexPointer(3, GL_FLOAT, 0, &(m_vertices[0]));
glNormalPointer(GL_FLOAT, 0, &(m_normals[0]));
glDrawElements(GL_TRIANGLES, m_indices.size(), GL_UNSIGNED_INT, &(m_indices[0]));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
virtual void set_scale(vec3f const& s) {
shape()->setLocalScaling(btVector3(s[0], s[1], s[2]));
update();
}
virtual void get_scale(vec3f& s) {
const btVector3& scale = shape()->getLocalScaling();
s = vec3f(scale.x(), scale.y(), scale.z());
}
virtual float volume() { return m_volume; }
virtual vec3f const& local_inertia() { return m_local_inertia; }
virtual vec3f const& center() { return m_center; }
virtual quatf const& rotation() { return m_rotation; }
protected:
friend class bt_solver_t;
bt_convex_hull_shape_t(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices):
bt_collision_shape_t(),
m_normals(normals, normals + num_vertices),
m_indices(indices, indices + num_indices)
{
m_volume = ::volume(vertices, (int*)indices, num_indices);
m_center = center_of_mass(vertices, (int*)indices, num_indices);
mat3x3f I = inertia(vertices, (int*)indices, num_indices, m_center);
m_rotation = diagonalizer(I);
mat3x3f Q, Qinv;
q_to_mat(m_rotation, Q);
q_to_mat(qconj(m_rotation), Qinv);
//D = trans(Q) * I * Q;
m_local_inertia = diag(prod(trans(Q), mat3x3f(prod(I, Q))));
m_vertices.resize(num_vertices);
for(size_t i = 0; i < m_vertices.size(); ++i) {
m_vertices[i] = prod(Qinv, vertices[i] - m_center);
}
set_shape(new btConvexHullShape((float const*)&(m_vertices[0]), num_vertices, sizeof(vec3f)));
}
void update()
{
btConvexHullShape *cu_shape = static_cast<btConvexHullShape*>(shape());
//apply the scaling
btVector3 const& scale = cu_shape->getLocalScaling();
btPoint3 const* points = cu_shape->getPoints();
for(int i = 0; i < cu_shape->getNumPoints(); ++i) {
m_vertices[i] = vec3f(scale.x() * points[i].x(), scale.y() * points[i].y(), scale.z() * points[i].z());
}
m_volume = ::volume(&(m_vertices[0]), (int*)&(m_indices[0]), m_indices.size());
mat3x3f I = inertia(&(m_vertices[0]), (int*)&(m_indices[0]), (int)m_indices.size(), vec3f(0, 0, 0));
//std::cout << I << std::endl;
//m_rotation = diagonalizer(I);
//std::cout << rotation << std::endl;
//the rotation shouldn't change from scaling
mat3x3f Q, Qinv;
q_to_mat(m_rotation, Q);
q_to_mat(qconj(m_rotation), Qinv);
//D = Q * I * trans(Q);
m_local_inertia = diag(prod(trans(Q), mat3x3f(prod(I, Q))));
}
private:
std::vector<vec3f> m_vertices;
std::vector<vec3f> m_normals;
std::vector<unsigned int> m_indices;
float m_volume;
vec3f m_center;
quatf m_rotation;
vec3f m_local_inertia;
};
#endif

View File

@@ -0,0 +1,154 @@
/*
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>
*/
//bt_mesh_shape.h
#ifndef DYN_BT_MESH_SHAPE_H
#define DYN_BT_MESH_SHAPE_H
#include <vector>
#include <iterator>
#include "mesh_shape_impl.h"
#include "bt_collision_shape.h"
class bt_mesh_shape_t: public bt_collision_shape_t, public mesh_shape_impl_t
{
public:
virtual void gl_draw(size_t draw_style) {
if(m_vertices.empty() || m_indices.empty()) return;
btVector3 const& scale = shape()->getLocalScaling();
glPushMatrix();
//glTranslatef(m_center[0], m_center[1], m_center[2]);
glScalef(scale.x(), scale.y(), scale.z());
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if(draw_style & collision_shape_t::kDSSolid) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
} else {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
glVertexPointer(3, GL_FLOAT, 0, &(m_vertices[0]));
glNormalPointer(GL_FLOAT, 0, &(m_normals[0]));
glDrawElements(GL_TRIANGLES, m_indices.size(), GL_UNSIGNED_INT, &(m_indices[0]));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glPopMatrix();
}
virtual void set_scale(vec3f const& s) {
btGImpactMeshShape *gi_shape = static_cast<btGImpactMeshShape*>(shape());
gi_shape->setLocalScaling(btVector3(s[0], s[1], s[2]));
gi_shape->updateBound();
update();
}
virtual void get_scale(vec3f& s) {
const btVector3& scale = shape()->getLocalScaling();
s = vec3f(scale.x(), scale.y(), scale.z());
}
virtual float volume() { return m_volume; }
virtual vec3f const& local_inertia() { return m_local_inertia; }
virtual vec3f const& center() { return m_center; }
virtual quatf const& rotation() { return m_rotation; }
protected:
friend class bt_solver_t;
bt_mesh_shape_t(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices):
bt_collision_shape_t(),
m_normals(normals, normals + num_vertices),
m_indices(indices, indices + num_indices)
{
m_volume = ::volume(vertices, (int*)indices, num_indices);
m_center = center_of_mass(vertices, (int*)indices, num_indices);
mat3x3f I = inertia(vertices, (int*)indices, num_indices, m_center);
m_rotation = diagonalizer(I);
mat3x3f Q, Qinv;
q_to_mat(m_rotation, Q);
q_to_mat(qconj(m_rotation), Qinv);
//D = trans(Q) * I * Q;
m_local_inertia = diag(prod(trans(Q), mat3x3f(prod(I, Q))));
m_vertices.resize(num_vertices);
for(size_t i = 0; i < m_vertices.size(); ++i) {
m_vertices[i] = prod(Qinv, vertices[i] - m_center);
}
m_tiva.reset(new btTriangleIndexVertexArray(num_indices / 3, (int*)&(m_indices[0]), 3 * sizeof(unsigned int),
num_vertices, (float*)&(m_vertices[0]), sizeof(vec3f)));
btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(m_tiva.get());
gimpactShape->setLocalScaling(btVector3(1.0f,1.0f,1.0f));
gimpactShape->updateBound();
set_shape(gimpactShape);
// gimpactShape->setMargin(0.05);
}
void update()
{
btGImpactMeshShape *gi_shape = static_cast<btGImpactMeshShape*>(shape());
//apply the scaling
btVector3 const& scale = gi_shape->getLocalScaling();
std::vector<vec3f> vertices(m_vertices.size());
for(int i = 0; i < vertices.size(); ++i) {
vertices[i] = vec3f(scale.x() * m_vertices[i][0], scale.y() * m_vertices[i][1], scale.z() * m_vertices[i][2]);
}
m_volume = ::volume(&(vertices[0]), (int*)&(m_indices[0]), (int)m_indices.size());
mat3x3f I = inertia(&(vertices[0]), (int*)&(m_indices[0]), (int)m_indices.size(), vec3f(0, 0, 0));
// std::cout << I << std::endl;
//m_rotation = diagonalizer(I);
//std::cout << rotation << std::endl;
//the rotation shouldn't change from scaling
mat3x3f Q, Qinv;
q_to_mat(m_rotation, Q);
q_to_mat(qconj(m_rotation), Qinv);
//D = Q * I * trans(Q);
m_local_inertia = diag(prod(trans(Q), mat3x3f(prod(I, Q))));
}
private:
std::vector<vec3f> m_vertices;
std::vector<vec3f> m_normals;
std::vector<unsigned int> m_indices;
shared_ptr<btTriangleIndexVertexArray> m_tiva;
float m_volume;
vec3f m_center;
quatf m_rotation;
vec3f m_local_inertia;
};
#endif

View File

@@ -0,0 +1,81 @@
/*
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>
*/
//bt_plane_shape.h
#ifndef DYN_BT_PLANE_SHAPE_H
#define DYN_BT_PLANE_SHAPE_H
#include "plane_shape_impl.h"
class bt_plane_shape_t: public bt_collision_shape_t, public plane_shape_impl_t
{
public:
virtual void gl_draw(size_t draw_style) {
// btStaticPlaneShape *plane_shape = static_cast<btStaticPlaneShape*>(shape());
glPushMatrix();
glScalef(100.0, 0.001, 100.0);
if(draw_style & collision_shape_t::kDSSolid) {
glutSolidCube(1.0);
} else {
glutWireCube(1.0);
}
glPopMatrix();
}
virtual void set_scale(vec3f const& s) {
shape()->setLocalScaling(btVector3(s[0], s[1], s[2]));
}
virtual void get_scale(vec3f& s) {
const btVector3& scale = shape()->getLocalScaling();
s = vec3f(scale.x(), scale.y(), scale.z());
}
virtual float volume() { return m_volume; }
virtual vec3f const& local_inertia() { return m_local_inertia; }
virtual vec3f const& center() { return m_center; }
virtual quatf const& rotation() { return m_rotation; }
protected:
friend class bt_solver_t;
bt_plane_shape_t(vec3f const& normal, float d):
bt_collision_shape_t(),
m_volume(0),
m_local_inertia(1, 1, 1),
m_center(0, 0, 0),
m_rotation(qidentity<float>())
{
set_shape(new btStaticPlaneShape(btVector3(normal[0], normal[1], normal[2]), d));
// shape()->setMargin(0.1);
}
private:
float m_volume;
vec3f m_center;
quatf m_rotation;
vec3f m_local_inertia;
};
#endif

View File

@@ -0,0 +1,194 @@
/*
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>
*/
//bt_rigid_body.h
#ifndef DYN_BT_RIGID_BODY_H
#define DYN_BT_RIGID_BODY_H
#include "shared_ptr.h"
#include "rigid_body_impl.h"
#include "bt_collision_shape.h"
class bt_rigid_body_t: public rigid_body_impl_t {
public:
virtual void get_transform(mat4x4f &xform) const
{
float m[16];
m_body->getWorldTransform().getOpenGLMatrix(m);
xform = trans(cmat<float, 4, 4>(m));
}
virtual void get_transform(vec3f &position, quatf &rotation) const
{
const btTransform& btxform = m_body->getWorldTransform();
btQuaternion q = btxform.getRotation();
btVector3 p = btxform.getOrigin();
// position = vec3f(p.x(), p.y(), p.z()) - m_collision_shape->center();
position = vec3f(p.x(), p.y(), p.z());
//rotation = qprod(quatf(q.w(), q.x(), q.y(), q.z()), qconj(m_collision_shape->rotation()));
rotation = quatf(q.w(), q.x(), q.y(), q.z());
}
virtual void set_transform(vec3f const &position, quatf const &rotation)
{
// vec3f tp = position + m_collision_shape->center();
vec3f tp = position;
// quatf tr = qprod(rotation, m_collision_shape->rotation());
quatf tr = rotation;
// std::cout << "----------" << std::endl;
// std::cout << rotation << std::endl;
// std::cout << m_collision_shape->rotation() << std::endl;
btTransform xform(btQuaternion(tr[1], tr[2], tr[3], tr[0]),
btVector3(tp[0], tp[1], tp[2]));
m_body->setWorldTransform(xform);
}
virtual void set_kinematic(bool kinematic)
{
if(kinematic) {
m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
m_body->setActivationState(DISABLE_DEACTIVATION);
m_body->setMassProps(0, btVector3(0.0,0.0,0.0));
m_body->updateInertiaTensor();
} else {
m_body->setCollisionFlags(m_body->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
m_body->setActivationState(ACTIVE_TAG);
m_body->setMassProps(m_mass, m_inertia);
m_body->updateInertiaTensor();
}
}
virtual void set_mass(float mass)
{
// std::cout << "bt_rigid_body::set_mass: " << mass << std::endl;
m_mass = mass;
if(m_body->getCollisionFlags() & btCollisionObject::CF_KINEMATIC_OBJECT) {
m_body->setMassProps(0, btVector3(0,0,0));
} else {
m_body->setMassProps(m_mass, m_inertia);
}
m_body->updateInertiaTensor();
}
virtual void set_inertia(vec3f const& I)
{
m_inertia = btVector3(I[0], I[1], I[2]);
if(m_body->getCollisionFlags() & btCollisionObject::CF_KINEMATIC_OBJECT) {
m_body->setMassProps(0, btVector3(0,0,0));
} else {
m_body->setMassProps(m_mass, m_inertia);
}
m_body->updateInertiaTensor();
}
virtual void set_restitution(float r)
{
// std::cout << r << std::endl;
m_body->setRestitution(r);
}
virtual void set_friction(float f)
{
m_body->setFriction(f);
}
virtual void set_linear_damping(float d)
{
m_linear_damping = d;
m_body->setDamping(m_linear_damping, m_angular_damping);
}
virtual void set_angular_damping(float d)
{
m_angular_damping = d;
m_body->setDamping(m_linear_damping, m_angular_damping);
}
virtual void set_linear_velocity(vec3f const& v)
{
m_body->setLinearVelocity(btVector3(v[0], v[1], v[2]));
}
virtual void get_linear_velocity(vec3f& v) const
{
const btVector3 &val = m_body->getLinearVelocity();
v = vec3f(val.x(), val.y(), val.z());
}
virtual void set_angular_velocity(vec3f const& v)
{
m_body->setAngularVelocity(btVector3(v[0], v[1], v[2]));
}
virtual void get_angular_velocity(vec3f& v) const
{
const btVector3 &val = m_body->getAngularVelocity();
v = vec3f(val.x(), val.y(), val.z());
}
virtual void clear_forces()
{
m_body->clearForces();
}
virtual void apply_central_force(vec3f const& f)
{
m_body->applyCentralForce(btVector3(f[0], f[1], f[2]));
}
virtual void apply_torque(vec3f const& t)
{
m_body->applyTorque(btVector3(t[0], t[1], t[2]));
}
btRigidBody* body() { return m_body.get(); }
protected:
friend class bt_solver_t;
bt_rigid_body_t(collision_shape_impl_t* cs):
m_collision_shape(cs),
m_mass(1),
m_inertia(2.0/5.0, 2.0/5.0, 2.0/5.0),
m_linear_damping(0),
m_angular_damping(0)
{
bt_collision_shape_t* bt_shape = dynamic_cast<bt_collision_shape_t*>(cs);
btRigidBody::btRigidBodyConstructionInfo rbInfo(m_mass, NULL, bt_shape->shape(), m_inertia);
rbInfo.m_restitution = 0;
rbInfo.m_friction = 0.1;
rbInfo.m_linearDamping = m_linear_damping;
rbInfo.m_angularDamping = m_angular_damping;
m_body.reset(new btRigidBody(rbInfo));
}
private:
shared_ptr<btRigidBody> m_body;
collision_shape_impl_t* m_collision_shape;
float m_mass;
btVector3 m_inertia;
float m_linear_damping;
float m_angular_damping;
};
#endif

View File

@@ -0,0 +1,48 @@
/*
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>
*/
//bt_solver.cpp
#include "bt_solver.h"
btVector3 worldAabbMin(-10000, -10000, -10000);
btVector3 worldAabbMax(10000, 10000, 10000);
int maxProxies = 32000;
bt_solver_t::bt_solver_t():
m_broadphase(new btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies)),
m_solver(new btSequentialImpulseConstraintSolver),
m_collisionConfiguration(new btDefaultCollisionConfiguration),
m_dispatcher(new btCollisionDispatcher(m_collisionConfiguration.get())),
m_dynamicsWorld(new btDiscreteDynamicsWorld(m_dispatcher.get(),
m_broadphase.get(),
m_solver.get(),
m_collisionConfiguration.get()))
{
//register algorithm for concave meshes
btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher.get());
m_dynamicsWorld->setGravity(btVector3(0, -9.81, 0));
// m_dynamicsWorld->getSolverInfo().m_splitImpulse = true;
}

View File

@@ -0,0 +1,114 @@
/*
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>
*/
//bt_solver.h
#ifndef DYN_BT_SOLVER_H
#define DYN_BT_SOLVER_H
#include "btBulletCollisionCommon.h"
#include "btBulletDynamicsCommon.h"
#include "GIMPACT/Bullet/btGImpactShape.h"
#include "GIMPACT/Bullet/btGImpactCollisionAlgorithm.h"
#include "solver_impl.h"
#include "bt_rigid_body.h"
#include "bt_sphere_shape.h"
#include "bt_plane_shape.h"
#include "bt_box_shape.h"
#include "bt_convex_hull_shape.h"
#include "bt_mesh_shape.h"
class bt_solver_t: public solver_impl_t
{
public:
virtual rigid_body_impl_t* create_rigid_body(collision_shape_impl_t* cs) {
return new bt_rigid_body_t(cs);
}
virtual collision_shape_impl_t* create_sphere_shape(float radius) {
return new bt_sphere_shape_t(radius);
}
virtual collision_shape_impl_t* create_plane_shape(vec3f const& normal, float d) {
return new bt_plane_shape_t(normal, d);
}
virtual collision_shape_impl_t* create_box_shape(vec3f const& halfExtents) {
return new bt_box_shape_t(halfExtents);
}
virtual collision_shape_impl_t* create_convex_hull_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices)
{
return new bt_convex_hull_shape_t(vertices, num_vertices, normals, indices, num_indices);
}
virtual collision_shape_impl_t* create_mesh_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices)
{
return new bt_mesh_shape_t(vertices, num_vertices, normals, indices, num_indices);
}
virtual void add_rigid_body(rigid_body_impl_t* rb)
{
bt_rigid_body_t* bt_body = static_cast<bt_rigid_body_t*>(rb);
m_dynamicsWorld->addRigidBody(bt_body->body());
}
virtual void remove_rigid_body(rigid_body_impl_t* rb)
{
bt_rigid_body_t* bt_body = static_cast<bt_rigid_body_t*>(rb);
m_dynamicsWorld->removeRigidBody(bt_body->body());
}
virtual void set_gravity(vec3f const& g)
{
m_dynamicsWorld->setGravity(btVector3(g[0], g[1], g[2]));
}
virtual void set_split_impulse(bool enabled)
{
m_dynamicsWorld->getSolverInfo().m_splitImpulse = enabled;
}
virtual void step_simulation(float dt)
{
m_dynamicsWorld->stepSimulation(dt, 1000, 1.0 / 120.0);
}
protected:
friend class solver_t;
bt_solver_t();
private:
shared_ptr<btBroadphaseInterface> m_broadphase;
shared_ptr<btConstraintSolver> m_solver;
shared_ptr<btDefaultCollisionConfiguration> m_collisionConfiguration;
shared_ptr<btCollisionDispatcher> m_dispatcher;
shared_ptr<btDiscreteDynamicsWorld> m_dynamicsWorld;
};
#endif

View File

@@ -0,0 +1,92 @@
/*
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>
*/
//bt_sphere_shape.h
#ifndef DYN_BT_SPHERE_SHAPE_H
#define DYN_BT_SPHERE_SHAPE_H
#include <GL/glut.h>
#include "sphere_shape_impl.h"
#include "bt_collision_shape.h"
#include "collision_shape.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());
if(draw_style & collision_shape_t::kDSSolid) {
glutSolidSphere(sphere_shape->getRadius(), 10, 10);
} else {
glutWireSphere(sphere_shape->getRadius(), 10, 10);
}
}
virtual void set_scale(vec3f const& s) {
shape()->setLocalScaling(btVector3(s[0], s[1], s[2]));
update();
}
virtual void get_scale(vec3f& s) {
const btVector3& scale = shape()->getLocalScaling();
s = vec3f(scale.x(), scale.y(), scale.z());
}
virtual float volume() { return m_volume; }
virtual vec3f const& local_inertia() { return m_local_inertia; }
virtual vec3f const& center() { return m_center; }
virtual quatf const& rotation() { return m_rotation; }
protected:
friend class bt_solver_t;
bt_sphere_shape_t(float radius):
bt_collision_shape_t()
{
set_shape(new btSphereShape(radius));
// shape()->setMargin(0.1);
update();
}
void update()
{
btSphereShape *sphere_shape = static_cast<btSphereShape*>(shape());
float radius = sphere_shape->getRadius();
m_volume = (4.0 * 3.1415926 * radius * radius * radius) / 3.0;
m_center = vec3f(0, 0, 0);
m_rotation = qidentity<float>();
m_local_inertia = vec3f(2.0 / 5.0 * radius * radius,
2.0 / 5.0 * radius * radius,
2.0 / 5.0 * radius * radius);
}
private:
float m_volume;
vec3f m_center;
quatf m_rotation;
vec3f m_local_inertia;
};
#endif

View File

@@ -0,0 +1,326 @@
/*
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>
*/
//collisionShapeNode.cpp
#include <GL/glut.h>
#include <maya/MFnMessageAttribute.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnEnumAttribute.h>
#include <maya/MPlugArray.h>
#include <maya/MFloatPointArray.h>
#include <maya/MFloatVectorArray.h>
#include <maya/MIntArray.h>
#include <maya/MFnMesh.h>
#include <maya/MDagPath.h>
#include <iterator>
#include <vector>
#include <assert.h>
#include "collisionShapeNode.h"
#include "mayaUtils.h"
#include "solver.h"
MTypeId collisionShapeNode::typeId( 0x100307 );
MString collisionShapeNode::typeName( "dCollisionShape" );
MObject collisionShapeNode::ia_shape;
MObject collisionShapeNode::ia_type;
MObject collisionShapeNode::ia_scale;
MObject collisionShapeNode::ca_collisionShape;
MObject collisionShapeNode::ca_collisionShapeParam;
MObject collisionShapeNode::oa_collisionShape;
MStatus collisionShapeNode::initialize()
{
MStatus status;
MFnMessageAttribute fnMsgAttr;
MFnNumericAttribute fnNumericAttr;
MFnEnumAttribute fnEnumAttr;
ia_type = fnEnumAttr.create("type", "tp", 5, &status);
MCHECKSTATUS(status, "creating type attribute")
fnEnumAttr.addField("Convex Hull", 0);
fnEnumAttr.addField("Mesh", 1);
fnEnumAttr.addField("Cylinder", 2);
fnEnumAttr.addField("Capsule", 3);
fnEnumAttr.addField("Box", 4);
fnEnumAttr.addField("Sphere", 5);
fnEnumAttr.addField("Plane", 6);
fnEnumAttr.setKeyable(true);
status = addAttribute(ia_type);
MCHECKSTATUS(status, "adding type attribute")
ia_scale = fnNumericAttr.createPoint("scale", "sc", &status);
MCHECKSTATUS(status, "creating ia_scale attribute")
fnNumericAttr.setDefault(1.0, 1.0, 1.0);
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_scale);
MCHECKSTATUS(status, "adding ia_scale attribute")
oa_collisionShape = fnMsgAttr.create("outCollisionShape", "oucs", &status);
MCHECKSTATUS(status, "creating outCollisionShape attribute")
status = addAttribute(oa_collisionShape);
MCHECKSTATUS(status, "adding outCollisionShape attribute")
ia_shape = fnMsgAttr.create("inShape", "insh", &status);
MCHECKSTATUS(status, "creating inShape attribute")
status = addAttribute(ia_shape);
MCHECKSTATUS(status, "adding inShape attribute")
ca_collisionShape = fnNumericAttr.create("ca_collisionShape", "ccs", MFnNumericData::kBoolean, 0, &status);
MCHECKSTATUS(status, "creating ca_collisionShape attribute")
fnNumericAttr.setConnectable(false);
fnNumericAttr.setHidden(true);
fnNumericAttr.setStorable(false);
fnNumericAttr.setKeyable(false);
status = addAttribute(ca_collisionShape);
MCHECKSTATUS(status, "adding ca_collisionShape attribute")
ca_collisionShapeParam = fnNumericAttr.create("collisionShapeParam", "cspm", MFnNumericData::kBoolean, 0, &status);
MCHECKSTATUS(status, "creating ca_collisionShapeParam attribute")
fnNumericAttr.setConnectable(false);
fnNumericAttr.setHidden(true);
fnNumericAttr.setStorable(false);
fnNumericAttr.setKeyable(false);
status = addAttribute(ca_collisionShapeParam);
MCHECKSTATUS(status, "adding ca_collisionShapeParam attribute")
//
status = attributeAffects(ia_shape, oa_collisionShape);
MCHECKSTATUS(status, "adding attributeAffects(ia_shape, oa_collisionShape)")
status = attributeAffects(ia_type, oa_collisionShape);
MCHECKSTATUS(status, "adding attributeAffects(ia_type, oa_collisionShape)")
status = attributeAffects(ia_scale, oa_collisionShape);
MCHECKSTATUS(status, "adding attributeAffects(ia_scale, oa_collisionShape)")
//
status = attributeAffects(ia_shape, ca_collisionShape);
MCHECKSTATUS(status, "adding attributeAffects(ia_shape, ca_collisionShape)")
status = attributeAffects(ia_type, ca_collisionShape);
MCHECKSTATUS(status, "adding attributeAffects(ia_shape, ca_collisionShape)")
//
status = attributeAffects(ia_shape, ca_collisionShapeParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_shape, oa_collisionShapeParam)")
status = attributeAffects(ia_scale, ca_collisionShapeParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_scale, oa_collisionShapeParam)")
status = attributeAffects(ia_type, ca_collisionShapeParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_type, oa_collisionShapeParam)")
return MS::kSuccess;
}
collisionShapeNode::collisionShapeNode()
{
// std::cout << "collisionShapeNode::collisionShapeNode" << std::endl;
}
collisionShapeNode::~collisionShapeNode()
{
// std::cout << "collisionShapeNode::~collisionShapeNode" << std::endl;
}
void* collisionShapeNode::creator()
{
return new collisionShapeNode();
}
bool collisionShapeNode::setInternalValueInContext ( const MPlug & plug,
const MDataHandle & dataHandle,
MDGContext & ctx)
{
return false; //setInternalValueInContext(plug,dataHandle,ctx);
}
MStatus collisionShapeNode::compute( const MPlug& plug, MDataBlock& data )
{
if(plug == oa_collisionShape) {
computeOutputShape(plug, data);
} else if(plug == ca_collisionShape) {
computeCollisionShape(plug, data);
} else if(plug == ca_collisionShapeParam) {
computeCollisionShapeParam(plug, data);
} else {
return MStatus::kUnknownParameter;
}
return MStatus::kSuccess;
}
collision_shape_t::pointer collisionShapeNode::collisionShape()
{
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, oa_collisionShape).getValue(update);
MPlug(thisObject, ca_collisionShapeParam).getValue(update);
return m_collision_shape;
}
void collisionShapeNode::computeCollisionShape(const MPlug& plug, MDataBlock& data)
{
// std::cout << "collisionShapeNode::computeCollisionShape" << std::endl;
MObject thisObject(thisMObject());
MPlug plgInShape(thisObject, ia_shape);
MPlug plgType(thisObject, ia_type);
int type;
plgType.getValue(type);
switch(type) {
case 0:
{
//convex hull
MPlugArray plgaConnectedTo;
plgInShape.connectedTo(plgaConnectedTo, true, true);
if(plgaConnectedTo.length() > 0) {
MObject node = plgaConnectedTo[0].node();
if(node.hasFn(MFn::kMesh)) {
MDagPath dagPath;
MDagPath::getAPathTo(node, dagPath);
MFnMesh fnMesh(dagPath);
MFloatPointArray mpoints;
MFloatVectorArray mnormals;
MIntArray mtrianglecounts;
MIntArray mtrianglevertices;
fnMesh.getPoints(mpoints, MSpace::kWorld);
fnMesh.getNormals(mnormals, MSpace::kWorld);
fnMesh.getTriangles(mtrianglecounts, mtrianglevertices);
std::vector<vec3f> vertices(mpoints.length());
std::vector<vec3f> normals(mpoints.length());
std::vector<unsigned int> indices(mtrianglevertices.length());
for(size_t i = 0; i < vertices.size(); ++i) {
vertices[i] = vec3f(mpoints[i].x, mpoints[i].y, mpoints[i].z);
normals[i] = vec3f(mnormals[i].x, mnormals[i].y, mnormals[i].z);
}
for(size_t i = 0; i < indices.size(); ++i) {
indices[i] = mtrianglevertices[i];
}
m_collision_shape = solver_t::create_convex_hull_shape(&(vertices[0]), vertices.size(), &(normals[0]),
&(indices[0]), indices.size());
}
}
}
break;
case 1:
//mesh
{
//convex hull
MPlugArray plgaConnectedTo;
plgInShape.connectedTo(plgaConnectedTo, true, true);
if(plgaConnectedTo.length() > 0) {
MObject node = plgaConnectedTo[0].node();
if(node.hasFn(MFn::kMesh)) {
MDagPath dagPath;
MDagPath::getAPathTo(node, dagPath);
MFnMesh fnMesh(dagPath);
MFloatPointArray mpoints;
MFloatVectorArray mnormals;
MIntArray mtrianglecounts;
MIntArray mtrianglevertices;
fnMesh.getPoints(mpoints, MSpace::kWorld);
fnMesh.getNormals(mnormals, MSpace::kWorld);
fnMesh.getTriangles(mtrianglecounts, mtrianglevertices);
std::vector<vec3f> vertices(mpoints.length());
std::vector<vec3f> normals(mpoints.length());
std::vector<unsigned int> indices(mtrianglevertices.length());
for(size_t i = 0; i < vertices.size(); ++i) {
vertices[i] = vec3f(mpoints[i].x, mpoints[i].y, mpoints[i].z);
normals[i] = vec3f(mnormals[i].x, mnormals[i].y, mnormals[i].z);
}
for(size_t i = 0; i < indices.size(); ++i) {
indices[i] = mtrianglevertices[i];
}
m_collision_shape = solver_t::create_mesh_shape(&(vertices[0]), vertices.size(), &(normals[0]),
&(indices[0]), indices.size());
}
}
}
break;
case 2:
//cylinder
break;
case 3:
//capsule
break;
case 4:
//box
m_collision_shape = solver_t::create_box_shape();
break;
case 5:
//sphere
m_collision_shape = solver_t::create_sphere_shape();
break;
case 6:
//plane
m_collision_shape = solver_t::create_plane_shape();
break;
}
assert(m_collision_shape);
data.setClean(plug);
}
void collisionShapeNode::computeCollisionShapeParam(const MPlug& plug, MDataBlock& data)
{
// std::cout << "collisionShapeNode::computeCollisionShapeParam" << std::endl;
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ia_shape).getValue(update);
MPlug(thisObject, ia_type).getValue(update);
float3& scale = data.inputValue(ia_scale).asFloat3();
m_collision_shape->set_scale(vec3f(scale[0], scale[1], scale[2]));
data.setClean(plug);
}
void collisionShapeNode::computeOutputShape(const MPlug& plug, MDataBlock& data)
{
// std::cout << "collisionShapeNode::computeOutputShape" << std::endl;
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ca_collisionShape).getValue(update);
MPlug(thisObject, ca_collisionShapeParam).getValue(update);
data.setClean(plug);
}

View File

@@ -0,0 +1,80 @@
/*
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>
*/
//collisionShapeNode.h
#ifndef DYN_COLLISION_SHAPE_NODE_H
#define DYN_COLLISION_SHAPE_NODE_H
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPxNode.h>
#include "collision_shape.h"
class collisionShapeNode: public MPxNode
{
public:
collisionShapeNode();
virtual ~collisionShapeNode();
virtual bool setInternalValueInContext ( const MPlug & plug,
const MDataHandle & dataHandle,
MDGContext & ctx);
virtual MStatus compute( const MPlug& plug, MDataBlock& data );
static void * creator();
static MStatus initialize();
public:
collision_shape_t::pointer collisionShape();
public:
//Attributes
static MObject ia_shape;
static MObject ia_type;
static MObject ia_scale;
static MObject ca_collisionShape;
static MObject ca_collisionShapeParam;
static MObject oa_collisionShape;
public:
static MTypeId typeId;
static MString typeName;
protected:
void computeCollisionShape(const MPlug& plug, MDataBlock& data);
void computeCollisionShapeParam(const MPlug& plug, MDataBlock& data);
void computeOutputShape(const MPlug& plug, MDataBlock& data);
private:
collision_shape_t::pointer m_collision_shape;
};
#endif

View File

@@ -0,0 +1,68 @@
/*
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>
*/
//collision_shape.h
#ifndef DYN_COLLISION_SHAPE_H
#define DYN_COLLISION_SHAPE_H
#include "shared_ptr.h"
#include "collision_shape_impl.h"
class collision_shape_t
{
public:
//typedefs
typedef shared_ptr<collision_shape_t> pointer;
//enums
enum DrawStyle {
kDSWireframe = 0x0001,
kDSSolid = 0x0002
};
virtual void gl_draw(size_t draw_style = kDSSolid) { m_impl->gl_draw(draw_style); }
virtual void set_scale(vec3f const& s) { m_impl->set_scale(s); }
virtual void get_scale(vec3f& s) { m_impl->get_scale(s); }
virtual float volume() { return m_impl->volume(); }
//for the inertia is assumed that the mass is 1.0. just multiply by the mass
virtual vec3f const& local_inertia() { return m_impl->local_inertia(); }
virtual vec3f const& center() { return m_impl->center(); }
virtual quatf const& rotation() { return m_impl->rotation(); }
public:
virtual ~collision_shape_t() {}
protected:
friend class solver_t;
collision_shape_t(collision_shape_impl_t* impl): m_impl(impl) { }
collision_shape_impl_t* impl() { return m_impl.get(); }
private:
shared_ptr<collision_shape_impl_t> m_impl;
};
#endif

View File

@@ -0,0 +1,49 @@
/*
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>
*/
//collision_shape_impl.h
#ifndef DYN_COLLISION_SHAPE_IMPL_H
#define DYN_COLLISION_SHAPE_IMPL_H
#include "shared_ptr.h"
#include "mathUtils.h"
class collision_shape_impl_t
{
public:
//
virtual void gl_draw(size_t draw_style) = 0;
virtual void set_scale(vec3f const& s) = 0;
virtual void get_scale(vec3f& s) = 0;
virtual float volume() = 0;
virtual vec3f const& local_inertia() = 0;
virtual vec3f const& center() = 0;
virtual quatf const& rotation() = 0;
public:
virtual ~collision_shape_impl_t() {};
};
#endif

View File

@@ -0,0 +1,44 @@
/*
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>
*/
//convex_hull_shape.h
#ifndef DYN_CONVEX_HULL_SHAPE_H
#define DYN_CONVEX_HULL_SHAPE_H
#include "collision_shape.h"
#include "collision_shape_impl.h"
class convex_hull_shape_t: public collision_shape_t
{
public:
//typedefs
typedef shared_ptr<convex_hull_shape_t> pointer;
protected:
friend class solver_t;
convex_hull_shape_t(collision_shape_impl_t* impl): collision_shape_t(impl) { }
};
#endif

View File

@@ -0,0 +1,39 @@
/*
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>
*/
//convex_hull_shape_impl.h
#ifndef DYN_CONVEX_HULL_SHAPE_IMPL_H
#define DYN_CONVEX_HULL_SHAPE_IMPL_H
#include "collision_shape_impl.h"
class convex_hull_shape_impl_t: public collision_shape_impl_t
{
public:
//typedefs
private:
};
#endif

View File

@@ -0,0 +1,147 @@
/*
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>
*/
//dRigidBodyArrayCmd.cpp
#include <maya/MGlobal.h>
#include <maya/MItDependencyNodes.h>
#include <maya/MSyntax.h>
#include "rigidBodyArrayNode.h"
#include "dRigidBodyArrayCmd.h"
MString dRigidBodyArrayCmd::typeName("dRigidBodyArray");
dRigidBodyArrayCmd::dRigidBodyArrayCmd()
: m_argDatabase(0),
m_dagModifier(0)
{
}
dRigidBodyArrayCmd::~dRigidBodyArrayCmd()
{
if (m_argDatabase) {
delete m_argDatabase;
}
if (m_dagModifier) {
delete m_dagModifier;
}
}
void *
dRigidBodyArrayCmd::creator()
{
return new dRigidBodyArrayCmd;
}
MSyntax
dRigidBodyArrayCmd::syntax()
{
MSyntax syntax;
syntax.enableQuery(false);
syntax.enableEdit(false);
syntax.addFlag("-n", "-name", MSyntax::kString);
// syntax.addFlag("-fn", "-filename", MSyntax::kString);
// syntax.addFlag("-col", "-color", MSyntax::kString);
// syntax.addFlag("-dia", "-diameter", MSyntax::kDouble);
return syntax;
}
MStatus
dRigidBodyArrayCmd::doIt(const MArgList &args)
{
MStatus stat;
m_argDatabase = new MArgDatabase(syntax(), args, &stat);
if (stat == MS::kFailure) {
return stat;
}
return redoIt();
}
MStatus
dRigidBodyArrayCmd::undoIt()
{
MGlobal::setActiveSelectionList(m_undoSelectionList);
if (m_dagModifier) {
m_dagModifier->undoIt();
delete m_dagModifier;
m_dagModifier = 0;
}
return MS::kSuccess;
}
MStatus
dRigidBodyArrayCmd::redoIt()
{
MGlobal::getActiveSelectionList(m_undoSelectionList);
MString name;
if (m_argDatabase->isFlagSet("-name")) {
m_argDatabase->getFlagArgument("-name", 0, name);
}
if (!name.length()) {
name = "dRigidBodyArray";
}
m_dagModifier = new MDagModifier;
MObject parentObj = m_dagModifier->createNode("transform");
m_dagModifier->renameNode(parentObj, name + "#");
m_dagModifier->doIt();
MObject dRigidBodyArrayObj = m_dagModifier->createNode(rigidBodyArrayNode::typeId, parentObj);
std::string dRigidBodyArrayName = MFnDependencyNode(parentObj).name().asChar();
std::string::size_type pos = dRigidBodyArrayName.find_last_not_of("0123456789");
dRigidBodyArrayName.insert(pos + 1, "Shape");
m_dagModifier->renameNode(dRigidBodyArrayObj, dRigidBodyArrayName.c_str());
m_dagModifier->doIt();
// connect the solver attribute
MPlug plgSolver(dRigidBodyArrayObj, rigidBodyArrayNode::ia_solver);
MSelectionList slist;
slist.add("dSolver1");
MObject solverObj;
if(slist.length() != 0) {
slist.getDependNode(0, solverObj);
MPlug plgRigidBodies = MFnDependencyNode(solverObj).findPlug("rigidBodies", false);
m_dagModifier->connect(plgRigidBodies, plgSolver);
m_dagModifier->doIt();
}
MGlobal::select(parentObj, MGlobal::kReplaceList);
setResult(MFnDependencyNode(dRigidBodyArrayObj).name());
return MS::kSuccess;
}

View File

@@ -0,0 +1,58 @@
/*
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>
*/
//dRigidBodyArrayCmd.h
#ifndef DYN_DRIGIDBODYARRAYCMD_H
#define DYN_DRIGIDBODYARRAYCMD_H
#include <maya/MArgDatabase.h>
#include <maya/MDagModifier.h>
#include <maya/MSelectionList.h>
#include <maya/MPxCommand.h>
class dRigidBodyArrayCmd : public MPxCommand
{
public:
dRigidBodyArrayCmd();
virtual ~dRigidBodyArrayCmd();
static void *creator();
static MSyntax syntax();
MStatus doIt(const MArgList &i_mArgList);
MStatus redoIt();
MStatus undoIt();
bool isUndoable() const { return true; }
bool hasSyntax() const { return true; }
static MString typeName;
protected:
MArgDatabase *m_argDatabase;
MDagModifier *m_dagModifier;
MSelectionList m_undoSelectionList;
};
#endif

View File

@@ -0,0 +1,147 @@
/*
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>
*/
//dRidigBodyCmd.cpp
#include <maya/MGlobal.h>
#include <maya/MItDependencyNodes.h>
#include <maya/MSyntax.h>
#include "rigidBodyNode.h"
#include "dRigidBodyCmd.h"
MString dRigidBodyCmd::typeName("dRigidBody");
dRigidBodyCmd::dRigidBodyCmd()
: m_argDatabase(0),
m_dagModifier(0)
{
}
dRigidBodyCmd::~dRigidBodyCmd()
{
if (m_argDatabase) {
delete m_argDatabase;
}
if (m_dagModifier) {
delete m_dagModifier;
}
}
void *
dRigidBodyCmd::creator()
{
return new dRigidBodyCmd;
}
MSyntax
dRigidBodyCmd::syntax()
{
MSyntax syntax;
syntax.enableQuery(false);
syntax.enableEdit(false);
syntax.addFlag("-n", "-name", MSyntax::kString);
// syntax.addFlag("-fn", "-filename", MSyntax::kString);
// syntax.addFlag("-col", "-color", MSyntax::kString);
// syntax.addFlag("-dia", "-diameter", MSyntax::kDouble);
return syntax;
}
MStatus
dRigidBodyCmd::doIt(const MArgList &args)
{
MStatus stat;
m_argDatabase = new MArgDatabase(syntax(), args, &stat);
if (stat == MS::kFailure) {
return stat;
}
return redoIt();
}
MStatus
dRigidBodyCmd::undoIt()
{
MGlobal::setActiveSelectionList(m_undoSelectionList);
if (m_dagModifier) {
m_dagModifier->undoIt();
delete m_dagModifier;
m_dagModifier = 0;
}
return MS::kSuccess;
}
MStatus
dRigidBodyCmd::redoIt()
{
MGlobal::getActiveSelectionList(m_undoSelectionList);
MString name;
if (m_argDatabase->isFlagSet("-name")) {
m_argDatabase->getFlagArgument("-name", 0, name);
}
if (!name.length()) {
name = "dRigidBody";
}
m_dagModifier = new MDagModifier;
MObject parentObj = m_dagModifier->createNode("transform");
m_dagModifier->renameNode(parentObj, name + "#");
m_dagModifier->doIt();
MObject dRigidBodyObj = m_dagModifier->createNode(rigidBodyNode::typeId, parentObj);
std::string dRigidBodyName = MFnDependencyNode(parentObj).name().asChar();
std::string::size_type pos = dRigidBodyName.find_last_not_of("0123456789");
dRigidBodyName.insert(pos + 1, "Shape");
m_dagModifier->renameNode(dRigidBodyObj, dRigidBodyName.c_str());
m_dagModifier->doIt();
// connect the solver attribute
MPlug plgSolver(dRigidBodyObj, rigidBodyNode::ia_solver);
MSelectionList slist;
slist.add("dSolver1");
MObject solverObj;
if(slist.length() != 0) {
slist.getDependNode(0, solverObj);
MPlug plgRigidBodies = MFnDependencyNode(solverObj).findPlug("rigidBodies", false);
m_dagModifier->connect(plgRigidBodies, plgSolver);
m_dagModifier->doIt();
}
MGlobal::select(parentObj, MGlobal::kReplaceList);
setResult(MFnDependencyNode(dRigidBodyObj).name());
return MS::kSuccess;
}

View File

@@ -0,0 +1,58 @@
/*
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>
*/
//dRigidBodyCmd.h
#ifndef DYN_DRIGIDBODYCMD_H
#define DYN_DRIGIDBODYCMD_H
#include <maya/MArgDatabase.h>
#include <maya/MDagModifier.h>
#include <maya/MSelectionList.h>
#include <maya/MPxCommand.h>
class dRigidBodyCmd : public MPxCommand
{
public:
dRigidBodyCmd();
virtual ~dRigidBodyCmd();
static void *creator();
static MSyntax syntax();
MStatus doIt(const MArgList &i_mArgList);
MStatus redoIt();
MStatus undoIt();
bool isUndoable() const { return true; }
bool hasSyntax() const { return true; }
static MString typeName;
protected:
MArgDatabase *m_argDatabase;
MDagModifier *m_dagModifier;
MSelectionList m_undoSelectionList;
};
#endif

View File

@@ -0,0 +1,126 @@
/*
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>
*/
//dSolverCmd.cpp
#include <maya/MItDependencyNodes.h>
#include <maya/MSyntax.h>
#include "dSolverNode.h"
#include "dSolverCmd.h"
MString dSolverCmd::typeName("dSolver");
dSolverCmd::dSolverCmd()
: m_argDatabase(0),
m_dgModifier(0)
{
}
dSolverCmd::~dSolverCmd()
{
if (m_argDatabase) {
delete m_argDatabase;
}
if (m_dgModifier) {
delete m_dgModifier;
}
}
void *
dSolverCmd::creator()
{
return new dSolverCmd;
}
MSyntax
dSolverCmd::syntax()
{
MSyntax syntax;
syntax.enableQuery(false);
syntax.enableEdit(false);
return syntax;
}
MStatus
dSolverCmd::doIt(const MArgList &args)
{
MStatus stat;
m_argDatabase = new MArgDatabase(syntax(), args, &stat);
if (stat == MS::kFailure) {
return stat;
}
return redoIt();
}
MStatus
dSolverCmd::undoIt()
{
if (m_dgModifier) {
m_dgModifier->undoIt();
delete m_dgModifier;
m_dgModifier = 0;
}
return MS::kSuccess;
}
MStatus
dSolverCmd::redoIt()
{
MStatus stat;
// see if node exists
MItDependencyNodes depIt(MFn::kPluginDependNode);
for (; !depIt.isDone(); depIt.next()) {
MObject obj = depIt.thisNode();
if (MFnDependencyNode(obj).typeId() == dSolverNode::typeId) {
return stat;
}
}
m_dgModifier = new MDGModifier;
MObject dSolverObj = m_dgModifier->createNode(dSolverNode::typeId);
m_dgModifier->doIt();
// connect the time attribute
MPlug plgInTime(dSolverObj, dSolverNode::ia_time);
MItDependencyNodes depNodeIt(MFn::kTime);
MObject timeObj = depNodeIt.thisNode();
if (timeObj != MObject::kNullObj) {
MPlug plgOutTime = MFnDependencyNode(timeObj).findPlug("outTime", false);
m_dgModifier->connect(plgOutTime, plgInTime);
m_dgModifier->doIt();
}
setResult(MFnDependencyNode(dSolverObj).name());
return stat;
}

View File

@@ -0,0 +1,56 @@
/*
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>
*/
//dSolverCmd.h
#ifndef DYN_DSOLVERCMD_H
#define DYN_DSOLVERCMD_H
#include <maya/MArgDatabase.h>
#include <maya/MDagModifier.h>
#include <maya/MPxCommand.h>
class dSolverCmd : public MPxCommand
{
public:
dSolverCmd();
virtual ~dSolverCmd();
static void *creator();
static MSyntax syntax();
MStatus doIt(const MArgList &i_mArgList);
MStatus redoIt();
MStatus undoIt();
bool isUndoable() const { return true; }
bool hasSyntax() const { return true; }
static MString typeName;
protected:
MArgDatabase *m_argDatabase;
MDGModifier *m_dgModifier;
};
#endif

View File

@@ -0,0 +1,771 @@
/*
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>
*/
//dSolverNode.cpp
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnEnumAttribute.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnUnitAttribute.h>
#include <maya/MFnMessageAttribute.h>
#include <maya/MFnStringData.h>
#include <maya/MFnStringArrayData.h>
#include <maya/MPlugArray.h>
#include <maya/MFnDagNode.h>
#include <maya/MEulerRotation.h>
#include <maya/MQuaternion.h>
#include <maya/MFnTransform.h>
#include <maya/MVector.h>
#include <maya/MGlobal.h>
#include <maya/MFnField.h>
#include <maya/MVectorArray.h>
#include <maya/MItDag.h>
#include <fstream>
#include <sstream>
#include "mayaUtils.h"
#include "dSolverNode.h"
#include "solver.h"
#include "rigidBodyNode.h"
#include "rigidBodyArrayNode.h"
#include "pdbIO.h"
MTypeId dSolverNode::typeId( 0x104203 );
MString dSolverNode::typeName( "dSolver" );
MObject dSolverNode::ia_time;
MObject dSolverNode::ia_startTime;
MObject dSolverNode::ia_gravity;
MObject dSolverNode::ia_enabled;
MObject dSolverNode::ia_splitImpulse;
MObject dSolverNode::ia_substeps;
MObject dSolverNode::oa_rigidBodies;
MObject dSolverNode::ssSolverType;
#define ATTR_POSITION "position"
//#define ATTR_POSITION_TYPE VECTOR_ATTR
#define ATTR_VELOCITY "velocity"
//#define ATTR_VELOCITY_TYPE VECTOR_ATTR
#define ATTR_IN_RAXIS "in_rotvec" /* vector */
//#define ATTR_IN_RAXIS_TYPE VECTOR_ATTR
#define ATTR_IN_RANGLE "in_rotang" /* float */
//#define ATTR_IN_RANGLE_TYPE FLOAT_ATTR
#define ATTR_IN_ROTVEL "in_rotvel" /* float */
//#define ATTR_IN_ROTVEL_TYPE FLOAT_ATTR
#define ATTR_IN_RAXISNEXT "in_rotvec_next" /* vector */
//#define ATTR_IN_RAXISNEXT_TYPE VECTOR_ATTR
#define ATTR_IN_RANGLENEXT "in_rotang_next" /* float */
//#define ATTR_IN_RANGLENEXT_TYPE FLOAT_ATTR
MStatus dSolverNode::initialize()
{
MStatus status;
MFnEnumAttribute fnEnumAttr;
MFnMessageAttribute fnMsgAttr;
MFnUnitAttribute fnUnitAttr;
MFnNumericAttribute fnNumericAttr;
//
ssSolverType = fnEnumAttr.create( "ssSolverType", "ssst", 0, &status );
MCHECKSTATUS(status, "creating ssSolverType attribute")
fnEnumAttr.addField( "Bullet Physics", 0 );
fnEnumAttr.addField( "Ageia PhysX", 1 );
fnEnumAttr.addField( "Stanford PhysBAM", 2 );
status = addAttribute(ssSolverType);
MCHECKSTATUS(status, "adding ssSolverType attribute")
//
ia_time = fnUnitAttr.create( "inTime", "it", MFnUnitAttribute::kTime, 0.0, &status );
MCHECKSTATUS(status, "creating ia_time attribute")
fnUnitAttr.setHidden(true);
status = addAttribute(ia_time);
MCHECKSTATUS(status, "adding ia_time attribute")
ia_startTime = fnUnitAttr.create( "startTime", "stm", MFnUnitAttribute::kTime, 1.0, &status );
MCHECKSTATUS(status, "creating ia_startTime attribute")
status = addAttribute(ia_startTime);
MCHECKSTATUS(status, "adding ia_startTime attribute")
oa_rigidBodies = fnMsgAttr.create("rigidBodies", "rbds", &status);
MCHECKSTATUS(status, "creating oa_rigidBodies attribute")
status = addAttribute(oa_rigidBodies);
MCHECKSTATUS(status, "adding oa_rigidBodies attribute")
ia_gravity = fnNumericAttr.createPoint("gravity", "grvt", &status);
MCHECKSTATUS(status, "creating gravity attribute")
fnNumericAttr.setDefault(0.0, -9.81, 0.0);
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_gravity);
MCHECKSTATUS(status, "adding ia_gravity attribute")
ia_substeps = fnNumericAttr.create("substeps", "sbs", MFnNumericData::kInt, 1, &status);
MCHECKSTATUS(status, "creating substeps attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_substeps);
MCHECKSTATUS(status, "adding ia_substeps attribute")
ia_enabled = fnNumericAttr.create("enabled", "enbl", MFnNumericData::kBoolean, true, &status);
MCHECKSTATUS(status, "creating enabled attribute")
status = addAttribute(ia_enabled);
MCHECKSTATUS(status, "adding ia_enabled attribute")
ia_splitImpulse = fnNumericAttr.create("splitImpulse", "spli", MFnNumericData::kBoolean, false, &status);
MCHECKSTATUS(status, "creating splitImpulse attribute")
status = addAttribute(ia_splitImpulse);
MCHECKSTATUS(status, "adding ia_splitImpulse attribute")
status = attributeAffects(ia_time, oa_rigidBodies);
MCHECKSTATUS(status, "adding attributeAffects(ia_time, oa_rigidBodies)")
status = attributeAffects(ia_enabled, oa_rigidBodies);
MCHECKSTATUS(status, "adding attributeAffects(ia_enabled, oa_rigidBodies)")
return MS::kSuccess;
}
dSolverNode::dSolverNode()
{
}
dSolverNode::~dSolverNode()
{
}
void dSolverNode::postConstructor()
{
//prevent deletion if all the rigidbodies are deleted
setExistWithoutOutConnections(true);
}
void* dSolverNode::creator()
{
return new dSolverNode();
}
bool dSolverNode::setInternalValueInContext( const MPlug & plug, const MDataHandle & dataHandle, MDGContext & ctx )
{
return false;
}
MStatus dSolverNode::compute(const MPlug& plug, MDataBlock& data)
{
if(plug == oa_rigidBodies) {
computeRigidBodies(plug, data);
} else {
return MStatus::kUnknownParameter;
}
return MStatus::kSuccess;
}
void initRigidBody(MObject &node)
{
MFnDagNode fnDagNode(node);
rigidBodyNode *rbNode = static_cast<rigidBodyNode*>(fnDagNode.userNode());
rigid_body_t::pointer rb = rbNode->rigid_body();
if(fnDagNode.parentCount() == 0) {
std::cout << "No transform found!" << std::endl;
return;
}
MFnTransform fnTransform(fnDagNode.parent(0));
MPlug plgActive(node, rigidBodyNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(active) {
//active rigid body, set the world transform from the initial* attributes
MObject obj;
vec3f pos;
MPlug plgInitialValue(node, rigidBodyNode::ia_initialPosition);
plgInitialValue.child(0).getValue(pos[0]);
plgInitialValue.child(1).getValue(pos[1]);
plgInitialValue.child(2).getValue(pos[2]);
vec3f rot;
plgInitialValue.setAttribute(rigidBodyNode::ia_initialRotation);
plgInitialValue.child(0).getValue(rot[0]);
plgInitialValue.child(1).getValue(rot[1]);
plgInitialValue.child(2).getValue(rot[2]);
vec3f vel;
plgInitialValue.setAttribute(rigidBodyNode::ia_initialVelocity);
plgInitialValue.child(0).getValue(vel[0]);
plgInitialValue.child(1).getValue(vel[1]);
plgInitialValue.child(2).getValue(vel[2]);
vec3f spin;
plgInitialValue.setAttribute(rigidBodyNode::ia_initialSpin);
plgInitialValue.child(0).getValue(spin[0]);
plgInitialValue.child(1).getValue(spin[1]);
plgInitialValue.child(2).getValue(spin[2]);
MEulerRotation meuler(deg2rad(rot[0]), deg2rad(rot[1]), deg2rad(rot[2]));
MQuaternion mquat = meuler.asQuaternion();
rb->set_transform(pos, quatf(mquat.w, mquat.x, mquat.y, mquat.z));
rb->set_linear_velocity(vel);
rb->set_angular_velocity(spin);
rb->set_kinematic(false);
fnTransform.setRotation(meuler);
fnTransform.setTranslation(MVector(pos[0], pos[1], pos[2]), MSpace::kTransform);
} else {
//passive rigid body, get the world trasform from from the shape node
MQuaternion mquat;
fnTransform.getRotation(mquat);
MVector mpos(fnTransform.getTranslation(MSpace::kTransform));
rb->set_transform(vec3f(mpos.x, mpos.y, mpos.z), quatf(mquat.w, mquat.x, mquat.y, mquat.z));
rb->set_kinematic(true);
}
}
void initRigidBodyArray(MObject &node)
{
MFnDagNode fnDagNode(node);
rigidBodyArrayNode *rbNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
std::vector<rigid_body_t::pointer>& rbs = rbNode->rigid_bodies();
if(fnDagNode.parentCount() == 0) {
std::cout << "No transform found!" << std::endl;
return;
}
MFnTransform fnTransform(fnDagNode.parent(0));
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(active) {
//active rigid body, set the world transform from the initial* attributes
MObject obj;
MPlug plgInitialPosition(node, rigidBodyArrayNode::ia_initialPosition);
MPlug plgInitialRotation(node, rigidBodyArrayNode::ia_initialRotation);
MPlug plgInitialVelocity(node, rigidBodyArrayNode::ia_initialVelocity);
MPlug plgInitialSpin(node, rigidBodyArrayNode::ia_initialSpin);
MPlug plgElement;
for(size_t j = 0; j < rbs.size(); ++j) {
vec3f pos;
plgElement = plgInitialPosition.elementByLogicalIndex(j);
plgElement.child(0).getValue(pos[0]);
plgElement.child(1).getValue(pos[1]);
plgElement.child(2).getValue(pos[2]);
vec3f rot;
plgElement = plgInitialRotation.elementByLogicalIndex(j);
plgElement.child(0).getValue(rot[0]);
plgElement.child(1).getValue(rot[1]);
plgElement.child(2).getValue(rot[2]);
vec3f vel;
plgElement = plgInitialVelocity.elementByLogicalIndex(j);
plgElement.child(0).getValue(vel[0]);
plgElement.child(1).getValue(vel[1]);
plgElement.child(2).getValue(vel[2]);
vec3f spin;
plgElement = plgInitialSpin.elementByLogicalIndex(j);
plgElement.child(0).getValue(spin[0]);
plgElement.child(1).getValue(spin[1]);
plgElement.child(2).getValue(spin[2]);
MEulerRotation meuler(deg2rad(rot[0]), deg2rad(rot[1]), deg2rad(rot[2]));
MQuaternion mquat = meuler.asQuaternion();
rbs[j]->set_transform(pos, quatf(mquat.w, mquat.x, mquat.y, mquat.z));
rbs[j]->set_linear_velocity(vel);
rbs[j]->set_angular_velocity(spin);
rbs[j]->set_kinematic(false);
}
} else {
//passive rigid body, get the world trasform from from the position/rotation attributes
MPlug plgPosition(node, rigidBodyArrayNode::io_position);
MPlug plgRotation(node, rigidBodyArrayNode::io_rotation);
MPlug plgElement;
for(size_t j = 0; j < rbs.size(); ++j) {
vec3f pos;
plgElement = plgPosition.elementByLogicalIndex(j);
plgElement.child(0).getValue(pos[0]);
plgElement.child(1).getValue(pos[1]);
plgElement.child(2).getValue(pos[2]);
vec3f rot;
plgElement = plgRotation.elementByLogicalIndex(j);
plgElement.child(0).getValue(rot[0]);
plgElement.child(1).getValue(rot[1]);
plgElement.child(2).getValue(rot[2]);
MEulerRotation meuler(deg2rad(rot[0]), deg2rad(rot[1]), deg2rad(rot[2]));
MQuaternion mquat = meuler.asQuaternion();
rbs[j]->set_transform(pos, quatf(mquat.w, mquat.x, mquat.y, mquat.z));
rbs[j]->set_kinematic(false);
}
}
}
//init the rigid bodies to it's first frame configuration
void dSolverNode::initRigidBodies(MPlugArray &rbConnections)
{
for(size_t i = 0; i < rbConnections.length(); ++i) {
MObject node = rbConnections[i].node();
MFnDependencyNode fnNode(node);
if(fnNode.typeId() == rigidBodyNode::typeId) {
initRigidBody(node);
} else if(fnNode.typeId() == rigidBodyArrayNode::typeId) {
initRigidBodyArray(node);
}
}
}
//gather previous and current frame transformations for substep interpolation
void dSolverNode::gatherPassiveTransforms(MPlugArray &rbConnections, std::vector<xforms_t> &xforms)
{
xforms.resize(0);
xforms_t xform;
for(size_t i = 0; i < rbConnections.length(); ++i) {
MObject node = rbConnections[i].node();
MFnDagNode fnDagNode(node);
if(fnDagNode.typeId() == rigidBodyNode::typeId) {
rigidBodyNode *rbNode = static_cast<rigidBodyNode*>(fnDagNode.userNode());
rigid_body_t::pointer rb = rbNode->rigid_body();
if(fnDagNode.parentCount() == 0) {
std::cout << "No transform found!" << std::endl;
continue;
}
MFnTransform fnTransform(fnDagNode.parent(0));
MPlug plgActive(node, rigidBodyNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(!active) {
MQuaternion mquat;
fnTransform.getRotation(mquat);
MVector mpos(fnTransform.getTranslation(MSpace::kTransform));
rb->get_transform(xform.m_x0, xform.m_q0);
xform.m_x1 = vec3f(mpos.x, mpos.y, mpos.z);
xform.m_q1 = quatf(mquat.w, mquat.x, mquat.y, mquat.z);
xforms.push_back(xform);
}
} else if(fnDagNode.typeId() == rigidBodyArrayNode::typeId) {
rigidBodyArrayNode *rbNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
std::vector<rigid_body_t::pointer>& rbs = rbNode->rigid_bodies();
if(fnDagNode.parentCount() == 0) {
std::cout << "No transform found!" << std::endl;
return;
}
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(!active) {
MPlug plgPosition(node, rigidBodyArrayNode::io_position);
MPlug plgRotation(node, rigidBodyArrayNode::io_rotation);
MPlug plgElement;
for(size_t j = 0; j < rbs.size(); ++j) {
rbs[j]->get_transform(xform.m_x0, xform.m_q0);
plgElement = plgPosition.elementByLogicalIndex(j);
plgElement.child(0).getValue(xform.m_x1[0]);
plgElement.child(1).getValue(xform.m_x1[1]);
plgElement.child(2).getValue(xform.m_x1[2]);
vec3f rot;
plgElement = plgRotation.elementByLogicalIndex(j);
plgElement.child(0).getValue(rot[0]);
plgElement.child(1).getValue(rot[1]);
plgElement.child(2).getValue(rot[2]);
MEulerRotation meuler(deg2rad(rot[0]), deg2rad(rot[1]), deg2rad(rot[2]));
MQuaternion mquat = meuler.asQuaternion();
xform.m_q1 = quatf(mquat.w, mquat.x, mquat.y, mquat.z);
xforms.push_back(xform);
}
}
}
}
}
//update the passive rigid bodies by interpolation of the previous and current frame
void dSolverNode::updatePassiveRigidBodies(MPlugArray &rbConnections, std::vector<xforms_t> &xforms, float t)
{
size_t pb = 0;
for(size_t i = 0; i < rbConnections.length(); ++i) {
MObject node = rbConnections[i].node();
MFnDagNode fnDagNode(node);
if(fnDagNode.typeId() == rigidBodyNode::typeId) {
rigidBodyNode *rbNode = static_cast<rigidBodyNode*>(fnDagNode.userNode());
rigid_body_t::pointer rb = rbNode->rigid_body();
if(fnDagNode.parentCount() == 0) {
std::cout << "No transform found!" << std::endl;
continue;
}
MPlug plgActive(node, rigidBodyNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(!active) {
//do linear interpolation for now
rb->set_transform(xforms[pb].m_x0 + t * (xforms[pb].m_x1 - xforms[pb].m_x0),
normalize(xforms[pb].m_q0 + t * (xforms[pb].m_q1 - xforms[pb].m_q0)));
++pb;
}
} else if(fnDagNode.typeId() == rigidBodyArrayNode::typeId) {
rigidBodyArrayNode *rbNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
std::vector<rigid_body_t::pointer>& rbs = rbNode->rigid_bodies();
if(fnDagNode.parentCount() == 0) {
std::cout << "No transform found!" << std::endl;
return;
}
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(!active) {
for(size_t j = 0; j < rbs.size(); ++j) {
rbs[j]->set_transform(xforms[pb].m_x0 + t * (xforms[pb].m_x1 - xforms[pb].m_x0),
normalize(xforms[pb].m_q0 + t * (xforms[pb].m_q1 - xforms[pb].m_q0)));
++pb;
}
}
}
}
}
//update the scene after a simulation step
void dSolverNode::updateActiveRigidBodies(MPlugArray &rbConnections)
{
//update the active rigid bodies to the new configuration
for(size_t i = 0; i < rbConnections.length(); ++i) {
MObject node = rbConnections[i].node();
MFnDagNode fnDagNode(node);
if(fnDagNode.typeId() == rigidBodyNode::typeId) {
rigidBodyNode *rbNode = static_cast<rigidBodyNode*>(fnDagNode.userNode());
rigid_body_t::pointer rb = rbNode->rigid_body();
if(fnDagNode.parentCount() == 0) {
std::cout << "No transform found!" << std::endl;
continue;
}
MFnTransform fnTransform(fnDagNode.parent(0));
MPlug plgActive(node, rigidBodyNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(active) {
quatf rot;
vec3f pos;
rb->get_transform(pos, rot);
fnTransform.setRotation(MQuaternion(rot[1], rot[2], rot[3], rot[0]));
fnTransform.setTranslation(MVector(pos[0], pos[1], pos[2]), MSpace::kTransform);
}
} else if(fnDagNode.typeId() == rigidBodyArrayNode::typeId) {
//check if we have to output the rigid bodies to a file
MPlug plgFileIO(node, rigidBodyArrayNode::ia_fileIO);
bool doIO;
plgFileIO.getValue(doIO);
if(doIO) {
dumpRigidBodyArray(node);
}
}
}
}
//apply fields in the scene from the rigid body
void dSolverNode::applyFields(MPlugArray &rbConnections, float dt)
{
MVectorArray position;
MVectorArray velocity;
MDoubleArray mass;
std::vector<rigid_body_t*> rigid_bodies;
//gather active rigid bodies
for(size_t i = 0; i < rbConnections.length(); ++i) {
MObject node = rbConnections[i].node();
MFnDagNode fnDagNode(node);
if(fnDagNode.typeId() == rigidBodyNode::typeId) {
rigidBodyNode *rbNode = static_cast<rigidBodyNode*>(fnDagNode.userNode());
rigid_body_t::pointer rb = rbNode->rigid_body();
MPlug plgActive(node, rigidBodyNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(active) {
rigid_bodies.push_back(rb.get());
}
} else if(fnDagNode.typeId() == rigidBodyArrayNode::typeId) {
rigidBodyArrayNode *rbNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
std::vector<rigid_body_t::pointer>& rbs = rbNode->rigid_bodies();
MPlug plgActive(node, rigidBodyArrayNode::ia_active);
bool active = false;
plgActive.getValue(active);
if(active) {
for(size_t j = 0; j < rbs.size(); ++j) {
rigid_bodies.push_back(rbs[j].get());
}
}
}
}
//clear forces and get the properties needed for field computation
for(size_t i = 0; i < rigid_bodies.size(); ++i) {
rigid_bodies[i]->clear_forces();
vec3f pos, vel;
quatf rot;
rigid_bodies[i]->get_transform(pos, rot);
rigid_bodies[i]->get_linear_velocity(vel);
position.append(MVector(pos[0], pos[1], pos[2]));
velocity.append(MVector(vel[0], vel[1], vel[2]));
//TODO
mass.append(1.0);
//
}
//apply the fields to the rigid bodies
MVectorArray force;
for(MItDag it(MItDag::kDepthFirst, MFn::kField); !it.isDone(); it.next()) {
MFnField fnField(it.item());
fnField.getForceAtPoint(position, velocity, mass, force, dt);
for(size_t i = 0; i < rigid_bodies.size(); ++i) {
rigid_bodies[i]->apply_central_force(vec3f(force[i].x, force[i].y, force[i].z));
}
}
}
void dSolverNode::computeRigidBodies(const MPlug& plug, MDataBlock& data)
{
// std::cout << "dSolverNode::computeRigidBodies" << std::endl;
bool enabled = data.inputValue(ia_enabled).asBool();
if(!enabled) {
data.outputValue(oa_rigidBodies).set(true);
data.setClean(plug);
return;
}
MTime time = data.inputValue(ia_time).asTime();
MTime startTime = data.inputValue(ia_startTime).asTime();
int subSteps = data.inputValue(ia_substeps).asInt();
MObject thisObject = thisMObject();
MPlug plgRigidBodies(thisObject, oa_rigidBodies);
MPlugArray rbConnections;
plgRigidBodies.connectedTo(rbConnections, true, true);
MPlug plgSplitImpulse(thisObject, ia_splitImpulse);
bool splitImpulseEnabled;
plgSplitImpulse.getValue(splitImpulseEnabled);
if(time == startTime) {
//first frame, init the simulation
initRigidBodies(rbConnections);
solver_t::set_split_impulse(splitImpulseEnabled);
m_prevTime = time;
} else if(time > m_prevTime && ((time - m_prevTime).value() <= 1.0)) {
//step the simulation forward,
//don't update if we are jumping more than one frame
float dt = (time - m_prevTime).as(MTime::kSeconds);
//gather start and end transform for passive rigid bodies, used for interpolation
std::vector<xforms_t> passiveXForms;
gatherPassiveTransforms(rbConnections, passiveXForms);
//set the gravity in the solver
MPlug plgGravity(thisObject, ia_gravity);
vec3f gravity;
plgGravity.child(0).getValue(gravity[0]);
plgGravity.child(1).getValue(gravity[1]);
plgGravity.child(2).getValue(gravity[2]);
solver_t::set_gravity(gravity);
solver_t::set_split_impulse(splitImpulseEnabled);
for(int i = 1; i <= subSteps; ++i) {
//first update the passive rigid bodies
updatePassiveRigidBodies(rbConnections, passiveXForms, i * dt / subSteps);
//fields
applyFields(rbConnections, dt / subSteps);
//step the simulation
solver_t::step_simulation(dt / subSteps);
}
m_prevTime = time;
updateActiveRigidBodies(rbConnections);
}
data.outputValue(oa_rigidBodies).set(true);
data.setClean(plug);
}
void tokenize(const std::string& str,
std::vector<std::string>& tokens,
const std::string& delimiters = " ")
{
// Skip delimiters at beginning.
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
while (std::string::npos != pos || std::string::npos != lastPos)
{
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
pos = str.find_first_of(delimiters, lastPos);
}
}
void replace(std::string &str, std::string const& what, std::string const& with_what)
{
size_t pos;
while((pos = str.find(what)) != std::string::npos) {
str.replace(pos, pos + what.size(), with_what);
}
}
bool dSolverNode::expandFileExpression(std::string const& expr, std::string &base_name, std::string &extension)
{
std::vector<std::string> tokens;
//check for extension
tokenize(expr, tokens, ".");
if(tokens.size() < 2) return false;
if(tokens.back().size() != 3) return false;
extension = tokens.back();
std::copy(expr.begin(), expr.end() - 4, std::back_inserter(base_name));
int time = (int) m_prevTime.value();
std::stringstream ss;
ss << time;
std::string str_time(ss.str());
//replace ${frame}
replace(base_name, "${frame}", str_time);
//replace ${waveFrame}
while(str_time.size() < 4) str_time = "0" + str_time;
replace(base_name, "${waveFrame}", str_time);
return true;
}
void dSolverNode::dumpRigidBodyArray(MObject &node)
{
// std::cout << "dSolverNode::dumpRigidBodyArray" << std::endl;
MFnDagNode fnDagNode(node);
rigidBodyArrayNode *rbaNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
MPlug plgFiles(node, rigidBodyArrayNode::ia_fioFiles);
// MPlug plgPositionAttribute(node, rigidBodyArrayNode::ia_fioPositionAttribute);
// MPlug plgRotationAttribute(node, rigidBodyArrayNode::ia_fioRotationAttribute);
MString mstr;
plgFiles.getValue(mstr);
std::string expr(mstr.asChar());
std::string base_path, extension;
if(!expandFileExpression(expr, base_path, extension)) {
std::cout << "dSolverNode::dumpRigidBodyArray: syntax error in file expression: " << std::endl <<
expr << std::endl;
return;
}
if(extension != "pdb") {
std::cout << "dSolverNode::dumpRigidBodyArray: only pdb files are supported" << std::endl;
return;
}
std::string file_name = base_path + "." + extension;
std::vector<rigid_body_t::pointer>& rbs = rbaNode->rigid_bodies();
pdb_io_t pdb_io;
pdb_io.m_num_particles = rbs.size();
pdb_io.m_time = m_prevTime.value();
pdb_io.m_attributes.resize(3);
//position
pdb_io.m_attributes[0].m_num_elements = 1;
pdb_io.m_attributes[0].m_name = ATTR_POSITION;
pdb_io.m_attributes[0].m_type = pdb_io_t::kVector;
pdb_io.m_attributes[0].m_vector_data.resize(rbs.size());
//rotation angle (in degrees)
pdb_io.m_attributes[1].m_num_elements = 1;
pdb_io.m_attributes[1].m_name = ATTR_IN_RANGLE;
pdb_io.m_attributes[1].m_type = pdb_io_t::kReal;
pdb_io.m_attributes[1].m_real_data.resize(rbs.size());
//rotation vector
pdb_io.m_attributes[2].m_num_elements = 1;
pdb_io.m_attributes[2].m_name = ATTR_IN_RAXIS;
pdb_io.m_attributes[2].m_type = pdb_io_t::kVector;
pdb_io.m_attributes[2].m_vector_data.resize(rbs.size());
for(size_t i = 0; i < rbs.size(); ++i) {
vec3f pos;
quatf rot;
rbs[i]->get_transform(pos, rot);
pdb_io.m_attributes[0].m_vector_data[i].x = pos[0];
pdb_io.m_attributes[0].m_vector_data[i].y = pos[1];
pdb_io.m_attributes[0].m_vector_data[i].z = pos[2];
//
vec3f axis;
float angle;
q_to_axis_angle(rot, axis, angle);
pdb_io.m_attributes[1].m_real_data[i] = rad2deg(angle);
pdb_io.m_attributes[2].m_vector_data[i].x = axis[0];
pdb_io.m_attributes[2].m_vector_data[i].y = axis[1];
pdb_io.m_attributes[2].m_vector_data[i].z = axis[2];
}
std::ofstream out(file_name.c_str());
pdb_io.write(out);
}

View File

@@ -0,0 +1,92 @@
/*
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>
*/
//dSolverNode.h
#ifndef DYN_DSOLVERNODE_H
#define DYN_DSOLVERNODE_H
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPxNode.h>
#include <maya/MTime.h>
#include <vector>
#include "mathUtils.h"
class dSolverNode : public MPxNode
{
public:
dSolverNode();
virtual ~dSolverNode();
virtual void postConstructor();
static void * creator();
static MStatus initialize();
virtual bool setInternalValueInContext ( const MPlug & plug, const MDataHandle & dataHandle, MDGContext & ctx );
virtual MStatus compute( const MPlug& plug, MDataBlock& data );
static MObject ia_time;
static MObject ia_startTime;
static MObject ia_gravity;
static MObject ia_enabled;
static MObject ia_splitImpulse;
static MObject ia_substeps;
static MObject oa_rigidBodies;
//Solver Settings
static MObject ssSolverType;
//
public:
static MTypeId typeId;
static MString typeName;
protected:
struct xforms_t {
vec3f m_x0;
vec3f m_x1;
quatf m_q0;
quatf m_q1;
};
void computeRigidBodies(const MPlug& plug, MDataBlock& data);
void dumpRigidBodyArray(MObject &node);
bool expandFileExpression(std::string const& expr, std::string &base_name, std::string &extension);
void initRigidBodies(MPlugArray &rbConnections);
void gatherPassiveTransforms(MPlugArray &rbConnections, std::vector<xforms_t> &xforms);
void updatePassiveRigidBodies(MPlugArray &rbConnections, std::vector<xforms_t> &xforms, float t);
void updateActiveRigidBodies(MPlugArray &rbConnections);
void applyFields(MPlugArray &rbConnections, float dt);
protected:
MTime m_prevTime;
};
#endif

View File

@@ -0,0 +1,511 @@
/* XPM */
static char * dynamica1_xpm[] = {
"32 32 476 2",
" c #B1B1B1",
". c #B0B0B0",
"+ c #AFAFAF",
"@ c #AAAAAA",
"# c #A8A8A8",
"$ c #ABABAB",
"% c #A6A6A6",
"& c #A9A9A9",
"* c #AAA9A7",
"= c #979288",
"- c #9B9B9B",
"; c #959595",
"> c #9F9F9F",
", c #625236",
"' c #402900",
") c #776C57",
"! c #ADADAD",
"~ c #A0A0A0",
"{ c #9A9A9A",
"] c #776C58",
"^ c #6A5C44",
"/ c #919190",
"( c #898989",
"_ c #908E8B",
": c #47320C",
"< c #5D4D2F",
"[ c #A5A5A5",
"} c #99948B",
"| c #B1B0B0",
"1 c #9E9E9E",
"2 c #8D8D8D",
"3 c #8C8C8C",
"4 c #756B5B",
"5 c #62563F",
"6 c #82817E",
"7 c #736B5C",
"8 c #49340F",
"9 c #908F8E",
"0 c #989898",
"a c #817969",
"b c #442E06",
"c c #48320C",
"d c #ABAAA7",
"e c #AEAEAE",
"f c #868686",
"g c #777267",
"h c #402901",
"i c #47330E",
"j c #432D05",
"k c #524122",
"l c #5B4B2F",
"m c #584626",
"n c #B0AFAF",
"o c #A7A7A7",
"p c #9B9893",
"q c #8E8A83",
"r c #7E7A74",
"s c #412A02",
"t c #72654E",
"u c #929292",
"v c #91908E",
"w c #503D1C",
"x c #422B03",
"y c #514020",
"z c #665A44",
"A c #564526",
"B c #48330D",
"C c #675940",
"D c #80786A",
"E c #918E88",
"F c #969595",
"G c #84817B",
"H c #70685A",
"I c #5D4F36",
"J c #47320D",
"K c #7D7463",
"L c #999999",
"M c #8A8A8A",
"N c #848382",
"O c #534224",
"P c #5D4C2D",
"Q c #8D8579",
"R c #939393",
"S c #776F63",
"T c #574627",
"U c #4C3815",
"V c #675942",
"W c #635438",
"X c #594727",
"Y c #625235",
"Z c #A2A2A2",
"` c #878787",
" . c #817E79",
".. c #47310C",
"+. c #5D4C2E",
"@. c #99948C",
"#. c #909090",
"$. c #79746B",
"%. c #402A01",
"&. c #9E9B94",
"*. c #8F8F8F",
"=. c #827B6F",
"-. c #412A01",
";. c #49340E",
">. c #8E877A",
",. c #9C9C9C",
"'. c #8E8E8E",
"). c #767067",
"!. c #503E1E",
"~. c #4E3A16",
"{. c #969086",
"]. c #A4A4A4",
"^. c #979797",
"/. c #949492",
"(. c #776D5A",
"_. c #6C5E45",
":. c #9D9D9D",
"<. c #949494",
"[. c #767065",
"}. c #514022",
"|. c #3F2900",
"1. c #46300A",
"2. c #9F9B95",
"3. c #ACACAC",
"4. c #A1A1A1",
"5. c #6E6556",
"6. c #5D4E35",
"7. c #4E3A17",
"8. c #8A8274",
"9. c #919191",
"0. c #8B8B8B",
"a. c #6F685B",
"b. c #4D3C1C",
"c. c #3E2800",
"d. c #432E08",
"e. c #63563F",
"f. c #7A7160",
"g. c #53401E",
"h. c #45300A",
"i. c #A09C97",
"j. c #A3A3A3",
"k. c #878786",
"l. c #6B6354",
"m. c #493615",
"n. c #3C2700",
"o. c #472600",
"p. c #672A07",
"q. c #923918",
"r. c #B23610",
"s. c #CC3102",
"t. c #D54012",
"u. c #B04012",
"v. c #8C4118",
"w. c #7A583B",
"x. c #867D6E",
"y. c #A6A4A0",
"z. c #6F675B",
"A. c #564629",
"B. c #432C06",
"C. c #3F2800",
"D. c #9E9E9D",
"E. c #838280",
"F. c #675D4D",
"G. c #44300F",
"H. c #3B2600",
"I. c #3A2500",
"J. c #54280B",
"K. c #762B12",
"L. c #882000",
"M. c #A02600",
"N. c #B82B00",
"O. c #CF3100",
"P. c #E13B07",
"Q. c #E44E1F",
"R. c #E76036",
"S. c #C9623C",
"T. c #864B24",
"U. c #4D3915",
"V. c #8A8780",
"W. c #4E3C1C",
"X. c #7F7D77",
"Y. c #7E7D7B",
"Z. c #615644",
"`. c #3F2D0A",
" + c #392500",
".+ c #493819",
"++ c #674231",
"@+ c #5E1701",
"#+ c #701B00",
"$+ c #A32600",
"%+ c #BC2C00",
"&+ c #D43200",
"*+ c #E13E0B",
"=+ c #E45224",
"-+ c #E7653D",
";+ c #EA7652",
">+ c #EB8363",
",+ c #9B6241",
"'+ c #7F7F7F",
")+ c #838383",
"!+ c #4D3E22",
"~+ c #392400",
"{+ c #4D3F26",
"]+ c #3C2906",
"^+ c #382300",
"/+ c #372300",
"(+ c #4A3A1D",
"_+ c #787268",
":+ c #79615A",
"<+ c #4F1301",
"[+ c #5B1600",
"}+ c #731B00",
"|+ c #8D2100",
"1+ c #AA2800",
"2+ c #C32E00",
"3+ c #D93300",
"4+ c #E2410F",
"5+ c #E55427",
"6+ c #E86840",
"7+ c #EB7B58",
"8+ c #ED8B6D",
"9+ c #EE977C",
"0+ c #CBA89E",
"a+ c #969696",
"b+ c #888888",
"c+ c #797979",
"d+ c #737373",
"e+ c #5B5446",
"f+ c #372603",
"g+ c #352200",
"h+ c #342100",
"i+ c #4A3C23",
"j+ c #78746C",
"k+ c #877F7C",
"l+ c #542A1D",
"m+ c #4C1200",
"n+ c #5F1600",
"o+ c #7A1D00",
"p+ c #982400",
"q+ c #B32A00",
"r+ c #CA3000",
"s+ c #DD3400",
"t+ c #E24210",
"u+ c #E55326",
"v+ c #E8663E",
"w+ c #EE8E70",
"x+ c #F09D83",
"y+ c #E5A794",
"z+ c #BBAFAB",
"A+ c #848484",
"B+ c #6A6A69",
"C+ c #9D8100",
"D+ c #DCB600",
"E+ c #F7CC00",
"F+ c #F3C900",
"G+ c #EDC400",
"H+ c #E6BE00",
"I+ c #E0B900",
"J+ c #DBB500",
"K+ c #D8B300",
"L+ c #936800",
"M+ c #421000",
"N+ c #4E1200",
"O+ c #651800",
"P+ c #831F00",
"Q+ c #BD2D00",
"R+ c #D13100",
"S+ c #DF3500",
"T+ c #E45022",
"U+ c #E7633A",
"V+ c #EA7855",
"W+ c #F09F86",
"X+ c #F2AA94",
"Y+ c #CEAFA5",
"Z+ c #7B7B7B",
"`+ c #6B6B6B",
" @ c #666564",
".@ c #746000",
"+@ c #D1AC00",
"@@ c #F9CE03",
"#@ c #F4CA03",
"$@ c #EDC403",
"%@ c #E6BE03",
"&@ c #E0B903",
"*@ c #DBB503",
"=@ c #D8B303",
"-@ c #6D4101",
";@ c #431000",
">@ c #521300",
",@ c #6B1900",
"'@ c #8C2100",
")@ c #AB2900",
"!@ c #C52F00",
"~@ c #D53300",
"{@ c #E03500",
"]@ c #E13F0C",
"^@ c #E34B1C",
"/@ c #E65D33",
"(@ c #EA744F",
"_@ c #F0A087",
":@ c #F2AD97",
"<@ c #DFB1A3",
"[@ c #7D7D7D",
"}@ c #727272",
"|@ c #6E6E6E",
"1@ c #655300",
"2@ c #C9A500",
"3@ c #F8CC00",
"4@ c #F2C700",
"5@ c #EBC200",
"6@ c #E4BC00",
"7@ c #DEB700",
"8@ c #DAB400",
"9@ c #D7B100",
"0@ c #502300",
"a@ c #441000",
"b@ c #541400",
"c@ c #922300",
"d@ c #B12A00",
"e@ c #C93000",
"f@ c #D83300",
"g@ c #E13C09",
"h@ c #E34717",
"i@ c #E6592E",
"j@ c #E9704A",
"k@ c #ED896A",
"l@ c #F09E85",
"m@ c #EBB2A0",
"n@ c #818181",
"o@ c #787878",
"p@ c #C8A400",
"q@ c #F7CB00",
"r@ c #F1C600",
"s@ c #E9C000",
"t@ c #E2BA00",
"u@ c #DDB600",
"v@ c #D9B300",
"w@ c #3F1000",
"x@ c #551400",
"y@ c #711B00",
"z@ c #932300",
"A@ c #B22A00",
"B@ c #E34615",
"C@ c #E5562A",
"D@ c #E96D47",
"E@ c #ED8767",
"F@ c #F09C82",
"G@ c #F2AC96",
"H@ c #F2B19D",
"I@ c #808080",
"J@ c #747474",
"K@ c #F6CB00",
"L@ c #DCB500",
"M@ c #D6B000",
"N@ c #502200",
"O@ c #531400",
"P@ c #6E1A00",
"Q@ c #8F2200",
"R@ c #AF2900",
"S@ c #C72F00",
"T@ c #D63300",
"U@ c #E96C46",
"V@ c #EC8464",
"W@ c #EF9A7F",
"X@ c #F2A992",
"Y@ c #EBAF9D",
"Z@ c #6C4100",
"`@ c #410F00",
" # c #4F1300",
".# c #671800",
"+# c #862000",
"@# c #A52700",
"## c #BF2D00",
"$# c #DC3400",
"%# c #E34616",
"&# c #E5572B",
"*# c #EC8363",
"=# c #EF977C",
"-# c #F1A48C",
";# c #DEAB9C",
"># c #926800",
",# c #3F0F00",
"'# c #4A1100",
")# c #5E1600",
"!# c #D73300",
"~# c #E03804",
"{# c #E5582C",
"]# c #EC8160",
"^# c #EE9276",
"/# c #F09E84",
"(# c #CEAA9F",
"_# c #F9CD00",
":# c #F4C900",
"<# c #EDC300",
"[# c #E6BD00",
"}# c #E0B800",
"|# c #DBB400",
"1# c #D8B200",
"2# c #C09800",
"3# c #5C2F08",
"4# c #451000",
"5# c #6C1A00",
"6# c #A32700",
"7# c #BB2C00",
"8# c #CE3100",
"9# c #E24413",
"0# c #E86942",
"a# c #EB7C59",
"b# c #E39A84",
"c# c #BBADA9",
"d# c #828282",
"e# c #767676",
"f# c #C9A600",
"g# c #FACE00",
"h# c #F0C600",
"i# c #E3BB00",
"j# c #9B7318",
"k# c #451101",
"l# c #4D1200",
"m# c #601700",
"n# c #781C00",
"o# c #AC2900",
"p# c #C22E00",
"q# c #E45123",
"r# c #E7643B",
"s# c #EA7450",
"t# c #EC8262",
"u# c #C9A194",
"v# c #CAA600",
"w# c #FCD000",
"x# c #F3C800",
"y# c #E8BF00",
"z# c #DABA29",
"A# c #916D34",
"B# c #4D1301",
"C# c #591500",
"D# c #9E2500",
"E# c #B62B00",
"F# c #CD3000",
"G# c #E03702",
"H# c #E34A1A",
"I# c #E65C31",
"J# c #E86D46",
"K# c #CC9482",
"L# c #6E5B00",
"M# c #F6CA00",
"N# c #DAB300",
"O# c #DEBD20",
"P# c #DDC65E",
"Q# c #7C635B",
"R# c #662E1D",
"S# c #691900",
"T# c #7E1E00",
"U# c #952300",
"V# c #AD2900",
"W# c #DA3400",
"X# c #DA6440",
"Y# c #C6907F",
"Z# c #8A7200",
"`# c #C4A100",
" $ c #DFB700",
".$ c #DCB400",
"+$ c #D5AF00",
"@$ c #D0AB00",
"#$ c #CDA800",
"$$ c #E4BC01",
"%$ c #E2C53B",
"&$ c #948884",
"*$ c #896357",
"=$ c #8A4632",
"-$ c #963214",
";$ c #A92902",
">$ c #BC3C14",
",$ c #C75735",
"'$ c #C57B64",
")$ c #B79F98",
" ",
" . . . + @ # $ . ",
" . @ % & * = @ - ; > , ' ) + + . ",
" ! ~ ; { ] ' ^ / ( _ : ' < [ [ ! } = | ",
" ! 1 2 3 4 ' ' 5 6 7 ' ' 8 9 0 a b c d ",
" . . . . e ~ 2 f g h ' ' i j ' ' h k l ' ' m n ",
" e o [ o p q 3 f r s ' ' ' ' ' ' ' ' ' ' ' t ",
" . & { u v w x y z A ' B C D E F G H I J ' ' K $ + ",
" . & L M N O ' ' ' ' P Q . + ! # > R 3 S T ' U V W X Y * ",
" e Z u ` ...' ' +.@. . $ ~ #.( $.O ' ' ' ' %.&. ",
" . $ - 3 *.=.-.;.>. . + ! % ,.'.f ).!.' ' ' ~.{. ",
". ! @ ].^.'./.(.%._. . . + $ [ :.<.2 [.}.|.' s ' 1.2. ",
"3.4.0 u 5.6.7.' ' 8.. + @ ].{ 9.0.a.b.c.c.d.e.f.' g.. ",
"@ L 2 ` h.' ' ' ' i.@ j.L #.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y. ",
"3.4.; 3 z.A.B.C.C.D.^.3 E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U. ",
"! & ].L M ( V.W.n.X.Y.Z.`.I. +.+++@+#+L.$+%+&+*+=+-+;+>+,+ ",
"$ # ].L f '+)+!+~+{+]+^+/+(+_+:+<+[+}+|+1+2+3+4+5+6+7+8+9+0+ ",
"o 4.a+b+c+d+e+f+g+h+h+i+j+9.k+l+m+n+o+p+q+r+s+t+u+v+7+w+x+y+z+ ",
"Z a+A+d+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+$+Q+R+S+4+T+U+V+w+W+X+Y+ ",
"1 *.Z+`+ @.@+@@@#@$@%@&@*@=@-@;@>@,@'@)@!@~@{@]@^@/@(@8+_@:@<@ ",
"- 2 [@}@|@1@2@3@4@5@6@7@8@9@0@a@b@#+c@d@e@f@{@g@h@i@j@k@l@:@m@ ",
"L 0.n@o@d+1@p@q@r@s@t@u@v@9@w@a@x@y@z@A@r+3+{@P.B@C@D@E@F@G@H@ ",
"^.0.I@c+J@1@p@K@r@s@t@L@v@M@N@M+O@P@Q@R@S@T@S+P.B@C@U@V@W@X@Y@ ",
"^.0.I@c+J@1@p@q@r@s@t@u@v@9@Z@`@ #.#+#@###R+$#P.%#&#U@*#=#-#;# ",
"^.0.I@c+J@1@2@3@4@5@6@7@8@9@>#,#'#)#o+p+q+S@!#~#%#{#U@]#^#/#(# ",
"^.0.I@c+J@1@2@_#:#<#[#}#|#1#2#3#4#b@5#L.6#7#8#S+9#C@0#a#8+b#c# ",
"L 3 d#Z+e#1@f#g#K@h#s@i#7@|#1#j#k#l#m#n#z@o#p#T@]@q#r#s#t#u# ",
"- *.f I@Z+1@v#w#3@x#<#y#t@7@|#z#A#B#C#P@+#D#E#F#G#H#I#J#K# ",
"1 <.3 f d#L#2@M#x#h#5@H+t@u@N#O#P#Q#R#S#T#U#V#2+W#t+X#Y#. ",
"Z { <.*.3 Z#`# $u@.$1#+$@$#$v#$$%$:.&$*$=$-$;$>$,$'$)$. ",
"o Z 1 - L ^.^.^.a+^.0 L { :.> ~ 4.Z Z j.[ o & $ e + . ",
"$ # [ ].Z Z Z Z 4.4.Z Z j.[ % % % o o # & $ 3.e + . . "};

View File

@@ -0,0 +1,114 @@
/* XPM */
static char * dynamicaCreateActiveBoxRB_xpm[] = {
"32 32 79 1",
" c #A47D7D",
". c #A53030",
"+ c #AA2424",
"@ c #AD5E5E",
"# c #B1B1B1",
"$ c #880202",
"% c #A61B1B",
"& c #A80101",
"* c #AD5A5A",
"= c #850000",
"- c #C30000",
"; c #B1ADAD",
"> c #A88C8C",
", c #860202",
"' c #A17070",
") c #A17373",
"! c #898989",
"~ c #969696",
"{ c #9C9C9C",
"] c #A7A7A7",
"^ c #0F0F0F",
"/ c #707070",
"( c #ABABAB",
"_ c #737373",
": c #2C2C2C",
"< c #000000",
"[ c #8E8E8E",
"} c #7F7F7F",
"| c #080808",
"1 c #6E6E6E",
"2 c #0C0C0C",
"3 c #A2A2A2",
"4 c #4F4F4F",
"5 c #212121",
"6 c #ADADAD",
"7 c #494949",
"8 c #4B4B4B",
"9 c #606060",
"0 c #131313",
"a c #060606",
"b c #1D1D1D",
"c c #7D7D7D",
"d c #858585",
"e c #929292",
"f c #A0A0A0",
"g c #797979",
"h c #626262",
"i c #6C6C6C",
"j c #414141",
"k c #454545",
"l c #2A2A2A",
"m c #434343",
"n c #7C7C7C",
"o c #5A5A5A",
"p c #121212",
"q c #2F2F2F",
"r c #141414",
"s c #686868",
"t c #A9A9A9",
"u c #818181",
"v c #5C5C5C",
"w c #646464",
"x c #2D2D2D",
"y c #050505",
"z c #151515",
"A c #575757",
"B c #636363",
"C c #555555",
"D c #6A6A6A",
"E c #3C3C3C",
"F c #111111",
"G c #666666",
"H c #090909",
"I c #515151",
"J c #5B5B5B",
"K c #5F5F5F",
"L c #616161",
"M c #A5A5A5",
"N c #959595",
" .+++++++++++++@################",
" $%&&&&&&&&&&&&&*###############",
" =$%&&&&&&&&&&&&&*##############",
" ==$%&&&&&&&&&&&&&*#############",
" ===$--------------;############",
" ====--------------#############",
" ====--------------#############",
" ====--------------#############",
" ====--------------#############",
" ====--------------#############",
" ====--------------#############",
" ====--------------#############",
" ====--------------#############",
">,===--------------#############",
"#',==--------------#############",
"##),=--------------#############",
"###),--------------#############",
"####)--------------#############",
"##########!###############~{####",
"#########]^/###########(_:<[####",
"##########}|~#########12<<<3####",
"###########456########67<<|#####",
"###########658#########90ab#####",
"############~|c#######da[e8#####",
"#############/^fgh###f^i########",
"##############j0<k##6lm#########",
"#niiiiiiiiiiiop<<5iiqrsiii1t####",
"#uvwwwwwwwwwhxy<<zwmaAwwwwBCt###",
"##uvsDDDDDDDDDwEF2GH8DDDDDDsCt##",
"###uvsDDDDDDDDDDDIDBDDDDDDDDsC##",
"####uJKKKKKKKKKKKKKKKKKKKKKKKKL#",
"#####MNNNNNNNNNNNNNNNNNNNNNNNN##"};

View File

@@ -0,0 +1,100 @@
/* XPM */
static char * dynamicaCreateActiveBoxRBArray_xpm[] = {
"32 32 65 1",
" c #B1B1B1",
". c #BE0000",
"+ c #898989",
"@ c #969696",
"# c #9C9C9C",
"$ c #A7A7A7",
"% c #0F0F0F",
"& c #707070",
"* c #ABABAB",
"= c #737373",
"- c #2C2C2C",
"; c #000000",
"> c #8E8E8E",
", c #7F7F7F",
"' c #080808",
") c #6E6E6E",
"! c #0C0C0C",
"~ c #A2A2A2",
"{ c #4F4F4F",
"] c #212121",
"^ c #ADADAD",
"/ c #494949",
"( c #4B4B4B",
"_ c #606060",
": c #131313",
"< c #060606",
"[ c #1D1D1D",
"} c #7D7D7D",
"| c #858585",
"1 c #929292",
"2 c #A0A0A0",
"3 c #797979",
"4 c #626262",
"5 c #6C6C6C",
"6 c #414141",
"7 c #454545",
"8 c #2A2A2A",
"9 c #434343",
"0 c #7C7C7C",
"a c #5A5A5A",
"b c #121212",
"c c #2F2F2F",
"d c #141414",
"e c #686868",
"f c #A9A9A9",
"g c #818181",
"h c #5C5C5C",
"i c #646464",
"j c #2D2D2D",
"k c #050505",
"l c #151515",
"m c #575757",
"n c #636363",
"o c #555555",
"p c #6A6A6A",
"q c #3C3C3C",
"r c #111111",
"s c #666666",
"t c #090909",
"u c #515151",
"v c #5B5B5B",
"w c #5F5F5F",
"x c #616161",
"y c #A5A5A5",
"z c #959595",
" ",
" ",
" ",
" ....... ....... ",
" . . . . ",
" . . . . ",
" . . . . ",
" . . . . ",
" . . . . ",
" ....... ....... ",
" ",
" ....... ....... ",
" . . . . ",
" . . . . ",
" . . . . ",
" . . . . ",
" . . . . ",
" ....... ....... ",
" + @# ",
" $%& *=-;> ",
" ,'@ )!;;;~ ",
" {]^ ^/;;' ",
" ^]( _:<[ ",
" @'} |<>1( ",
" &%234 2%5 ",
" 6:;7 ^89 ",
" 055555555555ab;;]55cde555)f ",
" ghiiiiiiiii4jk;;li9<miiiinof ",
" ghepppppppppiqr!st(ppppppeof ",
" ghepppppppppppupnppppppppeo ",
" gvwwwwwwwwwwwwwwwwwwwwwwwwx ",
" yzzzzzzzzzzzzzzzzzzzzzzzz "};

View File

@@ -0,0 +1,273 @@
/* XPM */
static char * dynamicaCreateActiveHullRB_xpm[] = {
"32 32 238 2",
" c #B1B1B1",
". c #BB8C8C",
"+ c #BE8383",
"@ c #B89898",
"# c #B4A7A7",
"$ c #BB4E4E",
"% c #DD0505",
"& c #C81515",
"* c #D81010",
"= c #E20000",
"- c #D91F1F",
"; c #D43434",
"> c #CE4949",
", c #C56A6A",
"' c #BE8181",
") c #B89696",
"! c #B5A2A2",
"~ c #CC4F4F",
"{ c #DD0E0E",
"] c #AE2121",
"^ c #AB8888",
"/ c #ACACAC",
"( c #7A7A7A",
"_ c #8D8D8D",
": c #BB8E8E",
"< c #C17979",
"[ c #C66464",
"} c #CE4747",
"| c #D62C2C",
"1 c #DC1717",
"2 c #DA1D1D",
"3 c #D43232",
"4 c #CE4646",
"5 c #BC6161",
"6 c #AE6F6F",
"7 c #B28D8D",
"8 c #B69E9E",
"9 c #CD4B4B",
"0 c #DF0C0C",
"a c #B19999",
"b c #686868",
"c c #ABABAB",
"d c #C4C4C4",
"e c #727272",
"f c #6A6A6A",
"g c #6E6E6E",
"h c #717171",
"i c #7C7C7C",
"j c #A3A3A3",
"k c #BA9090",
"l c #A56060",
"m c #8F2F2F",
"n c #AE2626",
"o c #C21B1B",
"p c #D50909",
"q c #D32D2D",
"r c #B79A9A",
"s c #DE0F0F",
"t c #C65151",
"u c #867676",
"v c #666666",
"w c #595959",
"x c #B6B6B6",
"y c #9F9F9F",
"z c #999999",
"A c #959595",
"B c #8A8A8A",
"C c #797979",
"D c #5D5D5D",
"E c #A1A1A1",
"F c #AEAEAE",
"G c #7D7D7D",
"H c #C81111",
"I c #BA7878",
"J c #B2ADAD",
"K c #DC1414",
"L c #B95252",
"M c #8B7E7E",
"N c #5A5A5A",
"O c #919191",
"P c #C2C2C2",
"Q c #CACACA",
"R c #C7C7C7",
"S c #C3C3C3",
"T c #C0C0C0",
"U c #BDBDBD",
"V c #B9B9B9",
"W c #B7B7B7",
"X c #B5B5B5",
"Y c #696969",
"Z c #8F8F8F",
"` c #6D6D6D",
" . c #969696",
".. c #767676",
"+. c #965B5B",
"@. c #D91C1C",
"#. c #937373",
"$. c #D20A0A",
"%. c #888888",
"&. c #BBBBBB",
"*. c #CDCDCD",
"=. c #CCCCCC",
"-. c #C8C8C8",
";. c #C5C5C5",
">. c #C1C1C1",
",. c #BEBEBE",
"'. c #B4B4B4",
"). c #B3B3B3",
"!. c #9C9C9C",
"~. c #676767",
"{. c #A8A8A8",
"]. c #B0B0B0",
"^. c #616161",
"/. c #C37070",
"(. c #855050",
"_. c #D82B2B",
":. c #A7A7A7",
"<. c #B2B2B2",
"[. c #6C6C6C",
"}. c #818181",
"|. c #808080",
"1. c #946A6A",
"2. c #DC1515",
"3. c #B25D5D",
"4. c #DF1414",
"5. c #575454",
"6. c #CBCBCB",
"7. c #BABABA",
"8. c #B8B8B8",
"9. c #9E9E9E",
"0. c #7F7F7F",
"a. c #656565",
"b. c #C93939",
"c. c #C76060",
"d. c #6D6B6B",
"e. c #DC2D2D",
"f. c #924545",
"g. c #828282",
"h. c #A2A2A2",
"i. c #634848",
"j. c #DE0C0C",
"k. c #B3A9A9",
"l. c #9E5454",
"m. c #D42A2A",
"n. c #C6C6C6",
"o. c #BC3A3A",
"p. c #CF4343",
"q. c #8D8A8A",
"r. c #D50B0B",
"s. c #C49F9F",
"t. c #9F4D4D",
"u. c #DD1313",
"v. c #AA3D3D",
"w. c #C13F3F",
"x. c #A0A0A0",
"y. c #A05353",
"z. c #9B8686",
"A. c #DA0808",
"B. c #BCB1B1",
"C. c #5E5E5E",
"D. c #A55D5D",
"E. c #DD1111",
"F. c #BA9292",
"G. c #BE2929",
"H. c #B24242",
"I. c #B5B2B2",
"J. c #626262",
"K. c #9E5C5C",
"L. c #B48989",
"M. c #CA1C1C",
"N. c #D30E0E",
"O. c #BA5F5F",
"P. c #A5A5A5",
"Q. c #858585",
"R. c #9D6060",
"S. c #9E6B6B",
"T. c #BB1919",
"U. c #D70C0C",
"V. c #AB4C4C",
"W. c #8E7E7E",
"X. c #9A6D6D",
"Y. c #9E5E5E",
"Z. c #A34949",
"`. c #A83333",
" + c #AB2323",
".+ c #CA1D1D",
"++ c #D62121",
"@+ c #E10404",
"#+ c #BD8787",
"$+ c #9C7272",
"%+ c #C22929",
"&+ c #E10101",
"*+ c #CD1818",
"=+ c #C82121",
"-+ c #BE3737",
";+ c #BE4C4C",
">+ c #C06666",
",+ c #898989",
"'+ c #0F0F0F",
")+ c #707070",
"!+ c #737373",
"~+ c #2C2C2C",
"{+ c #000000",
"]+ c #8E8E8E",
"^+ c #080808",
"/+ c #0C0C0C",
"(+ c #4F4F4F",
"_+ c #212121",
":+ c #ADADAD",
"<+ c #494949",
"[+ c #4B4B4B",
"}+ c #606060",
"|+ c #131313",
"1+ c #060606",
"2+ c #1D1D1D",
"3+ c #929292",
"4+ c #414141",
"5+ c #454545",
"6+ c #2A2A2A",
"7+ c #434343",
"8+ c #121212",
"9+ c #2F2F2F",
"0+ c #141414",
"a+ c #A9A9A9",
"b+ c #5C5C5C",
"c+ c #646464",
"d+ c #2D2D2D",
"e+ c #050505",
"f+ c #151515",
"g+ c #575757",
"h+ c #636363",
"i+ c #555555",
"j+ c #3C3C3C",
"k+ c #111111",
"l+ c #090909",
"m+ c #515151",
"n+ c #5B5B5B",
"o+ c #5F5F5F",
" . + @ ",
" # $ % & * = - ; > , ' ) ",
" ! ~ { ] ^ / ( _ : < [ } | 1 = 2 3 4 5 6 7 ",
" 8 9 0 9 a b c d e b f g h i j k l m n o p q ",
" r } s t u v w h / d x j y z A B C A D E F G H I ",
"J K L M N O P Q R S T U V W X X Y Z ` . ..+.@. ",
"#.$.e %.&.*.=.Q -.;.>.,.&.W X '.).!.~.{.N ].E ^.3 /. ",
"(._.:.E *.=.Q -.;.P ,.&.V X ).<. [.( }. |.1.2.J ",
"3.4.5.b *.6.-.;.P ,.7.8.x ). 9.0.]. a.b.c. ",
"d.e.f.g.Q -.;.P ,.V x '.<. h.i.j.k. ",
"C l.m.c n.d T U V '. g o.p. ",
" q.r.s.>.,.&.W ). c ..t.u.r ",
" v.w.U 7.W ). x.D y.u.) ",
" z.A.B.W '. {.C.D.E.F. ",
" G.H.I. :.J.K.s : ",
" L.M.N.O.J P.Q.N R.0 . ",
" S.T.U.V.W.X.Y.Z.`. +.+++@+#+ ",
" c $+%+&+*+=+-+;+>+' : J ",
" ,+ .!. ",
" :.'+)+ c !+~+{+]+ ",
" 0.^+ . g /+{+{+{+h. ",
" (+_+:+ :+<+{+{+^+ ",
" :+_+[+ }+|+1+2+ ",
" .^+G Q.1+]+3+[+ ",
" )+'+x.C J. x.'+[. ",
" 4+|+{+5+ :+6+7+ ",
" i [.[.[.[.[.[.[.[.[.[.[.N 8+{+{+_+[.[.9+0+b [.[.[.g a+ ",
" }.b+c+c+c+c+c+c+c+c+c+J.d+e+{+{+f+c+7+1+g+c+c+c+c+h+i+a+ ",
" }.b+b f f f f f f f f f c+j+k+/+v l+[+f f f f f f b i+a+ ",
" }.b+b f f f f f f f f f f f m+f h+f f f f f f f f b i+ ",
" }.n+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+^. ",
" P.A A A A A A A A A A A A A A A A A A A A A A A A "};

View File

@@ -0,0 +1,145 @@
/* XPM */
static char * dynamicaCreateActiveHullRBArray_xpm[] = {
"32 32 110 2",
" c #B1B1B1",
". c #B3ABAB",
"+ c #C17777",
"@ c #CA5757",
"# c #C66464",
"$ c #C27272",
"% c #BD8484",
"& c #B99595",
"* c #B5A2A2",
"= c #B3A9A9",
"- c #CB5454",
"; c #C37070",
"> c #B79A9A",
", c #BE8383",
"' c #C27575",
") c #C76363",
"! c #C95C5C",
"~ c #C85E5E",
"{ c #C76262",
"] c #C56A6A",
"^ c #BB8E8E",
"/ c #CA5555",
"( c #C27474",
"_ c #B4A5A5",
": c #B3AAAA",
"< c #CE4747",
"[ c #C95B5B",
"} c #B89696",
"| c #BE8080",
"1 c #B89797",
"2 c #BC8A8A",
"3 c #C66767",
"4 c #C36E6E",
"5 c #B2AEAE",
"6 c #CA5858",
"7 c #B4A7A7",
"8 c #BF7F7F",
"9 c #C95A5A",
"0 c #C07979",
"a c #BE8181",
"b c #C37171",
"c c #BD8585",
"d c #C17878",
"e c #C46C6C",
"f c #B3A8A8",
"g c #946464",
"h c #969696",
"i c #9C9C9C",
"j c #BD5757",
"k c #110707",
"l c #726B6B",
"m c #ABABAB",
"n c #737373",
"o c #2C2C2C",
"p c #000000",
"q c #8E8E8E",
"r c #7F7F7F",
"s c #080808",
"t c #6E6E6E",
"u c #0C0C0C",
"v c #A2A2A2",
"w c #4F4F4F",
"x c #212121",
"y c #ADADAD",
"z c #494949",
"A c #4B4B4B",
"B c #606060",
"C c #131313",
"D c #060606",
"E c #1D1D1D",
"F c #7D7D7D",
"G c #858585",
"H c #929292",
"I c #707070",
"J c #0F0F0F",
"K c #A0A0A0",
"L c #797979",
"M c #626262",
"N c #6C6C6C",
"O c #414141",
"P c #454545",
"Q c #2A2A2A",
"R c #434343",
"S c #7C7C7C",
"T c #5A5A5A",
"U c #121212",
"V c #2F2F2F",
"W c #141414",
"X c #686868",
"Y c #A9A9A9",
"Z c #818181",
"` c #5C5C5C",
" . c #646464",
".. c #2D2D2D",
"+. c #050505",
"@. c #151515",
"#. c #575757",
"$. c #636363",
"%. c #555555",
"&. c #6A6A6A",
"*. c #3C3C3C",
"=. c #111111",
"-. c #666666",
";. c #090909",
">. c #515151",
",. c #5B5B5B",
"'. c #5F5F5F",
"). c #616161",
"!. c #A5A5A5",
"~. c #959595",
" ",
" . + @ # $ % & * = ",
" = + - ; > & , ' ) ! ~ { ] ",
" ^ / ( _ : ^ < ",
" [ } ( | . + @ # $ % & * = ",
" @ 1 = / = = + - ; > & , ' ) ! ~ { ] ",
" 2 3 4 ; ^ / ( _ : ^ < ",
" 5 6 7 8 9 . [ } ( | ",
" 0 ) 7 a / : @ 1 = / = ",
" 5 ' - b c d e ! 6 f 2 3 4 ; ",
" 5 6 7 8 9 . ",
" . + @ # $ % & * = 0 ) 7 a / : ",
" = + - ; > & , ' ) ! ~ { ] 5 ' - b c d e ! 6 f ",
" ^ / ( _ : ^ < ",
" [ } ( | ",
" @ 1 = / = ",
" 2 3 4 ; ",
" 5 6 7 8 9 . ",
" 0 ) 7 g / : h i ",
" 5 ' - b c d e j k l m n o p q ",
" r s h t u p p p v ",
" w x y y z p p s ",
" y x A B C D E ",
" h s F G D q H A ",
" I J K L M K J N ",
" O C p P y Q R ",
" S N N N N N N N N N N N T U p p x N N V W X N N N t Y ",
" Z ` . . . . . . . . .M ..+.p p @. .R D #. . . . .$.%.Y ",
" Z ` X &.&.&.&.&.&.&.&.&. .*.=.u -.;.A &.&.&.&.&.&.X %.Y ",
" Z ` X &.&.&.&.&.&.&.&.&.&.&.>.&.$.&.&.&.&.&.&.&.&.X %. ",
" Z ,.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.). ",
" !.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. "};

View File

@@ -0,0 +1,247 @@
/* XPM */
static char * dynamicaCreateActiveMeshRB_xpm[] = {
"32 32 212 2",
" c #B1B1B1",
". c #A7A7A7",
"+ c #989898",
"@ c #939393",
"# c #A2A2A2",
"$ c #AFAFAF",
"% c #918888",
"& c #BC5B5B",
"* c #C34949",
"= c #A56969",
"- c #A3A3A3",
"; c #ABABAB",
"> c #A8A8A8",
", c #AEAEAE",
"' c #959595",
") c #C35858",
"! c #D13D3D",
"~ c #A07171",
"{ c #969696",
"] c #979797",
"^ c #9C9C9C",
"/ c #ACACAC",
"( c #8C8B8B",
"_ c #957777",
": c #996B6B",
"< c #918080",
"[ c #ADADAD",
"} c #9E9E9E",
"| c #949494",
"1 c #A07C7C",
"2 c #C35A5A",
"3 c #D23E3E",
"4 c #C93B3B",
"5 c #BD4141",
"6 c #BA3C3C",
"7 c #B63939",
"8 c #B33B3B",
"9 c #AD4848",
"0 c #9B9B9B",
"a c #A6A6A6",
"b c #937E7E",
"c c #BA2020",
"d c #C10404",
"e c #A54C4C",
"f c #908282",
"g c #A0A0A0",
"h c #B37272",
"i c #C76464",
"j c #D15959",
"k c #D65151",
"l c #D44848",
"m c #D13C3C",
"n c #CF3131",
"o c #CC2626",
"p c #C91B1B",
"q c #C71212",
"r c #C60E0E",
"s c #C60D0D",
"t c #9A6E6E",
"u c #A4A4A4",
"v c #B42D2D",
"w c #C30000",
"x c #A15757",
"y c #A1A1A1",
"z c #8F8989",
"A c #A07D7D",
"B c #AE7676",
"C c #CD6565",
"D c #D85B5B",
"E c #D75757",
"F c #D65252",
"G c #D54C4C",
"H c #D34242",
"I c #CF3535",
"J c #CD2B2B",
"K c #CB2020",
"L c #C81515",
"M c #C60C0C",
"N c #C50909",
"O c #C50707",
"P c #B72323",
"Q c #917F7F",
"R c #C20202",
"S c #BA1717",
"T c #929292",
"U c #9B7F7F",
"V c #CB5A5A",
"W c #C16767",
"X c #BE6D6D",
"Y c #D95D5D",
"Z c #D85959",
"` c #D34343",
" . c #D03737",
".. c #CB2222",
"+. c #C91919",
"@. c #C40606",
"#. c #C30202",
"$. c #9C6464",
"%. c #A84646",
"&. c #A74848",
"*. c #9F9F9F",
"=. c #B66565",
"-. c #D25050",
";. c #8D8D8D",
">. c #9A8383",
",. c #D85A5A",
"'. c #D75454",
"). c #D03838",
"!. c #CD2929",
"~. c #CA1E1E",
"{. c #C81717",
"]. c #C71010",
"^. c #B81B1B",
"/. c #976F6F",
"(. c #A9A9A9",
"_. c #9C7B7B",
":. c #D44949",
"<. c #9A8080",
"[. c #AB7575",
"}. c #D75353",
"|. c #CD2A2A",
"1. c #C60B0B",
"2. c #C40303",
"3. c #BA1616",
"4. c #8D8A8A",
"5. c #A76E6E",
"6. c #C35353",
"7. c #C35757",
"8. c #D34545",
"9. c #CF3232",
"0. c #CC2727",
"a. c #9D6262",
"b. c #9C7878",
"c. c #CD3B3B",
"d. c #CF3434",
"e. c #C81414",
"f. c #C00808",
"g. c #A15656",
"h. c #9A9A9A",
"i. c #B45252",
"j. c #C71313",
"k. c #BA1818",
"l. c #937A7A",
"m. c #9D9D9D",
"n. c #9F6D6D",
"o. c #BE0E0E",
"p. c #937979",
"q. c #AA5151",
"r. c #BD0F0F",
"s. c #967373",
"t. c #9C6565",
"u. c #B91A1A",
"v. c #BC1212",
"w. c #AA4141",
"x. c #8F8383",
"y. c #A94242",
"z. c #AB3C3C",
"A. c #A35252",
"B. c #9A6969",
"C. c #898989",
"D. c #0F0F0F",
"E. c #707070",
"F. c #737373",
"G. c #2C2C2C",
"H. c #000000",
"I. c #8E8E8E",
"J. c #7F7F7F",
"K. c #080808",
"L. c #6E6E6E",
"M. c #0C0C0C",
"N. c #4F4F4F",
"O. c #212121",
"P. c #494949",
"Q. c #4B4B4B",
"R. c #606060",
"S. c #131313",
"T. c #060606",
"U. c #1D1D1D",
"V. c #7D7D7D",
"W. c #858585",
"X. c #797979",
"Y. c #626262",
"Z. c #6C6C6C",
"`. c #414141",
" + c #454545",
".+ c #2A2A2A",
"++ c #434343",
"@+ c #7C7C7C",
"#+ c #5A5A5A",
"$+ c #121212",
"%+ c #2F2F2F",
"&+ c #141414",
"*+ c #686868",
"=+ c #818181",
"-+ c #5C5C5C",
";+ c #646464",
">+ c #2D2D2D",
",+ c #050505",
"'+ c #151515",
")+ c #575757",
"!+ c #636363",
"~+ c #555555",
"{+ c #6A6A6A",
"]+ c #3C3C3C",
"^+ c #111111",
"/+ c #666666",
"(+ c #090909",
"_+ c #515151",
":+ c #5B5B5B",
"<+ c #5F5F5F",
"[+ c #616161",
"}+ c #A5A5A5",
" ",
" . + @ # ",
" $ % & * = - ; > , ",
" $ ' ) ! ~ ' { ] + ^ / # ( _ : < , ",
" [ } | % 1 2 3 4 5 6 7 8 9 0 a b c d e f , ",
" $ . g % h i j k l m n o p q r s t u ] v w x ^ , ",
"y z A B C D E F G H I J K L M N O P ' , Q R S T ",
"U V W X Y Z F G ` .J ..+.r @.#.w w $.^ %.w &.*. ",
"=.-.;.>.,.'.G ` ).!.~.{.].@.w w w w ^.&.R w /.(. ",
"_.:.<.[.}.G H .|.p ].1.2.w w w w w w w w 3.4. ",
"0 5.6.7.8.! 9.0.+.N w w w w w w w w w w w a.y ",
" - b.c.d.J K e.@.w w w w w w w w w w f.g.0 ",
" h.i.0.~.j.@.w w w w w w w w w w k.l.m. ",
" a n.~.e.N w w w w w w w w w w o.p.# ",
" 0 q.1.w w w w w w w w w w r.s.*. ",
" , 0 t.u.w w w w w w w v.w.Q *. ",
" # x.x y.z.z.y.A.B.f m./ ",
" $ - } ^ ^ } # > , ",
" C. { ^ ",
" . D.E. ; F.G.H.I. ",
" J.K.{ L.M.H.H.H.# ",
" N.O.[ [ P.H.H.K. ",
" [ O.Q. R.S.T.U. ",
" { K.V. W.T.I.T Q. ",
" E.D.g X.Y. g D.Z. ",
" `.S.H. + [ .+++ ",
" @+Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.#+$+H.H.O.Z.Z.%+&+*+Z.Z.Z.L.(. ",
" =+-+;+;+;+;+;+;+;+;+;+Y.>+,+H.H.'+;+++T.)+;+;+;+;+!+~+(. ",
" =+-+*+{+{+{+{+{+{+{+{+{+;+]+^+M./+(+Q.{+{+{+{+{+{+*+~+(. ",
" =+-+*+{+{+{+{+{+{+{+{+{+{+{+_+{+!+{+{+{+{+{+{+{+{+*+~+ ",
" =+:+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+<+[+ ",
" }+' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' "};

View File

@@ -0,0 +1,174 @@
/* XPM */
static char * dynamicaCreateActiveMeshRBArray_xpm[] = {
"32 32 139 2",
" c #B1B1B1",
". c #A2A2A2",
"+ c #929292",
"@ c #AFAFAF",
"# c #B0B0B0",
"$ c #ABABAB",
"% c #ACACAC",
"& c #ADADAD",
"* c #928787",
"= c #C75252",
"- c #9E7777",
"; c #8F8888",
"> c #8E8888",
", c #A4A4A4",
"' c #947777",
") c #947878",
"! c #A9A9A9",
"~ c #A0A0A0",
"{ c #948787",
"] c #AA7878",
"^ c #BB6868",
"/ c #D24A4A",
"( c #CA4141",
"_ c #C33939",
": c #BE2E2E",
"< c #996E6E",
"[ c #A5A5A5",
"} c #9E5E5E",
"| c #B62020",
"1 c #957474",
"2 c #A7A7A7",
"3 c #9C7E7E",
"4 c #AE7373",
"5 c #CB6262",
"6 c #D75757",
"7 c #D65050",
"8 c #D24141",
"9 c #CE2D2D",
"0 c #C81616",
"a c #C30000",
"b c #B32929",
"c c #B52323",
"d c #A25454",
"e c #989898",
"f c #BC5C5C",
"g c #A77474",
"h c #CC5555",
"i c #D54B4B",
"j c #C71212",
"k c #C10404",
"l c #B32828",
"m c #BE0D0D",
"n c #917F7F",
"o c #AEAEAE",
"p c #9A7B7B",
"q c #B75A5A",
"r c #CF3F3F",
"s c #CF3535",
"t c #CC2525",
"u c #C60B0B",
"v c #A84646",
"w c #9E9E9E",
"x c #9E7272",
"y c #CC2626",
"z c #C91919",
"A c #C40404",
"B c #C30101",
"C c #A35252",
"D c #8C8B8B",
"E c #8D8A8A",
"F c #B03F3F",
"G c #A35151",
"H c #9B9B9B",
"I c #A15656",
"J c #B22A2A",
"K c #B52424",
"L c #B22C2C",
"M c #A94141",
"N c #976F6F",
"O c #9C9C9C",
"P c #A3A3A3",
"Q c #979797",
"R c #969696",
"S c #9D9D9D",
"T c #937777",
"U c #898686",
"V c #797979",
"W c #9F9F9F",
"X c #0F0F0F",
"Y c #707070",
"Z c #737373",
"` c #2C2C2C",
" . c #000000",
".. c #8E8E8E",
"+. c #7F7F7F",
"@. c #080808",
"#. c #6E6E6E",
"$. c #0C0C0C",
"%. c #4F4F4F",
"&. c #212121",
"*. c #494949",
"=. c #4B4B4B",
"-. c #606060",
";. c #131313",
">. c #060606",
",. c #1D1D1D",
"'. c #7D7D7D",
"). c #858585",
"!. c #626262",
"~. c #6C6C6C",
"{. c #414141",
"]. c #454545",
"^. c #2A2A2A",
"/. c #434343",
"(. c #7C7C7C",
"_. c #5A5A5A",
":. c #121212",
"<. c #2F2F2F",
"[. c #141414",
"}. c #686868",
"|. c #818181",
"1. c #5C5C5C",
"2. c #646464",
"3. c #2D2D2D",
"4. c #050505",
"5. c #151515",
"6. c #575757",
"7. c #636363",
"8. c #555555",
"9. c #6A6A6A",
"0. c #3C3C3C",
"a. c #111111",
"b. c #666666",
"c. c #090909",
"d. c #515151",
"e. c #5B5B5B",
"f. c #5F5F5F",
"g. c #616161",
"h. c #959595",
" . + . @ # $ % ",
" & . * = - ; > . , ' ) % ",
" ! ~ { ] ^ / ( _ : < [ } | 1 $ ",
"2 3 4 5 6 7 8 9 0 a b > c d . ",
"e f g h i 8 9 j a a k l m n o . + . @ # $ % ",
"2 p q r s t u a a a a a v w & . * = - ; > . , ' ) % ",
" 2 x y z A a a a a B C D o ! ~ { ] ^ / ( _ : < [ } | 1 $ ",
" # E F a a a a a k G H 2 3 4 5 6 7 8 9 0 a b > c d . ",
" ! D I J K L M N O e f g h i 8 9 j a a k l m n o ",
" P Q R e S ! 2 p q r s t u a a a a a v w ",
" . + . @ # $ . x y z A a a a a B C D o ",
" & . * = - ; > . , ' T U F a a a a a k G H ",
" ! ~ { ] ^ / ( _ : < [ } | 1 P D I J K L M N O ",
"2 3 4 5 6 7 8 9 0 a b > c d . P Q R e S ! ",
"e f g h i 8 9 j a a k l m n o ",
"2 p q r s t u a a a a a v w ",
" 2 x y z A a a a a B C D o ",
" # E F a a a a a k G H ",
" ! D I J K L M N V R O ",
" P Q R e S W X Y $ Z ` ... ",
" +.@.R #.$. . . .. ",
" %.&.& & *. . .@. ",
" & &.=. -.;.>.,. ",
" R @.'. ).>...+ =. ",
" Y X ~ V !. ~ X ~. ",
" {.;. .]. & ^./. ",
" (.~.~.~.~.~.~.~.~.~.~.~._.:. . .&.~.~.<.[.}.~.~.~.#.! ",
" |.1.2.2.2.2.2.2.2.2.2.!.3.4. . .5.2./.>.6.2.2.2.2.7.8.! ",
" |.1.}.9.9.9.9.9.9.9.9.9.2.0.a.$.b.c.=.9.9.9.9.9.9.}.8.! ",
" |.1.}.9.9.9.9.9.9.9.9.9.9.9.d.9.7.9.9.9.9.9.9.9.9.}.8. ",
" |.e.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.g. ",
" [ h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h. "};

View File

@@ -0,0 +1,55 @@
/* XPM */
static char * dynamicaCreateActivePlaneRB_xpm[] = {
"32 32 20 1",
" c #B1B1B1",
". c #958F8F",
"+ c #8F8181",
"@ c #908383",
"# c #ACACAC",
"$ c #969595",
"% c #8B7171",
"& c #C52525",
"* c #C22828",
"= c #7C7C7C",
"- c #8A7272",
"; c #DC0909",
"> c #E40000",
", c #DB0B0B",
"' c #887373",
") c #867575",
"! c #986161",
"~ c #887B7B",
"{ c #AAAAAA",
"] c #A1A1A1",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .++++++++++++++++++++++++@# ",
" $%&&&&&&&&&&&&&&&&&&&&&&&*=# ",
" $-;>>>>>>>>>>>>>>>>>>>>>>,=# ",
" $';>>>>>>>>>>>>>>>>>>>>>>,= ",
" $)!!!!!!!!!!!!!!!!!!!!!!!!~ ",
" {]]]]]]]]]]]]]]]]]]]]]]]] ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,66 @@
/* XPM */
static char * dynamicaCreateActivePlaneRBArray_xpm[] = {
"32 32 31 1",
" c #B1B1B1",
". c #928787",
"+ c #8B7D7D",
"@ c #8C7E7E",
"# c #8C7D7D",
"$ c #8F8181",
"% c #969696",
"& c #8D7E7E",
"* c #AE4141",
"= c #CB1E1E",
"- c #CC1D1D",
"; c #AC4444",
"> c #8D7F7F",
", c #ADADAD",
"' c #7F7B7B",
") c #E30101",
"! c #E40000",
"~ c #946666",
"{ c #959090",
"] c #948D8D",
"^ c #9C5C5C",
"/ c #DE0707",
"( c #807B7B",
"_ c #7D7B7B",
": c #986161",
"< c #956565",
"[ c #996060",
"} c #7F7A7A",
"| c #AFAFAF",
"1 c #A1A1A1",
"2 c #A2A2A2",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .+@@@@@@@@@@@#$% ",
" &*===========-;> ",
" ,')!!!!!!!!!!!!~{ ",
" ]^!!!!!!!!!!!!/( ",
" _:<<<<<<<<<<<[}| ",
" 1222222222221| ",
" .+@@@@@@@@@@@#$% ",
" &*===========-;> ",
" ,')!!!!!!!!!!!!~{ ",
" ]^!!!!!!!!!!!!/( ",
" _:<<<<<<<<<<<[}| ",
" 1222222222221| ",
" .+@@@@@@@@@@@#$% ",
" &*===========-;> ",
" ,')!!!!!!!!!!!!~{ ",
" ]^!!!!!!!!!!!!/( ",
" _:<<<<<<<<<<<[}| ",
" 1222222222221| ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,37 @@
/* XPM */
static char * dynamicaCreateActiveRB_xpm[] = {
"32 32 2 1",
" c None",
". c #4E36E0",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................"};

View File

@@ -0,0 +1,229 @@
/* XPM */
static char * dynamicaCreateActiveSphereRB_xpm[] = {
"32 32 194 2",
" c #B1B1B1",
". c #B2AFAF",
"+ c #BAA2A2",
"@ c #BD9C9C",
"# c #BC9A9A",
"$ c #BB9696",
"% c #B69E9E",
"& c #B5ACAC",
"* c #C69696",
"= c #D18686",
"- c #D18181",
"; c #CF7E7E",
"> c #CC7777",
", c #C96D6D",
"' c #C46161",
") c #BE5A5A",
"! c #B57878",
"~ c #B1ABAB",
"{ c #BEA2A2",
"] c #D28989",
"^ c #D38787",
"/ c #D28484",
"( c #CE7C7C",
"_ c #CB7474",
": c #C76969",
"< c #C25A5A",
"[ c #BB4848",
"} c #B43434",
"| c #AC2D2D",
"1 c #AE8D8D",
"2 c #C19E9E",
"3 c #D38888",
"4 c #D08080",
"5 c #CE7A7A",
"6 c #CA7070",
"7 c #C56363",
"8 c #BE5151",
"9 c #B63B3B",
"0 c #AE2323",
"a c #A40A0A",
"b c #A20707",
"c c #AD8686",
"d c #BAA6A6",
"e c #D48989",
"f c #D28686",
"g c #D18383",
"h c #CC7676",
"i c #C86A6A",
"j c #C25B5B",
"k c #BA4545",
"l c #B02A2A",
"m c #A60E0E",
"n c #A10101",
"o c #A20F0F",
"p c #AF9E9E",
"q c #CE8E8E",
"r c #C96E6E",
"s c #BE4F4F",
"t c #B43535",
"u c #A81414",
"v c #A74343",
"w c #BDA2A2",
"x c #CB7272",
"y c #C56262",
"z c #BF5353",
"A c #B73E3E",
"B c #AC1F1F",
"C c #A10303",
"D c #AF9C9C",
"E c #C89494",
"F c #CF7D7D",
"G c #C66565",
"H c #B73D3D",
"I c #AE2525",
"J c #AA6666",
"K c #CC8989",
"L c #D18282",
"M c #C76767",
"N c #BE5050",
"O c #AC1E1E",
"P c #A20404",
"Q c #A74545",
"R c #CF8282",
"S c #C15858",
"T c #B73C3C",
"U c #AB1B1B",
"V c #A20505",
"W c #A63535",
"X c #CC7F7F",
"Y c #C35D5D",
"Z c #BC4A4A",
"` c #B02B2B",
" . c #A63939",
".. c #C87F7F",
"+. c #C86C6C",
"@. c #BD4C4C",
"#. c #A71111",
"$. c #A84949",
"%. c #BF8888",
"&. c #C45F5F",
"*. c #C05656",
"=. c #A91717",
"-. c #AB7373",
";. c #B69C9C",
">. c #BA4444",
",. c #B33232",
"'. c #AA1919",
"). c #A20909",
"!. c #B0A9A9",
"~. c #BA6767",
"{. c #B84040",
"]. c #B23030",
"^. c #A95A5A",
"/. c #B29F9F",
"(. c #B23636",
"_. c #A20303",
":. c #A42222",
"<. c #B0ABAB",
"[. c #AF8C8C",
"}. c #A40E0E",
"|. c #A31A1A",
"1. c #AE9292",
"2. c #A41E1E",
"3. c #B0A5A5",
"4. c #B1AFAF",
"5. c #AB6B6B",
"6. c #A52C2C",
"7. c #7D0101",
"8. c #A63737",
"9. c #AD8383",
"0. c #969696",
"a. c #9C9C9C",
"b. c #A48686",
"c. c #0E0C0C",
"d. c #6F5B5B",
"e. c #ABABAB",
"f. c #737373",
"g. c #2C2C2C",
"h. c #000000",
"i. c #8E8E8E",
"j. c #7F7F7F",
"k. c #080808",
"l. c #6E6E6E",
"m. c #0C0C0C",
"n. c #A2A2A2",
"o. c #4F4F4F",
"p. c #212121",
"q. c #ADADAD",
"r. c #494949",
"s. c #4B4B4B",
"t. c #606060",
"u. c #131313",
"v. c #060606",
"w. c #1D1D1D",
"x. c #7D7D7D",
"y. c #858585",
"z. c #929292",
"A. c #707070",
"B. c #0F0F0F",
"C. c #A0A0A0",
"D. c #797979",
"E. c #626262",
"F. c #6C6C6C",
"G. c #414141",
"H. c #454545",
"I. c #2A2A2A",
"J. c #434343",
"K. c #7C7C7C",
"L. c #5A5A5A",
"M. c #121212",
"N. c #2F2F2F",
"O. c #141414",
"P. c #686868",
"Q. c #A9A9A9",
"R. c #818181",
"S. c #5C5C5C",
"T. c #646464",
"U. c #2D2D2D",
"V. c #050505",
"W. c #151515",
"X. c #575757",
"Y. c #636363",
"Z. c #555555",
"`. c #6A6A6A",
" + c #3C3C3C",
".+ c #111111",
"++ c #666666",
"@+ c #090909",
"#+ c #515151",
"$+ c #5B5B5B",
"%+ c #5F5F5F",
"&+ c #616161",
"*+ c #A5A5A5",
"=+ c #959595",
" . + @ # $ % ",
" & * = - ; > , ' ) ! ~ ",
" { ] ^ / - ( _ : < [ } | 1 ",
" 2 3 3 ^ / 4 5 6 7 8 9 0 a b c ",
" d e 3 3 f g ; h i j k l m n n o p ",
" q 3 3 ^ / 4 5 r ' s t u n n n n v ",
" w 3 ^ ^ / - ( x y z A B n n n n n C D ",
" E f f / - F _ G s H I n n n n n n n J ",
" K g L 4 ( _ M N } O P n n n n n n n Q ",
" R 4 ; 5 _ : S T U V n n n n n n n n W ",
" X 5 > x i Y Z ` a n n n n n n n n n . ",
" ..x +.G j @.t #.n n n n n n n n n n $. ",
" %.M &.*.[ } =.n n n n n n n n n n n -. ",
" ;.j 8 >.,.'.n n n n n n n n n n n ).!. ",
" ~.{.].U n n n n n n n n n n n n ^. ",
" /.(.U _.n n n n n n n n n n n :.<. ",
" [.}.n n n n n n n n n n n |.p ",
" 1.2.n n n n n n n n n W 3. ",
" 4.5.6.n n 7.n b 8.9. 0.a. ",
" <.b.c.d. e.f.g.h.i. ",
" j.k.0. l.m.h.h.h.n. ",
" o.p.q. q.r.h.h.k. ",
" q.p.s. t.u.v.w. ",
" 0.k.x. y.v.i.z.s. ",
" A.B.C.D.E. C.B.F. ",
" G.u.h.H. q.I.J. ",
" K.F.F.F.F.F.F.F.F.F.F.F.L.M.h.h.p.F.F.N.O.P.F.F.F.l.Q. ",
" R.S.T.T.T.T.T.T.T.T.T.E.U.V.h.h.W.T.J.v.X.T.T.T.T.Y.Z.Q. ",
" R.S.P.`.`.`.`.`.`.`.`.`.T. +.+m.++@+s.`.`.`.`.`.`.P.Z.Q. ",
" R.S.P.`.`.`.`.`.`.`.`.`.`.`.#+`.Y.`.`.`.`.`.`.`.`.P.Z. ",
" R.$+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+&+ ",
" *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ "};

View File

@@ -0,0 +1,134 @@
/* XPM */
static char * dynamicaCreateActiveSphereRBArray_xpm[] = {
"32 32 99 2",
" c #B1B1B1",
". c #B69C9C",
"+ c #B99292",
"@ c #BE7B7B",
"# c #D13232",
"$ c #D81515",
"% c #D51F1F",
"& c #D61B1B",
"* c #C46464",
"= c #BB8989",
"- c #D90F0F",
"; c #BD7F7F",
"> c #B89696",
", c #C56262",
"' c #CD4141",
") c #C17070",
"! c #B79898",
"~ c #DC0202",
"{ c #B2AFAF",
"] c #DB0808",
"^ c #B3A9A9",
"/ c #B5A2A2",
"( c #D71717",
"_ c #B79A9A",
": c #C85555",
"< c #C65C5C",
"[ c #BD8181",
"} c #D13030",
"| c #B69E9E",
"1 c #B4A5A5",
"2 c #C26E6E",
"3 c #DA0A0A",
"4 c #BF7979",
"5 c #DA0C0C",
"6 c #CC4343",
"7 c #BA8C8C",
"8 c #898989",
"9 c #969696",
"0 c #9C9C9C",
"a c #A7A7A7",
"b c #0F0F0F",
"c c #707070",
"d c #ABABAB",
"e c #737373",
"f c #2C2C2C",
"g c #000000",
"h c #8E8E8E",
"i c #7F7F7F",
"j c #080808",
"k c #6E6E6E",
"l c #0C0C0C",
"m c #A2A2A2",
"n c #4F4F4F",
"o c #212121",
"p c #ADADAD",
"q c #494949",
"r c #4B4B4B",
"s c #606060",
"t c #131313",
"u c #060606",
"v c #1D1D1D",
"w c #7D7D7D",
"x c #858585",
"y c #929292",
"z c #A0A0A0",
"A c #797979",
"B c #626262",
"C c #6C6C6C",
"D c #414141",
"E c #454545",
"F c #2A2A2A",
"G c #434343",
"H c #7C7C7C",
"I c #5A5A5A",
"J c #121212",
"K c #2F2F2F",
"L c #141414",
"M c #686868",
"N c #A9A9A9",
"O c #818181",
"P c #5C5C5C",
"Q c #646464",
"R c #2D2D2D",
"S c #050505",
"T c #151515",
"U c #575757",
"V c #636363",
"W c #555555",
"X c #6A6A6A",
"Y c #3C3C3C",
"Z c #111111",
"` c #666666",
" . c #090909",
".. c #515151",
"+. c #5B5B5B",
"@. c #5F5F5F",
"#. c #616161",
"$. c #A5A5A5",
"%. c #959595",
" ",
" . + . + ",
" @ # $ % & * @ # $ % & * ",
" = - ; > % , = - ; > % , ",
" ' ) ! ~ { ' ) ! ~ { ",
" ] ^ % + ] ^ % + ",
" - / ( _ - / ( _ ",
" : < [ } : < [ } ",
" | ~ : . 1 2 3 4 | ~ : . 1 2 3 4 ",
" 1 < $ 5 6 7 1 < $ 5 6 7 ",
" . + . + ",
" @ # $ % & * @ # $ % & * ",
" = - ; > % , = - ; > % , ",
" ' ) ! ~ { ' ) ! ~ { ",
" ] ^ % + ] ^ % + ",
" - / ( _ - / ( _ ",
" : < [ } : < [ } ",
" | ~ : . 1 2 3 4 | ~ : . 1 2 3 4 ",
" 1 < $ 5 6 7 8 1 < $ 5 6 7 9 0 ",
" a b c d e f g h ",
" i j 9 k l g g g m ",
" n o p p q g g j ",
" p o r s t u v ",
" 9 j w x u h y r ",
" c b z A B z b C ",
" D t g E p F G ",
" H C C C C C C C C C C C I J g g o C C K L M C C C k N ",
" O P Q Q Q Q Q Q Q Q Q B R S g g T Q G u U Q Q Q Q V W N ",
" O P M X X X X X X X X X Q Y Z l ` .r X X X X X X M W N ",
" O P M X X X X X X X X X X X ..X V X X X X X X X X M W ",
" O +.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.#. ",
" $.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%.%. "};

View File

@@ -0,0 +1,112 @@
/* XPM */
static char * dynamicaCreatePassiveBoxRB_xpm[] = {
"32 32 77 1",
" c #B1B1B1",
". c #B0B0B0",
"+ c #979797",
"@ c #808080",
"# c #949494",
"$ c #595959",
"% c #7A7A7A",
"& c #747474",
"* c #939393",
"= c #575757",
"- c #7B7B7B",
"; c #888888",
"> c #A2A2A2",
", c #848484",
"' c #5F5F5F",
") c #323232",
"! c #313131",
"~ c #373737",
"{ c #444444",
"] c #9E9E9E",
"^ c #656565",
"/ c #3D3D3D",
"( c #343434",
"_ c #454545",
": c #4C4C4C",
"< c #303030",
"[ c #2B2B2B",
"} c #202020",
"| c #2C2C2C",
"1 c #4A4A4A",
"2 c #8A8A8A",
"3 c #8C8C8C",
"4 c #ADADAD",
"5 c #434343",
"6 c #262626",
"7 c #797979",
"8 c #4D4D4D",
"9 c #868686",
"0 c #565656",
"a c #101010",
"b c #000000",
"c c #505050",
"d c #020202",
"e c #0E0E0E",
"f c #828282",
"g c #AFAFAF",
"h c #555555",
"i c #161616",
"j c #989898",
"k c #515151",
"l c #0C0C0C",
"m c #686868",
"n c #585858",
"o c #090909",
"p c #060606",
"q c #636363",
"r c #2E2E2E",
"s c #181818",
"t c #909090",
"u c #535353",
"v c #171717",
"w c #6B6B6B",
"x c #919191",
"y c #5E5E5E",
"z c #424242",
"A c #6E6E6E",
"B c #858585",
"C c #4F4F4F",
"D c #080808",
"E c #414141",
"F c #242424",
"G c #1A1A1A",
"H c #3F3F3F",
"I c #9C9C9C",
"J c #666666",
"K c #A5A5A5",
"L c #878787",
" ",
" ",
" ",
" ",
" ",
" . ",
" +@@@@@@@@@@@@@@# ",
" +$%&&&&&&&&&&&&&* ",
" +=$-&&&&&&&&&&&&&* ",
" +==$-&&&&&&&&&&&&&* ",
" +===$;;;;;;;;;;;;;;. ",
" +====;;;;;;;;;;;;;; ",
" +====;;;;;;;;;;;;;; ",
" >,')!~{@;;;;;;;;;;;;; ",
" ]^/(_:<![}|1-;;;;;;;;;;; ",
" 2=34 +====&56789;;;;;;;; ",
" +====;;0abc;;;;;;;; ",
" +====;;0dbef;;;;;;; 4-g",
" +====;;hibb5;;;;;;; jklm ",
" ]n===;;;;cop%;;;;;qrbbsg ",
" tn==;;;;;uvk;;;;;webb@ ",
" xn=;;;;;;y[zAB;&CDdE ",
" xn;;;;;;;-1FvGFHIJK ",
" x;;;;;;;;;;;,L; ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,100 @@
/* XPM */
static char * dynamicaCreatePassiveBoxRBArray_xpm[] = {
"32 32 65 1",
" c #B1B1B1",
". c #4E4E4E",
"+ c #A2A2A2",
"@ c #848484",
"# c #707070",
"$ c #666666",
"% c #2C2C2C",
"& c #8B8B8B",
"* c #A7A7A7",
"= c #9E9E9E",
"- c #656565",
"; c #3D3D3D",
"> c #343434",
", c #454545",
"' c #595959",
") c #626262",
"! c #575757",
"~ c #414141",
"{ c #3A3A3A",
"] c #606060",
"^ c #A0A0A0",
"/ c #8A8A8A",
"( c #8C8C8C",
"_ c #ADADAD",
": c #424242",
"< c #262626",
"[ c #161616",
"} c #646464",
"| c #4D4D4D",
"1 c #141414",
"2 c #000000",
"3 c #686868",
"4 c #323232",
"5 c #010101",
"6 c #080808",
"7 c #4A4A4A",
"8 c #7B7B7B",
"9 c #AFAFAF",
"0 c #6E6E6E",
"a c #0D0D0D",
"b c #989898",
"c c #515151",
"d c #0C0C0C",
"e c #676767",
"f c #050505",
"g c #818181",
"h c #2E2E2E",
"i c #181818",
"j c #2F2F2F",
"k c #1D1D1D",
"l c #696969",
"m c #0E0E0E",
"n c #808080",
"o c #383838",
"p c #555555",
"q c #909090",
"r c #979797",
"s c #020202",
"t c #1F1F1F",
"u c #0F0F0F",
"v c #525252",
"w c #9C9C9C",
"x c #A5A5A5",
"y c #4C4C4C",
"z c #B0B0B0",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ....... ....... ",
" . . . . ",
" . . . . ",
" . . . . ",
" +@#$%#&* . . . ",
" =-;>,')%!~{]^. . . ",
" /!(_ ...:<[,}|...... ",
" #123 ",
" .....45267..... _89",
" . 0a22! . bcd3 ",
" . .ef6= . gh22i9 ",
" . . jkl . (m22n ",
" . . .8opq_.re6s~ ",
" . . . ^]jtujvw$x ",
" ....... ......yz ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,159 @@
/* XPM */
static char * dynamicaCreatePassiveHullRB_xpm[] = {
"32 32 124 2",
" c #B1B1B1",
". c #9D9D9D",
"+ c #989898",
"@ c #A4A4A4",
"# c #ABABAB",
"$ c #838383",
"% c #565656",
"& c #5D5D5D",
"* c #575757",
"= c #525252",
"- c #636363",
"; c #6E6E6E",
"> c #797979",
", c #8B8B8B",
"' c #979797",
") c #A2A2A2",
"! c #A9A9A9",
"~ c #7C7C7C",
"{ c #5A5A5A",
"] c #747474",
"^ c #727272",
"/ c #B3B3B3",
"( c #919191",
"_ c #8C8C8C",
": c #939393",
"< c #888888",
"[ c #787878",
"} c #696969",
"| c #5E5E5E",
"1 c #626262",
"2 c #6D6D6D",
"3 c #8F8F8F",
"4 c #959595",
"5 c #ACACAC",
"6 c #A7A7A7",
"7 c #7A7A7A",
"8 c #595959",
"9 c #ADADAD",
"0 c #828282",
"a c #AFAFAF",
"b c #C2C2C2",
"c c #858585",
"d c #8E8E8E",
"e c #A8A8A8",
"f c #9F9F9F",
"g c #949494",
"h c #606060",
"i c #A5A5A5",
"j c #808080",
"k c #818181",
"l c #BBBBBB",
"m c #AAAAAA",
"n c #8D8D8D",
"o c #C0C0C0",
"p c #5F5F5F",
"q c #848484",
"r c #9B9B9B",
"s c #9C9C9C",
"t c #B0B0B0",
"u c #BCBCBC",
"v c #868686",
"w c #5C5C5C",
"x c #767676",
"y c #969696",
"z c #B6B6B6",
"A c #C1C1C1",
"B c #B5B5B5",
"C c #7F7F7F",
"D c #707070",
"E c #7B7B7B",
"F c #B7B7B7",
"G c #8A8A8A",
"H c #9E9E9E",
"I c #444444",
"J c #1F1F1F",
"K c #383838",
"L c #2E2E2E",
"M c #414141",
"N c #6B6B6B",
"O c #484848",
"P c #3F3F3F",
"Q c #6A6A6A",
"R c #999999",
"S c #646464",
"T c #7E7E7E",
"U c #4F4F4F",
"V c #4A4A4A",
"W c #373737",
"X c #545454",
"Y c #161616",
"Z c #000000",
"` c #6C6C6C",
" . c #7D7D7D",
".. c #BFBFBF",
"+. c #030303",
"@. c #151515",
"#. c #B9B9B9",
"$. c #BDBDBD",
"%. c #585858",
"&. c #A3A3A3",
"*. c #202020",
"=. c #B4B4B4",
"-. c #515151",
";. c #0C0C0C",
">. c #686868",
",. c #717171",
"'. c #080808",
"). c #BABABA",
"!. c #A0A0A0",
"~. c #181818",
"{. c #737373",
"]. c #0E0E0E",
"^. c #676767",
"/. c #323232",
"(. c #363636",
"_. c #474747",
":. c #020202",
"<. c #666666",
"[. c #909090",
"}. c #5B5B5B",
"|. c #555555",
"1. c #292929",
"2. c #212121",
"3. c #2F2F2F",
" ",
" ",
" ",
" ",
" ",
" ",
" . + @ ",
" # $ % & * = - ; > , ' ) ",
" ! ~ { ] ^ ! / ( _ : < [ } | = 1 2 [ , 3 4 5 ",
" 6 7 8 7 6 9 0 a b , 0 $ c < d e f g 7 h | * & 5 ",
" i [ { j @ ( k [ < a b l a 9 m e f n f ~ / o p ; 5 ",
" a & q r 4 > s t u b b b b b b b b b v r c # b k w 5 ",
" @ { x < y z b b b b b b b b b b b b t k # 7 A B | d ",
" ( | e C } D ; E + F b b b b b b b b b G n r b _ { a ",
" H I J K L M N ; p O P Q a b b b b b b b / R A b S T ",
" G U V + 0 : b b b b i p W 9 ; o b b b b b b b m X 5 ",
" 7 1 t a b b b b b b E Y Z ^ b b b b b b b Q ` ",
" t { ...b b b b b b E +.Z @.#.b b b b $.E %.i 9 E a ",
" $ Q &.b b b b b b > *.Z Z h b b b =.; 8 ) + -.;.>. ",
" e * < b b b b b b b b ,.;.'.9 b ).D %.!.k L Z Z ~.a ",
" ^ D R b b b b b b b b x *.{.).{.* H _ ].Z Z j ",
" f ^.{ {. b b b b b b b j /.(._.R ' ^.'.:.M ",
" s <.% x + [.G C ^ ^.}.|.L 1.J 2.3.= s <.i ",
" s } = | 1 N ] 0 g H a 5 t ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,125 @@
/* XPM */
static char * dynamicaCreatePassiveHullRBArray_xpm[] = {
"32 32 90 1",
" c #B1B1B1",
". c #ADADAD",
"+ c #878787",
"@ c #707070",
"# c #797979",
"$ c #838383",
"% c #909090",
"& c #9C9C9C",
"* c #A6A6A6",
"= c #ABABAB",
"- c #6D6D6D",
"; c #818181",
"> c #A0A0A0",
", c #858585",
"' c #787878",
") c #737373",
"! c #747474",
"~ c #777777",
"{ c #7D7D7D",
"] c #979797",
"^ c #6E6E6E",
"/ c #848484",
"( c #A8A8A8",
"_ c #ACACAC",
": c #989898",
"< c #646464",
"[ c #727272",
"} c #9D9D9D",
"| c #8E8E8E",
"1 c #9E9E9E",
"2 c #959595",
"3 c #7B7B7B",
"4 c #808080",
"5 c #828282",
"6 c #AFAFAF",
"7 c #9B9B9B",
"8 c #666666",
"9 c #656565",
"0 c #8B8B8B",
"a c #A7A7A7",
"b c #8D8D8D",
"c c #717171",
"d c #2F2F2F",
"e c #232323",
"f c #424242",
"g c #595959",
"h c #626262",
"i c #575757",
"j c #414141",
"k c #2E2E2E",
"l c #3C3C3C",
"m c #8A8A8A",
"n c #919191",
"o c #888888",
"p c #7F7F7F",
"q c #5F5F5F",
"r c #535353",
"s c #323232",
"t c #545454",
"u c #7A7A7A",
"v c #141414",
"w c #000000",
"x c #A9A9A9",
"y c #020202",
"z c #0F0F0F",
"A c #484848",
"B c #AAAAAA",
"C c #515151",
"D c #0C0C0C",
"E c #686868",
"F c #3B3B3B",
"G c #0B0B0B",
"H c #080808",
"I c #181818",
"J c #6C6C6C",
"K c #1D1D1D",
"L c #696969",
"M c #8C8C8C",
"N c #0E0E0E",
"O c #383838",
"P c #555555",
"Q c #676767",
"R c #606060",
"S c #1F1F1F",
"T c #212121",
"U c #525252",
"V c #A5A5A5",
"W c #B0B0B0",
"X c #898989",
"Y c #AEAEAE",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .+@#$%&*= ",
" =+-;>&%,')!~{ ",
" ]^/( _:< ",
" [} /| .+@#$%&*= ",
" @1 =^==+-;>&%,')!~{ ",
" 23 45]^/( _:< ",
" 6@7/@89@0abc.[} /| ",
" 19defgh<ijkl7 @1 =^= ",
" mim5-5nop)qrs1tu 45 ",
" @vwfx bc. ",
" .+@#$%&*-ywz[x |^_ .36",
" =+-;>&%,')Avwwf-5nop)@B:CDE ",
" ]^/( _:FGH1 ;kwwI6 ",
" [} /|JKL MNww4 ",
" @1 =^= 3OP%. ]QHyj ",
" 23 45 >RdSTdU&8V ",
" 6@x bc. _W ",
" X'x |^_ ",
" Y,-5nop)@B ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,152 @@
/* XPM */
static char * dynamicaCreatePassiveMeshRB_xpm[] = {
"32 32 117 2",
" c #B1B1B1",
". c #A5A5A5",
"+ c #929292",
"@ c #8C8C8C",
"# c #9F9F9F",
"$ c #AEAEAE",
"% c #858585",
"& c #9B9B9B",
"* c #9E9E9E",
"= c #8E8E8E",
"- c #A0A0A0",
"; c #AAAAAA",
"> c #A6A6A6",
", c #ADADAD",
"' c #8F8F8F",
") c #919191",
"! c #979797",
"~ c #838383",
"{ c #868686",
"] c #848484",
"^ c #ACACAC",
"/ c #999999",
"( c #8D8D8D",
"_ c #949494",
": c #969696",
"< c #A3A3A3",
"[ c #AFAFAF",
"} c #9C9C9C",
"| c #A1A1A1",
"1 c #A7A7A7",
"2 c #A9A9A9",
"3 c #959595",
"4 c #888888",
"5 c #909090",
"6 c #9D9D9D",
"7 c #9A9A9A",
"8 c #8B8B8B",
"9 c #A8A8A8",
"0 c #727272",
"a c #616161",
"b c #606060",
"c c #5E5E5E",
"d c #696969",
"e c #7F7F7F",
"f c #989898",
"g c #878787",
"h c #898989",
"i c #7B7B7B",
"j c #565656",
"k c #313131",
"l c #2D2D2D",
"m c #343434",
"n c #444444",
"o c #595959",
"p c #5B5B5B",
"q c #4E4E4E",
"r c #3A3A3A",
"s c #515151",
"t c #7A7A7A",
"u c #6C6C6C",
"v c #7C7C7C",
"w c #8A8A8A",
"x c #6B6B6B",
"y c #464646",
"z c #282828",
"A c #828282",
"B c #B0B0B0",
"C c #585858",
"D c #101010",
"E c #000000",
"F c #808080",
"G c #787878",
"H c #6F6F6F",
"I c #636363",
"J c #505050",
"K c #4C4C4C",
"L c #545454",
"M c #020202",
"N c #0D0D0D",
"O c #656565",
"P c #4B4B4B",
"Q c #6D6D6D",
"R c #797979",
"S c #767676",
"T c #757575",
"U c #494949",
"V c #131313",
"W c #4F4F4F",
"X c #555555",
"Y c #0C0C0C",
"Z c #686868",
"` c #6A6A6A",
" . c #676767",
".. c #646464",
"+. c #626262",
"@. c #050505",
"#. c #030303",
"$. c #434343",
"%. c #818181",
"&. c #2E2E2E",
"*. c #181818",
"=. c #777777",
"-. c #5D5D5D",
";. c #525252",
">. c #2C2C2C",
",. c #0E0E0E",
"'. c #393939",
"). c #202020",
"!. c #3D3D3D",
"~. c #7E7E7E",
"{. c #080808",
"]. c #414141",
"^. c #6E6E6E",
"/. c #666666",
"(. c #2F2F2F",
"_. c #1F1F1F",
":. c #212121",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" . + @ # ",
" $ % & * = - ; > , ",
" $ = # . @ = ' ) + ! ; * ~ { { ] , ",
" ^ / ( % ( # . # / ! _ + = : < { + ' % ~ $ ",
" [ . } { ! | 1 2 > < | # } / ! 3 4 | ) + 5 ] ! $ ",
" 6 ] @ _ < 2 2 1 . | # } & 7 ! 3 _ ) = , % 5 % 8 ",
" 9 4 ' 0 a b c d e : & f ! : 3 _ + + + g : h ~ i & ",
" * j k l m n o p q r k s ] ) 5 5 ' = = @ 4 ~ t u v 1 ",
" w s x ) g @ & 7 f 3 i y z v q 4 4 % A i 0 d b c A B ",
" : g @ ( ) ) 5 ' @ w C D E q F G H I C J K 0 6 ",
" # ~ { { g 4 g % ] L M E N u O C P P q Q : , i [ ",
" 3 e i t R G S T U V E E l W P P X v / f s Y Z ",
" < e 0 Q ` ...+.a c m @.#.$.P J v * %.&.E E *.[ ",
" : =.+.-.C L ;.W P P &.Y >.s R 7 @ ,.E E F ",
" , : G -.q P P P P P P '.).!.~., ! .{.M ]. ",
" * F ^./.I I /.u T e h -.(._.:.(.;.} /.. ",
" $ - / ! ! / * > $ ^ B ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,128 @@
/* XPM */
static char * dynamicaCreatePassiveMeshRBArray_xpm[] = {
"32 32 93 2",
" c #B1B1B1",
". c #898989",
"+ c #616161",
"@ c #ACACAC",
"# c #AEAEAE",
"$ c #A3A3A3",
"% c #A7A7A7",
"& c #8A8A8A",
"* c #525252",
"= c #656565",
"- c #565656",
"; c #515151",
"> c #8E8E8E",
", c #545454",
"' c #9C9C9C",
") c #868686",
"! c #535353",
"~ c #5A5A5A",
"{ c #606060",
"] c #686868",
"^ c #676767",
"/ c #646464",
"( c #909090",
"_ c #585858",
": c #636363",
"< c #A0A0A0",
"[ c #989898",
"} c #555555",
"| c #5B5B5B",
"1 c #696969",
"2 c #626262",
"3 c #707070",
"4 c #595959",
"5 c #666666",
"6 c #A8A8A8",
"7 c #5D5D5D",
"8 c #808080",
"9 c #979797",
"0 c #575757",
"a c #505050",
"b c #AFAFAF",
"c c #5F5F5F",
"d c #787878",
"e c #A2A2A2",
"f c #848484",
"g c #2D2D2D",
"h c #393939",
"i c #4C4C4C",
"j c #7B7B7B",
"k c #B0B0B0",
"l c #9E9E9E",
"m c #3D3D3D",
"n c #343434",
"o c #454545",
"p c #444444",
"q c #282828",
"r c #222222",
"s c #3C3C3C",
"t c #717171",
"u c #9D9D9D",
"v c #8C8C8C",
"w c #ADADAD",
"x c #323232",
"y c #878787",
"z c #303030",
"A c #0D0D0D",
"B c #000000",
"C c #020202",
"D c #090909",
"E c #6E6E6E",
"F c #171717",
"G c #4D4D4D",
"H c #0C0C0C",
"I c #3A3A3A",
"J c #030303",
"K c #040404",
"L c #5E5E5E",
"M c #424242",
"N c #1F1F1F",
"O c #181818",
"P c #4B4B4B",
"Q c #353535",
"R c #0E0E0E",
"S c #2C2C2C",
"T c #6B6B6B",
"U c #7D7D7D",
"V c #080808",
"W c #414141",
"X c #2F2F2F",
"Y c #212121",
"Z c #A5A5A5",
"` c #8B8B8B",
" . c #6D6D6D",
" ",
" ",
" ",
" ",
" ",
" . + . @ # $ $ ",
" % & * = - ; ; & > , , $ ",
" ' ) ! ~ { ] ^ = / - ( _ : , < ",
" [ } | = 1 1 1 1 1 1 2 ; : ~ & ",
" 3 + 4 5 1 1 1 1 1 1 ] 2 ^ * 6 ",
" [ } { ] 1 1 1 1 1 1 1 1 7 8 ",
" 9 0 1 1 1 1 1 1 1 1 ~ a 6 ",
" b a c 1 1 1 1 1 ] ~ d . + . @ # $ $ ",
" e f 3 | g h i 7 + 7 } j k % & * = - ; ; & > , , $ ",
" l = m n o 4 2 / p q r s t u ' ) ! ~ { ] ^ = / - ( _ : , < ",
" & 0 v w 9 0 x y z ~ = 1 1 1 1 1 1 2 ; : ~ & ",
" 3 A B n 5 1 1 1 1 1 1 ] 2 ^ * 6 ",
" . + . @ # 3 C B D : 1 1 1 1 1 1 1 1 7 8 w j b ",
" % & * = - ; ; & E F B B z 1 1 1 1 1 1 1 ~ o G H ] ",
" ' ) ! ~ { ] ^ = / - ( _ I J K L 1 1 1 1 ] M N B B O b ",
" [ } | = 1 1 1 1 1 1 2 ; : ~ P A Q + : + 7 } + R B B 8 ",
" 3 + 4 5 1 1 1 1 1 1 ] 2 ^ * 6 j S Q } T U ) ^ V C W ",
" [ } { ] 1 1 1 1 1 1 1 1 7 8 < { X N Y X * ' 5 Z ",
" 9 0 1 1 1 1 1 1 1 1 ~ a 6 @ k ",
" b a c 1 1 1 1 1 ] ~ d ",
" u a ~ + : + 7 } j k ",
" ` .1 E U u ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,108 @@
/* XPM */
static char * dynamicaCreatePassivePlaneRB_xpm[] = {
"32 32 73 1",
" c #B1B1B1",
". c #A2A2A2",
"+ c #848484",
"@ c #707070",
"# c #666666",
"$ c #656565",
"% c #8B8B8B",
"& c #A7A7A7",
"* c #9E9E9E",
"= c #3D3D3D",
"- c #343434",
"; c #454545",
"> c #595959",
", c #626262",
"' c #646464",
") c #575757",
"! c #414141",
"~ c #3A3A3A",
"{ c #606060",
"] c #A0A0A0",
"^ c #8A8A8A",
"/ c #8C8C8C",
"( c #ADADAD",
"_ c #979797",
": c #323232",
"< c #AFAFAF",
"[ c #7C7C7C",
"} c #6C6C6C",
"| c #0C0C0C",
"1 c #000000",
"2 c #404040",
"3 c #6E6E6E",
"4 c #A9A9A9",
"5 c #818181",
"6 c #5C5C5C",
"7 c #010101",
"8 c #0B0B0B",
"9 c #5F5F5F",
"0 c #636363",
"a c #555555",
"b c #7B7B7B",
"c c #686868",
"d c #6A6A6A",
"e c #424242",
"f c #111111",
"g c #272727",
"h c #3E3E3E",
"i c #070707",
"j c #050505",
"k c #4D4D4D",
"l c #1B1B1B",
"m c #5B5B5B",
"n c #0F0F0F",
"o c #383838",
"p c #4B4B4B",
"q c #616161",
"r c #A5A5A5",
"s c #959595",
"t c #676767",
"u c #2F2F2F",
"v c #484848",
"w c #797979",
"x c #919191",
"y c #7F7F7F",
"z c #565656",
"A c #020202",
"B c #363636",
"C c #1F1F1F",
"D c #212121",
"E c #525252",
"F c #9C9C9C",
"G c #ACACAC",
"H c #B0B0B0",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .+@#$@%& ",
" *$=-;>,')!~{] ",
" ^)/( _):*'< ",
" [}}}}}}}}}}}};|12}}}}}}}}34 ",
" 56'''''''''''27189'''''''0a4(b<",
" 56cdddddddddef11-dddddddd>g|c ",
" 56cddddddddddhij9dddddkl11|< ",
" 5m99999999999~no99999pi11;q ",
" rsssssssssssstuvwxsyziABs ",
" ]{uCDuEF#r ",
" GH ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,117 @@
/* XPM */
static char * dynamicaCreatePassivePlaneRBArray_xpm[] = {
"32 32 82 1",
" c #B1B1B1",
". c #6E6E6E",
"+ c #5F5F5F",
"@ c #616161",
"# c #606060",
"$ c #666666",
"% c #7E7E7E",
"& c #626262",
"* c #6D6D6D",
"= c #636363",
"- c #A9A9A9",
"; c #4E4E4E",
"> c #767676",
", c #777777",
"' c #5B5B5B",
") c #787878",
"! c #757575",
"~ c #5E5E5E",
"{ c #747474",
"] c #505050",
"^ c #4D4D4D",
"/ c #5C5C5C",
"( c #5D5D5D",
"_ c #4F4F4F",
": c #ADADAD",
"< c #868686",
"[ c #6F6F6F",
"} c #565656",
"| c #555555",
"1 c #8C8C8C",
"2 c #959595",
"3 c #929292",
"4 c #9E9E9E",
"5 c #656565",
"6 c #3D3D3D",
"7 c #343434",
"8 c #454545",
"9 c #595959",
"0 c #646464",
"a c #575757",
"b c #414141",
"c c #3A3A3A",
"d c #3C3C3C",
"e c #8A8A8A",
"f c #979797",
"g c #303030",
"h c #1B1B1B",
"i c #3E3E3E",
"j c #6C6C6C",
"k c #323232",
"l c #0E0E0E",
"m c #000000",
"n c #464646",
"o c #4A4A4A",
"p c #010101",
"q c #0D0D0D",
"r c #717171",
"s c #7B7B7B",
"t c #AFAFAF",
"u c #2D2D2D",
"v c #2B2B2B",
"w c #060606",
"x c #090909",
"y c #858585",
"z c #272727",
"A c #181818",
"B c #151515",
"C c #696969",
"D c #808080",
"E c #383838",
"F c #909090",
"G c #676767",
"H c #080808",
"I c #020202",
"J c #2F2F2F",
"K c #1F1F1F",
"L c #212121",
"M c #525252",
"N c #9C9C9C",
"O c #A5A5A5",
"P c #ACACAC",
"Q c #B0B0B0",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .+@@@@@@@@@@@#$% ",
" &@************@= ",
" -;>,,,,,,,,,,,,') ",
" !~,,,,,,,,,,,,{] ",
" ^/'''''''''''(_: ",
" <[~}|+!122223: ",
" 456789&0abcd}@@@@@@@@@@@#$% ",
" ea1: fgh@ij*********@= ",
" -klmn,,,,,,,,,,') ",
" opmqr,,,,,,,,,{;st",
" .qmmu'''''''';vw$ ",
" |xwy22222*zmmAt ",
" .+@@@@@@@@@@@#iBC 1lmmD ",
" &@************@8E|F: fGHIb ",
" -;>,,,,,,,,,,,,'j#JKLJMN$O ",
" !~,,,,,,,,,,,,{] PQ ",
" ^/'''''''''''(_: ",
" 3222222222223: ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,37 @@
/* XPM */
static char * dynamicaCreatePassiveRB_xpm[] = {
"32 32 2 1",
" c None",
". c #E0AE36",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................",
"................................"};

View File

@@ -0,0 +1,177 @@
/* XPM */
static char * dynamicaCreatePassiveSphereRB_xpm[] = {
"32 32 142 2",
" c #B1B1B1",
". c #ADADAD",
"+ c #ABABAB",
"@ c #AEAEAE",
"# c #A8A8A8",
"$ c #A5A5A5",
"% c #B2B2B2",
"& c #B6B6B6",
"* c #B5B5B5",
"= c #A4A4A4",
"- c #AAAAAA",
"; c #B0B0B0",
"> c #A9A9A9",
", c #C3C3C3",
"' c #D4D4D4",
") c #D5D5D5",
"! c #D3D3D3",
"~ c #D2D2D2",
"{ c #D0D0D0",
"] c #CDCDCD",
"^ c #C7C7C7",
"/ c #D6D6D6",
"( c #CFCFCF",
"_ c #CBCBCB",
": c #C2C2C2",
"< c #BABABA",
"[ c #A7A7A7",
"} c #B9B9B9",
"| c #D1D1D1",
"1 c #CECECE",
"2 c #CACACA",
"3 c #C5C5C5",
"4 c #BFBFBF",
"5 c #B8B8B8",
"6 c #C8C8C8",
"7 c #BBBBBB",
"8 c #A0A0A0",
"9 c #A2A2A2",
"0 c #C6C6C6",
"a c #BEBEBE",
"b c #9F9F9F",
"c c #939393",
"d c #929292",
"e c #ACACAC",
"f c #B3B3B3",
"g c #C1C1C1",
"h c #838383",
"i c #767676",
"j c #9D9D9D",
"k c #AFAFAF",
"l c #7C7C7C",
"m c #797979",
"n c #777777",
"o c #848484",
"p c #A3A3A3",
"q c #C4C4C4",
"r c #CCCCCC",
"s c #A1A1A1",
"t c #919191",
"u c #808080",
"v c #727272",
"w c #6B6B6B",
"x c #8A8A8A",
"y c #9E9E9E",
"z c #656565",
"A c #3D3D3D",
"B c #343434",
"C c #414141",
"D c #626262",
"E c #707070",
"F c #737373",
"G c #646464",
"H c #4B4B4B",
"I c #424242",
"J c #6E6E6E",
"K c #BCBCBC",
"L c #8E8E8E",
"M c #7A7A7A",
"N c #666666",
"O c #5E5E5E",
"P c #575757",
"Q c #8C8C8C",
"R c #5F5F5F",
"S c #363636",
"T c #8D8D8D",
"U c #606060",
"V c #4F4F4F",
"W c #676767",
"X c #747474",
"Y c #141414",
"Z c #000000",
"` c #696969",
" . c #5C5C5C",
".. c #505050",
"+. c #4E4E4E",
"@. c #6A6A6A",
"#. c #020202",
"$. c #0F0F0F",
"%. c #6F6F6F",
"&. c #565656",
"*. c #717171",
"=. c #7B7B7B",
"-. c #A6A6A6",
";. c #9B9B9B",
">. c #979797",
",. c #151515",
"'. c #2E2E2E",
"). c #858585",
"!. c #989898",
"~. c #515151",
"{. c #0C0C0C",
"]. c #686868",
"^. c #909090",
"/. c #898989",
"(. c #828282",
"_. c #383838",
":. c #050505",
"<. c #030303",
"[. c #464646",
"}. c #525252",
"|. c #181818",
"1. c #7E7E7E",
"2. c #535353",
"3. c #2F2F2F",
"4. c #0D0D0D",
"5. c #0E0E0E",
"6. c #545454",
"7. c #191919",
"8. c #262626",
"9. c #3F3F3F",
"0. c #4C4C4C",
"a. c #888888",
"b. c #080808",
"c. c #959595",
"d. c #595959",
"e. c #2B2B2B",
"f. c #101010",
"g. c #1D1D1D",
"h. c #9C9C9C",
"i. c #969696",
"j. c #818181",
"k. c #636363",
" ",
" ",
" ",
" ",
" ",
" . + + + @ ",
" @ # $ % & & * . = - ; ",
" > > , ' ) ! ~ { ] ^ * = - ",
" ; > & ) / / ) ! ~ ( _ ^ : < [ > ",
" > } / / / / ' ! | 1 2 3 4 5 $ - ",
" + ; ! ' ) / ) ' ~ { ] 6 : 7 % > 8 9 @ ",
" = _ ! ! ' ' ' ! | 1 _ 0 a * + b c d # ",
" e f | | ~ ! ! ~ | 1 _ ^ g 5 . 8 d h i j k ",
" 9 l m n i o p q ( r 6 0 : < @ s t u v w x + ",
" y z A B C D E F G H I J f g K 5 @ b L M J N O n # ",
" x P Q . p q 3 0 0 0 # R S = z + 8 T i w U P V W [ ",
" = K a a a a K < X Y Z U t n ` ...+.+.` [ ",
" $ % f % ; @ e @.#.Z $.%.z &.+.+.+.+.*.> . =.k ",
" > # -.9 y ;.>.d &.,.Z Z '.+.+.+.+.+.+.).e !.~.{.]. ",
" . 9 !.^./.(.M F J W _.:.<.[.+.+.+.+.}.X '.Z Z |.k ",
" [ ^.1.X %.@.G .2.+.3.4.3.+.+.+.+.m ).5.Z Z u ",
" e j X @.G .6.+.+.+.+.S 7.8.9.0.O a.N b.#.C ",
" - c.z d...+.+.+.+.+.+.[.e.Y f.g.'.}.h.N $ ",
" > i.O +.+.+.+.+.+.+.+.+.W j -.; ",
" + 9 j.k.+.+.+.+.~.].T [ . ",
" + -.8 d d c p [ . ",
" @ @ @ ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,122 @@
/* XPM */
static char * dynamicaCreatePassiveSphereRBArray_xpm[] = {
"32 32 87 1",
" c #B1B1B1",
". c #A6A6A6",
"+ c #A0A0A0",
"@ c #949494",
"# c #6D6D6D",
"$ c #5D5D5D",
"% c #636363",
"& c #616161",
"* c #888888",
"= c #9C9C9C",
"- c #5A5A5A",
"; c #969696",
"> c #A2A2A2",
", c #878787",
"' c #757575",
") c #8E8E8E",
"! c #A4A4A4",
"~ c #535353",
"{ c #B0B0B0",
"] c #565656",
"^ c #ADADAD",
"/ c #A9A9A9",
"( c #5E5E5E",
"_ c #A5A5A5",
": c #848484",
"< c #606060",
"[ c #5C5C5C",
"} c #656565",
"| c #707070",
"1 c #8B8B8B",
"2 c #A7A7A7",
"3 c #979797",
"4 c #6C6C6C",
"5 c #808080",
"6 c #838383",
"7 c #9E9E9E",
"8 c #3D3D3D",
"9 c #343434",
"0 c #454545",
"a c #585858",
"b c #525252",
"c c #5B5B5B",
"d c #424242",
"e c #434343",
"f c #AAAAAA",
"g c #8D8D8D",
"h c #939393",
"i c #8A8A8A",
"j c #575757",
"k c #8C8C8C",
"l c #595959",
"m c #323232",
"n c #646464",
"o c #AFAFAF",
"p c #767676",
"q c #9D9D9D",
"r c #141414",
"s c #000000",
"t c #686868",
"u c #020202",
"v c #131313",
"w c #7B7B7B",
"x c #545454",
"y c #1D1D1D",
"z c #2C2C2C",
"A c #989898",
"B c #515151",
"C c #0C0C0C",
"D c #676767",
"E c #121212",
"F c #060606",
"G c #2E2E2E",
"H c #181818",
"I c #1F1F1F",
"J c #696969",
"K c #7E7E7E",
"L c #0E0E0E",
"M c #787878",
"N c #383838",
"O c #555555",
"P c #909090",
"Q c #080808",
"R c #414141",
"S c #2F2F2F",
"T c #494949",
"U c #666666",
"V c #929292",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .+ .+ ",
" @#$%&* @#$%&* ",
" =-; >%, =-; >%, ",
" ') !~{ ') !~{ ",
" ]^ %+ ]^ %+ ",
" -/ (_ -/ (_ ",
" >:<[}|1234 56 34 ",
" 7}890abc]de~, 2~5.fgah ",
" ijk^ f6$l4]m7nof6$lpq ",
" .+ |rst .+ ",
" @#$%&*|usvg#$%&* ^wo",
" =-; >%xyssz; >%, ABCt ",
" ') !~{DEF7 !~5GssHo ",
" ]^ %+ ~IJ %KLss5 ",
" -/ (_ -MNOP^ cnQuR ",
" 56 34 56+<SIGTb=U_ ",
" 2~5.fgah 2~5.fgjV ",
" f6$lpq f6$lpq ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};

View File

@@ -0,0 +1,183 @@
/*
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>
*/
//mathUtils.h
#ifndef DYN_MATH_UTILS_H
#define DYN_MATH_UTILS_H
#include "mvl/vec.h"
#include "mvl/mat.h"
#include "mvl/quat.h"
using namespace mvl;
typedef vec<float, 3> vec3f;
typedef mat<float, 4, 4> mat4x4f;
typedef mat<float, 3, 3> mat3x3f;
typedef vec<float, 4> quatf;
template<typename T>
inline T deg2rad(T x) { return x * T(3.141592654 / 180.0); }
template<typename T>
inline T rad2deg(T x) { return x * T(180.0 / 3.141592654); }
template<typename T>
inline T clamp(T x, T min, T max)
{
if(x < min) return min;
if(x > max) return max;
return x;
}
template<typename T>
inline T sqr(T x) {
return x * x;
}
// A must be a symmetric matrix.
// returns quaternion q such that its corresponding matrix Q
// can be used to Diagonalize A
//Diagonal matrix D = Q^T * A * Q; and A = Q*D*Q^T
// The colums of q are the eigenvectors D's diagonal is the eigenvalues
// As per 'column' convention if float3x3 Q = q.getmatrix(); then Q*v = q*v*conj(q)
template<typename T>
vec<T, 4> diagonalizer(const mat<T, 3, 3> &A)
{
const int maxsteps = 24; // certainly wont need that many.
typedef vec<T, 3> vec3_t;
typedef vec<T, 4> quat_t;
typedef mat<T, 3, 3> mat3x3_t;
quat_t q(qidentity<T>());
for(int i = 0; i < maxsteps; ++i)
{
mat3x3_t Q;
q_to_mat(q, Q); // Q*v == q*v*conj(q)
mat3x3_t D = prod(trans(Q), mat3x3_t(prod(A, Q))); // A = Q^T*D*Q
vec3_t offdiag(D(2, 1), D(2, 0), D(1, 0)); // elements not on the diagonal
vec3_t om(fabs(offdiag[0]), fabs(offdiag[1]), fabs(offdiag[2])); // mag of each offdiag elem
int k = (om[0] > om[1] && om[0] > om[2]) ? 0 : (om[1] > om[2]) ? 1 : 2; // index of largest element of offdiag
int k1 = (k + 1) % 3;
int k2 = (k + 2) % 3;
if(offdiag[k] == T()) break; // diagonal already
T thet = (D(k2, k2) - D(k1, k1)) / (T(2.0) * offdiag[k]);
T sgn = (thet > 0.0f) ? T(1.0) : T(-1.0);
thet *= sgn; // make it positive
T t = sgn / (thet + ((thet < T(1.E6)) ? sqrtf(sqr(thet) + T(1.0)) : thet)) ; // sign(T)/(|T|+sqrt(T^2+1))
T c = T(1.0) / sqrtf(sqr(t) + T(1.0)); // c= 1/(t^2+1) , t=s/c
if(c == T(1.0)) break; // no room for improvement - reached machine precision.
quat_t jr(0,0,0,0); // jacobi rotation for this iteration.
jr[1 + k] = sgn * sqrtf((T(1.0) - c) / T(2.0)); // using 1/2 angle identity sin(a/2) = sqrt((1-cos(a))/2)
jr[1 + k] *= -T(1.0); // since our quat-to-matrix convention was for v*M instead of M*v
jr[0] = sqrtf(T(1.0) - sqr(jr[1 + k]));
if(jr[0] == T(1.0)) break; // reached limits of floating point precision
q = qprod(q, jr);
q = normalize(q);
}
return q;
}
template<typename T>
inline T determinant(vec<T, 3> const& v0, vec<T, 3> const& v1, vec<T, 3> const& v2)
{
return dot(v0, cross(v1, v2));
}
template<typename T>
T volume(vec<T, 3> const* vertices, int const* indices, const int num_indices)
{
// count is the number of triangles (tris)
T volume = T();
for(int i = 0; i < num_indices / 3; i++) { // for each triangle
volume += determinant(vertices[indices[i * 3 + 0]],
vertices[indices[i * 3 + 1]],
vertices[indices[i * 3 + 2]]);
}
return volume / T(6.0); // since the determinant give 6 times tetra volume
}
template<typename T>
vec<T, 3> center_of_mass(vec<T, 3> const* vertices, int const* indices, int num_indices)
{
// count is the number of triangles (tris)
vec<T, 3> com(0, 0, 0);
T volume = 0; // actually accumulates the volume*6
for(int i = 0; i < num_indices / 3; i++) // for each triangle
{
T vol = determinant(vertices[indices[i * 3 + 0]],
vertices[indices[i * 3 + 1]],
vertices[indices[i * 3 + 2]]);
com += vol * (vertices[indices[i * 3 + 0]] + vertices[indices[i * 3 + 1]] + vertices[indices[i * 3 + 2]]);
volume += vol;
}
com /= volume * 4.0f;
return com;
}
template<typename T>
mat<T, 3, 3> inertia(vec<T, 3> const* vertices, int const* indices, int num_indices, vec<T, 3> com = vec<T, 3>(0, 0, 0))
{
typedef vec<T, 3> vec3_t;
typedef mat<T, 3, 3> mat3x3_t;
// count is the number of triangles (tris)
// The moments are calculated based on the center of rotation com which is [0,0,0] by default
// assume mass==1.0 you can multiply by mass later.
// for improved accuracy the next 3 variables, the determinant d, and its calculation should be changed to double
T volume = 0; // technically this variable accumulates the volume times 6
vec3_t diag(0,0,0); // accumulate matrix main diagonal integrals [x*x, y*y, z*z]
vec3_t offd(0,0,0); // accumulate matrix off-diagonal integrals [y*z, x*z, x*y]
for(int i=0; i < num_indices / 3; i++) // for each triangle
{
vec3_t const &v0(vertices[indices[i * 3 + 0]]);
vec3_t const &v1(vertices[indices[i * 3 + 1]]);
vec3_t const &v2(vertices[indices[i * 3 + 2]]);
mat3x3_t A(v0[0] - com[0], v0[1] - com[1], v0[2] - com[2],
v1[0] - com[0], v1[1] - com[1], v1[2] - com[2],
v2[0] - com[0], v2[1] - com[1], v2[2] - com[2]);
// vol of tiny parallelapiped= d * dr * ds * dt (the 3 partials of my tetral triple integral equation)
T d = determinant(vec<T, 3>(A(0, 0), A(1, 0), A(2, 0)),
vec<T, 3>(A(0, 1), A(1, 1), A(2, 1)),
vec<T, 3>(A(0, 2), A(1, 2), A(2, 2)));
volume +=d; // add vol of current tetra (note it could be negative - that's ok we need that sometimes)
for(int j = 0; j < 3; ++j) {
int j1=(j+1)%3;
int j2=(j+2)%3;
diag[j] += (A(0, j) * A(1, j) + A(1, j) * A(2, j) + A(2, j) * A(0, j) +
A(0, j) * A(0, j) + A(1, j) * A(1, j) + A(2, j) * A(2, j) ) * d; // divide by 60.0f later;
offd[j] += (A(0, j1) * A(1, j2) + A(1, j1) * A(2, j2) + A(2, j1) * A(0, j2) +
A(0, j1) * A(2, j2) + A(1, j1) * A(0, j2) + A(2, j1) * A(1, j2) +
A(0, j1) * A(0, j2) * T(2) + A(1, j1) * A(1, j2) * T(2) + A(2, j1) * A(2, j2) * T(2)) *d; // divide by 120.0f later
}
}
diag /= volume * (T(60.0) / T(6.0)); // divide by total volume (vol/6) since density=1/volume
offd /= volume * (T(120.0) / T(6.0));
return mat3x3_t(diag[1] + diag[2] , -offd[2] , -offd[1],
-offd[2] , diag[0] + diag[2], -offd[0],
-offd[1] , -offd[0] , diag[0] + diag[1] );
}
#endif

View File

@@ -0,0 +1,38 @@
/*
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>
*/
//mayaUtils.h
#ifndef DYN_MAYA_UTILS_H
#define DYN_MAYA_UTILS_H
#define MCHECKSTATUS(status, context) \
{ \
if(!status) { \
std::cout << "maya error: " << status.errorString().asChar() \
<< " while: " << context << std::endl; \
return status; \
} \
}
#endif

View File

@@ -0,0 +1,44 @@
/*
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>
*/
//mesh_shape.h
#ifndef DYN_MESH_SHAPE_H
#define DYN_MESH_SHAPE_H
#include "collision_shape.h"
#include "collision_shape_impl.h"
class mesh_shape_t: public collision_shape_t
{
public:
//typedefs
typedef shared_ptr<mesh_shape_t> pointer;
protected:
friend class solver_t;
mesh_shape_t(collision_shape_impl_t* impl): collision_shape_t(impl) { }
};
#endif

View File

@@ -0,0 +1,39 @@
/*
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>
*/
//mesh_shape_impl.h
#ifndef DYN_MESH_SHAPE_IMPL_H
#define DYN_MESH_SHAPE_IMPL_H
#include "collision_shape_impl.h"
class mesh_shape_impl_t: public collision_shape_impl_t
{
public:
//typedefs
private:
};
#endif

View File

@@ -0,0 +1,35 @@
/*
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>
*/
//base.h
#ifndef MVL_BASE_H
#define MVL_BASE_H
namespace mvl {
} //namespace mvl
#endif

399
Extras/MayaPlugin/mvl/mat.h Normal file
View File

@@ -0,0 +1,399 @@
/*
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>
*/
//mat.h
#ifndef MVL_MAT_H
#define MVL_MAT_H
#include <cmath>
#include "base.h"
#include "traits.h"
namespace mvl {
template<typename T, std::size_t R, std::size_t C>
class mat
{
public:
typedef T value_type;
typedef T& reference;
typedef T const& const_reference;
typedef T* iterator;
typedef T const* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
public:
enum {
Rows = R,
Cols = C,
Size = Rows * Cols,
};
public:
//constructors
explicit mat() {}
template<typename T2>
mat(mat<T2, Rows, Cols> const& m)
{
*this = m;
}
explicit mat(value_type val)
{
for(int i = 0; i < Size; ++i){
m_data[i] = val;
}
}
explicit mat(value_type m00, value_type m01,
value_type m10, value_type m11)
{
operator()(0, 0) = m00; operator()(0, 1) = m01;
operator()(1, 0) = m10; operator()(1, 1) = m11;
}
explicit mat(value_type m00, value_type m01, value_type m02,
value_type m10, value_type m11, value_type m12,
value_type m20, value_type m21, value_type m22)
{
operator()(0, 0) = m00; operator()(0, 1) = m01; operator()(0, 2) = m02;
operator()(1, 0) = m10; operator()(1, 1) = m11; operator()(1, 2) = m12;
operator()(2, 0) = m20; operator()(2, 1) = m21; operator()(2, 2) = m22;
}
explicit mat(value_type m00, value_type m01, value_type m02, value_type m03,
value_type m10, value_type m11, value_type m12, value_type m13,
value_type m20, value_type m21, value_type m22, value_type m23,
value_type m30, value_type m31, value_type m32, value_type m33)
{
operator()(0, 0) = m00; operator()(0, 1) = m01; operator()(0, 2) = m02; operator()(0, 3) = m03;
operator()(1, 0) = m10; operator()(1, 1) = m11; operator()(1, 2) = m12; operator()(1, 3) = m13;
operator()(2, 0) = m20; operator()(2, 1) = m21; operator()(2, 2) = m22; operator()(2, 3) = m23;
operator()(3, 0) = m30; operator()(3, 1) = m31; operator()(3, 2) = m32; operator()(3, 3) = m33;
}
public:
//data access
value_type operator()(std::size_t i, std::size_t j) const { return m_data[j * Rows + i]; }
reference operator()(std::size_t i, std::size_t j) { return m_data[j * Rows + i]; }
public:
//stl
static std::size_t size() { return Size; }
static std::size_t max_size() { return Size; }
static bool empty() { return false; }
iterator begin() { return m_data; }
iterator end() { return m_data + Size; }
const_iterator begin() const { return m_data; }
const_iterator end() const { return m_data + Size; }
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
value_type front() { return m_data[0]; }
value_type back() { return m_data[Size - 1]; }
const_reference front() const { return m_data[0]; }
const_reference back() const { return m_data[Size - 1]; }
friend std::ostream& operator << (std::ostream& out, mat const& m) {
out << "(";
for(size_t i = 0; i < Rows - 1; i++) {
for(size_t j = 0; j < Cols; j++) {
out << m(i, j) << ", ";
}
out << std::endl;
}
for(size_t j = 0; j < Cols - 1; j++) {
out << m(Rows - 1, j) << ", ";
}
out << m(Rows - 1, Cols - 1) << ")";
return out;
}
public:
//
mat& operator=(mat const& rhs) {
std::copy(rhs.begin(),rhs.end(), begin());
return *this;
}
template<typename T2>
mat& operator=(mat<T2, Rows, Cols> const& rhs) {
std::copy(rhs.begin(),rhs.end(), begin());
return *this;
}
private:
//data is stored in column major order, so the matrix can passed directly to the graphics APIs
T m_data[Size];
};
//assignment operators
// OP(mat<T1>, mat<T2>)
// OP(mat<T>, T)
#define MAT_IMPLEMENT_MACRO(OP) \
template<typename T1, typename T2, std::size_t R, std::size_t C> \
inline \
mat<T1, R, C>& \
operator OP(mat<T1, R, C>& lhs, mat<T2, R, C> const& rhs) { \
for(int i = 0; i < C * R; ++i) { \
lhs[i] OP rhs[i]; \
} \
return lhs; \
} \
\
template<typename T, std::size_t R, std::size_t C> \
inline \
mat<T, R, C>& \
operator OP(mat<T, R, C>& lhs, typename mat<T, R, C>::value_type const& rhs) { \
for(int i = 0; i < C * R; ++i) { \
lhs[i] OP rhs[i]; \
} \
return lhs; \
} \
MAT_IMPLEMENT_MACRO(+=)
MAT_IMPLEMENT_MACRO(-=)
MAT_IMPLEMENT_MACRO(*=)
MAT_IMPLEMENT_MACRO(/=)
#undef MAT_IMPLEMENT_MACRO
//operator + (mat, mat)
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
mat<typename promote_traits<T1, T2>::value_type, R, C>
operator + (mat<T1, R, C> const& lhs, mat<T2, R, C> const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = lhs(i, j) + rhs(i, j);
}
}
return res;
}
//operator - (mat, mat)
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
mat<typename promote_traits<T1, T2>::value_type, R, C>
operator - (mat<T1, R, C> const& lhs, mat<T2, R, C> const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = lhs(i, j) - rhs(i, j);
}
}
return res;
}
//operator * (mat, POD)
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
mat<typename promote_traits<T1, T2>::value_type, R, C>
operator * (mat<T1, R, C> const& lhs, T2 const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = lhs(i, j) * rhs;
}
}
return res;
}
//operator * (POD, mat)
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
mat<typename promote_traits<T1, T2>::value_type, R, C>
operator * (T1 const& lhs, mat<T2, R, C> const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = lhs * rhs(i, j);
}
}
return res;
}
//operator / (mat, POD)
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
mat<typename promote_traits<T1, T2>::value_type, R, C>
operator / (mat<T1, R, C> const& lhs, T2 const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = lhs(i, j) / rhs;
}
}
return res;
}
//element_prod(mat, mat)
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
mat<typename promote_traits<T1, T2>::value_type, R, C>
element_prod(mat<T1, R, C> const& lhs, mat<T2, R, C> const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = lhs(i, j) * rhs(i, j);
}
}
return res;
}
//element_div(mat, mat)
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
mat<typename promote_traits<T1, T2>::value_type, R, C>
element_div(mat<T1, R, C> const& lhs, mat<T2, R, C> const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = lhs(i, j) / rhs(i, j);
}
}
return res;
}
//unary operator -(mat)
template<typename T, std::size_t R, std::size_t C>
inline
mat<T, R, C>
operator -(mat<T, R, C> const& rhs) {
mat<T, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = -rhs(i, j);
}
}
return res;
}
//matrix transpose
template<typename T, std::size_t R, std::size_t C>
inline
mat<T, R, C>
trans(mat<T, R, C> const& rhs) {
mat<T, R, C> res;
for(int i = 0; i < R ; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = rhs(j, i);
}
}
return res;
}
//identity matrix
template<typename T, std::size_t Sz>
inline
mat<T, Sz, Sz>
identity() {
mat<T, Sz, Sz> res;
for(int i = 0; i < Sz ; ++i) {
for(int j = 0; j < Sz; ++j) {
res(i, j) = i == j ? 1 : 0;
}
}
return res;
}
//matrix diagonal as vector (for square matrices)
template<typename T, std::size_t N>
inline
vec<T, N>
diag(mat<T, N, N> const& rhs) {
vec<T, N> res;
for(int i = 0; i < N; ++i) {
res[i] = rhs(i, i);
}
return res;
}
//matrix row as vector
template<typename T, std::size_t R, std::size_t C>
inline
vec<T, C>
row(mat<T, R, C> const& rhs, std::size_t r) {
vec<T, C> res;
for(int i = 0; i < C; ++i) {
res[i] = rhs(r, i);
}
return res;
}
//matrix column as vector
template<typename T, std::size_t R, std::size_t C>
inline
vec<T, R>
col(mat<T, R, C> const& rhs, std::size_t c) {
vec<T, R> res;
for(int i = 0; i < R; ++i) {
res[i] = rhs(i, c);
}
return res;
}
//matrix-matrix product
template<typename T1, typename T2, std::size_t R1, std::size_t C1, std::size_t C2>
inline
mat<typename promote_traits<T1, T2>::value_type, R1, C2>
prod(mat<T1, R1, C1> const& lhs, mat<T2, C1, C2> const& rhs) {
mat<typename promote_traits<T1, T2>::value_type, R1, C2> res;
for(int i = 0; i < R1; ++i) {
for(int j = 0; j < C2; ++j) {
res(i, j) = 0;
for(int k = 0; k < C1; ++k) {
res(i, j) += lhs(i, k) * rhs(k, j);
}
}
}
return res;
}
//matrix - column vector product
template<typename T1, typename T2, std::size_t R, std::size_t C>
inline
vec<typename promote_traits<T1, T2>::value_type, R>
prod(mat<T1, R, C> const& lhs, vec<T2, C> const& rhs) {
vec<typename promote_traits<T1, T2>::value_type, R> res;
for(int i = 0; i < R; ++i) {
res(i) = 0;
for(int j = 0; j < C; ++j) {
res(i) += lhs(i, j) * rhs(j);
}
}
return res;
}
} // namespace mvl
#endif

View File

@@ -0,0 +1,280 @@
/*
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>
*/
//quat.h
#ifndef MVL_QUAT_H
#define MVL_QUAT_H
#include <limits>
#include "vec.h"
#include "mat.h"
//quaternions are vectors of size 4
// it's assumed that the layout is in the form (w, (x, y, z)),
// so that the identity quaternion is (1, 0, 0, 0)
namespace mvl {
//quaternion conjugate
template<typename T>
inline vec<T, 4>
qconj(vec<T, 4> const& rhs) {
return vec<T, 4>(-rhs[0], rhs[1], rhs[2], rhs[3]);
}
//quaternion identity
template<typename T>
inline
vec<T, 4>
qidentity() {
return vec<T, 4>(1, 0, 0, 0);
}
//quaternion - quaternion product
template<typename T1, typename T2>
inline
vec<typename promote_traits<T1, T2>::value_type, 4>
qprod(vec<T1, 4> const& lhs, vec<T2, 4> const& rhs) {
typedef typename promote_traits<T1, T2>::value_type value_type;
return vec<value_type, 4>((lhs(0)*rhs(0)) - (lhs(1)*rhs(1)) - (lhs(2)*rhs(2)) - (lhs(3)*rhs(3)),
(lhs(0)*rhs(1)) + (lhs(1)*rhs(0)) + (lhs(2)*rhs(3)) - (lhs(3)*rhs(2)),
(lhs(0)*rhs(2)) - (lhs(1)*rhs(3)) + (lhs(2)*rhs(0)) + (lhs(3)*rhs(1)),
(lhs(0)*rhs(3)) + (lhs(1)*rhs(2)) - (lhs(2)*rhs(1)) + (lhs(3)*rhs(0)));
}
//quanternion - vector product (rotation)
template<typename T1, typename T2>
inline
vec<typename promote_traits<T1, T2>::value_type, 3>
qprod(vec<T1, 4> const& q, vec<T2, 3> const& v) {
typedef typename promote_traits<T1, T2>::value_type value_type;
vec<value_type, 4> tmp = qprod(qprod(q, vec<value_type, 4>(0, v[0], v[1], v[2])), qconj(q));
return vec<value_type, 3>(tmp[0], tmp[1], tmp[2]);
}
//spherical interpolation between q0 and q1
template <typename T1, typename T2, typename T3>
inline
vec<typename promote_traits<T1, T2>::value_type, 4>
qslerp(vec<T1, 4> const& q1, vec<T2, 4> const& q2, T3 t) {
typedef typename promote_traits<T1, T2>::value_type value_type;
value_type omega, cosom, sinom, scale0, scale1;
vec<value_type, 4> tmp;
cosom = dot(q1, q2);
if (cosom < static_cast<value_type>(0.0)) {
cosom = -cosom;
tmp = -q2;
} else {
tmp = q2;
}
if ((static_cast<value_type>(1.0) - cosom) > std::numeric_limits<value_type>::epsilon()) {
omega = (value_type) acos(cosom);
sinom = sin(omega);
scale0 = sin((static_cast<value_type>(1.0) - t) * omega) / sinom;
scale1 = sin(t * omega) / sinom;
} else {
scale0 = static_cast<value_type>(1.0) - t;
scale1 = t;
}
return scale0 * q1 + scale1 * tmp;
}
//init quaternion from axis-angle
template<typename T1, typename T2>
inline
vec<typename promote_traits<T1, T2>::value_type, 4>
q_from_axis_angle(vec<T1, 3> const& axis, T2 theta) {
typedef typename promote_traits<T1, T2>::value_type value_type;
value_type sin_theta = sin(static_cast<value_type>(static_cast<value_type>(0.5)) * theta);
return vec<value_type, 4>(cos(static_cast<value_type>(static_cast<value_type>(0.5)) * theta),
sin_theta * axis[0],
sin_theta * axis[1],
sin_theta * axis[2]);
}
//get the axis/angle from quaternion
template<typename T1, typename T2, typename T3>
inline
void
q_to_axis_angle(vec<T1, 4> const& q, vec<T2, 3>& axis, T3& theta) {
T3 half_theta= acos(q[0]);
if(half_theta > 10 * std::numeric_limits<T3>::epsilon()) {
T3 oost = 1 / sin(half_theta);
axis[0] = oost * q[1];
axis[1] = oost * q[2];
axis[2] = oost * q[3];
theta = 2 * half_theta;
} else {
axis[0] = axis[1] = axis[2] = 0;
theta = 0;
}
}
//init quaternion from rotation matrix
template<typename T1>
inline
vec<T1, 4>
q_from_mat(mat<T1, 3, 3> const& m) {
T1 trace, s, hos;
trace = m(0, 0) + m(1, 1) + m(2, 2);
if (trace > static_cast<T1>(0.0)) {
s = sqrt(trace + static_cast<T1>(1.0));
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>(s * static_cast<T1>(0.5), (m(2, 1) - m(1, 2)) * hos, (m(0, 2) - m(2, 0)) * hos, (m(1, 0) - m(0, 1)) * hos);
} else {
int biggest;
enum {A,T,I};
if (m(0, 0) > m(1, 1)) {
if (m(2, 2) > m(0, 0)) biggest = I;
else biggest = A;
} else {
if (m(2, 2) > m(0, 0)) biggest = I;
else biggest = T;
}
switch (biggest) {
case A:
s = sqrt( m(0, 0) - (m(1, 1) + m(2, 2)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(2, 1) - m(1, 2)) * hos, s * static_cast<T1>(0.5), (m(0, 1) + m(1, 0)) * hos, (m(0, 2) + m(2, 0)) * hos);
}
// I
s = sqrt( m(2, 2) - (m(0, 0) + m(1, 1)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(1, 0) - m(0, 1)) * hos, (m(2, 0) + m(0, 2)) * hos, (m(2, 1) + m(1, 2)) * hos, s * static_cast<T1>(0.5));
}
// T
s = sqrt( m(1, 1) - (m(2, 2) + m(0, 0)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(0, 2) - m(2, 0)) * hos, (m(1, 0) + m(0, 1)) * hos, s * static_cast<T1>(0.5), (m(1, 2) + m(2, 1)) * hos);
}
break;
case T:
s = sqrt( m(1, 1) - (m(2, 2) + m(0, 0)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(0, 2) - m(2, 0)) * hos, (m(1, 0) + m(0, 1)) * hos, s * static_cast<T1>(0.5), (m(1, 2) + m(2, 1)) * hos);
}
// I
s = sqrt( m(2, 2) - (m(0, 0) + m(1, 1)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(1, 0) - m(0, 1)) * hos, (m(2, 0) + m(0, 2)) * hos, (m(2, 1) + m(1, 2)) * hos, s * static_cast<T1>(0.5));
}
// A
s = sqrt( m(0, 0) - (m(1, 1) + m(2, 2)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(2, 1) - m(1, 2)) * hos, s * static_cast<T1>(0.5), (m(0, 1) + m(1, 0)) * hos, (m(0, 2) + m(2, 0)) * hos);
}
break;
case I:
s = sqrt( m(2, 2) - (m(0, 0) + m(1, 1)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(1, 0) - m(0, 1)) * hos, (m(2, 0) + m(0, 2)) * hos, (m(2, 1) + m(1, 2)) * hos, s * static_cast<T1>(0.5));
}
// A
s = sqrt( m(0, 0) - (m(1, 1) + m(2, 2)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(2, 1) - m(1, 2)) * hos, s * static_cast<T1>(0.5), (m(0, 1) + m(1, 0)) * hos, (m(0, 2) + m(2, 0)) * hos);
}
// T
s = sqrt( m(1, 1) - (m(2, 2) + m(0, 0)) + static_cast<T1>(1.0));
if (s > (100 * std::numeric_limits<T1>::epsilon())) {
hos = static_cast<T1>(0.5) / s;
return vec<T1, 4>((m(0, 2) - m(2, 0)) * hos, (m(1, 0) + m(0, 1)) * hos, s * static_cast<T1>(0.5), (m(1, 2) + m(2, 1)) * hos);
}
break;
}
}
}
//get rotation matrix from quaternion
template<typename T>
inline
void
q_to_mat(vec<T, 4> const& q, mat<T, 3, 3>& m) {
T X2,Y2,Z2; //2*QX, 2*QY, 2*QZ
T XX2,YY2,ZZ2; //2*QX*QX, 2*QY*QY, 2*QZ*QZ
T XY2,XZ2,XW2; //2*QX*QY, 2*QX*QZ, 2*QX*QW
T YZ2,YW2,ZW2; // ...
X2 = 2 * q[1];
XX2 = X2 * q[1];
XY2 = X2 * q[2];
XZ2 = X2 * q[3];
XW2 = X2 * q[0];
Y2 = 2 * q[2];
YY2 = Y2 * q[2];
YZ2 = Y2 * q[3];
YW2 = Y2 * q[0];
Z2 = 2 * q[3];
ZZ2 = Z2 * q[3];
ZW2 = Z2 * q[0];
m(0, 0) = 1 - YY2 - ZZ2;
m(0, 1) = XY2 - ZW2;
m(0, 2) = XZ2 + YW2;
m(1, 0) = XY2 + ZW2;
m(1, 1) = 1 - XX2 - ZZ2;
m(1, 2) = YZ2 - XW2;
m(2, 0) = XZ2 - YW2;
m(2, 1) = YZ2 + XW2;
m(2, 2) = 1 - XX2 - YY2;
}
template<typename T, size_t R, size_t C>
mat<T, R, C>
cmat(T const* m)
{
mat<T, R, C> res;
for(int i = 0; i < R; ++i) {
for(int j = 0; j < C; ++j) {
res(i, j) = m[i * C + j];
}
}
return res;
}
} //namespace mvl
#endif

View File

@@ -0,0 +1,85 @@
/*
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>
*/
//traits.h
#ifndef MVL_TRAITS_H
#define MVL_TRAITS_H
namespace mvl {
//simple promotion for now
//check if a type is a POD
template<typename T>
struct isPOD { enum { value = false }; };
template<> struct isPOD<char> { enum { value = true }; };
template<> struct isPOD<short> { enum { value = true }; };
template<> struct isPOD<int> { enum { value = true }; };
template<> struct isPOD<float> { enum { value = true }; };
template<> struct isPOD<double> { enum { value = true }; };
template<> struct isPOD<long double> { enum { value = true }; };
//
template<bool Condition, typename T1, typename T2> struct ifThenElse { typedef T2 value_type; };
template<typename T1, typename T2> struct ifThenElse<true, T1, T2> { typedef T1 value_type; };
template<typename T1, typename T2>
struct promote_traits
{
typedef typename ifThenElse<isPOD<T1>::value, T2, T1>::value_type value_type;
};
template<typename T>
struct promote_traits<T, T>
{
typedef T value_type;
};
#define TRAITS_DEFINE_MACRO(T1, T2, TP) \
template<> \
struct promote_traits<T1, T2> \
{ \
typedef TP value_type; \
}; \
template<> \
struct promote_traits<T2, T1> \
{ \
typedef TP value_type; \
};
TRAITS_DEFINE_MACRO(int, float, float)
TRAITS_DEFINE_MACRO(int, double, double)
TRAITS_DEFINE_MACRO(int, long double, long double)
TRAITS_DEFINE_MACRO(float, double, double)
TRAITS_DEFINE_MACRO(float, long double, long double)
TRAITS_DEFINE_MACRO(double, long double, long double)
#undef TRAITS_DEFINE_MACRO
} // namespace mvl
#endif

View File

@@ -0,0 +1,62 @@
/*
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>
*/
//util.h
#ifndef MVL_UTIL_H
#define MVL_UTIL_H
#include <cmath>
#include "base.h"
#include "traits.h"
#include "vec.h"
namespace mvl {
//translation
template<typename T>
inline
mat<T, 4, 4> translation(vec<T, 3> const& v)
{
return mat<T, 4, 4>(1, 0, 0, v(0),
0, 1, 0, v(1),
0, 0, 1, v(2),
0, 0, 0, 1);
return res;
}
//scale
template<typename T>
inline
mat<T, 4, 4> scale(vec<T, 3> const& v)
{
return mat<T, 4, 4> (v(0), 0, 0, 0,
0, v(1), 0, 0,
0, 0, v(2), 0,
0, 0, 0, 1);
}
} // namespace mvl
#endif

347
Extras/MayaPlugin/mvl/vec.h Normal file
View File

@@ -0,0 +1,347 @@
/*
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>
*/
//vec.h
#ifndef MVL_VEC_H
#define MVL_VEC_H
#include <iostream>
#include <cmath>
#include "base.h"
#include "traits.h"
namespace mvl {
template<typename T, std::size_t Sz>
class vec
{
public:
typedef T value_type;
typedef T& reference;
typedef T const& const_reference;
typedef T* iterator;
typedef T const* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
public:
enum {
Size = Sz,
};
public:
//constructors
explicit vec() {}
template<typename T2>
vec(vec<T2, Size> const& v)
{
*this = v;
}
explicit vec(value_type val)
{
for(int i = 0; i < Size; ++i) {
m_data[i] = val;
}
}
explicit vec(value_type x0, value_type x1)
{
m_data[0] = x0; m_data[1] = x1;
}
explicit vec(value_type x0, value_type x1, value_type x2)
{
m_data[0] = x0; m_data[1] = x1; m_data[2] = x2;
}
explicit vec(value_type x0, value_type x1, value_type x2, value_type x3)
{
m_data[0] = x0; m_data[1] = x1; m_data[2] = x2; m_data[3] = x3;
}
explicit vec(value_type x0, value_type x1, value_type x2, value_type x3, value_type x4)
{
m_data[0] = x0; m_data[1] = x1; m_data[2] = x2; m_data[3] = x3; m_data[4] = x4;
}
explicit vec(value_type x0, value_type x1, value_type x2, value_type x3, value_type x4, value_type x5)
{
m_data[0] = x0; m_data[1] = x1; m_data[2] = x2; m_data[3] = x3; m_data[4] = x4; m_data[5] = x5;
}
public:
//data access
value_type operator[](std::size_t i) const { return m_data[i]; }
reference operator[](std::size_t i) { return m_data[i]; }
value_type operator()(std::size_t i) const { return m_data[i]; }
reference operator()(std::size_t i) { return m_data[i]; }
public:
//stl
static std::size_t size() { return Size; }
static std::size_t max_size() { return Size; }
static bool empty() { return false; }
iterator begin() { return m_data; }
iterator end() { return m_data + Size; }
const_iterator begin() const { return m_data; }
const_iterator end() const { return m_data + Size; }
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
value_type front() { return m_data[0]; }
value_type back() { return m_data[Size - 1]; }
const_reference front() const { return m_data[0]; }
const_reference back() const { return m_data[Size - 1]; }
friend std::ostream& operator << (std::ostream& out, vec const& v) {
out << "(";
for(size_t i = 0; i < Size - 1; i++) {
out << v(i) << ", ";
}
out << v(Size - 1) << ")";
return out;
}
public:
//assignment
vec& operator=(vec const& rhs) {
for(int i = 0; i < Size; ++i) {
m_data[i] = rhs[i];
}
return *this;
}
template<typename T2>
vec& operator=(vec<T2, Size> const& rhs) {
for(int i = 0; i < Size; ++i) {
m_data[i] = rhs[i];
}
return *this;
}
private:
T m_data[Size];
};
//assignment operators
// OP(vec<T1>, vec<T2>)
// OP(vec<T>, T)
#define VEC_IMPLEMENT_MACRO(OP) \
template<typename T1, typename T2, std::size_t Sz> \
inline \
vec<T1, Sz>& \
operator OP(vec<T1, Sz>& lhs, vec<T2, Sz> const& rhs) { \
for(int i = 0; i < Sz; ++i) { \
lhs[i] OP rhs[i]; \
} \
return lhs; \
} \
\
template<typename T, std::size_t Sz> \
inline \
vec<T, Sz>& \
operator OP(vec<T, Sz>& lhs, T const& rhs) { \
for(int i = 0; i < Sz; ++i) { \
lhs[i] OP rhs; \
} \
return lhs; \
} \
VEC_IMPLEMENT_MACRO(+=)
VEC_IMPLEMENT_MACRO(-=)
VEC_IMPLEMENT_MACRO(*=)
VEC_IMPLEMENT_MACRO(/=)
#undef VEC_IMPLEMENT_MACRO
//operator + (vec, vec)
template<typename T1, typename T2, std::size_t Sz>
inline
vec<typename promote_traits<T1, T2>::value_type, Sz>
operator + (vec<T1, Sz> const& lhs, vec<T2, Sz> const& rhs)
{
vec<typename promote_traits<T1, T2>::value_type, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = lhs[i] + rhs[i];
}
return res;
}
//operator - (vec, vec)
template<typename T1, typename T2, std::size_t Sz>
inline
vec<typename promote_traits<T1, T2>::value_type, Sz>
operator - (vec<T1, Sz> const& lhs, vec<T2, Sz> const& rhs)
{
vec<typename promote_traits<T1, T2>::value_type, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = lhs[i] - rhs[i];
}
return res;
}
//operator * (vec, POD)
template<typename T1, typename T2, std::size_t Sz>
inline
vec<typename promote_traits<T1, T2>::value_type, Sz>
operator * (vec<T1, Sz> const& lhs, T2 const& rhs) {
vec<typename promote_traits<T1, T2>::value_type, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = lhs[i] * rhs;
}
return res;
}
//operator * (POD, vec)
template<typename T1, typename T2, std::size_t Sz>
inline
vec<typename promote_traits<T1, T2>::value_type, Sz>
operator * (T1 const& lhs, vec<T2, Sz> const& rhs) {
vec<typename promote_traits<T1, T2>::value_type, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = lhs * rhs[i];
}
return res;
}
//operator / (vec, POD)
template<typename T1, typename T2, std::size_t Sz>
inline
vec<typename promote_traits<T1, T2>::value_type, Sz>
operator / (vec<T1, Sz> const& lhs, T2 const& rhs) {
vec<typename promote_traits<T1, T2>::value_type, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = lhs[i] / rhs;
}
return res;
}
//element_prod(vec, vec)
template<typename T1, typename T2, std::size_t Sz>
inline
vec<typename promote_traits<T1, T2>::value_type, Sz>
element_prod(vec<T1, Sz> const& lhs, vec<T2, Sz> const& rhs) {
vec<typename promote_traits<T1, T2>::value_type, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = lhs[i] * rhs[i];
}
return res;
}
//element_div(vec, vec)
template<typename T1, typename T2, std::size_t Sz>
inline
vec<typename promote_traits<T1, T2>::value_type, Sz>
element_div(vec<T1, Sz> const& lhs, vec<T2, Sz> const& rhs) {
vec<typename promote_traits<T1, T2>::value_type, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = lhs[i] / rhs[i];
}
return res;
}
//unary operator -(expr_vec)
template<typename T, std::size_t Sz>
inline
vec<T, Sz>
operator -(vec<T, Sz> const& rhs) {
vec<T, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = -rhs[i];
}
return res;
}
//dot product
template<typename T1, typename T2, std::size_t Sz>
inline
typename promote_traits<T1, T2>::value_type
dot(vec<T1, Sz> const& lhs, vec<T2, Sz> const& rhs)
{
typename promote_traits<T1, T2>::value_type res(0);
for(int i = 0; i < Sz; ++i) {
res += rhs[i] * lhs[i];
}
return res;
}
//cross product
template<typename T1, typename T2>
inline
vec<typename promote_traits<T1, T2>::value_type, 3>
cross(vec<T1, 3> const& lhs, vec<T2, 3> const& rhs) {
typedef typename promote_traits<T1, T2>::value_type value_type;
return vec<value_type, 3>(lhs(1)*rhs(2) - rhs(1)*lhs(2),
rhs(0)*lhs(2) - lhs(0)*rhs(2),
lhs(0)*rhs(1) - rhs(0)*lhs(1));
}
//length of the vector
template<typename T, std::size_t Sz>
inline T
norm2(vec<T, Sz> const& rhs)
{
return static_cast<T>(sqrt(dot(rhs, rhs)));
}
//length of the vector squared
template<typename T, std::size_t Sz>
inline T
norm_squared(vec<T, Sz> const& rhs)
{
return dot(rhs, rhs);
}
//normalize the vector
template<typename T, std::size_t Sz>
inline
vec<T, Sz>
normalize(vec<T, Sz> const& v) {
typedef T value_type;
T tmp = norm2(v);
if(tmp == value_type(0)) {
tmp = value_type(0);
} else {
tmp = value_type(1) / tmp;
}
vec<T, Sz> res;
for(int i = 0; i < Sz; ++i) {
res[i] = v[i] * tmp;
}
return res;
}
} //namespace mvl
#endif

308
Extras/MayaPlugin/pdbIO.cpp Normal file
View File

@@ -0,0 +1,308 @@
/*
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>
*/
#include "pdbIO.h"
#include <string.h>
#include <map>
#include <stdexcept>
#define PDB_MAGIC 670
//headers used for reading and writing
struct pdb_channel_data_t
{
int type;
unsigned int datasize;
unsigned int blocksize;
int num_blocks;
//void **block;
int block;
};
struct pdb_channel_t
{
//char *name;
int name;
int type;
unsigned int size;
unsigned int active_start;
unsigned int active_end;
char hide;
char disconnect;
//pdb_channel_data_t *data;
int data;
//pdb_channel_t *link;
int link;
//pdb_channel_t *next;
int next;
};
struct pdb_channel_header_t
{
char magic;
unsigned short swap;
char encoding;
char type;
};
/*
struct pdb_data_t
{
int numAttributes;
int numParticles;
float time;
// short *types;
int types;
// char **names;
int names;
// void **data;
int data;
};
*/
struct pdb_header_t
{
int magic;
unsigned short swap;
float version;
float time;
unsigned int data_size;
unsigned int num_data;
char padding[32];
//pdb_channel_t **data;
int data;
};
/*
struct pdb_channel_data_t
{
int type;
unsigned datasize;
unsigned long blocksize;
int num_blocks;
void **block;
};
struct pdb_channel_t
{
char *name;
int type;
unsigned long size;
unsigned long active_start;
unsigned long active_end;
char hide;
char disconnect;
pdb_channel_data_t *data;
pdb_channel_t *link;
pdb_channel_t *next;
};
struct pdb_channel_header_t
{
char magic;
unsigned short swap;
char encoding;
char type;
};
struct pdb_data_t
{
int numAttributes;
int numParticles;
float time;
short *types;
char **names;
void **data;
};
struct pdb_header_t
{
int magic;
unsigned short swap;
float version;
float time;
unsigned data_size;
unsigned num_data;
char padding[32];
pdb_channel_t **data;
};
*/
void read_string( std::istream &in, std::string &str )
{
int c;
while( (c = in.get()) ) {
if ( in.eof()) {
str.clear();
return;
}
str.push_back(c);
}
}
void write_string( std::ostream &out, std::string &str )
{
for(size_t i = 0; i < str.size(); ++i) {
out.put(str[i]);
}
out.put(0);
}
bool pdb_io_t::read(std::istream &in)
{
pdb_header_t header;
pdb_channel_header_t channel_header;
pdb_channel_t channel;
pdb_channel_data_t channel_data;
// read the header
in.read( (char*)&header, sizeof(pdb_header_t) );
m_time = header.time;
m_num_particles = header.data_size;
m_attributes.clear();
m_attributes.resize( header.num_data );
for (unsigned int i=0; i<header.num_data; i++) {
//
in.read( (char*)&channel_header, sizeof(pdb_channel_header_t));
in.read( (char*)&channel, sizeof(pdb_channel_t));
read_string(in, m_attributes[i].m_name);
m_attributes[i].m_type = channel.type;
// std::cout << m_attributes[i].m_name << std::endl;
in.read( (char*)&channel_data, sizeof(pdb_channel_data_t));
switch( channel.type ) {
case kVector:
throw std::runtime_error("pdb_io_t::read: channel_data.datasize == sizeof(vec3_t)");
m_attributes[i].m_num_elements = 1;
m_attributes[i].m_vector_data.resize(m_attributes[i].m_num_elements * header.data_size);
in.read( (char*)&(m_attributes[i].m_vector_data[0]), channel_data.datasize * header.data_size);
break;
case kReal:
// throw std::runtime_error("pdb_io_t::read: channel_data.datasize == sizeof(vec3_t)");
m_attributes[i].m_num_elements = channel_data.datasize / sizeof(float);
m_attributes[i].m_real_data.resize(m_attributes[i].m_num_elements * header.data_size);
in.read( (char*)&(m_attributes[i].m_real_data[0]), channel_data.datasize * header.data_size);
break;
case kLong:
// assert(channel_data.datasize == sizeof(int));
// throw std::runtime_error("pdb_io_t::read: channel_data.datasize == sizeof(vec3_t)");
m_attributes[i].m_num_elements = 1;
m_attributes[i].m_long_data.resize(m_attributes[i].m_num_elements * header.data_size);
in.read( (char*)&(m_attributes[i].m_long_data[0]), channel_data.datasize * header.data_size);
break;
}
}
return true;
}
bool pdb_io_t::write(std::ostream &out)
{
pdb_header_t header;
pdb_channel_header_t channel_header;
pdb_channel_t channel;
pdb_channel_data_t channel_data;
// read the header
header.magic = PDB_MAGIC;
header.swap = 0;
header.version = 1.0;
header.time = m_time;
header.data_size = m_num_particles;
header.num_data = m_attributes.size();
memset(header.padding, 0, 32 * sizeof(char) + sizeof(int));
out.write( (char*)&header, sizeof(pdb_header_t) );
for (size_t i = 0; i < m_attributes.size(); ++i) {
//
channel_header.magic = 0;
channel_header.swap = 0;
channel_header.encoding = 0;
channel_header.type = m_attributes[i].m_type;
out.write( (char*)&channel_header, sizeof(pdb_channel_header_t));
channel.name = 0;
channel.type = m_attributes[i].m_type;
channel.size = 0;
channel.active_start = 0;
channel.active_end = 0;
channel.hide = 0;
channel.disconnect = 0;
channel.data = 0;
channel.link = 0;
channel.next = 0;
out.write( (char*)&channel, sizeof(pdb_channel_t));
write_string(out, m_attributes[i].m_name);
channel_data.type = m_attributes[i].m_type;
//size of a single element
switch(m_attributes[i].m_type) {
case kVector:
channel_data.datasize = sizeof(vec3_t);
break;
case kReal:
channel_data.datasize = sizeof(float) * m_attributes[i].m_real_data.size() / m_num_particles;
break;
case kLong:
channel_data.datasize = sizeof(int) * m_attributes[i].m_long_data.size() / m_num_particles;
break;
}
channel_data.blocksize = 0;
channel_data.num_blocks = 0;
channel_data.block = 0;
out.write( (char*)&channel_data, sizeof(pdb_channel_data_t));
switch(m_attributes[i].m_type ) {
case kVector:
out.write( (char*)&(m_attributes[i].m_vector_data[0]), channel_data.datasize * header.data_size);
break;
case kReal:
out.write( (char*)&(m_attributes[i].m_real_data[0]), channel_data.datasize * header.data_size);
break;
case kLong:
out.write( (char*)&(m_attributes[i].m_long_data[0]), channel_data.datasize * header.data_size);
break;
}
}
return true;
}

76
Extras/MayaPlugin/pdbIO.h Normal file
View File

@@ -0,0 +1,76 @@
/*
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>
*/
#ifndef PDBIO_H
#define PDBIO_H
#include <iostream>
#include <vector>
struct pdb_io_t
{
enum Type {
kVector = 1,
kReal = 2,
kLong = 3,
kChar = 4,
kPointer = 5
};
struct vec3_t
{
float x;
float y;
float z;
};
struct attribute_t
{
std::string m_name;
int m_type;
int m_num_elements;
//
std::vector< vec3_t > m_vector_data;
std::vector< float > m_real_data;
std::vector< int > m_long_data;
};
//data
float m_time;
int m_num_particles;
std::vector< attribute_t > m_attributes;
//methods
bool read(std::istream &in);
bool write(std::ostream &out);
pdb_io_t():
m_time(0.0f)
{}
};
#endif

View File

@@ -0,0 +1,44 @@
/*
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>
*/
//plane_shape.h
#ifndef DYN_PLANE_SHAPE_H
#define DYN_PLANE_SHAPE_H
#include "collision_shape.h"
#include "plane_shape_impl.h"
class plane_shape_t: public collision_shape_t
{
public:
//typedefs
typedef shared_ptr<plane_shape_t> pointer;
protected:
friend class solver_t;
plane_shape_t(collision_shape_impl_t* impl): collision_shape_t(impl) { }
};
#endif

View File

@@ -0,0 +1,39 @@
/*
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>
*/
//plane_shape_impl.h
#ifndef DYN_PLANE_SHAPE_IMPL_H
#define DYN_PLANE_SHAPE_IMPL_H
#include "collision_shape_impl.h"
class plane_shape_impl_t: public collision_shape_impl_t
{
public:
//typedefs
private:
};
#endif

View File

@@ -0,0 +1,135 @@
/*
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>
*/
//pluginMain.cpp
#include <GL/glew.h>
#include <GL/glut.h>
#include <maya/MFnPlugin.h>
#include <maya/MGlobal.h>
#include <maya/MDGMessage.h>
#include "mayaUtils.h"
#include "rigidBodyNode.h"
#include "rigidBodyArrayNode.h"
#include "collisionShapeNode.h"
#include "dSolverNode.h"
#include "dSolverCmd.h"
#include "dRigidBodyCmd.h"
#include "dRigidBodyArrayCmd.h"
#include "mvl/util.h"
MStatus initializePlugin( MObject obj )
{
MStatus status;
MFnPlugin plugin( obj, "Walt Disney Feature Animation", "1.0", "Any");
int argc = 1;
char* argv[1] = {"ciao"};
glutInit(&argc, argv);
solver_t::initialize();
//
status = plugin.registerNode( rigidBodyNode::typeName, rigidBodyNode::typeId,
rigidBodyNode::creator,
rigidBodyNode::initialize,
MPxNode::kLocatorNode );
MCHECKSTATUS(status, "registering rigidBodyNode")
MDGMessage::addNodeRemovedCallback(rigidBodyNode::nodeRemoved, rigidBodyNode::typeName);
//
status = plugin.registerNode( rigidBodyArrayNode::typeName, rigidBodyArrayNode::typeId,
rigidBodyArrayNode::creator,
rigidBodyArrayNode::initialize,
MPxNode::kLocatorNode );
MCHECKSTATUS(status, "registering rigidBodyArrayNode")
MDGMessage::addNodeRemovedCallback(rigidBodyArrayNode::nodeRemoved, rigidBodyArrayNode::typeName);
//
status = plugin.registerNode( collisionShapeNode::typeName, collisionShapeNode::typeId,
collisionShapeNode::creator,
collisionShapeNode::initialize,
MPxNode::kDependNode );
MCHECKSTATUS(status, "registering collisionShapeNode")
//
status = plugin.registerNode( dSolverNode::typeName, dSolverNode::typeId,
dSolverNode::creator,
dSolverNode::initialize,
MPxNode::kDependNode );
MCHECKSTATUS(status, "registering dSolverNode")
status = plugin.registerCommand( dSolverCmd::typeName,
dSolverCmd::creator,
dSolverCmd::syntax);
MCHECKSTATUS(status, "registering dSolverCmd")
status = plugin.registerCommand( dRigidBodyCmd::typeName,
dRigidBodyCmd::creator,
dRigidBodyCmd::syntax);
MCHECKSTATUS(status, "registering dRigidBodyCmd")
status = plugin.registerCommand( dRigidBodyArrayCmd::typeName,
dRigidBodyArrayCmd::creator,
dRigidBodyArrayCmd::syntax);
MCHECKSTATUS(status, "registering dRigidBodyArrayCmd")
MGlobal::executeCommand( "source dynamicaUI.mel" );
MGlobal::executeCommand( "dynamicaUI_initialize" );
return status;
}
MStatus uninitializePlugin( MObject obj )
{
MStatus status;
MFnPlugin plugin( obj );
status = plugin.deregisterCommand(dRigidBodyArrayCmd::typeName);
MCHECKSTATUS(status, "deregistering dRigidBodyArrayCmd")
status = plugin.deregisterCommand(dRigidBodyCmd::typeName);
MCHECKSTATUS(status, "deregistering dRigidBodyCmd")
status = plugin.deregisterCommand(dSolverCmd::typeName);
MCHECKSTATUS(status, "deregistering dSolverGlobalsCmd")
status = plugin.deregisterNode(dSolverNode::typeId);
MCHECKSTATUS(status, "deregistering dSolverNode")
status = plugin.deregisterNode(collisionShapeNode::typeId);
MCHECKSTATUS(status, "deregistering collisionShapeNode")
status = plugin.deregisterNode(rigidBodyArrayNode::typeId);
MCHECKSTATUS(status, "deregistering rigidBodyArrayNode")
status = plugin.deregisterNode(rigidBodyNode::typeId);
MCHECKSTATUS(status, "deregistering rigidBodyNode")
solver_t::cleanup();
return status;
}

View File

@@ -0,0 +1,544 @@
/*
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>
*/
//rigidBodyArrayNode.cpp
//#include <GL/glut.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MPlugArray.h>
#include <maya/MFnMessageAttribute.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnMatrixAttribute.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MMatrix.h>
#include <maya/MFnMatrixData.h>
#include <maya/MFnStringData.h>
#include <maya/MFnTransform.h>
#include <maya/MQuaternion.h>
#include <maya/MEulerRotation.h>
#include <maya/MNodeMessage.h>
#include <maya/MVector.h>
#include "rigidBodyArrayNode.h"
#include "collisionShapeNode.h"
#include "mayaUtils.h"
#include "solver.h"
MTypeId rigidBodyArrayNode::typeId( 0x100314 );
MString rigidBodyArrayNode::typeName( "dRigidBodyArray" );
MObject rigidBodyArrayNode::ia_collisionShape;
MObject rigidBodyArrayNode::ia_solver;
MObject rigidBodyArrayNode::ia_numBodies;
MObject rigidBodyArrayNode::ia_active;
MObject rigidBodyArrayNode::ia_mass;
MObject rigidBodyArrayNode::ia_restitution;
MObject rigidBodyArrayNode::ia_friction;
MObject rigidBodyArrayNode::ia_linearDamping;
MObject rigidBodyArrayNode::ia_angularDamping;
MObject rigidBodyArrayNode::ia_initialPosition;
MObject rigidBodyArrayNode::ia_initialRotation;
MObject rigidBodyArrayNode::ia_initialVelocity;
MObject rigidBodyArrayNode::ia_initialSpin;
MObject rigidBodyArrayNode::ia_fileIO;
MObject rigidBodyArrayNode::ia_fioFiles;
MObject rigidBodyArrayNode::ia_fioPositionAttribute;
MObject rigidBodyArrayNode::ia_fioRotationAttribute;
MObject rigidBodyArrayNode::io_position;
MObject rigidBodyArrayNode::io_rotation;
MObject rigidBodyArrayNode::ca_rigidBodies;
MObject rigidBodyArrayNode::ca_rigidBodyParam;
MStatus rigidBodyArrayNode::initialize()
{
MStatus status;
MFnMessageAttribute fnMsgAttr;
MFnNumericAttribute fnNumericAttr;
MFnMatrixAttribute fnMatrixAttr;
MFnTypedAttribute fnTypedAttr;
MFnStringData fnStringData;
ia_collisionShape = fnMsgAttr.create("inCollisionShape", "incs", &status);
MCHECKSTATUS(status, "creating inCollisionShape attribute")
status = addAttribute(ia_collisionShape);
MCHECKSTATUS(status, "adding inCollisionShape attribute")
ia_solver = fnMsgAttr.create("solver", "solv", &status);
MCHECKSTATUS(status, "creating solver attribute")
status = addAttribute(ia_solver);
MCHECKSTATUS(status, "adding solver attribute")
ia_numBodies = fnNumericAttr.create("numBodies", "nbds", MFnNumericData::kInt, 1, &status);
MCHECKSTATUS(status, "creating numBodies attribute")
fnNumericAttr.setKeyable(false);
status = addAttribute(ia_numBodies);
MCHECKSTATUS(status, "adding numBodies attribute")
ia_active = fnNumericAttr.create("active", "ac", MFnNumericData::kBoolean, 1, &status);
MCHECKSTATUS(status, "creating active attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_active);
MCHECKSTATUS(status, "adding active attribute")
ia_mass = fnNumericAttr.create("mass", "ma", MFnNumericData::kDouble, 1.0, &status);
MCHECKSTATUS(status, "creating mass attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_mass);
MCHECKSTATUS(status, "adding mass attribute")
ia_restitution = fnNumericAttr.create("restitution", "rst", MFnNumericData::kDouble, 0.1, &status);
MCHECKSTATUS(status, "creating restitution attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_restitution);
MCHECKSTATUS(status, "adding restitution attribute")
ia_friction = fnNumericAttr.create("friction", "fc", MFnNumericData::kDouble, 0.5, &status);
MCHECKSTATUS(status, "creating friction attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_friction);
MCHECKSTATUS(status, "adding friction attribute")
ia_linearDamping = fnNumericAttr.create("linearDamping", "ld", MFnNumericData::kDouble, 0.3, &status);
MCHECKSTATUS(status, "creating linearDamping attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_linearDamping);
MCHECKSTATUS(status, "adding linearDamping attribute")
ia_angularDamping = fnNumericAttr.create("angularDamping", "ad", MFnNumericData::kDouble, 0.3, &status);
MCHECKSTATUS(status, "creating angularDamping attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_angularDamping);
MCHECKSTATUS(status, "adding angularDamping attribute")
ia_initialPosition = fnNumericAttr.createPoint("initialPosition", "inpo", &status);
MCHECKSTATUS(status, "creating initialPosition attribute")
fnNumericAttr.setArray(true);
status = addAttribute(ia_initialPosition);
MCHECKSTATUS(status, "adding initialPosition attribute")
ia_initialRotation = fnNumericAttr.createPoint("initialRotation", "inro", &status);
MCHECKSTATUS(status, "creating initialRotation attribute")
fnNumericAttr.setArray(true);
status = addAttribute(ia_initialRotation);
MCHECKSTATUS(status, "adding initialRotation attribute")
ia_initialVelocity = fnNumericAttr.createPoint("initialVelocity", "inve", &status);
MCHECKSTATUS(status, "creating initialVelocity attribute")
fnNumericAttr.setArray(true);
status = addAttribute(ia_initialVelocity);
MCHECKSTATUS(status, "adding initialVelocity attribute")
ia_initialSpin = fnNumericAttr.createPoint("initialSpin", "insp", &status);
MCHECKSTATUS(status, "creating initialSpin attribute")
fnNumericAttr.setArray(true);
status = addAttribute(ia_initialSpin);
MCHECKSTATUS(status, "adding initialSpin attribute")
ia_fileIO = fnNumericAttr.create("fileIO", "fio", MFnNumericData::kBoolean, 0, &status);
MCHECKSTATUS(status, "creating fileIO attribute")
fnNumericAttr.setKeyable(false);
status = addAttribute(ia_fileIO);
MCHECKSTATUS(status, "adding fileIO attribute")
ia_fioFiles = fnTypedAttr.create( "files", "fls", MFnData::kString,
fnStringData.create("/tmp/rigidBodyArray.${frame}.pdb"), &status );
MCHECKSTATUS(status, "creating ia_fioFiles attribute")
fnTypedAttr.setKeyable(false);
status = addAttribute(ia_fioFiles);
MCHECKSTATUS(status, "adding ia_fioFiles attribute")
/* ia_fioPositionAttribute = fnTypedAttr.create( "positionAttribute", "posa", MFnData::kString,
fnStringData.create("position"), &status );
MCHECKSTATUS(status, "creating ia_fioPositionAttribute attribute")
fnTypedAttr.setKeyable(false);
status = addAttribute(ia_fioPositionAttribute);
MCHECKSTATUS(status, "adding ia_fioPositionAttribute attribute")
ia_fioRotationAttribute = fnTypedAttr.create( "rotationAttribute", "rota", MFnData::kString,
fnStringData.create("rotation"), &status );
MCHECKSTATUS(status, "creating ia_fioRotationAttribute attribute")
fnTypedAttr.setKeyable(false);
status = addAttribute(ia_fioRotationAttribute);
MCHECKSTATUS(status, "adding ia_fioRotationAttribute attribute")*/
/*
MObject rigidBodyArrayNode::ia_fioFiles;
MObject rigidBodyArrayNode::ia_fioPositionAttribute;
MObject rigidBodyArrayNode::ia_fioRotationAttribute;*/
io_position = fnNumericAttr.createPoint("position", "pos", &status);
MCHECKSTATUS(status, "creating position attribute")
fnNumericAttr.setArray(true);
status = addAttribute(io_position);
MCHECKSTATUS(status, "adding io_position attribute")
io_rotation = fnNumericAttr.createPoint("rotation", "rot", &status);
MCHECKSTATUS(status, "creating rotation attribute")
fnNumericAttr.setArray(true);
status = addAttribute(io_rotation);
MCHECKSTATUS(status, "adding io_rotation attribute")
ca_rigidBodies = fnNumericAttr.create("ca_rigidBodies", "carb", MFnNumericData::kBoolean, 0, &status);
MCHECKSTATUS(status, "creating ca_rigidBodies attribute")
fnNumericAttr.setConnectable(false);
fnNumericAttr.setHidden(true);
fnNumericAttr.setStorable(false);
fnNumericAttr.setKeyable(false);
status = addAttribute(ca_rigidBodies);
MCHECKSTATUS(status, "adding ca_rigidBodies attribute")
ca_rigidBodyParam = fnNumericAttr.create("ca_rigidBodyParam", "carbp", MFnNumericData::kBoolean, 0, &status);
MCHECKSTATUS(status, "creating ca_rigidBodyParam attribute")
fnNumericAttr.setConnectable(false);
fnNumericAttr.setHidden(true);
fnNumericAttr.setStorable(false);
fnNumericAttr.setKeyable(false);
status = addAttribute(ca_rigidBodyParam);
MCHECKSTATUS(status, "adding ca_rigidBodyParam attribute")
status = attributeAffects(ia_numBodies, ca_rigidBodies);
MCHECKSTATUS(status, "adding attributeAffects(ia_numBodies, ca_rigidBodies)")
status = attributeAffects(ia_numBodies, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_numBodies, ca_rigidBodyParam)")
status = attributeAffects(ia_collisionShape, ca_rigidBodies);
MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBodies)")
status = attributeAffects(ia_collisionShape, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBodyParam)")
status = attributeAffects(ia_mass, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_mass, ca_rigidBodyParam)")
status = attributeAffects(ia_restitution, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_restitution, ca_rigidBodyParam)")
status = attributeAffects(ia_friction, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_friction, ca_rigidBodyParam)")
status = attributeAffects(ia_linearDamping, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_linearDamping, ca_rigidBodyParam)")
status = attributeAffects(ia_angularDamping, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_angularDamping, ca_rigidBodyParam)")
return MS::kSuccess;
}
rigidBodyArrayNode::rigidBodyArrayNode()
{
// std::cout << "rigidBodyArrayNode::rigidBodyArrayNode" << std::endl;
}
rigidBodyArrayNode::~rigidBodyArrayNode()
{
// std::cout << "rigidBodyArrayNode::~rigidBodyArrayNode" << std::endl;
for(size_t i = 0; i < m_rigid_bodies.size(); ++i) {
solver_t::remove_rigid_body(m_rigid_bodies[i]);
}
}
void rigidBodyArrayNode::nodeRemoved(MObject& node, void *clientData)
{
// std::cout << "rigidBodyArrayNode::nodeRemoved" << std::endl;
MFnDependencyNode fnNode(node);
rigidBodyArrayNode *thisNode = static_cast<rigidBodyArrayNode*>(fnNode.userNode());
for(size_t i = 0; i < thisNode->m_rigid_bodies.size(); ++i) {
solver_t::remove_rigid_body(thisNode->m_rigid_bodies[i]);
}
}
void rigidBodyArrayNode::postConstructor()
{
// MStatus status;
// MObject thisObject = thisMObject();
// MCallbackId cid = MNodeMessage::addAttributeAddedOrRemovedCallback(thisObject, attributeAddedOrRemoved, NULL, &status);
}
void* rigidBodyArrayNode::creator()
{
return new rigidBodyArrayNode();
}
bool rigidBodyArrayNode::setInternalValueInContext ( const MPlug & plug,
const MDataHandle & dataHandle,
MDGContext & ctx)
{
/* if ((plug == pdbFiles) || (plug == ia_scale) || (plug == ia_percent)) {
m_framesDirty = true;
} else if(plug == textureFiles) {
gpufx::m_renderer.setColorTextureDirty();
}*/
return false; //setInternalValueInContext(plug,dataHandle,ctx);
}
MStatus rigidBodyArrayNode::compute(const MPlug& plug, MDataBlock& data)
{
//std::cout << "rigidBodyArrayNode::compute: " << plug.name() << std::endl;
//MTime time = data.inputValue( rigidBodyArrayNode::inTime ).asTime();
if(plug == ca_rigidBodies) {
computeRigidBodies(plug, data);
} else if(plug == ca_rigidBodyParam) {
computeRigidBodyParam(plug, data);
} else if(plug.isElement()) {
if(plug.array() == worldMatrix) {
computeWorldMatrix(plug, data);
} else {
return MStatus::kUnknownParameter;
}
} else {
return MStatus::kUnknownParameter;
}
return MStatus::kSuccess;
}
void rigidBodyArrayNode::draw( M3dView & view, const MDagPath &path,
M3dView::DisplayStyle style,
M3dView::DisplayStatus status )
{
// std::cout << "rigidBodyArrayNode::draw" << std::endl;
update();
view.beginGL();
glPushAttrib( GL_ALL_ATTRIB_BITS );
glPushMatrix();
//remove the parent transform here
double m[4][4];
m_worldMatrix.inverse().get(m);
glMultMatrixd(&(m[0][0]));
if(!m_rigid_bodies.empty()) {
mat4x4f xform;
if(style == M3dView::kFlatShaded ||
style == M3dView::kGouraudShaded) {
glEnable(GL_LIGHTING);
float material[] = { 0.4, 0.3, 1.0, 1.0 };
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, material);
for(size_t i = 0; i < m_rigid_bodies.size(); ++i) {
glPushMatrix();
m_rigid_bodies[i]->get_transform(xform);
glMultMatrixf(xform.begin());
m_rigid_bodies[i]->collision_shape()->gl_draw(collision_shape_t::kDSSolid);
glPopMatrix();
}
}
if( status == M3dView::kActive ||
status == M3dView::kLead ||
status == M3dView::kHilite ||
( style != M3dView::kGouraudShaded && style != M3dView::kFlatShaded ) ) {
glDisable(GL_LIGHTING);
for(size_t i = 0; i < m_rigid_bodies.size(); ++i) {
glPushMatrix();
m_rigid_bodies[i]->get_transform(xform);
glMultMatrixf(xform.begin());
m_rigid_bodies[i]->collision_shape()->gl_draw(collision_shape_t::kDSWireframe);
glPopMatrix();
}
}
}
glPopMatrix();
glPopAttrib();
view.endGL();
}
bool rigidBodyArrayNode::isBounded() const
{
//return true;
return false;
}
MBoundingBox rigidBodyArrayNode::boundingBox() const
{
// std::cout << "rigidBodyArrayNode::boundingBox()" << std::endl;
//load the pdbs
MObject node = thisMObject();
MPoint corner1(-1, -1, -1);
MPoint corner2(1, 1, 1);
return MBoundingBox(corner1, corner2);
}
//standard attributes
void rigidBodyArrayNode::computeRigidBodies(const MPlug& plug, MDataBlock& data)
{
// std::cout << "rigidBodyArrayNode::computeRigidBodies" << std::endl;
MObject thisObject(thisMObject());
MPlug plgCollisionShape(thisObject, ia_collisionShape);
MObject update;
//force evaluation of the shape
plgCollisionShape.getValue(update);
size_t numBodies = data.inputValue(ia_numBodies).asInt();
// MDataHandle coll = data.inputValue(ia_collisionShape);
// collisionShapeNode * pCollisionShapeNode = NULL;
collision_shape_t::pointer collision_shape;
if(plgCollisionShape.isConnected()) {
MPlugArray connections;
plgCollisionShape.connectedTo(connections, true, true);
if(connections.length() != 0) {
MFnDependencyNode fnNode(connections[0].node());
if(fnNode.typeId() == collisionShapeNode::typeId) {
collisionShapeNode *pCollisionShapeNode = static_cast<collisionShapeNode*>(fnNode.userNode());
collision_shape = pCollisionShapeNode->collisionShape();
} else {
std::cout << "rigidBodyArrayNode connected to a non-collision shape node!" << std::endl;
}
}
}
if(!collision_shape) {
//not connected to a collision shape, put a default one
collision_shape = solver_t::create_sphere_shape();
}
//save the positions and orientations to restore them
std::vector<vec3f> positions(m_rigid_bodies.size());
std::vector<quatf> rotations(m_rigid_bodies.size());
for(size_t i = 0; i < m_rigid_bodies.size(); ++i) {
m_rigid_bodies[i]->get_transform(positions[i], rotations[i]);
solver_t::remove_rigid_body(m_rigid_bodies[i]);
}
m_rigid_bodies.resize(numBodies);
for(size_t i = 0; i < m_rigid_bodies.size(); ++i) {
m_rigid_bodies[i] = solver_t::create_rigid_body(collision_shape);
m_rigid_bodies[i]->set_transform(positions[i], rotations[i]);
solver_t::add_rigid_body(m_rigid_bodies[i]);
}
data.outputValue(ca_rigidBodies).set(true);
data.setClean(plug);
}
void rigidBodyArrayNode::computeRigidBodyParam(const MPlug& plug, MDataBlock& data)
{
// std::cout << "rigidBodyArrayNode::computeRigidBodyParam" << std::endl;
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ca_rigidBodies).getValue(update);
double mass = data.inputValue(ia_mass).asDouble();
vec3f inertia;
if(!m_rigid_bodies.empty()) {
inertia = mass * m_rigid_bodies[0]->collision_shape()->local_inertia();
}
double restitution = data.inputValue(ia_restitution).asDouble();
double friction = data.inputValue(ia_friction).asDouble();
double linearDamping = data.inputValue(ia_linearDamping).asDouble();
double angularDamping = data.inputValue(ia_angularDamping).asDouble();
for(size_t i = 0; i < m_rigid_bodies.size(); ++i) {
m_rigid_bodies[i]->set_mass(mass);
m_rigid_bodies[i]->set_inertia(inertia);
m_rigid_bodies[i]->set_restitution(restitution);
m_rigid_bodies[i]->set_friction(friction);
m_rigid_bodies[i]->set_linear_damping(linearDamping);
m_rigid_bodies[i]->set_angular_damping(angularDamping);
}
data.outputValue(ca_rigidBodyParam).set(true);
data.setClean(plug);
}
void rigidBodyArrayNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data)
{
//std::cout << "rigidBodyArrayNode::computeWorldMatrix" << std::endl;
MObject thisObject(thisMObject());
MFnDagNode fnDagNode(thisObject);
MObject update;
MPlug(thisObject, ca_rigidBodies).getValue(update);
MPlug(thisObject, ca_rigidBodyParam).getValue(update);
MFnTransform fnParentTransform(fnDagNode.parent(0));
MTransformationMatrix dm(fnParentTransform.transformation().asMatrix() * m_worldMatrix.inverse());
MVector mtranslation = dm.getTranslation(MSpace::kTransform);
MQuaternion mrotation = dm.rotation();
// std::cout << mtranslation << std::endl;
MArrayDataHandle hInitPosArray = data.outputArrayValue(ia_initialPosition);
if(hInitPosArray.elementCount() < m_rigid_bodies.size()) {
std::cout << "rigidBodyArrayNode::computeWorldMatrix: array size mismatch" << std::endl;
}
for(size_t i = 0; i < m_rigid_bodies.size(); ++i) {
MDataHandle hInitPos = hInitPosArray.outputValue();
float3 &ipos = hInitPos.asFloat3();
vec3f pos, newpos;
quatf rot, newrot;
m_rigid_bodies[i]->get_transform(pos, rot);
newpos = pos + vec3f(mtranslation.x, mtranslation.y, mtranslation.z);
// newrot = qprod(rot, quatf(mrotation.w, mrotation.x, mrotation.y, mrotation.z));
newrot = rot;
m_rigid_bodies[i]->set_transform(newpos, newrot);
hInitPos.set3Float(ipos[0] + mtranslation.x, ipos[1] + mtranslation.y, ipos[2] + mtranslation.z);
hInitPosArray.next();
}
m_worldMatrix = fnParentTransform.transformation().asMatrix();
data.setClean(plug);
}
std::vector<rigid_body_t::pointer>& rigidBodyArrayNode::rigid_bodies()
{
// std::cout << "rigidBodyArrayNode::rigid_bodies" << std::endl;
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ca_rigidBodies).getValue(update);
MPlug(thisObject, ca_rigidBodyParam).getValue(update);
return m_rigid_bodies;
}
void rigidBodyArrayNode::update()
{
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ca_rigidBodies).getValue(update);
MPlug(thisObject, ca_rigidBodyParam).getValue(update);
MPlug(thisObject, ia_solver).getValue(update);
MPlug(thisObject, worldMatrix).elementByLogicalIndex(0).getValue(update);
}

View File

@@ -0,0 +1,120 @@
/*
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>
*/
//rigidBodyArrayNode.h
#ifndef DYN_RIGID_BODY_ARRAY_NODE_H
#define DYN_RIGID_BODY_ARRAY_NODE_H
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPxLocatorNode.h>
#include <maya/MMatrix.h>
#include <vector>
#include "solver.h"
class rigidBodyArrayNode: public MPxLocatorNode
{
public:
rigidBodyArrayNode();
virtual ~rigidBodyArrayNode();
virtual void postConstructor();
virtual bool setInternalValueInContext ( const MPlug & plug,
const MDataHandle & dataHandle,
MDGContext & ctx);
// virtual MStatus setDependentsDirty ( const MPlug & plug, MPlugArray & plugArray);
virtual MStatus compute( const MPlug& plug, MDataBlock& data );
virtual void draw( M3dView & view, const MDagPath & path,
M3dView::DisplayStyle style,
M3dView::DisplayStatus status );
virtual bool isBounded() const ;
virtual MBoundingBox boundingBox() const;
virtual bool excludeAsLocator() const { return false; }
virtual bool isTransparent() const { return false; }
static void * creator();
static MStatus initialize();
public:
std::vector<rigid_body_t::pointer>& rigid_bodies();
public:
//Attributes
static MObject ia_collisionShape;
static MObject ia_solver;
static MObject ia_numBodies;
static MObject ia_active;
static MObject ia_mass;
static MObject ia_restitution;
static MObject ia_friction;
static MObject ia_linearDamping;
static MObject ia_angularDamping;
static MObject ia_initialPosition;
static MObject ia_initialRotation;
static MObject ia_initialVelocity;
static MObject ia_initialSpin;
static MObject ia_fileIO;
static MObject ia_fioFiles;
static MObject ia_fioPositionAttribute;
static MObject ia_fioRotationAttribute;
static MObject io_position;
static MObject io_rotation;
static MObject ca_rigidBodies;
static MObject ca_rigidBodyParam;
public:
static MTypeId typeId;
static MString typeName;
private:
void update();
void computeRigidBodies(const MPlug& plug, MDataBlock& data);
void computeRigidBodyParam(const MPlug& plug, MDataBlock& data);
void computeWorldMatrix(const MPlug& plug, MDataBlock& data);
public:
static void nodeRemoved(MObject& node, void *clientData);
private:
std::vector<rigid_body_t::pointer> m_rigid_bodies;
MMatrix m_worldMatrix;
};
#endif

View File

@@ -0,0 +1,526 @@
/*
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>
*/
//rigidBodyNode.cpp
//#include <GL/glut.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MPlugArray.h>
#include <maya/MFnMessageAttribute.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnMatrixAttribute.h>
#include <maya/MMatrix.h>
#include <maya/MFnMatrixData.h>
#include <maya/MFnTransform.h>
#include <maya/MQuaternion.h>
#include <maya/MEulerRotation.h>
#include <maya/MVector.h>
#include "rigidBodyNode.h"
#include "collisionShapeNode.h"
#include "mayaUtils.h"
#include "solver.h"
MTypeId rigidBodyNode::typeId( 0x100306 );
MString rigidBodyNode::typeName( "dRigidBody" );
MObject rigidBodyNode::ia_collisionShape;
MObject rigidBodyNode::ia_solver;
MObject rigidBodyNode::ia_active;
MObject rigidBodyNode::ia_mass;
MObject rigidBodyNode::ia_restitution;
MObject rigidBodyNode::ia_friction;
MObject rigidBodyNode::ia_linearDamping;
MObject rigidBodyNode::ia_angularDamping;
MObject rigidBodyNode::ia_initialPosition;
MObject rigidBodyNode::ia_initialRotation;
MObject rigidBodyNode::ia_initialVelocity;
MObject rigidBodyNode::ia_initialSpin;
MObject rigidBodyNode::ca_rigidBody;
MObject rigidBodyNode::ca_rigidBodyParam;
MStatus rigidBodyNode::initialize()
{
MStatus status;
MFnMessageAttribute fnMsgAttr;
MFnNumericAttribute fnNumericAttr;
MFnMatrixAttribute fnMatrixAttr;
ia_collisionShape = fnMsgAttr.create("inCollisionShape", "incs", &status);
MCHECKSTATUS(status, "creating inCollisionShape attribute")
status = addAttribute(ia_collisionShape);
MCHECKSTATUS(status, "adding inCollisionShape attribute")
ia_solver = fnMsgAttr.create("solver", "solv", &status);
MCHECKSTATUS(status, "creating solver attribute")
status = addAttribute(ia_solver);
MCHECKSTATUS(status, "adding solver attribute")
ia_active = fnNumericAttr.create("active", "ac", MFnNumericData::kBoolean, 1, &status);
MCHECKSTATUS(status, "creating active attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_active);
MCHECKSTATUS(status, "adding active attribute")
ia_mass = fnNumericAttr.create("mass", "ma", MFnNumericData::kDouble, 1.0, &status);
MCHECKSTATUS(status, "creating mass attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_mass);
MCHECKSTATUS(status, "adding mass attribute")
ia_restitution = fnNumericAttr.create("restitution", "rst", MFnNumericData::kDouble, 0.1, &status);
MCHECKSTATUS(status, "creating restitution attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_restitution);
MCHECKSTATUS(status, "adding restitution attribute")
ia_friction = fnNumericAttr.create("friction", "fc", MFnNumericData::kDouble, 0.5, &status);
MCHECKSTATUS(status, "creating friction attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_friction);
MCHECKSTATUS(status, "adding friction attribute")
ia_linearDamping = fnNumericAttr.create("linearDamping", "ld", MFnNumericData::kDouble, 0.3, &status);
MCHECKSTATUS(status, "creating linearDamping attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_linearDamping);
MCHECKSTATUS(status, "adding linearDamping attribute")
ia_angularDamping = fnNumericAttr.create("angularDamping", "ad", MFnNumericData::kDouble, 0.3, &status);
MCHECKSTATUS(status, "creating angularDamping attribute")
fnNumericAttr.setKeyable(true);
status = addAttribute(ia_angularDamping);
MCHECKSTATUS(status, "adding angularDamping attribute")
ia_initialPosition = fnNumericAttr.createPoint("initialPosition", "inpo", &status);
MCHECKSTATUS(status, "creating initialPosition attribute")
status = addAttribute(ia_initialPosition);
MCHECKSTATUS(status, "adding initialPosition attribute")
ia_initialRotation = fnNumericAttr.createPoint("initialRotation", "inro", &status);
MCHECKSTATUS(status, "creating initialRotation attribute")
status = addAttribute(ia_initialRotation);
MCHECKSTATUS(status, "adding initialRotation attribute")
ia_initialVelocity = fnNumericAttr.createPoint("initialVelocity", "inve", &status);
MCHECKSTATUS(status, "creating initialVelocity attribute")
status = addAttribute(ia_initialVelocity);
MCHECKSTATUS(status, "adding initialVelocity attribute")
ia_initialSpin = fnNumericAttr.createPoint("initialSpin", "insp", &status);
MCHECKSTATUS(status, "creating initialSpin attribute")
status = addAttribute(ia_initialSpin);
MCHECKSTATUS(status, "adding initialSpin attribute")
ca_rigidBody = fnNumericAttr.create("ca_rigidBody", "carb", MFnNumericData::kBoolean, 0, &status);
MCHECKSTATUS(status, "creating ca_rigidBody attribute")
fnNumericAttr.setConnectable(false);
fnNumericAttr.setHidden(true);
fnNumericAttr.setStorable(false);
fnNumericAttr.setKeyable(false);
status = addAttribute(ca_rigidBody);
MCHECKSTATUS(status, "adding ca_rigidBody attribute")
ca_rigidBodyParam = fnNumericAttr.create("ca_rigidBodyParam", "carbp", MFnNumericData::kBoolean, 0, &status);
MCHECKSTATUS(status, "creating ca_rigidBodyParam attribute")
fnNumericAttr.setConnectable(false);
fnNumericAttr.setHidden(true);
fnNumericAttr.setStorable(false);
fnNumericAttr.setKeyable(false);
status = addAttribute(ca_rigidBodyParam);
MCHECKSTATUS(status, "adding ca_rigidBodyParam attribute")
status = attributeAffects(ia_collisionShape, ca_rigidBody);
MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBody)")
status = attributeAffects(ia_collisionShape, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBodyParam)")
status = attributeAffects(ia_mass, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_mass, ca_rigidBodyParam)")
status = attributeAffects(ia_restitution, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_restitution, ca_rigidBodyParam)")
status = attributeAffects(ia_friction, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_friction, ca_rigidBodyParam)")
status = attributeAffects(ia_linearDamping, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_linearDamping, ca_rigidBodyParam)")
status = attributeAffects(ia_angularDamping, ca_rigidBodyParam);
MCHECKSTATUS(status, "adding attributeAffects(ia_angularDamping, ca_rigidBodyParam)")
// status = attributeAffects(ia_active, ca_rigidBodyParam);
// MCHECKSTATUS(status, "adding attributeAffects(ia_active, ca_rigidBodyParam)")
return MS::kSuccess;
}
rigidBodyNode::rigidBodyNode()
{
// std::cout << "rigidBodyNode::rigidBodyNode" << std::endl;
}
rigidBodyNode::~rigidBodyNode()
{
// std::cout << "rigidBodyNode::~rigidBodyNode" << std::endl;
}
void rigidBodyNode::nodeRemoved(MObject& node, void *clientData)
{
// std::cout << "rigidBodyNode::nodeRemoved" << std::endl;
MFnDependencyNode fnNode(node);
solver_t::remove_rigid_body(static_cast<rigidBodyNode*>(fnNode.userNode())->m_rigid_body);
}
void* rigidBodyNode::creator()
{
return new rigidBodyNode();
}
bool rigidBodyNode::setInternalValueInContext ( const MPlug & plug,
const MDataHandle & dataHandle,
MDGContext & ctx)
{
/* if ((plug == pdbFiles) || (plug == ia_scale) || (plug == ia_percent)) {
m_framesDirty = true;
} else if(plug == textureFiles) {
gpufx::m_renderer.setColorTextureDirty();
}*/
return false; //setInternalValueInContext(plug,dataHandle,ctx);
}
/*
MStatus rigidBodyNode::setDependentsDirty( const MPlug & plug, MPlugArray & plugArray)
{
std::cout << "rigidBodyNode::setDependentsDirty: " << plug.name().asChar() << std::endl;
MObject thisNode = thisMObject();
if(plug == ia_solver) {
MPlug plgAffected(thisNode, ca_update);
plugArray.append(plgAffected);
plgAffected.setValue(true);
} else if(plug == ia_collisionShape) {
//ia_collisionShape -> ca_rigidBody
MPlug plgAffected(thisNode, ca_rigidBody);
plugArray.append(plgAffected);
plgAffected.setValue(true);
//ia_collisionShape -> ca_rigidBodyParam
plgAffected.setAttribute(ca_rigidBodyParam);
plugArray.append(plgAffected);
plgAffected.setValue(true);
} else if(plug == ca_rigidBody) {
//ca_rigidBody -> ca_update
MPlug plgAffected(thisNode, ca_update);
plugArray.append(plgAffected);
plgAffected.setValue(true);
//ca_rigidBody -> ca_rigidBodyParam
plgAffected.setAttribute(ca_rigidBodyParam);
plugArray.append(plgAffected);
plgAffected.setValue(true);
} else if(plug == ia_mass) {
//ia_mass -> ca_rigidBodyParam
MPlug plgAffected(thisNode, ca_rigidBodyParam);
plugArray.append(plgAffected);
plgAffected.setValue(true);
plgAffected.setAttribute(ca_update);
plugArray.append(plgAffected);
plgAffected.setValue(true);
} else if(plug == ca_rigidBodyParam) {
//ca_rigidBodyParam -> ca_update
MPlug plgAffected(thisNode, ca_update);
plugArray.append(plgAffected);
plgAffected.setValue(true);
}
return MS::kSuccess;
}*/
MStatus rigidBodyNode::compute(const MPlug& plug, MDataBlock& data)
{
//std::cout << "rigidBodyNode::compute: " << plug.name() << std::endl;
//MTime time = data.inputValue( rigidBodyNode::inTime ).asTime();
if(plug == ca_rigidBody) {
computeRigidBody(plug, data);
} else if(plug == ca_rigidBodyParam) {
computeRigidBodyParam(plug, data);
} else if(plug.isElement()) {
if(plug.array() == worldMatrix && plug.logicalIndex() == 0) {
computeWorldMatrix(plug, data);
} else {
return MStatus::kUnknownParameter;
}
} else {
return MStatus::kUnknownParameter;
}
return MStatus::kSuccess;
}
void rigidBodyNode::draw( M3dView & view, const MDagPath &path,
M3dView::DisplayStyle style,
M3dView::DisplayStatus status )
{
// std::cout << "rigidBodyNode::draw" << std::endl;
update();
view.beginGL();
glPushAttrib( GL_ALL_ATTRIB_BITS );
if(m_rigid_body) {
//remove the scale, since it's already include in the node transform
vec3f scale;
m_rigid_body->collision_shape()->get_scale(scale);
glPushMatrix();
glScalef(1/scale[0], 1/scale[1], 1/scale[2]);
if(style == M3dView::kFlatShaded ||
style == M3dView::kGouraudShaded) {
glEnable(GL_LIGHTING);
float material[] = { 0.4, 0.7, 1.0, 1.0 };
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, material);
m_rigid_body->collision_shape()->gl_draw(collision_shape_t::kDSSolid);
}
if( status == M3dView::kActive ||
status == M3dView::kLead ||
status == M3dView::kHilite ||
( style != M3dView::kGouraudShaded && style != M3dView::kFlatShaded ) ) {
glDisable(GL_LIGHTING);
m_rigid_body->collision_shape()->gl_draw(collision_shape_t::kDSWireframe);
}
glPopMatrix();
}
glPopAttrib();
view.endGL();
}
bool rigidBodyNode::isBounded() const
{
//return true;
return false;
}
MBoundingBox rigidBodyNode::boundingBox() const
{
// std::cout << "rigidBodyNode::boundingBox()" << std::endl;
//load the pdbs
MObject node = thisMObject();
MPoint corner1(-1, -1, -1);
MPoint corner2(1, 1, 1);
return MBoundingBox(corner1, corner2);
}
//standard attributes
void rigidBodyNode::computeRigidBody(const MPlug& plug, MDataBlock& data)
{
// std::cout << "rigidBodyNode::computeRigidBody" << std::endl;
MObject thisObject(thisMObject());
MPlug plgCollisionShape(thisObject, ia_collisionShape);
MObject update;
//force evaluation of the shape
plgCollisionShape.getValue(update);
vec3f prevCenter(0, 0, 0);
quatf prevRotation(qidentity<float>());
if(m_rigid_body) {
prevCenter = m_rigid_body->collision_shape()->center();
prevRotation = m_rigid_body->collision_shape()->rotation();
}
collision_shape_t::pointer collision_shape;
if(plgCollisionShape.isConnected()) {
MPlugArray connections;
plgCollisionShape.connectedTo(connections, true, true);
if(connections.length() != 0) {
MFnDependencyNode fnNode(connections[0].node());
if(fnNode.typeId() == collisionShapeNode::typeId) {
collisionShapeNode *pCollisionShapeNode = static_cast<collisionShapeNode*>(fnNode.userNode());
collision_shape = pCollisionShapeNode->collisionShape();
} else {
std::cout << "rigidBodyNode connected to a non-collision shape node!" << std::endl;
}
}
}
if(!collision_shape) {
//not connected to a collision shape, put a default one
collision_shape = solver_t::create_sphere_shape();
}
/* vec3f deltaCenter = prevCenter - collision_shape->center();
quatf deltaRotation = qprod(qconj(collision_shape->rotation()), prevRotation);
MDataHandle hInitPos = data.outputValue(ia_initialPosition);
float3 &ipos = hInitPos.asFloat3();
MDataHandle hInitRot = data.outputValue(ia_initialRotation);
float3 &irot = hInitRot.asFloat3();
MQuaternion iquat = MEulerRotation(deg2rad(irot[0]), deg2rad(irot[1]), deg2rad(irot[2])).asQuaternion();
// MVector deltapos(mtranslation.x - pos[0], mtranslation.y - pos[1], mtranslation.z - pos[2]);
// MQuaternion deltarot = MQuaternion(rot[1], rot[2], rot[3], rot[0]).conjugate() * mrotation;
MVector newipos(ipos[0] + deltaCenter[0], ipos[1] + deltaCenter[1], ipos[2] + deltaCenter[2]); */
// MEulerRotation newirot((iquat * deltarot).asEulerRotation());
//hInitPos.set3Float(newipos.x, newipos.y, newipos.z);
// hInitRot.set3Float(rad2deg(newirot.x), rad2deg(newirot.y), rad2deg(newirot.z));*/
solver_t::remove_rigid_body(m_rigid_body);
m_rigid_body = solver_t::create_rigid_body(collision_shape);
solver_t::add_rigid_body(m_rigid_body);
data.outputValue(ca_rigidBody).set(true);
data.setClean(plug);
}
void rigidBodyNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data)
{
// std::cout << "rigidBodyNode::computeWorldMatrix" << std::endl;
MObject thisObject(thisMObject());
MFnDagNode fnDagNode(thisObject);
MObject update;
MPlug(thisObject, ca_rigidBody).getValue(update);
MPlug(thisObject, ca_rigidBodyParam).getValue(update);
vec3f pos;
quatf rot;
MFnTransform fnParentTransform(fnDagNode.parent(0));
MVector mtranslation = fnParentTransform.getTranslation(MSpace::kTransform);
MQuaternion mrotation;
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
double mscale[3];
fnParentTransform.getScale(mscale);
// std::cout << mtranslation << std::endl;
m_rigid_body->get_transform(pos, rot);
MDataHandle hInitPos = data.outputValue(ia_initialPosition);
float3 &ipos = hInitPos.asFloat3();
MDataHandle hInitRot = data.outputValue(ia_initialRotation);
float3 &irot = hInitRot.asFloat3();
MQuaternion iquat = MEulerRotation(deg2rad(irot[0]), deg2rad(irot[1]), deg2rad(irot[2])).asQuaternion();
MVector deltapos(mtranslation.x - pos[0], mtranslation.y - pos[1], mtranslation.z - pos[2]);
MQuaternion deltarot = MQuaternion(rot[1], rot[2], rot[3], rot[0]).conjugate() * mrotation;
MVector newipos(ipos[0] + deltapos.x, ipos[1] + deltapos.y, ipos[2] + deltapos.z);
MEulerRotation newirot((iquat * deltarot).asEulerRotation());
hInitPos.set3Float(newipos.x, newipos.y, newipos.z);
hInitRot.set3Float(rad2deg(newirot.x), rad2deg(newirot.y), rad2deg(newirot.z));
m_rigid_body->set_transform(vec3f(mtranslation.x, mtranslation.y, mtranslation.z),
quatf(mrotation.w, mrotation.x, mrotation.y, mrotation.z));
data.setClean(plug);
//set the scale to the collision shape
m_rigid_body->collision_shape()->set_scale(vec3f(mscale[0], mscale[1], mscale[2]));
/*
MPlug plgCollisionShape(thisObject, ia_collisionShape);
//force evaluation of the shape
plgCollisionShape.getValue(update);
if(plgCollisionShape.isConnected()) {
MPlugArray connections;
plgCollisionShape.connectedTo(connections, true, true);
if(connections.length() != 0) {
MFnDependencyNode fnNode(connections[0].node());
if(fnNode.typeId() == collisionShapeNode::typeId) {
MPlug plgScale(fnNode.object(), collisionShapeNode::ia_scale);
plgScale.child(0).setValue(mscale[0]);
plgScale.child(1).setValue(mscale[1]);
plgScale.child(2).setValue(mscale[2]);
} else {
std::cout << "rigidBodyNode connected to a non-collision shape node!" << std::endl;
}
}
}*/
}
void rigidBodyNode::computeRigidBodyParam(const MPlug& plug, MDataBlock& data)
{
// std::cout << "rigidBodyNode::computeRigidBodyParam" << std::endl;
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ca_rigidBody).getValue(update);
double mass = data.inputValue(ia_mass).asDouble();
m_rigid_body->set_mass(mass);
m_rigid_body->set_inertia(mass * m_rigid_body->collision_shape()->local_inertia());
m_rigid_body->set_restitution(data.inputValue(ia_restitution).asDouble());
m_rigid_body->set_friction(data.inputValue(ia_friction).asDouble());
m_rigid_body->set_linear_damping(data.inputValue(ia_linearDamping).asDouble());
m_rigid_body->set_angular_damping(data.inputValue(ia_angularDamping).asDouble());
// m_rigid_body->set_kinematic(!data.inputValue(ia_active).asBool());
data.outputValue(ca_rigidBodyParam).set(true);
data.setClean(plug);
}
rigid_body_t::pointer rigidBodyNode::rigid_body()
{
// std::cout << "rigidBodyNode::rigid_body" << std::endl;
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ca_rigidBody).getValue(update);
MPlug(thisObject, ca_rigidBodyParam).getValue(update);
return m_rigid_body;
}
void rigidBodyNode::update()
{
MObject thisObject(thisMObject());
MObject update;
MPlug(thisObject, ca_rigidBody).getValue(update);
MPlug(thisObject, ca_rigidBodyParam).getValue(update);
MPlug(thisObject, ia_solver).getValue(update);
MPlug(thisObject, worldMatrix).elementByLogicalIndex(0).getValue(update);
// MPlug plg = MPlug(thisObject, worldMatrix).elementByLogicalIndex(0);
}

View File

@@ -0,0 +1,107 @@
/*
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>
*/
//rigidBodyNode.h
#ifndef DYN_RIGID_BODY_NODE_H
#define DYN_RIGID_BODY_NODE_H
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPxLocatorNode.h>
#include "solver.h"
class rigidBodyNode: public MPxLocatorNode
{
public:
rigidBodyNode();
virtual ~rigidBodyNode();
virtual bool setInternalValueInContext ( const MPlug & plug,
const MDataHandle & dataHandle,
MDGContext & ctx);
// virtual MStatus setDependentsDirty ( const MPlug & plug, MPlugArray & plugArray);
virtual MStatus compute( const MPlug& plug, MDataBlock& data );
virtual void draw( M3dView & view, const MDagPath & path,
M3dView::DisplayStyle style,
M3dView::DisplayStatus status );
virtual bool isBounded() const ;
virtual MBoundingBox boundingBox() const;
virtual bool excludeAsLocator() const { return false; }
virtual bool isTransparent() const { return false; }
static void * creator();
static MStatus initialize();
public:
rigid_body_t::pointer rigid_body();
public:
//Attributes
static MObject ia_collisionShape;
static MObject ia_solver;
static MObject ia_active;
static MObject ia_mass;
static MObject ia_restitution;
static MObject ia_friction;
static MObject ia_linearDamping;
static MObject ia_angularDamping;
static MObject ia_initialPosition;
static MObject ia_initialRotation;
static MObject ia_initialVelocity;
static MObject ia_initialSpin;
static MObject ca_rigidBody;
static MObject ca_rigidBodyParam;
public:
static MTypeId typeId;
static MString typeName;
private:
void update();
void computeRigidBody(const MPlug& plug, MDataBlock& data);
void computeWorldMatrix(const MPlug& plug, MDataBlock& data);
void computeRigidBodyParam(const MPlug& plug, MDataBlock& data);
public:
static void nodeRemoved(MObject& node, void *clientData);
private:
rigid_body_t::pointer m_rigid_body;
};
#endif

View 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>
*/
//rigid_body.h
#ifndef DYN_RIGID_BODY_H
#define DYN_RIGID_BODY_H
#include "shared_ptr.h"
#include "collision_shape.h"
#include "mathUtils.h"
#include "rigid_body_impl.h"
class rigid_body_t
{
public:
//typedefs
typedef shared_ptr<rigid_body_t> pointer;
//
collision_shape_t::pointer collision_shape() { return m_collision_shape; }
//
void set_kinematic(bool kinematic) { m_impl->set_kinematic(kinematic); }
//
void set_mass(float mass) { m_impl->set_mass(mass); }
void set_inertia(vec3f const& I) { m_impl->set_inertia(I); }
void set_restitution(float r) { m_impl->set_restitution(r); }
void set_friction(float f) { m_impl->set_friction(f); }
void set_linear_damping(float d) { m_impl->set_linear_damping(d); }
void set_angular_damping(float d) { m_impl->set_angular_damping(d); }
void set_transform(vec3f const& position, quatf const& rotation) { m_impl->set_transform(position, rotation); }
void get_transform(vec3f& position, quatf& rotation) const { m_impl->get_transform(position, rotation); }
void get_transform(mat4x4f& xform) const { m_impl->get_transform(xform); }
//
void set_linear_velocity(vec3f const& v) { m_impl->set_linear_velocity(v); }
void get_linear_velocity(vec3f& v) const { m_impl->get_linear_velocity(v); }
void set_angular_velocity(vec3f const& v) { m_impl->set_angular_velocity(v); }
void get_angular_velocity(vec3f& v) const { m_impl->get_angular_velocity(v); }
//
void clear_forces() { m_impl->clear_forces(); }
void apply_central_force(vec3f const& f) { m_impl->apply_central_force(f); }
void apply_torque(vec3f const& t) { m_impl->apply_torque(t); }
public:
virtual ~rigid_body_t() {};
protected:
friend class solver_t;
rigid_body_t(rigid_body_impl_t* impl, collision_shape_t::pointer& shape): m_impl(impl), m_collision_shape(shape)
{
}
rigid_body_impl_t* impl() { return m_impl.get(); }
// rigid_body_impl_t const* impl() const { return m_impl.get(); }
private:
shared_ptr<rigid_body_impl_t> m_impl;
collision_shape_t::pointer m_collision_shape;
};
#endif

View File

@@ -0,0 +1,63 @@
/*
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>
*/
//rigid_body_impl.h
#ifndef DYN_RIGID_BODY_IMPL_H
#define DYN_RIGID_BODY_IMPL_H
#include "rigid_body_impl.h"
#include "mathUtils.h"
class rigid_body_impl_t
{
public:
virtual void set_kinematic(bool kinematic) = 0;
//
virtual void set_mass(float mass) = 0;
virtual void set_inertia(vec3f const& I) = 0;
virtual void set_restitution(float r) = 0;
virtual void set_friction(float f) = 0;
virtual void set_linear_damping(float d) = 0;
virtual void set_angular_damping(float d) = 0;
virtual void set_transform(vec3f const& position, quatf const& rotation) = 0;
virtual void get_transform(vec3f& position, quatf& rotation) const = 0;
virtual void get_transform(mat4x4f& xform) const = 0;
virtual void set_linear_velocity(vec3f const& v) = 0;
virtual void get_linear_velocity(vec3f& v) const = 0;
virtual void set_angular_velocity(vec3f const& v) = 0;
virtual void get_angular_velocity(vec3f& v) const = 0;
virtual void clear_forces() = 0;
virtual void apply_central_force(vec3f const& f) = 0;
virtual void apply_torque(vec3f const& t) = 0;
public:
virtual ~rigid_body_impl_t() {};
};
#endif

View 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;
}

View 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;
}

View 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;
}
*/

View 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;
}

View 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

View 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);
}
}
}
}

View File

@@ -0,0 +1,200 @@
/*
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>
*/
//shared_ptr.h
#ifndef DYN_SHARED_PTR_H
#define DYN_SHARED_PTR_H
#define DYN_SHARED_PTR_THREAD_SAFE
#ifdef WIN32
#include <windows.h>
class shared_count {
public:
shared_count(): m_count(1) { }
~shared_count() { }
long increment()
{
#ifdef DYN_SHARED_PTR_THREAD_SAFE
return InterlockedIncrement(&m_count);
#else
return ++m_count;
#endif
}
long decrement() {
#ifdef DYN_SHARED_PTR_THREAD_SAFE
return InterlockedDecrement(&m_count);
#else
return ++m_count;
#endif
return c;
}
long use_count() { return m_count; }
private:
long m_count;
};
#else //ifdef WIN32
#include <pthread.h>
class shared_count {
public:
shared_count(): m_count(1) {
#ifdef DYN_SHARED_PTR_THREAD_SAFE
pthread_mutex_init(&m_mutex, 0);
#endif
}
~shared_count() {
#ifdef DYN_SHARED_PTR_THREAD_SAFE
pthread_mutex_destroy(&m_mutex);
#endif
}
long increment()
{
#ifdef DYN_SHARED_PTR_THREAD_SAFE
pthread_mutex_lock(&m_mutex);
#endif
long c = ++m_count;
#ifdef DYN_SHARED_PTR_THREAD_SAFE
pthread_mutex_unlock(&m_mutex);
#endif
return c;
}
long decrement() {
#ifdef DYN_SHARED_PTR_THREAD_SAFE
pthread_mutex_lock(&m_mutex);
#endif
long c = --m_count;
#ifdef DYN_SHARED_PTR_THREAD_SAFE
pthread_mutex_unlock(&m_mutex);
#endif
return c;
}
long use_count() { return m_count; }
private:
long m_count;
mutable pthread_mutex_t m_mutex;
};
#endif
template<typename T>
class shared_ptr
{
public:
shared_ptr(): m_ptr(NULL), m_count(NULL) { }
shared_ptr(shared_ptr<T> const& other):
m_ptr(other.m_ptr),
m_count(other.m_count)
{
if(other.m_count != NULL) other.m_count->increment();
}
template<typename U>
shared_ptr(shared_ptr<U> const& other):
m_ptr(other.m_ptr),
m_count(other.m_count)
{
if(other.m_count != NULL) other.m_count->increment();
}
shared_ptr(T const* other): m_ptr(const_cast<T*>(other)), m_count(NULL)
{
if(other != NULL) m_count = new shared_count;
}
~shared_ptr()
{
giveup_ownership();
}
void reset(T const* other)
{
if(m_ptr == other) return;
giveup_ownership();
m_ptr = const_cast<T*>(other);
if(other != NULL) m_count = new shared_count;
else m_count = NULL;
}
T* get() { return m_ptr; }
T const* get() const { return m_ptr; }
T* operator->() { return m_ptr; }
T const* operator->() const { return m_ptr; }
operator bool() { return m_ptr != NULL; }
bool operator<(shared_ptr<T> const& rhs) const { return m_ptr < rhs.m_ptr; }
shared_ptr<T>& operator=(shared_ptr<T> const& other) {
if(m_ptr == other.m_ptr) return *this;
giveup_ownership();
m_ptr = other.m_ptr;
m_count = other.m_count;
if(other.m_count != NULL) m_count->increment();
return *this;
}
template<typename U>
shared_ptr<T>& operator=(shared_ptr<U>& other) {
if(m_ptr == other.m_ptr) return *this;
giveup_ownership();
m_ptr = other.m_ptr;
m_count = other.m_count;
if(other.m_count != NULL) m_count->increment();
return *this;
}
protected:
template<typename U> friend class shared_ptr;
void giveup_ownership()
{
if(m_count != NULL) {
if( m_count->decrement() == 0) {
delete m_ptr;
m_ptr = NULL;
delete m_count;
m_count = NULL;
}
}
}
protected:
T *m_ptr;
shared_count *m_count;
};
#endif

View File

@@ -0,0 +1,124 @@
/*
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>
*/
//solver.cpp
#include "solver.h"
#include "bt_solver.h"
shared_ptr<solver_impl_t> solver_t::m_impl;
std::set<rigid_body_t::pointer> solver_t::m_rigid_bodies;
void solver_t::initialize()
{
m_impl.reset(new bt_solver_t);
}
void solver_t::cleanup()
{
}
//creation methods
sphere_shape_t::pointer solver_t::create_sphere_shape(float radius)
{
return sphere_shape_t::pointer(new sphere_shape_t(m_impl->create_sphere_shape(radius)));
}
plane_shape_t::pointer solver_t::create_plane_shape(vec3f const& normal, float d)
{
return plane_shape_t::pointer(new plane_shape_t(m_impl->create_plane_shape(normal, d)));
}
box_shape_t::pointer solver_t::create_box_shape(vec3f const& halfExtents)
{
return box_shape_t::pointer(new box_shape_t(m_impl->create_box_shape(halfExtents)));
}
convex_hull_shape_t::pointer solver_t::create_convex_hull_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices)
{
return convex_hull_shape_t::pointer(new convex_hull_shape_t(m_impl->create_convex_hull_shape(vertices, num_vertices,
normals,
indices, num_indices)));
}
mesh_shape_t::pointer solver_t::create_mesh_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices)
{
return mesh_shape_t::pointer(new mesh_shape_t(m_impl->create_mesh_shape(vertices, num_vertices,
normals,
indices, num_indices)));
}
rigid_body_t::pointer solver_t::create_rigid_body(collision_shape_t::pointer& cs)
{
return rigid_body_t::pointer(new rigid_body_t(m_impl->create_rigid_body(cs->impl()), cs));
}
//add/remove from world
void solver_t::add_rigid_body(rigid_body_t::pointer& rb)
{
if(rb) {
if(m_rigid_bodies.find(rb) == m_rigid_bodies.end()) {
m_rigid_bodies.insert(rb);
m_impl->add_rigid_body(rb->impl());
}
}
}
void solver_t::remove_rigid_body(rigid_body_t::pointer& rb)
{
if(rb) {
if(m_rigid_bodies.find(rb) != m_rigid_bodies.end()) {
m_impl->remove_rigid_body(rb->impl());
m_rigid_bodies.erase(rb);
}
}
}
void solver_t::remove_all_rigid_bodies()
{
std::set<rigid_body_t::pointer>::iterator it;
for(it = m_rigid_bodies.begin(); it != m_rigid_bodies.end(); ++it) {
m_impl->remove_rigid_body(const_cast<rigid_body_t*>((*it).get())->impl());
}
m_rigid_bodies.clear();
}
void solver_t::set_gravity(vec3f const& g)
{
m_impl->set_gravity(g);
}
void solver_t::set_split_impulse(bool enabled)
{
m_impl->set_split_impulse(enabled);
}
void solver_t::step_simulation(float dt)
{
m_impl->step_simulation(dt);
}

View File

@@ -0,0 +1,88 @@
/*
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>
*/
//solver.h
//basic class for all solvers
#ifndef DYN_SOLVER_H
#define DYN_SOLVER_H
#include <set>
#include "mathUtils.h"
#include "shared_ptr.h"
#include "rigid_body.h"
#include "sphere_shape.h"
#include "plane_shape.h"
#include "box_shape.h"
#include "convex_hull_shape.h"
#include "mesh_shape.h"
#include "solver_impl.h"
class solver_t
{
public:
static void initialize();
static void cleanup();
//creation methods
static sphere_shape_t::pointer create_sphere_shape(float radius = 1.0);
static plane_shape_t::pointer create_plane_shape(vec3f const& normal = vec3f(0, 1, 0), float d = 0);
static box_shape_t::pointer create_box_shape(vec3f const& halfExtents = vec3f(0.5f, 0.5f, 0.5f));
static convex_hull_shape_t::pointer create_convex_hull_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices);
static mesh_shape_t::pointer create_mesh_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices);
static rigid_body_t::pointer create_rigid_body(collision_shape_t::pointer& cs);
//add/remove from world
static void add_rigid_body(rigid_body_t::pointer& rb);
static void remove_rigid_body(rigid_body_t::pointer& rb);
static void remove_all_rigid_bodies();
//
static void set_gravity(vec3f const& g);
//
static void set_split_impulse(bool enabled);
//
static void step_simulation(float dt);
private:
static shared_ptr<solver_impl_t> m_impl;
static std::set<rigid_body_t::pointer> m_rigid_bodies;
};
#endif

View File

@@ -0,0 +1,65 @@
/*
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>
*/
//solver_impl.h
#ifndef DYN_SOLVER_IMPL_H
#define DYN_SOLVER_IMPL_H
#include "rigid_body_impl.h"
#include "collision_shape_impl.h"
class solver_impl_t
{
public:
virtual collision_shape_impl_t* create_sphere_shape(float radius) = 0;
virtual collision_shape_impl_t* create_plane_shape(vec3f const& normal, float d) = 0;
virtual collision_shape_impl_t* create_box_shape(vec3f const& halfExtents) = 0;
virtual collision_shape_impl_t* create_convex_hull_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices) = 0;
virtual collision_shape_impl_t* create_mesh_shape(vec3f const* vertices, size_t num_vertices,
vec3f const* normals,
unsigned int const *indices, size_t num_indices) = 0;
virtual rigid_body_impl_t* create_rigid_body(collision_shape_impl_t* cs) = 0;
virtual void add_rigid_body(rigid_body_impl_t* rb) = 0;
virtual void remove_rigid_body(rigid_body_impl_t* rb) = 0;
virtual void set_gravity(vec3f const& g) = 0;
virtual void set_split_impulse(bool enabled) = 0;
virtual void step_simulation(float dt) = 0;
public:
virtual ~solver_impl_t() { }
};
#endif

View File

@@ -0,0 +1,45 @@
/*
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>
*/
//sphere_shape.h
#ifndef DYN_SPHERE_SHAPE_H
#define DYN_SPHERE_SHAPE_H
#include "collision_shape.h"
#include "sphere_shape_impl.h"
class sphere_shape_t: public collision_shape_t
{
public:
//typedefs
typedef shared_ptr<sphere_shape_t> pointer;
protected:
friend class solver_t;
sphere_shape_t(collision_shape_impl_t* impl): collision_shape_t(impl) { }
};
#endif

View File

@@ -0,0 +1,38 @@
/*
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>
*/
//sphere_shape_impl.h
#ifndef DYN_SPHERE_SHAPE_IMPL_H
#define DYN_SPHERE_SHAPE_IMPL_H
#include "collision_shape_impl.h"
class sphere_shape_impl_t: public collision_shape_impl_t
{
public:
private:
};
#endif