Just wanted to say that the development and support of jME-Physics will be on hold for some time as both me and Irrisor are away for a few weeks.
I've just made a move across the country (collage) so I'm trying to get my life back together
What needs to be done and how can I help?
Is the next major feature going to be rigid body support? I've read some about that and can try to develop that further if that's going to be the next step in this project. I am extremely excited about the possibilities of this endeavor and when it is at a mature state hopefully we can concentrate wholly on our games instead of worrying about the back-bone so much, but for now I think anything I can do to help I'll do what I can.
Thanks,
darkfrog
With "rigid body support" do you mean dynamic trimeshes? If so, it'd be great if that'd be fixed, though I can't point in any direction for you to start digging
Otherwise, what I'd like to see is that PhysicsGroup/PhysicsNode class that can be a foundation for both vehicles and ragdolls.
Hmmm, okay, well is there any current work done on this and/or a spec you'd like me to follow?
As I understand from other postings I've read regarding this PhysicsGroup/PhysicsNode concept is just a wrapper for physics objects just like Node is in jME? This gives a simple means to apply physics to a group of nodes instead of individually.
My first thought is just to internally maintain a List of the DynamicPhysicsObjects and have the PhysicsGroup or Node extend DynamicPhysicsObject and simply override every method so that it calls the same method on every child? Is it more complicated than this?
Thanks,
darkfrog
darkfrog said:
Hmmm, okay, well is there any current work done on this and/or a spec you'd like me to follow?
Not really... Though we will probably have to add an addObject(PhysicsNode) method to the PhysicsWorld.
As I understand from other postings I've read regarding this PhysicsGroup/PhysicsNode concept is just a wrapper for physics objects just like Node is in jME? This gives a simple means to apply physics to a group of nodes instead of individually.
Right, that's the thought.
My first thought is just to internally maintain a List of the DynamicPhysicsObjects and have the PhysicsGroup or Node extend DynamicPhysicsObject and simply override every method so that it calls the same method on every child? Is it more complicated than this?
That sounds good to me :)
I can have this done tonight…this is really a very simple feature. Especially since if I'm extending DynamicPhysicsObject then I don't have to add any code to PhysicsWorld at all. After I complete this how do I get it into the repository or get it to you guys to put in?
Thanks,
darkfrog
I'll probably have it done and have to rename it before I get a response to this question, but what do you want it to be called "DynamicPhysicsNode", "PhysicsNode", "DynamicPhysicsGroup", or "PhysicsGroup"?
Personally I think it should be called DynamicPhysicsGroup as this will make more logical sense to people as a grouping of physics objects and I can't imagine why you would ever want to group StatisPhysicsObjects it seems only logical to have it be an extension of DynamicPhysicsObject and thus necessary to have the "Dynamic" in the front of it. :o
darkfrog
Okay, I've gotten something functional, but as I've been going through this I've been wondering if perhaps this should be more closely tied to Node? I'd like to discuss the goals of this object further as I'm not confident what I've written is the best thing for this:
package com.jmex.physics;
import java.util.*;
import com.jme.math.*;
/**
* <p>
* <code>DynamicPhysicsGroup</code> is a wrapper class for DynamicPhysicsObjects
* to allow forces to be applied to an entire grouping of objects at a time.
* </p>
* <p>
* This is not necessary to add to a scene as the underlying DynamicPhysicsObjects
* should be added to the scene and this directly works with them.
* </p>
*
* @author Matthew D. Hicks
* @see com.jmex.physics.DynamicPhysicsObject
*/
public class DynamicPhysicsGroup {
// The DynamicPhysicsObjects attached to this group
private ArrayList children;
public DynamicPhysicsGroup() {
children = new ArrayList();
}
/**
* Add a DynamicPhysicsObject to this group
*
* @param dpo
* The DynamicPhysicsObject to add
*/
public void addObject(DynamicPhysicsObject dpo) {
children.add(dpo);
}
/**
* Calls syncWithGraphical() on all children of this group
*/
public void syncWithGraphical() {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.syncWithGraphical();
}
}
/**
* Returns true if and ONLY if all of the underlying
* DynamicPhysicsObjects are synced.
*
* @return
*/
public boolean isSynced() {
DynamicPhysicsObject dpo;
Quaternion qPhysics;
Vector3f vPhysics;
Quaternion qGraphics;
Vector3f vGraphics;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
qPhysics = dpo.getPhysicalEntity().getQuaternion();
vPhysics = dpo.getPhysicalEntity().getPosition();
qGraphics = dpo.getSpatial().getWorldRotation();
vGraphics = dpo.getSpatial().getWorldTranslation();
if ((qPhysics.x != qGraphics.x) ||
(qPhysics.y != qGraphics.y) ||
(qPhysics.z != qGraphics.z) ||
(qPhysics.w != qGraphics.w) ||
(vPhysics.x != vGraphics.x) ||
(vPhysics.y != vGraphics.y) ||
(vPhysics.z != vGraphics.z)) {
return false;
}
}
return true;
}
public void addForce(Vector3f force) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.addForce(force);
}
}
public void addRelativeForce(Vector3f force) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.addRelativeForce(force);
}
}
public void addTorque(Vector3f torque) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.addTorque(torque);
}
}
public void setTorque(Vector3f torque) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.setTorque(torque);
}
}
public void addRelativeTorque(Vector3f torque) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.addRelativeTorque(torque);
}
}
public void setLinearVelocity(Vector3f velocity) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.setLinearVelocity(velocity);
}
}
public void setAngularVelocity(Vector3f velocity) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.setAngularVelocity(velocity);
}
}
public void setGravityMode(int mode) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.setGravityMode(mode);
}
}
public void setEnabled(boolean enabled) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.setEnabled(enabled);
}
}
public void resetForces() {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.resetForces();
}
}
public void addForceAtRelativePosition(Vector3f force, Vector3f localTranslation) {
DynamicPhysicsObject dpo;
for (int i = 0; i < children.size(); i++) {
dpo = (DynamicPhysicsObject)children.get(i);
dpo.addForceAtRelativePosition(force, localTranslation);
}
}
}
If you're happy with that feel free to check it in as well as my getWorld() method I keep hounding you about. :-p Otherwise lets discuss more of what the goals of this are and get a cleaner solution.
Thanks,
darkfrog