MikuMikuDance viewer

Hi.

I’m working on MikuMikuDance viewer.

About MikuMikuDance:

http://en.wikipedia.org/wiki/MikuMikuDance

YouTube

http://www.youtube.com/watch?v=MhU2MP7euts


JavaWebStart

http://chototsumoushinp.dip.jp/miku/souko/test3/

features:

GLSL skinning

GLSL toon shade

Inverse Kinematics (CCD)

btGeneric6DofSpringConstraint support(ported from Bullet Physics 2.76)

http://i.imgur.com/HMmki.png



Thanks.

5 Likes

WOW, nice work!!! Rigid body rig is really cool. As as i understand, this program will be useful for motion capture, animation viewing, model viewing, glsl rendering. And it could be used in cartoon video production.?



I did not find a license of your program on your wiki, so i dont know if it is GPL or not. I suppose it’s not.



I just would like to ask if you can to share with your toon shader with our community…

I contributed some of my shaders to JME3, because i think that the community does not have good shader prefabs yet…

If you are able to share, so I can easily add your shader to my repository. http://code.google.com/p/jme-glsl-shaders/

Also, I can add you as a member to my repository for future shader improvements. :slight_smile:

Hi.

This software is open source and the license is same as JMonkey Engine.



Thanks.

1 Like

WOW! That’s really great. Thank you for sharing.

Question:

Can I add your shader to my repository? I can add any link or trademark you want. If yes, so where can I browse your shader code?

Or you can post pixel and vertex shaders here.



Thanks.

chototsu said:
btGeneric6DofSpringConstraint support(ported from Bullet Physics 2.76)

Why did you "port" that? Its available in the jME3 bullet system. com.jme3.bullet.joints.SixDofJoint

Can I add your shader to my repository?

Yes.



I can add any link or trademark you want

Please link my blog.

http://blogs.yahoo.co.jp/chototsu_moushinp



If yes, so where can I browse your shader code?

http://chototsumoushinp.dip.jp/miku/souko/test3/pmdshadersrc.zip

1 Like

Why did you “port” that? Its available in the jME3 bullet system. com.jme3.bullet.joints.SixDofJoint



JBullet supports btGeneric6DofConstraint , but JBullet doesn’t support btGeneric6DofSpringConstraint yet.

Oh, I didn’t read the “Spring” in there ^^ Cool, we can add that to our jbullet version maybe, then we can add it sooner than thought (w/o native bullet).

Nice. Something different between all the game projects. Like it.

Thanks!

Thank you again. I’ll put your shader to my repository asap.



Just interested… what benefits with glsl skinning against common (by engine) skinning? As far as I know glsl uses GPU. Will it be faster or better productivity?

The advantage is that reduce data transfer.

GLSL skinning on fast GPUs is faster than CPU skinning,

however GLSL skinning on old GPUs is slower than CPU skinning.

In other words, GLSL skinning can save fps if there are many animations in the scene, right? It’s interesting what kind of skinning preferred in cryengine, source engine… at present.



On the other hand, there will be in two times more shaders… with skinning and without it.



Or possibly, GLSL skinning could be better for the bullet physics calculations? I mean about bone rigged body, ragdoll…

Many modern setups have souped up graphics cards but slooooow buses. In this case, minimizing the mesh transfer is preferable.



For example, in Mythruna, some machines seem to get really high and consistent frame rates, but whenever they turn around it can take seconds (yes seconds) to send the new unculled data to the card. These machines would really like hardware skinning. :slight_smile:

By my experience:

GeForce Go 6150

GLSL skinning works, however it’s very slow and instability.



GeForce 8400GS

GLSL skinning works.



GeForce7600GT

GLSL skinning works fast.



GeForce9600GT

GLSL skinning works very fast.



CPU skinning:

All vertex data transferred only once per running application.

But matrix data transferred per frame.





GPU skinning:

All vertex data transferred per frame.



Uniform variable capacity is very small.



uniform mat4 m_BoneMatrices[100];



This code works on GeForce9600GT, but it doesn’t work on GeForce Go 6150.



GLSL skinning doesn’t work with MikuMikuDance models because bone size of MikuMikuDance is over than 200.

I divided mesh per 20 bones and at last, it works.



I tried Vertex Texture Fetch like this:

oZone3D.Net Tutorials - Vertex Displacement Mapping - Vertex Texture Fetching - Shader Model 3.0 - OpenGL / GLSL

However, it’s too hard for me.

Hi.

I succeeded to run my MikuMIkuDance viewer with native bullet!

my patch is here.

Thanks.

I made SixDofSpringJoint class and bug fix patch for native bullet.

OpenSolaris x86(32bit)binary is here.

http://chototsumoushinp.dip.jp/miku/souko/test3/jME3-bullet-natives-solaris.jar



Thanks.



[patch]

Index: com_jme3_bullet_PhysicsSpace.cpp

— com_jme3_bullet_PhysicsSpace.cpp Base (BASE)

+++ com_jme3_bullet_PhysicsSpace.cpp Locally Modified (Based On LOCAL)

@@ -124,7 +124,7 @@

  • Signature: (JJ)V

    */

    JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addRigidBody
  • (JNIEnv * env, jobject object, jlong spaceId, jlong rigidBodyId) {
  • (JNIEnv * env, jobject object, jlong spaceId, jlong rigidBodyId, jshort group, jshort groups) {

    jmePhysicsSpace* space = (jmePhysicsSpace*) spaceId;

    btRigidBody* collisionObject = (btRigidBody*) rigidBodyId;

    if (space == NULL) {

    @@ -137,7 +137,9 @@

    env->ThrowNew(newExc, "The collision object does not exist.");

    return;

    }
  •    space-&gt;getDynamicsWorld()-&gt;addRigidBody(collisionObject);<br />
    
  •    space-&gt;getDynamicsWorld()-&gt;addRigidBody(collisionObject, group, groups);<br />
    
  •    collisionObject-&gt;setActivationState(DISABLE_DEACTIVATION);<br />
    
  •    printf(&quot;addRigidBody:group = %d groups = %dn&quot;, group, groups);<br />
    

}



/*

@@ -159,7 +161,6 @@

env->ThrowNew(newExc, "The collision object does not exist.");

return;

}

  •    space-&gt;getDynamicsWorld()-&gt;removeRigidBody(collisionObject);<br />
    

}



/

Index: com_jme3_bullet_PhysicsSpace.h

— com_jme3_bullet_PhysicsSpace.h Base (BASE)

+++ com_jme3_bullet_PhysicsSpace.h Locally Modified (Based On LOCAL)

@@ -50,10 +50,10 @@

/

  • Class: com_jme3_bullet_PhysicsSpace
  • Method: addRigidBody
    • Signature: (JJ)V
    • Signature: (JJSS)V

      */

      JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addRigidBody
  • (JNIEnv *, jobject, jlong, jlong);
  • (JNIEnv , jobject, jlong, jlong, jshort, jshort);



    /

  • Class: com_jme3_bullet_PhysicsSpace

    Index: com_jme3_bullet_joints_SixDofJoint.cpp

    — com_jme3_bullet_joints_SixDofJoint.cpp Base (BASE)

    +++ com_jme3_bullet_joints_SixDofJoint.cpp Locally Modified (Based On LOCAL)

    @@ -85,7 +85,7 @@

    btGeneric6DofConstraint* joint = (btGeneric6DofConstraint*) jointId;

    btVector3* vec = &btVector3();

    jmeBulletUtil::convert(env, vector, vec);
  •    joint-&gt;setLinearUpperLimit(*vec);<br />
    
  •    joint-&gt;setLinearLowerLimit(*vec);<br />
    

}



/

@@ -98,7 +98,7 @@

btGeneric6DofConstraint
joint = (btGeneric6DofConstraint*) jointId;

btVector3* vec = &btVector3();

jmeBulletUtil::convert(env, vector, vec);

  •    joint-&gt;setLinearUpperLimit(*vec);<br />
    
  •    joint-&gt;setAngularUpperLimit(*vec);<br />
    

}



/

@@ -126,13 +126,21 @@

btRigidBody
bodyB = (btRigidBody*) bodyIdB;

btMatrix3x3* mtx1 = &btMatrix3x3();

btMatrix3x3* mtx2 = &btMatrix3x3();

  •    btTransform* transA = &amp;btTransform(*mtx1);<br />
    

+/* btTransform* transA = &btTransform(mtx1);

jmeBulletUtil::convert(env, pivotA, &transA->getOrigin());

jmeBulletUtil::convert(env, rotA, &transA->getBasis());

btTransform
transB = &btTransform(*mtx2);

jmeBulletUtil::convert(env, pivotB, &transB->getOrigin());

jmeBulletUtil::convert(env, rotB, &transB->getBasis());

  •    btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, *transA, *transB, useLinearReferenceFrameA);<br />
    

+*/

  •    btTransform transA;<br />
    
  •    jmeBulletUtil::convert(env, pivotA, &amp;transA.getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotA, &amp;transA.getBasis());<br />
    
  •    btTransform transB;<br />
    
  •    jmeBulletUtil::convert(env, pivotB, &amp;transB.getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotB, &amp;transB.getBasis());<br />
    

+

  •    btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);<br />
    

return (long)joint;

}

#ifdef __cplusplus

Index: com_jme3_bullet_joints_SixDofSpringJoint.cpp

— com_jme3_bullet_joints_SixDofSpringJoint.cpp Locally New

+++ com_jme3_bullet_joints_SixDofSpringJoint.cpp Locally New

@@ -0,0 +1,103 @@

+

+/**

    • Author: Normen Hansen
  • /

    +#include "com_jme3_bullet_joints_SixDofSpringJoint.h"

    +#include "jmeBulletUtil.h"

    +

    +#ifdef __cplusplus

    +extern "C" {

    +#endif

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: enableString
    • Signature: (JIZ)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_enableSpring
  • (JNIEnv *env, jobject object, jlong jointId, jint index, jboolean onOff) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> enableSpring(index, onOff);

    +}

    +

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setStiffness
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setStiffness
  • (JNIEnv *env, jobject object, jlong jointId, jint index, jfloat stiffness) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setStiffness(index, stiffness);

    +}

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setDamping
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setDamping
  • (JNIEnv *env, jobject object, jlong jointId, jint index, jfloat damping) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setDamping(index, damping);

    +}

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__JIF
  • (JNIEnv *env, jobject object, jlong jointId) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setEquilibriumPoint();

    +}

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (JI)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__JI
  • (JNIEnv *env, jobject object, jlong jointId, jint index) {
  • btGeneric6DofSpringConstraint* joint = (btGeneric6DofSpringConstraint*) jointId;
  • joint -> setEquilibriumPoint(index);

    +}

    +

    +

    +

    +

    +/*
    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: createJoint
    • Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
  • */

    +JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_createJoint
  • (JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
  •    jmeClasses::initJavaClasses(env);<br />
    
  •    btRigidBody* bodyA = (btRigidBody*) bodyIdA;<br />
    
  •    btRigidBody* bodyB = (btRigidBody*) bodyIdB;<br />
    
  •    btMatrix3x3* mtx1 = &amp;btMatrix3x3();<br />
    
  •    btMatrix3x3* mtx2 = &amp;btMatrix3x3();<br />
    

+/* btTransform* transA = &btTransform(*mtx1);

  •    jmeBulletUtil::convert(env, pivotA, &amp;transA-&gt;getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotA, &amp;transA-&gt;getBasis());<br />
    
  •    btTransform* transB = &amp;btTransform(*mtx2);<br />
    
  •    jmeBulletUtil::convert(env, pivotB, &amp;transB-&gt;getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotB, &amp;transB-&gt;getBasis());<br />
    

+*/

  •    btTransform transA;<br />
    
  •    jmeBulletUtil::convert(env, pivotA, &amp;transA.getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotA, &amp;transA.getBasis());<br />
    
  •    btTransform transB;<br />
    
  •    jmeBulletUtil::convert(env, pivotB, &amp;transB.getOrigin());<br />
    
  •    jmeBulletUtil::convert(env, rotB, &amp;transB.getBasis());<br />
    

+

  •    btGeneric6DofSpringConstraint* joint = new btGeneric6DofSpringConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);<br />
    
  •    return (long)joint;<br />
    
  • }

    +

    +#ifdef __cplusplus

    +}

    +#endif

    Index: com_jme3_bullet_joints_SixDofSpringJoint.h

    — com_jme3_bullet_joints_SixDofSpringJoint.h Locally New

    +++ com_jme3_bullet_joints_SixDofSpringJoint.h Locally New

    @@ -0,0 +1,61 @@

    +/* DO NOT EDIT THIS FILE - it is machine generated /

    +#include <jni.h>

    +/
    Header for class com_jme3_bullet_joints_SixDofSpringJoint /

    +

    +#ifndef _Included_com_jme3_bullet_joints_SixDofSpringJoint

    +#define _Included_com_jme3_bullet_joints_SixDofSpringJoint

    +#ifdef __cplusplus

    +extern "C" {

    +#endif

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: enableSpring
    • Signature: (JIZ)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_enableSpring
  • (JNIEnv , jobject, jlong, jint, jboolean);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setStiffness
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setStiffness
  • (JNIEnv , jobject, jlong, jint, jfloat);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setDamping
    • Signature: (JIF)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setDamping
  • (JNIEnv , jobject, jlong, jint, jfloat);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (J)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__J
  • (JNIEnv , jobject, jlong);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: setEquilibriumPoint
    • Signature: (JI)V
  • */

    +JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_setEquilibriumPoint__JI
  • (JNIEnv , jobject, jlong, jint);

    +

    +/

    • Class: com_jme3_bullet_joints_SixDofSpringJoint
    • Method: createJoint
    • Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
  • */

    +JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofSpringJoint_createJoint
  • (JNIEnv , jobject, jlong, jlong, jobject, jobject, jobject, jobject, jboolean);

    +

    +#ifdef __cplusplus

    +}

    +#endif

    +#endif

    Index: com_jme3_bullet_objects_PhysicsRigidBody.cpp

    — com_jme3_bullet_objects_PhysicsRigidBody.cpp Base (BASE)

    +++ com_jme3_bullet_objects_PhysicsRigidBody.cpp Locally Modified (Based On LOCAL)

    @@ -328,7 +328,7 @@

    JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularDamping

    (JNIEnv env, jobject object, jlong bodyId, jfloat value) {

    btRigidBody
    body = (btRigidBody
    ) bodyId;
  •    body-&gt;setDamping(body-&gt;getLinearDamping(), value);<br />
    
  •    body-&gt;setDamping(body-&gt;getAngularDamping(), value);<br />
    

}



/

@@ -556,7 +556,7 @@

JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setLinearSleepingThreshold

(JNIEnv env, jobject object, jlong bodyId, jfloat value) {

btRigidBody
body = (btRigidBody
) bodyId;

  •    body-&gt;setSleepingThresholds(value, body-&gt;getAngularSleepingThreshold());<br />
    
  •    body-&gt;setSleepingThresholds(value, body-&gt;getLinearSleepingThreshold());<br />
    

}



/

@@ -567,7 +567,7 @@

JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularSleepingThreshold

(JNIEnv env, jobject object, jlong bodyId, jfloat value) {

btRigidBody
body = (btRigidBody
) bodyId;

  •    body-&gt;setSleepingThresholds(body-&gt;getLinearSleepingThreshold(), value);<br />
    
  •    body-&gt;setSleepingThresholds(body-&gt;getAngularSleepingThreshold(), value);<br />
    

}



/*

Index: jmeMotionState.cpp

— jmeMotionState.cpp Base (BASE)

+++ jmeMotionState.cpp Locally Modified (Based On LOCAL)

@@ -38,6 +38,7 @@



jmeMotionState::jmeMotionState() {

trans = new btTransform();

  • trans -> setIdentity();

    worldTransform = *trans;

    dirty = true;

    }

    [/patch]

Sorry, I forgot to paste java patch.

[patch]

Index: jme3/bullet/PhysicsSpace.java

— jme3/bullet/PhysicsSpace.java Base (BASE)

+++ jme3/bullet/PhysicsSpace.java Locally Modified (Based On LOCAL)

@@ -546,7 +546,7 @@



private native void removeCollisionObject(long space, long id);


  • private native void addRigidBody(long space, long id);
  • private native void addRigidBody(long space, long id, short group, short mask);



    private native void removeRigidBody(long space, long id);



    @@ -603,7 +603,7 @@

    kinematic = true;

    node.setKinematic(false);

    }
  •    addRigidBody(physicsSpaceId, node.getObjectId());<br />
    
  •    addRigidBody(physicsSpaceId, node.getObjectId(), (short)node.getCollisionGroup(), (short)node.getCollideWithGroups());<br />
    

if (kinematic) {

node.setKinematic(true);

}

Index: jme3/bullet/joints/SixDofJoint.java

— jme3/bullet/joints/SixDofJoint.java Base (BASE)

+++ jme3/bullet/joints/SixDofJoint.java Locally Modified (Based On LOCAL)

@@ -59,14 +59,14 @@

*/

public class SixDofJoint extends PhysicsJoint {


  • private Matrix3f rotA, rotB;
  • private boolean useLinearReferenceFrameA;
  • private LinkedList<RotationalLimitMotor> rotationalMotors = new LinkedList<RotationalLimitMotor>();
  • private TranslationalLimitMotor translationalMotor;
  • private Vector3f angularUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • private Vector3f angularLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);
  • private Vector3f linearUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • private Vector3f linearLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);
  • Matrix3f rotA, rotB;
  • boolean useLinearReferenceFrameA;
  • LinkedList<RotationalLimitMotor> rotationalMotors = new LinkedList<RotationalLimitMotor>();
  • TranslationalLimitMotor translationalMotor;
  • Vector3f angularUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • Vector3f angularLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);
  • Vector3f linearUpperLimit = new Vector3f(Vector3f.POSITIVE_INFINITY);
  • Vector3f linearLowerLimit = new Vector3f(Vector3f.NEGATIVE_INFINITY);



    public SixDofJoint() {

    }

    @@ -160,7 +160,7 @@



    private native void setAngularLowerLimit(long objctId, Vector3f vector);


  • private native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Matrix3f rotA, Vector3f pivotB, Matrix3f rotB, boolean useLinearReferenceFrameA);
  • native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Matrix3f rotA, Vector3f pivotB, Matrix3f rotB, boolean useLinearReferenceFrameA);



    @Override

    public void read(JmeImporter im) throws IOException {

    Index: jme3/bullet/joints/SixDofSpringJoint.java

    — jme3/bullet/joints/SixDofSpringJoint.java Locally New

    +++ jme3/bullet/joints/SixDofSpringJoint.java Locally New

    @@ -0,0 +1,103 @@

    +/*
    • Copyright © 2009-2010 jMonkeyEngine
    • All rights reserved.
  • *
    • Redistribution and use in source and binary forms, with or without
    • modification, are permitted provided that the following conditions are
    • met:
  • *
      • Redistributions of source code must retain the above copyright
    • notice, this list of conditions and the following disclaimer.
  • *
      • Redistributions in binary form must reproduce the above copyright
    • notice, this list of conditions and the following disclaimer in the
    • documentation and/or other materials provided with the distribution.
  • *
      • Neither the name of ‘jMonkeyEngine’ nor the names of its contributors
    • may be used to endorse or promote products derived from this software
    • without specific prior written permission.
  • *
    • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    • "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    • TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    • PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    • CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    • EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    • PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    • PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    • LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    • NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  • */

    +package com.jme3.bullet.joints;

    +

    +import com.jme3.export.JmeExporter;

    +import com.jme3.export.JmeImporter;

    +import com.jme3.math.Matrix3f;

    +import com.jme3.math.Vector3f;

    +import com.jme3.bullet.joints.motors.RotationalLimitMotor;

    +import com.jme3.bullet.joints.motors.TranslationalLimitMotor;

    +import com.jme3.bullet.objects.PhysicsRigidBody;

    +import com.jme3.export.InputCapsule;

    +import com.jme3.export.OutputCapsule;

    +import java.io.IOException;

    +import java.util.Iterator;

    +import java.util.LinkedList;

    +import java.util.logging.Level;

    +import java.util.logging.Logger;

    +

    +/**
    • <i>From bullet manual:</i><br>
    • This generic constraint can emulate a variety of standard constraints,
    • by configuring each of the 6 degrees of freedom (dof).
    • The first 3 dof axis are linear axis, which represent translation of rigidbodies,
    • and the latter 3 dof axis represent the angular motion. Each axis can be either locked,
    • free or limited. On construction of a new btGeneric6DofConstraint, all axis are locked.
    • Afterwards the axis can be reconfigured. Note that several combinations that
    • include free and/or limited angular degrees of freedom are undefined.
    • @author normenhansen
  • */

    +public class SixDofSpringJoint extends SixDofJoint {

    +
  • final boolean springEnabled[] = new boolean[6];
  • final float equilibriumPoint[] = new float[6];
  • final float springStiffness[] = new float[6];
  • final float springDamping[] = new float[6]; // between 0 and 1 (1 == no damping)

    +
  • public SixDofSpringJoint() {
  • }

    +
  • /**
  • * @param pivotA local translation of the joint connection point in node A<br />
    
  • * @param pivotB local translation of the joint connection point in node B<br />
    
  • */<br />
    
  • public SixDofSpringJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) {
  •    super(nodeA, nodeB, pivotA, pivotB, rotA, rotB, useLinearReferenceFrameA);<br />
    
  • }
  • public void enableSpring(int index, boolean onOff) {
  •    enableSpring(objectId, index, onOff);<br />
    
  • }
  • native void enableSpring(long objctId, int index, boolean onOff);

    +
  • public void setStiffness(int index, float stiffness) {
  •    setStiffness(objectId, index, stiffness);<br />
    
  • }
  • native void setStiffness(long objctId, int index, float stiffness);

    +
  • public void setDamping(int index, float damping) {
  •    setDamping(objectId, index, damping);<br />
    

+

  • }
  • native void setDamping(long objctId, int index, float damping);
  • public void setEquilibriumPoint() { // set the current constraint position/orientation as an equilibrium point for all DOF
  •    setEquilibriumPoint(objectId);<br />
    
  • }
  • native void setEquilibriumPoint(long objctId);
  • public void setEquilibriumPoint(int index){ // set the current constraint position/orientation as an equilibrium point for given DOF
  •    setEquilibriumPoint(objectId, index);<br />
    
  • }
  • native void setEquilibriumPoint(long objctId, int index);
  • @Override
  • native long createJoint(long objectIdA, long objectIdB, Vector3f pivotA, Matrix3f rotA, Vector3f pivotB, Matrix3f rotB, boolean useLinearReferenceFrameA);

    +

    +}

    [/patch]

Thanks for the fixes, the joint I will not add yet tho.

Btw, your changes for PhysicsRigidBody are wrong. Also, what about that collisionObject->setActivationState(DISABLE_DEACTIVATION); ?? You would disable deactivation for all physics objects, everything will be computed all the time!!