Various nail constraint improvements
TODO: errors while scene loading / saving
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GR /GS /EHsc"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".;"C:\Program Files\Autodesk\Maya2009\include";"C:\Program Files\Autodesk\Maya2008\include";"C:\Program Files\Alias\Maya8.0\include";../../src;../../Extras\GIMPACT\include"
|
||||
AdditionalIncludeDirectories=".;"C:\Program Files\Autodesk\Maya8.5\include";../../src;../../Extras\GIMPACT\include"
|
||||
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;NT_PLUGIN;REQUIRE_IOSTREAM"
|
||||
RuntimeLibrary="3"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
@@ -80,7 +80,7 @@
|
||||
OutputFile="./BulletMayaPluginDebug.mll"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\lib;"C:\Program Files\Autodesk\Maya2009\lib";"C:\Program Files\Autodesk\Maya2008\lib";C:\develop\disney_bulletmaya\boost_1_35_0\lib;"C:\Program Files\Alias\Maya8.0\lib""
|
||||
AdditionalLibraryDirectories="..\..\lib;"C:\Program Files\Autodesk\Maya8.5\lib";C:\develop\disney_bulletmaya\boost_1_35_0\lib"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/BulletMayaPlugin.pdb"
|
||||
SubSystem="2"
|
||||
@@ -113,6 +113,65 @@
|
||||
CommandLine="install.bat"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="DebugDll|x64"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="ReleaseDll|Win32"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
@@ -209,6 +268,65 @@
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="ReleaseDll|x64"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="ReleaseDebug|Win32"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
@@ -269,244 +387,6 @@
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="DebugDll|x64"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="ReleaseDll|x64"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="ReleaseDebug|x64"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
@@ -567,6 +447,66 @@
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
@@ -627,6 +567,66 @@
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
|
||||
@@ -134,7 +134,7 @@ protected:
|
||||
btVector3 const& scale = m_gi_shape->getLocalScaling();
|
||||
|
||||
std::vector<vec3f> vertices(m_vertices.size());
|
||||
for(int i = 0; i < vertices.size(); ++i) {
|
||||
for(unsigned 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());
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_plane_shape.h
|
||||
@@ -36,7 +40,7 @@ public:
|
||||
// std::cout << "bt_plane_shape_t::draw" << std::endl;
|
||||
// btStaticPlaneShape *plane_shape = static_cast<btStaticPlaneShape*>(shape());
|
||||
glPushMatrix();
|
||||
glScalef(100.0, 0.001, 100.0);
|
||||
glScalef(100.0f, 0.001f, 100.0f);
|
||||
if(draw_style & collision_shape_t::kDSSolid) {
|
||||
solid_cube();
|
||||
} else {
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_rigid_body.h
|
||||
@@ -160,7 +164,7 @@ public:
|
||||
int count = m_constraintRef.size();
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
m_constraintRef[i]->update_constraint();
|
||||
m_constraintRef[i]->update_constraint(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,14 +185,14 @@ protected:
|
||||
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_inertia(2.0f/5.0f, 2.0f/5.0f, 2.0f/5.0f),
|
||||
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_friction = 0.1f;
|
||||
rbInfo.m_linearDamping = m_linear_damping;
|
||||
rbInfo.m_angularDamping = m_angular_damping;
|
||||
m_body.reset(new btRigidBody(rbInfo));
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_solver.h
|
||||
@@ -79,6 +83,10 @@ public:
|
||||
{
|
||||
return new bt_nail_constraint_t(rb, pivot);
|
||||
}
|
||||
virtual nail_constraint_impl_t* create_nail_constraint(rigid_body_impl_t* rbA, rigid_body_impl_t* rbB, vec3f const& pivot)
|
||||
{
|
||||
return new bt_nail_constraint_t(rbA, rbB, pivot);
|
||||
}
|
||||
virtual hinge_constraint_impl_t* create_hinge_constraint(rigid_body_impl_t* rb, vec3f const& pivot)
|
||||
{
|
||||
return new bt_hinge_constraint_t(rb, pivot);
|
||||
@@ -95,6 +103,7 @@ public:
|
||||
virtual void add_rigid_body(rigid_body_impl_t* rb)
|
||||
{
|
||||
bt_rigid_body_t* bt_body = static_cast<bt_rigid_body_t*>(rb);
|
||||
bt_body->body()->setActivationState(DISABLE_DEACTIVATION);
|
||||
m_dynamicsWorld->addRigidBody(bt_body->body());
|
||||
}
|
||||
|
||||
@@ -128,7 +137,7 @@ public:
|
||||
|
||||
virtual void step_simulation(float dt)
|
||||
{
|
||||
m_dynamicsWorld->stepSimulation(dt, 1000, 1.0 / 120.0);
|
||||
m_dynamicsWorld->stepSimulation(dt, 1000, 1.0f / 120.0f);
|
||||
}
|
||||
|
||||
virtual void export_collada_file(const char* fileName);
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_sphere_shape.h
|
||||
@@ -88,12 +92,12 @@ protected:
|
||||
{
|
||||
btSphereShape *sphere_shape = static_cast<btSphereShape*>(shape());
|
||||
float radius = sphere_shape->getRadius();
|
||||
m_volume = (4.0 * 3.1415926 * radius * radius * radius) / 3.0;
|
||||
m_volume = (4.0f * 3.1415926f * radius * radius * radius) / 3.0f;
|
||||
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);
|
||||
m_local_inertia = vec3f(2.0f / 5.0f * radius * radius,
|
||||
2.0f / 5.0f * radius * radius,
|
||||
2.0f / 5.0f * radius * radius);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_constraint.h
|
||||
@@ -29,6 +33,8 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "shared_ptr.h"
|
||||
|
||||
class rigid_body_impl_t;
|
||||
|
||||
class bt_constraint_t
|
||||
{
|
||||
public:
|
||||
@@ -40,7 +46,7 @@ protected:
|
||||
|
||||
btTypedConstraint* constraint() { return m_constraint.get(); }
|
||||
void set_constraint(btTypedConstraint *constraint) { return m_constraint.reset(constraint); }
|
||||
virtual void update_constraint() = 0;
|
||||
virtual void update_constraint(rigid_body_impl_t* rb) = 0;
|
||||
|
||||
public:
|
||||
friend class bt_rigid_body_t;
|
||||
|
||||
@@ -18,6 +18,10 @@ not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Herbert Law <Herbert.Law@gmail.com>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_hinge_constraint.h
|
||||
@@ -97,7 +101,7 @@ public:
|
||||
hinge->enableAngularMotor(enable, velocity, impulse);
|
||||
}
|
||||
|
||||
virtual void update_constraint()
|
||||
virtual void update_constraint(rigid_body_impl_t* rb)
|
||||
{
|
||||
btHingeConstraint* hc = static_cast<btHingeConstraint*>(m_constraint.get());
|
||||
btVector3 world = hc->getBFrame().getOrigin();
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_nail_constraint.h
|
||||
@@ -58,10 +62,15 @@ public:
|
||||
}
|
||||
|
||||
virtual void get_world_pivot(vec3f &p) const {
|
||||
// btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
// p[0] = p2pc->getPivotInB().x();
|
||||
// p[1] = p2pc->getPivotInB().y();
|
||||
// p[2] = p2pc->getPivotInB().z();
|
||||
btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
p[0] = p2pc->getPivotInB().x();
|
||||
p[1] = p2pc->getPivotInB().y();
|
||||
p[2] = p2pc->getPivotInB().z();
|
||||
btVector3 pivotAinW = p2pc->getRigidBodyA().getCenterOfMassTransform()* p2pc->getPivotInA();
|
||||
p[0] = pivotAinW.x();
|
||||
p[1] = pivotAinW.y();
|
||||
p[2] = pivotAinW.z();
|
||||
}
|
||||
|
||||
virtual void set_world(vec3f const &p) {
|
||||
@@ -69,23 +78,47 @@ public:
|
||||
btVector3 world(p[0], p[1], p[2]);
|
||||
btVector3 pivotA = p2pc->getRigidBodyA().getWorldTransform().inverse() (world);
|
||||
p2pc->setPivotA(pivotA);
|
||||
p2pc->setPivotB(world);
|
||||
p2pc->buildJacobian();
|
||||
btVector3 pivotB = p2pc->getRigidBodyB().getWorldTransform().inverse() (world);
|
||||
p2pc->setPivotB(pivotB);
|
||||
// p2pc->buildJacobian();
|
||||
}
|
||||
|
||||
virtual void get_world(vec3f &p) const {
|
||||
btPoint2PointConstraint const* p2pc = static_cast<btPoint2PointConstraint const*>(m_constraint.get());
|
||||
p[0] = p2pc->getPivotInB().x();
|
||||
p[1] = p2pc->getPivotInB().y();
|
||||
p[2] = p2pc->getPivotInB().z();
|
||||
btVector3 pivotAinW = p2pc->getRigidBodyA().getCenterOfMassTransform()* p2pc->getPivotInA();
|
||||
// p[0] = p2pc->getPivotInB().x();
|
||||
// p[1] = p2pc->getPivotInB().y();
|
||||
// p[2] = p2pc->getPivotInB().z();
|
||||
p[0] = pivotAinW.x();
|
||||
p[1] = pivotAinW.y();
|
||||
p[2] = pivotAinW.z();
|
||||
}
|
||||
|
||||
virtual void update_constraint()
|
||||
virtual void update_constraint(rigid_body_impl_t* rb)
|
||||
{
|
||||
btRigidBody* bt_body = static_cast<bt_rigid_body_t*>(rb)->body();
|
||||
btPoint2PointConstraint* p2pc = static_cast<btPoint2PointConstraint*>(m_constraint.get());
|
||||
btVector3 world = p2pc->getPivotInB();
|
||||
btVector3 pivotA = p2pc->getRigidBodyA().getWorldTransform().inverse() (world);
|
||||
p2pc->setPivotA(pivotA);
|
||||
btVector3 world, pivot;
|
||||
if(bt_body == &p2pc->getRigidBodyA())
|
||||
{
|
||||
world = p2pc->getRigidBodyB().getWorldTransform() * p2pc->getPivotInB();
|
||||
pivot = p2pc->getRigidBodyA().getWorldTransform().inverse() * world;
|
||||
p2pc->setPivotA(pivot);
|
||||
}
|
||||
else if(bt_body == &p2pc->getRigidBodyB())
|
||||
{
|
||||
world = p2pc->getRigidBodyA().getWorldTransform() * p2pc->getPivotInA();
|
||||
pivot = p2pc->getRigidBodyB().getWorldTransform().inverse() * world;
|
||||
p2pc->setPivotB(pivot);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setValue(0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
// btVector3 world = p2pc->getPivotInB();
|
||||
// btVector3 pivotA = p2pc->getRigidBodyA().getWorldTransform().inverse() (world);
|
||||
// p2pc->setPivotA(pivotA);
|
||||
}
|
||||
protected:
|
||||
friend class bt_solver_t;
|
||||
@@ -93,12 +126,34 @@ protected:
|
||||
bt_nail_constraint_t(rigid_body_impl_t* rb, vec3f const& pivot):
|
||||
nail_constraint_impl_t()
|
||||
{
|
||||
btVector3 pivotW(pivot[0], pivot[1], pivot[2]);
|
||||
btRigidBody& bt_body = *static_cast<bt_rigid_body_t*>(rb)->body();
|
||||
btVector3 pivotA = bt_body.getCenterOfMassPosition();
|
||||
m_constraint.reset(new btPoint2PointConstraint(bt_body, -pivotA));
|
||||
const btTransform& tr = bt_body.getCenterOfMassTransform();
|
||||
btTransform iTr = tr.inverse();
|
||||
btVector3 nPivot = iTr * pivotW;
|
||||
m_constraint.reset(new btPoint2PointConstraint(bt_body, nPivot));
|
||||
// btVector3 pivotA = bt_body.getCenterOfMassPosition();
|
||||
// m_constraint.reset(new btPoint2PointConstraint(bt_body, -pivotA));
|
||||
rb->add_constraint(this);
|
||||
}
|
||||
|
||||
bt_nail_constraint_t(rigid_body_impl_t* rbA, rigid_body_impl_t* rbB, vec3f const& pivot):
|
||||
nail_constraint_impl_t()
|
||||
{
|
||||
btVector3 pivotW(pivot[0], pivot[1], pivot[2]);
|
||||
btRigidBody& bt_bodyA = *static_cast<bt_rigid_body_t*>(rbA)->body();
|
||||
const btTransform& trA = bt_bodyA.getCenterOfMassTransform();
|
||||
btTransform iTrA = trA.inverse();
|
||||
btVector3 nPivotA = iTrA * pivotW;
|
||||
btRigidBody& bt_bodyB = *static_cast<bt_rigid_body_t*>(rbB)->body();
|
||||
const btTransform& trB = bt_bodyB.getCenterOfMassTransform();
|
||||
btTransform iTrB = trB.inverse();
|
||||
btVector3 nPivotB = iTrB * pivotW;
|
||||
m_constraint.reset(new btPoint2PointConstraint(bt_bodyA, bt_bodyB, nPivotA, nPivotB));
|
||||
rbA->add_constraint(this);
|
||||
rbB->add_constraint(this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@@ -18,6 +18,10 @@ not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Herbert Law <Herbert.Law@gmail.com>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_sixdof_constraint.h
|
||||
@@ -94,7 +98,7 @@ public:
|
||||
*/ p = world;
|
||||
}
|
||||
|
||||
virtual void update_constraint()
|
||||
virtual void update_constraint(rigid_body_impl_t* rb)
|
||||
{
|
||||
btGeneric6DofConstraint* constraint = static_cast<btGeneric6DofConstraint*>(m_constraint.get());
|
||||
constraint->getFrameOffsetA() = constraint->getRigidBodyA().getCenterOfMassTransform().inverse();
|
||||
|
||||
@@ -18,6 +18,10 @@ not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Written by: Herbert Law <Herbert.Law@gmail.com>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//bt_slider_constraint.h
|
||||
@@ -95,7 +99,7 @@ public:
|
||||
*/ p = world;
|
||||
}
|
||||
|
||||
virtual void update_constraint()
|
||||
virtual void update_constraint(rigid_body_impl_t* rb)
|
||||
{
|
||||
/* btRigidBody& bt_bodyA = *static_cast<bt_rigid_body_t*>(rbA)->body();
|
||||
btRigidBody& bt_bodyB = *static_cast<bt_rigid_body_t*>(rbB)->body();
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//nailConstraintNode.cpp
|
||||
@@ -43,7 +47,8 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
MTypeId nailConstraintNode::typeId(0x10033A);
|
||||
MString nailConstraintNode::typeName("dNailConstraint");
|
||||
|
||||
MObject nailConstraintNode::ia_rigidBody;
|
||||
MObject nailConstraintNode::ia_rigidBodyA;
|
||||
MObject nailConstraintNode::ia_rigidBodyB;
|
||||
MObject nailConstraintNode::ia_damping;
|
||||
MObject nailConstraintNode::ca_constraint;
|
||||
MObject nailConstraintNode::ca_constraintParam;
|
||||
@@ -56,10 +61,15 @@ MStatus nailConstraintNode::initialize()
|
||||
MFnNumericAttribute fnNumericAttr;
|
||||
MFnMatrixAttribute fnMatrixAttr;
|
||||
|
||||
ia_rigidBody = fnMsgAttr.create("inRigidBody", "inrb", &status);
|
||||
MCHECKSTATUS(status, "creating inRigidBody attribute")
|
||||
status = addAttribute(ia_rigidBody);
|
||||
MCHECKSTATUS(status, "adding inRigidBody attribute")
|
||||
ia_rigidBodyA = fnMsgAttr.create("inRigidBodyA", "inrbA", &status);
|
||||
MCHECKSTATUS(status, "creating inRigidBodyA attribute")
|
||||
status = addAttribute(ia_rigidBodyA);
|
||||
MCHECKSTATUS(status, "adding inRigidBodyA attribute")
|
||||
|
||||
ia_rigidBodyB = fnMsgAttr.create("inRigidBodyB", "inrbB", &status);
|
||||
MCHECKSTATUS(status, "creating inRigidBodyB attribute")
|
||||
status = addAttribute(ia_rigidBodyB);
|
||||
MCHECKSTATUS(status, "adding inRigidBodyB attribute")
|
||||
|
||||
ia_damping = fnNumericAttr.create("damping", "dmp", MFnNumericData::kDouble, 1.0, &status);
|
||||
MCHECKSTATUS(status, "creating damping attribute")
|
||||
@@ -86,11 +96,17 @@ MStatus nailConstraintNode::initialize()
|
||||
MCHECKSTATUS(status, "adding ca_constraintParam attribute")
|
||||
|
||||
|
||||
status = attributeAffects(ia_rigidBody, ca_constraint);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraint)")
|
||||
status = attributeAffects(ia_rigidBodyA, ca_constraint);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyA, ca_constraint)")
|
||||
|
||||
status = attributeAffects(ia_rigidBody, ca_constraintParam);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraintParam)")
|
||||
status = attributeAffects(ia_rigidBodyA, ca_constraintParam);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyA, ca_constraintParam)")
|
||||
|
||||
status = attributeAffects(ia_rigidBodyB, ca_constraint);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyB, ca_constraint)")
|
||||
|
||||
status = attributeAffects(ia_rigidBodyB, ca_constraintParam);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyB, ca_constraintParam)")
|
||||
|
||||
status = attributeAffects(ia_damping, ca_constraintParam);
|
||||
MCHECKSTATUS(status, "adding attributeAffects(ia_damping, ca_constraintParam)")
|
||||
@@ -174,19 +190,34 @@ void nailConstraintNode::draw( M3dView & view, const MDagPath &path,
|
||||
( style != M3dView::kGouraudShaded && style != M3dView::kFlatShaded )) ) {
|
||||
glColor3f(1.0, 1.0, 0.0);
|
||||
}
|
||||
vec3f pos;
|
||||
vec3f posA, posB;
|
||||
rigid_body_t::pointer rigid_bodyB = NULL;
|
||||
if (m_constraint) {
|
||||
vec3f world;
|
||||
m_constraint->get_world(world);
|
||||
vec3f posA;
|
||||
quatf rotA;
|
||||
m_constraint->rigid_body()->get_transform(posA, rotA);
|
||||
pos = posA - world;
|
||||
vec3f posT;
|
||||
quatf rotT;
|
||||
m_constraint->rigid_bodyA()->get_transform(posT, rotT);
|
||||
posA = posT - world;
|
||||
rigid_bodyB = m_constraint->rigid_bodyB();
|
||||
if(rigid_bodyB)
|
||||
{
|
||||
rigid_bodyB->get_transform(posT, rotT);
|
||||
posB = posT - world;
|
||||
}
|
||||
}
|
||||
|
||||
glBegin(GL_LINES);
|
||||
|
||||
glVertex3f(0.0, 0.0, 0.0);
|
||||
glVertex3f(pos[0], pos[1], pos[2]);
|
||||
glVertex3f(posA[0], posA[1], posA[2]);
|
||||
|
||||
if(rigid_bodyB)
|
||||
{
|
||||
glVertex3f(0.0, 0.0, 0.0);
|
||||
glVertex3f(posB[0], posB[1], posB[2]);
|
||||
}
|
||||
|
||||
|
||||
glVertex3f(-1.0, 0.0, 0.0);
|
||||
glVertex3f(1.0, 0.0, 0.0);
|
||||
@@ -225,35 +256,83 @@ void nailConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data)
|
||||
// std::cout << "nailConstraintNode::computeConstraint" << std::endl;
|
||||
|
||||
MObject thisObject(thisMObject());
|
||||
MPlug plgRigidBody(thisObject, ia_rigidBody);
|
||||
MPlug plgRigidBodyA(thisObject, ia_rigidBodyA);
|
||||
MPlug plgRigidBodyB(thisObject, ia_rigidBodyB);
|
||||
MObject update;
|
||||
//force evaluation of the rigidBody
|
||||
plgRigidBody.getValue(update);
|
||||
plgRigidBodyA.getValue(update);
|
||||
plgRigidBodyB.getValue(update);
|
||||
|
||||
rigid_body_t::pointer rigid_body;
|
||||
if(plgRigidBody.isConnected()) {
|
||||
rigid_body_t::pointer rigid_bodyA;
|
||||
if(plgRigidBodyA.isConnected()) {
|
||||
MPlugArray connections;
|
||||
plgRigidBody.connectedTo(connections, true, true);
|
||||
plgRigidBodyA.connectedTo(connections, true, true);
|
||||
if(connections.length() != 0) {
|
||||
MFnDependencyNode fnNode(connections[0].node());
|
||||
if(fnNode.typeId() == rigidBodyNode::typeId) {
|
||||
rigidBodyNode *pRigidBodyNode = static_cast<rigidBodyNode*>(fnNode.userNode());
|
||||
rigid_body = pRigidBodyNode->rigid_body();
|
||||
rigidBodyNode *pRigidBodyNodeA = static_cast<rigidBodyNode*>(fnNode.userNode());
|
||||
rigid_bodyA = pRigidBodyNodeA->rigid_body();
|
||||
} else {
|
||||
std::cout << "nailConstraintNode connected to a non-rigidbody node!" << std::endl;
|
||||
std::cout << "nailConstraintNode connected to a non-rigidbody node A!" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rigid_body) {
|
||||
rigid_body_t::pointer rigid_bodyB;
|
||||
if(plgRigidBodyB.isConnected()) {
|
||||
MPlugArray connections;
|
||||
plgRigidBodyB.connectedTo(connections, true, true);
|
||||
if(connections.length() != 0) {
|
||||
MFnDependencyNode fnNode(connections[0].node());
|
||||
if(fnNode.typeId() == rigidBodyNode::typeId) {
|
||||
rigidBodyNode *pRigidBodyNodeB = static_cast<rigidBodyNode*>(fnNode.userNode());
|
||||
rigid_bodyB = pRigidBodyNodeB->rigid_body();
|
||||
} else {
|
||||
std::cout << "nailConstraintNode connected to a non-rigidbody node B!" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((rigid_bodyA != NULL) && (rigid_bodyB != NULL))
|
||||
{
|
||||
constraint_t::pointer constraint = static_cast<constraint_t::pointer>(m_constraint);
|
||||
solver_t::remove_constraint(constraint);
|
||||
vec3f posA, posB, posP;
|
||||
quatf rotA, rotB;
|
||||
rigid_bodyA->get_transform(posA, rotA);
|
||||
rigid_bodyB->get_transform(posB, rotB);
|
||||
posP = posA;
|
||||
m_constraint = solver_t::create_nail_constraint(rigid_bodyA, rigid_bodyB, posP);
|
||||
constraint = static_cast<constraint_t::pointer>(m_constraint);
|
||||
solver_t::add_constraint(constraint);
|
||||
}
|
||||
else if(rigid_bodyA)
|
||||
{
|
||||
//not connected to a rigid body, put a default one
|
||||
constraint_t::pointer constraint = static_cast<constraint_t::pointer>(m_constraint);
|
||||
solver_t::remove_constraint(constraint);
|
||||
m_constraint = solver_t::create_nail_constraint(rigid_body);
|
||||
vec3f posA, posP;
|
||||
quatf rotA;
|
||||
rigid_bodyA->get_transform(posA, rotA);
|
||||
posP = posA;
|
||||
m_constraint = solver_t::create_nail_constraint(rigid_bodyA, posP);
|
||||
constraint = static_cast<constraint_t::pointer>(m_constraint);
|
||||
solver_t::add_constraint(constraint);
|
||||
}
|
||||
|
||||
MFnDagNode mDagNode(thisObject);
|
||||
if(mDagNode.parentCount() == 0)
|
||||
{
|
||||
std::cout << "No transform for nail constraint found!" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
MFnTransform mTransform(mDagNode.parent(0));
|
||||
vec3f constrPos;
|
||||
m_constraint->get_world(constrPos);
|
||||
mTransform.setTranslation(MVector(constrPos[0], constrPos[1], constrPos[2]), MSpace::kTransform);
|
||||
}
|
||||
|
||||
data.outputValue(ca_constraint).set(true);
|
||||
data.setClean(plug);
|
||||
}
|
||||
@@ -293,7 +372,14 @@ void nailConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data)
|
||||
std::cout << "pivot (" << pivot[0] << "," << pivot[0] << "," << pivot[0] << ")" << std::endl;
|
||||
*/
|
||||
// std::cout << "mtranslation (" << mtranslation[0] << "," << mtranslation[0] << "," << mtranslation[0] << ")" << std::endl;
|
||||
m_constraint->set_world(vec3f((float) mtranslation[0], (float) mtranslation[1], (float) mtranslation[2]));
|
||||
float deltaX = world[0] - float(mtranslation.x);
|
||||
float deltaY = world[1] - float(mtranslation.y);
|
||||
float deltaZ = world[2] - float(mtranslation.z);
|
||||
float deltaSq = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
||||
if(deltaSq > 0.000001f)
|
||||
{
|
||||
m_constraint->set_world(vec3f((float) mtranslation[0], (float) mtranslation[1], (float) mtranslation[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//nailConstraintNode.h
|
||||
@@ -66,7 +70,8 @@ public:
|
||||
public:
|
||||
|
||||
//Attributes
|
||||
static MObject ia_rigidBody;
|
||||
static MObject ia_rigidBodyA;
|
||||
static MObject ia_rigidBodyB;
|
||||
static MObject ia_damping;
|
||||
|
||||
static MObject ca_constraint;
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//nail_constraint.h
|
||||
@@ -39,7 +43,8 @@ public:
|
||||
typedef shared_ptr<nail_constraint_t> pointer;
|
||||
|
||||
//
|
||||
rigid_body_t::pointer rigid_body() { return m_rigid_body; }
|
||||
rigid_body_t::pointer rigid_bodyA() { return m_rigid_bodyA; }
|
||||
rigid_body_t::pointer rigid_bodyB() { return m_rigid_bodyB; }
|
||||
|
||||
//
|
||||
void set_pivotA(vec3f const& p) {
|
||||
@@ -81,14 +86,23 @@ public:
|
||||
|
||||
protected:
|
||||
friend class solver_t;
|
||||
nail_constraint_t(nail_constraint_impl_t* impl, rigid_body_t::pointer& rigid_body):
|
||||
nail_constraint_t(nail_constraint_impl_t* impl, rigid_body_t::pointer& rigid_bodyA):
|
||||
constraint_t(impl),
|
||||
m_rigid_body(rigid_body)
|
||||
m_rigid_bodyA(rigid_bodyA),
|
||||
m_rigid_bodyB(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nail_constraint_t(nail_constraint_impl_t* impl, rigid_body_t::pointer& rigid_bodyA, rigid_body_t::pointer& rigid_bodyB):
|
||||
constraint_t(impl),
|
||||
m_rigid_bodyA(rigid_bodyA),
|
||||
m_rigid_bodyB(rigid_bodyB)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
rigid_body_t::pointer m_rigid_body;
|
||||
rigid_body_t::pointer m_rigid_bodyA;
|
||||
rigid_body_t::pointer m_rigid_bodyB;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//dSolverNode.cpp
|
||||
@@ -49,6 +53,7 @@ Written by: Nicola Candussi <nicola@fluidinteractive.com>
|
||||
#include "solver.h"
|
||||
#include "rigidBodyNode.h"
|
||||
#include "rigidBodyArrayNode.h"
|
||||
#include "constraint/nailConstraintNode.h"
|
||||
#include "pdbIO.h"
|
||||
|
||||
MTypeId dSolverNode::typeId(0x100331);
|
||||
@@ -357,6 +362,7 @@ void dSolverNode::initRigidBodies(MPlugArray &rbConnections)
|
||||
|
||||
if(fnNode.typeId() == rigidBodyNode::typeId) {
|
||||
initRigidBody(node);
|
||||
updateConstraint(node);
|
||||
} else if(fnNode.typeId() == rigidBodyArrayNode::typeId) {
|
||||
initRigidBodyArray(node);
|
||||
}
|
||||
@@ -491,6 +497,34 @@ void dSolverNode::updatePassiveRigidBodies(MPlugArray &rbConnections, std::vecto
|
||||
}
|
||||
}
|
||||
|
||||
void dSolverNode::updateConstraint(MObject& bodyNode)
|
||||
{
|
||||
MFnDagNode fnDagNode(bodyNode);
|
||||
rigidBodyNode *rbNode = static_cast<rigidBodyNode*>(fnDagNode.userNode());
|
||||
MPlug plgMessages(bodyNode, rbNode->message);
|
||||
MPlugArray rbMsgConnections;
|
||||
plgMessages.connectedTo(rbMsgConnections, false, true);
|
||||
for(size_t j = 0; j < rbMsgConnections.length(); j++)
|
||||
{
|
||||
MObject msgNode = rbMsgConnections[j].node();
|
||||
MFnDagNode msgDagNode(msgNode);
|
||||
if(msgDagNode.typeId() == nailConstraintNode::typeId)
|
||||
{
|
||||
nailConstraintNode* nailNode = static_cast<nailConstraintNode*>(msgDagNode.userNode());
|
||||
if(msgDagNode.parentCount() == 0)
|
||||
{
|
||||
std::cout << "No transform for nail constraint found!" << std::endl;
|
||||
continue;
|
||||
}
|
||||
MFnTransform msgTransform(msgDagNode.parent(0));
|
||||
nail_constraint_t::pointer nail = nailNode->constraint();
|
||||
vec3f constrPos;
|
||||
nail->get_world(constrPos);
|
||||
msgTransform.setTranslation(MVector(constrPos[0], constrPos[1], constrPos[2]), MSpace::kTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update the scene after a simulation step
|
||||
void dSolverNode::updateActiveRigidBodies(MPlugArray &rbConnections)
|
||||
{
|
||||
@@ -520,6 +554,7 @@ void dSolverNode::updateActiveRigidBodies(MPlugArray &rbConnections)
|
||||
fnTransform.setRotation(MQuaternion(rot[1], rot[2], rot[3], rot[0]));
|
||||
fnTransform.setTranslation(MVector(pos[0], pos[1], pos[2]), MSpace::kTransform);
|
||||
}
|
||||
updateConstraint(node);
|
||||
} else if(fnDagNode.typeId() == rigidBodyArrayNode::typeId) {
|
||||
rigidBodyArrayNode *rbNode = static_cast<rigidBodyArrayNode*>(fnDagNode.userNode());
|
||||
std::vector<rigid_body_t::pointer>& rbs = rbNode->rigid_bodies();
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//dSolverNode.h
|
||||
@@ -83,6 +87,7 @@ protected:
|
||||
void updatePassiveRigidBodies(MPlugArray &rbConnections, std::vector<xforms_t> &xforms, float t);
|
||||
void updateActiveRigidBodies(MPlugArray &rbConnections);
|
||||
void applyFields(MPlugArray &rbConnections, float dt);
|
||||
void updateConstraint(MObject& bodyNode);
|
||||
|
||||
protected:
|
||||
MTime m_prevTime;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
xcopy /S /Y /C /I /h icons\*.xpm "C:\Program Files\Autodesk\Maya2008\icons"
|
||||
xcopy /S /Y /C /I /h scripts\*.mel "C:\Program Files\Autodesk\Maya2008\scripts"
|
||||
xcopy /S /Y /C /I /h BulletMayaPluginDebug.mll "C:\Program Files\Autodesk\Maya2008\bin\plug-ins"
|
||||
xcopy /S /Y /C /I /h icons\*.xpm "C:\Program Files\Autodesk\Maya8.5\icons"
|
||||
xcopy /S /Y /C /I /h scripts\*.mel "C:\Program Files\Autodesk\Maya8.5\scripts"
|
||||
xcopy /S /Y /C /I /h BulletMayaPluginDebug.mll "C:\Program Files\Autodesk\Maya8.5\bin\plug-ins"
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//mesh_shape.h
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//AEdNailConstraintTemplate.mel
|
||||
@@ -28,7 +32,8 @@ global proc AEdNailConstraintTemplate( string $nodeName )
|
||||
editorTemplate -beginScrollLayout;
|
||||
|
||||
editorTemplate -addControl damping;
|
||||
editorTemplate -addControl inRigidBody;
|
||||
editorTemplate -addControl inRigidBodyA;
|
||||
editorTemplate -addControl inRigidBodyB;
|
||||
|
||||
AEdependNodeTemplate $nodeName;
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//dynamicaUI.mel
|
||||
@@ -688,21 +692,40 @@ global proc dynamicaUI_createPassiveMeshRBArray()
|
||||
global proc dynamicaUI_createNailConstraint()
|
||||
{
|
||||
string $selection[] = `ls -selection -dag -leaf -showType -type "geometry"`;
|
||||
|
||||
//create dSolver node if necessary
|
||||
dSolver;
|
||||
|
||||
string $newConstraints[];
|
||||
for($i = 0; $i < size($selection) / 2; $i++) {
|
||||
if($selection[$i * 2 + 1] == "dRigidBody") {
|
||||
string $constraintNode = `dNailConstraint`;
|
||||
connectAttr ($selection[$i * 2] + ".message") ($constraintNode + ".inRigidBody");
|
||||
string $constraintTransforms[] = `listRelatives -parent $constraintNode`;
|
||||
$newConstraints[$i] = $constraintTransforms[0];
|
||||
}
|
||||
// check selection in scene : one or two rigidBodies should be selected
|
||||
int $selSize = size($selection);
|
||||
int $selOK = (($selSize == 2) || ($selSize == 4));
|
||||
for($i = 0; $i < $selSize/2; $i++)
|
||||
{
|
||||
if($selection[$i * 2 + 1] != "dRigidBody")
|
||||
{
|
||||
$selOK = 0;
|
||||
}
|
||||
}
|
||||
if(!$selOK)
|
||||
{
|
||||
error("Select one or two bodies to create a nail constraint");
|
||||
return;
|
||||
}
|
||||
// create nail constraint node
|
||||
string $constraintNode = `dNailConstraint`;
|
||||
// connect to bodies
|
||||
if($selSize == 2)
|
||||
{
|
||||
connectAttr ($selection[0] + ".message") ($constraintNode + ".inRigidBodyA");
|
||||
}
|
||||
select -r $newConstraints;
|
||||
else
|
||||
{
|
||||
connectAttr ($selection[0] + ".message") ($constraintNode + ".inRigidBodyA");
|
||||
connectAttr ($selection[2] + ".message") ($constraintNode + ".inRigidBodyB");
|
||||
}
|
||||
string $constraintTransforms[] = `listRelatives -parent $constraintNode`;
|
||||
string $newConstraint = $constraintTransforms[0];
|
||||
select -r $newConstraint;
|
||||
}
|
||||
|
||||
global proc dynamicaUI_createHingeConstraint()
|
||||
{
|
||||
string $selection[] = `ls -selection -dag -leaf -showType -type "geometry"`;
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//solver.cpp
|
||||
@@ -89,6 +93,10 @@ nail_constraint_t::pointer solver_t::create_nail_constraint(rigid_body_t::point
|
||||
{
|
||||
return nail_constraint_t::pointer(new nail_constraint_t(m_impl->create_nail_constraint(rb->impl(), pivot), rb));
|
||||
}
|
||||
nail_constraint_t::pointer solver_t::create_nail_constraint(rigid_body_t::pointer& rbA, rigid_body_t::pointer& rbB, vec3f const& pivot)
|
||||
{
|
||||
return nail_constraint_t::pointer(new nail_constraint_t(m_impl->create_nail_constraint(rbA->impl(), rbB->impl(), pivot), rbA, rbB));
|
||||
}
|
||||
hinge_constraint_t::pointer solver_t::create_hinge_constraint(rigid_body_t::pointer& rb, vec3f const& pivot)
|
||||
{
|
||||
return hinge_constraint_t::pointer(new hinge_constraint_t(m_impl->create_hinge_constraint(rb->impl(), pivot), rb));
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//solver.h
|
||||
@@ -69,6 +73,7 @@ public:
|
||||
static rigid_body_t::pointer create_rigid_body(collision_shape_t::pointer& cs);
|
||||
|
||||
static nail_constraint_t::pointer create_nail_constraint(rigid_body_t::pointer& rb, vec3f const& pivot = vec3f(0, 0, 0));
|
||||
static nail_constraint_t::pointer create_nail_constraint(rigid_body_t::pointer& rbA, rigid_body_t::pointer& rbB, vec3f const& pivot = vec3f(0, 0, 0));
|
||||
static hinge_constraint_t::pointer create_hinge_constraint(rigid_body_t::pointer& rb, vec3f const& pivot = vec3f(0, 0, 0));
|
||||
static slider_constraint_t::pointer create_slider_constraint(rigid_body_t::pointer& rbA, vec3f const& pivotA, rigid_body_t::pointer& rbB, vec3f const& pivotB = vec3f(0, 0, 0));
|
||||
static sixdof_constraint_t::pointer create_sixdof_constraint(rigid_body_t::pointer& rbA, vec3f const& pivotA, rigid_body_t::pointer& rbB, vec3f const& pivotB = vec3f(0, 0, 0));
|
||||
|
||||
@@ -18,6 +18,10 @@ 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>
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
12/24/2009 : Nail constraint improvements
|
||||
|
||||
*/
|
||||
|
||||
//solver_impl.h
|
||||
@@ -53,6 +57,7 @@ public:
|
||||
virtual rigid_body_impl_t* create_rigid_body(collision_shape_impl_t* cs) = 0;
|
||||
|
||||
virtual nail_constraint_impl_t* create_nail_constraint(rigid_body_impl_t* rb, vec3f const& pivot) = 0;
|
||||
virtual nail_constraint_impl_t* create_nail_constraint(rigid_body_impl_t* rbA, rigid_body_impl_t* rbB, vec3f const& pivot) = 0;
|
||||
virtual hinge_constraint_impl_t* create_hinge_constraint(rigid_body_impl_t* rb, vec3f const& pivot) = 0;
|
||||
virtual slider_constraint_impl_t* create_slider_constraint(rigid_body_impl_t* rbA, vec3f const& pivotA, rigid_body_impl_t* rbB, vec3f const& pivotB) = 0;
|
||||
virtual sixdof_constraint_impl_t* create_sixdof_constraint(rigid_body_impl_t* rbA, vec3f const& pivotA, rigid_body_impl_t* rbB, vec3f const& pivotB) = 0;
|
||||
|
||||
Reference in New Issue
Block a user