Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 3 [4] 5 6
  ignore  |  Print  
  Java port of Bullet Physics Library  (Read 102304 times)
0 Members and 1 Guest are viewing this topic.
Offline jezek2
« Reply #90 - Posted 2008-08-07 11:22:35 »

When I launch the vehicle demo, I get this:

org.lwjgl.LWJGLException: Could not choose visual
   at org.lwjgl.opengl.LinuxDisplayPeerInfo.initDefaultPeerInfo(Native Method)
   at org.lwjgl.opengl.LinuxDisplayPeerInfo.<init>(LinuxDisplayPeerInfo.java:52)
   at org.lwjgl.opengl.LinuxDisplay.createPeerInfo(LinuxDisplay.java:702)
   at org.lwjgl.opengl.Display.create(Display.java:779)
   at org.lwjgl.opengl.Display.create(Display.java:733)
   at com.bulletphysics.demos.opengl.LWJGL.main(LWJGL.java:53)
   at com.bulletphysics.demos.vehicle.VehicleDemo.main(VehicleDemo.java:609)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at com.sun.javaws.Launcher.executeApplication(Launcher.java:1272)
   at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1218)
   at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1065)
   at com.sun.javaws.Launcher.run(Launcher.java:105)
   at java.lang.Thread.run(Thread.java:619)

Odd, what graphics card/drivers/platform did you test on? Does other LWJGL based apps work for you? I'm using LWJGL 2.0rc1.

Is it possible to use JBullet with JOGL?

JBullet as physics engine is independent of any graphics API. The demo framework uses OpenGL through LWJGL. The drawing and input is already abstracted so it can support software renderer for applet demo, so it should be pretty easy to add JOGL support. If you're interested you can contribute the code Smiley
Offline jezek2
« Reply #91 - Posted 2008-08-07 11:26:21 »

But I was wondering, are  the walls meant to do anything?

They should be there just for something to block falling out. Or did you test the applet demo? The software renderer is currently very simple and there is only linear non-perspective interpolation, so they sometimes occlude geometry in front of them.
Offline LeoMaheo

Senior Newbie





« Reply #92 - Posted 2008-08-10 04:52:21 »

Hi Jezek2!

May I ask, for what projects do you use JBullet (curious Smiley) ?
For how long do you believe you'll continue developing JBullet?

Best wishes with future development,
Magnus
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jezek2
« Reply #93 - Posted 2008-08-10 07:32:21 »

Hi Jezek2!

May I ask, for what projects do you use JBullet (curious Smiley) ?

I'm working on few projects using it, two are major for me.

For how long do you believe you'll continue developing JBullet?

As long as there will be features interesting for my applications I will port them. Some features I do not use, but are usually not that complex and creates completness of library. In latest development version I'm focusing on writing descriptive JavaDocs and better method names and encapsulation. Goal is to transform it to a normal Java library without much signs of C++ origin. There is possibility that development will stagnate, but it's open source and I think there won't be problem supporting at least contributors in future.

Best wishes with future development,
Magnus

Thanks Smiley

To all: any ideas how to make JBullet more visible? It has some (small) popularity, but when I try googling it, not many sites are mentioning it.
Offline soul8o8

Junior Newbie





« Reply #94 - Posted 2008-08-12 14:40:24 »

To all: any ideas how to make JBullet more visible? It has some (small) popularity, but when I try googling it, not many sites are mentioning it.

First, great work jezek! Keep it up!

May I make some modest suggestions on how to increase visibilty?
(If not then please disregard the following :)

1) Start a project for jBullet on sourceforge.net (or equivalent). It doesn't mean you should use their tools. Just get a space and forward traffic to your home page. In the future it might also be a very good platform for incorporating contributors etc. It's also a nice way of making sure that the project never "disappears", and that makes people more confident and willing to use the library. (Of course that would require committing the code every once in a while to the sf code repository.)

2) Get more people involved in the project. Try to get people who write game engines, games and other stuff to contribute, test and use the library. They will write about it on their websites and so on. This might not be an option, depending on how "personal" this project is to you. You know best. Follow your heart. (Hehe gee that sounded corny..) The theory is, more people on the project, more activity and exposure.

3) Put up a minimal Wordpress website with a simple design. Utilize the blog-feature and post regular news. (Make sure people can subscribe to that RSS-feed.) I strongly suggest Wordpress as it's efficient, simple and a SEO-winner.

4) Make YouTube videos and screenshots and put up on the blog/website.

5) Create a jBullet logo that people can put in their games/websites to show that they use it.

6) Make screenshots and videos. Did I already say that? ;) The trick is really to make screenshots and videos that tickle people's imagination, imho. A checkerd plane with some boxes colliding is not very fun, apart from the occasional academic left-brain kick. A nicely lit basement with some crates moving around and being destroyed when shot at, tells the story.

I believe, that if you got all this going, Google rank will happend by itself. (Although a nice proper domain, like jbullet.org, wouldn't hurt.)

I'm kinda a layman-hobby-learning-game-deving-in-my-spare-time-guy, and I'd love to play around with jBullet, and I will a some point :) Anyway, if any of the suggestions above sound good and you wanna give them a try, but you feel pressed on time, then I'd be happy to help out. I'm a web designer and could help out with 1), 3) and 5). In the future I might be able to do videos and screenshots too. Just let me know somehow if I can help out!

ciao!
/soul8o8


Offline jezek2
« Reply #95 - Posted 2008-08-12 20:03:54 »

First, great work jezek! Keep it up!

May I make some modest suggestions on how to increase visibilty?
(If not then please disregard the following Smiley

Hi, thanks for your suggestions. I will be thinking about them more. You're right that more core developers would be really nice, but the problem is, that I feel that not much developers are interested in doing this kind of work. I somewhat always do the hard things that others don't have energy to put on, like this task of porting huge amount of C++ code to Java, it also requires quite good knowledge of both languages. I've been there before on another open source project: MetaTheme which provides unified look and feel of major Linux GUI toolkits (including Swing). It had some nice exposure, and even few contributors, but no one touched core Smiley Again you would need to master three different GUI toolkits to touch it... I use it everyday, it's not perfect but usable for me, and I still have future plans, just I had to abandon it for few years because of other projects (and partially also for regaining energy and rethinking architecture).

So JBullet is not that ordinary project. Also creating some news is problematic, since most work is about porting existing library and "only" fiddling with details on top of that. Even the original Bullet doesn't have news too often Smiley

I think that more real demo could be done as a part of my "main" project (for which JBullet was partly created). I plan to add some testing physics scene, could be used also for promoting JBullet, by both screenshots/videos and actual demo application. As a side effect I would gather some stats how it run on more HW (I'm especially curious about ATI Wink).
Offline soul8o8

Junior Newbie





« Reply #96 - Posted 2008-08-13 16:23:18 »


Cool jezek!
I understand your concerns and you have my respect :D
My offer still stands, just let me know at any time if you think I could help!


Anyway, I was really blown away by the webstart demos of jBullet—it's really looking good!
Btw, are you by any chance thinking about implementing the continious-step-thing?

Take care!
br
/soul8o8
Offline jezek2
« Reply #97 - Posted 2008-08-13 19:46:27 »

Cool jezek!
I understand your concerns and you have my respect Cheesy
My offer still stands, just let me know at any time if you think I could help!

Thanks for offer. I want to do the website myself (hosting/code-wise), but if you're in a creative mood you can try to look how it could be improved (content, design, logo, etc.). Your contribution is welcome, though as this is subjective thing, also count that I might not like some idea.

Anyway, I was really blown away by the webstart demos of jBullet—it's really looking good!

Yeah, they amazes me too Grin

Btw, are you by any chance thinking about implementing the continious-step-thing?

Currently it's only partially supported in original Bullet, and interaction between rigid bodies is non-existent. But it seems it will be improved in upcoming new versions. This is definitely thing that I want to port when it's ready Smiley
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #98 - Posted 2008-08-16 19:38:09 »

Quote
You're right that more core developers would be really nice, but the problem is, that I feel that not much developers are interested in doing this kind of work. I somewhat always do the hard things that others don't have energy to put on, like this task of porting huge amount of C++ code to Java, it also requires quite good knowledge of both languages.

Well I had to do the exact same thing porting ODE for JOODE.

Your attempt seems to be taking off pretty well. Can you tell me the features of JBullet?

What is the integrator?
What is the constraint satisfaction technique?  And how does it cope with redundant constraints like a door with two hinges?

Can you retrieve the actual forces used to enforce constraints?

Tom



Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Offline jezek2
« Reply #99 - Posted 2008-08-16 20:37:13 »

Well I had to do the exact same thing porting ODE for JOODE.

Your attempt seems to be taking off pretty well.

Thanks Smiley

Can you tell me the features of JBullet?

What is the integrator?
What is the constraint satisfaction technique?  And how does it cope with redundant constraints like a door with two hinges?

Can you retrieve the actual forces used to enforce constraints?

You should rather post these questions to original Bullet forum, I'm not a physics guy Smiley I'm more an user, but willing to see what is behind to better understand whole problem and it's specifics as every abstraction is leaking implementation details. Bullet is nice in it's object hierarchy, allowing using just stuff that you need and it even doesn't have to be for physics. As a nice side effect of porting I have much better whole image of internals, something that's very useful when implementing it for my purposes or possibly extending it.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #100 - Posted 2008-08-16 23:49:16 »

Quote
I'm not a physics guy Smiley

Haha, I wasn't initially either. I'll look it up.

Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Offline ewjordan

Junior Member





« Reply #101 - Posted 2008-08-17 03:45:55 »

I'm not involved with Bullet, but I'm pretty sure it uses most of the same techniques (at the core) as Box2d - they both solve constraints with sequential impulses and warm starting.  Forces should be available quite easily by pulling the warm starting values (there's probably a function to get the constraint force, or maybe you can get it from a callback), and redundant constraints should require no special treatment (iterative solvers don't have problems with redundant or inconsistent constraints because they apply constraints one at a time, though this can become unstable in some cases).  The integrator is probably symplectic Euler, though I could definitely be wrong there.

If and when continuous collision detection comes back, Bullet's approach is conservative advancement using GJK for nearest point distance calculations.  Can't wait for that to show up (or rather, be brought back - it used to work, I think), it's the killer feature that makes me love Box2d over all other 2d physics engines, it will be awesome to have it in 3d, too!
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #102 - Posted 2008-08-18 18:57:57 »

Yeah your right. Its sequential impulse whatsit.

Bullet does not offer me a way of getting at the forces exerted by the constraint though (that I could find anyway). Its not as easy as unwrapping it from the solver though, because the info at the solver level has allready integrated geometry information. So you would have to transform the info back out again to determine the force exerted by an anchor at a specific location (not a hard transformation admittedly, but someone has to write the transformation and the callback option for the solver).

Shame to hear the curvey collision detection is not currently working. That was the thing I liked most about Bullet.


Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Offline erwincoumans

Junior Newbie





« Reply #103 - Posted 2008-09-11 22:07:43 »


Bullet constraint solver is based on iterative sequential impulses, which is the very similar to ODE quickstep solver.

You should be able to get the applied impulse (=timestep*applied force) from the btManifoldPoint member m_appliedImpulse (in the C++ version at least).

What do you mean by 'curvey' collision detection? The btCollisionWorld::convexSweepQuery should be working fine. We'll try to make some basic CCD motion clamp support for Bullet 2.72.
Thanks,
Erwin

By the way, in the other thread they report some showstopper/issues on JBullet, lack of translational constraints? Aren't the btSliderJoint and such ported yet?
http://www.java-gaming.org/topics/odejava-project-s-next-steps/19108/msg/150571/view.html#msg150571
It would be good to get those remaining issues fixed.

Offline jezek2
« Reply #104 - Posted 2008-09-19 08:23:12 »

New version available on JBullet homepage.

Changes in release 20080917:
- Documented many classes and adjusted existing descriptions
- Minor API changes
- Changed method names for callbacks to be more descriptive
- Improved BulletGlobals
- Added SliderConstraint
- Added ForkLiftDemo
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #105 - Posted 2008-09-29 02:24:21 »

Great work with the JBullet adaptation. I may use it in the near future.

See my work:
OTC Software
Offline LeoMaheo

Senior Newbie





« Reply #106 - Posted 2008-11-30 16:15:02 »

Hi jezek2,

I have decided to port my game from using ODE to use JBullet. I do not want any native libs in my game; I don't won't security dialogs to pop up.

Are you familiar with Kenji Hiranabe's version of javax.vecmath?
(http://www.objectclub.jp/download/vecmath_e)

It is compatible with Sun's vecmath, at least earlier versions of Sun's vecmath. It uses "No 'new' operator at all except for GMatrix, GVecator and error exceptions." ( http://java-house.jp/ml/archive/j-h-b/017987.html )

My game API uses my own modified version of Hiranabe's vecmath (the API allows people to create their own Artificial Intelligence modules). It provides mutable, read only and immutable Vector3f:s, Matrix3f:s, etc., with a small memory footprint and, I think, no significant impact on performance. I think it is largely backwards compatible with Hiranabe's and Sun's versions.

I will probably maintain my own vendor branch of JBullet, where I have replaced Sun's vecmath with my own modified version of Hiranabe's vecmath. (Vendor branches: http://svnbook.red-bean.com/en/1.1/ch07s05.html )

Thanks,
Magnus
Offline jezek2
« Reply #107 - Posted 2008-11-30 17:23:54 »

Hi jezek2,

I have decided to port my game from using ODE to use JBullet. I do not want any native libs in my game; I don't won't security dialogs to pop up.

Nice to hear Smiley

Are you familiar with Kenji Hiranabe's version of javax.vecmath?
(http://www.objectclub.jp/download/vecmath_e)

It is compatible with Sun's vecmath, at least earlier versions of Sun's vecmath. It uses "No 'new' operator at all except for GMatrix, GVecator and error exceptions." ( http://java-house.jp/ml/archive/j-h-b/017987.html )

Yeah I know it. I'll probably distribute it instead of the Sun's mainly because of license (Sun doesn't allow GPLv3 usage with it's GPLv2 only+classpath exception and usage of the older non-GPL license with GPL is in grey area).

My game API uses my own modified version of Hiranabe's vecmath (the API allows people to create their own Artificial Intelligence modules). It provides mutable, read only and immutable Vector3f:s, Matrix3f:s, etc., with a small memory footprint and, I think, no significant impact on performance. I think it is largely backwards compatible with Hiranabe's and Sun's versions.

I'm interested in your approach. I've been myself experimenting with different ways how to handle vecmath library, but in the end found Sun's vecmath approach the best. Could you share JavaDoc or something (can be privately by e-mail)?

I will probably maintain my own vendor branch of JBullet, where I have replaced Sun's vecmath with my own modified version of Hiranabe's vecmath. (Vendor branches: http://svnbook.red-bean.com/en/1.1/ch07s05.html )

That's probably best option, the other option is to convert between Sun's vecmath and yours (which is not much problem as physics tends to be quite separated from other things anyway). There exist many vecmath libraries (mostly private/custom) and it would be impossible to support them.
Offline LeoMaheo

Senior Newbie





« Reply #108 - Posted 2008-12-06 21:36:23 »

I'm interested in your approach. I've been myself experimenting with different ways how to handle vecmath library, but in the end found Sun's vecmath approach the best. Could you share JavaDoc or something (can be privately by e-mail)?

I'd be happy to. Please find below usage examples, performance notes and the actual implementation.

Notes:
Memory overhead: New class field: ``Object key''
Performance overhead: ``if != null'' tests.

Concerning memory overhead:
According to the Netbeans 6.5 profiler:
For Quat4f and Vector3f, 33% more memory is required to store an instance.
For Matrix3f, no additional memory (?HotSpot happens to align memory so there's room fore Sealable.key anyway?)
For Matrix4f, 11% more memory is required to store an instance.


Usage examples:

Immutable variables (sealForever()):
1  
2  
3  
4  
5  
public class Vector3f extends Tuple3f implements Serializable {

    public static final Vector3f PLUS_X = new Vector3f(1, 0, 0).sealForever();
    public static final Vector3f PLUS_Y = new Vector3f(0, 1, 0).sealForever();
    ...



Read-only variables (seal() and unseal()).

Can actually be written to by the one with the appropriate key.
This is exemplified by interpolate(...) below (`limbRotations' is used as key).
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
public class KeyFrame<L extends Enum<L> & BodyPart> {

    // ...

   /**
    * Also seals the Quat4f instances. */

   private final EnumMap<L, Quat4f> limbRotations;

   /**
    * Sets the rotation of {@code limb} to a normalized clone of {@code rotation}.
    */

   public void setRotation(L limb, Quat4f rotation) {
      limbRotations.put(limb, new Quat4f(rotation).normalize().seal(limbRotations));
   }

   /**
    * Returns the rotation of {@code limb}, for read access only.
    */

   public Quat4f getRotation(L limb) {
      return limbRotations.get(limb);
   }

   /**
    * Interpolates this {@code KeyFrame} and {@code target},
    * and places the result into this instance.
    * @param amount how close to {@code target} the resulting key frame should be. In [0, 1].
    */

   public void interpolate(KeyFrame<L> target, float amount) {

      for (Entry<L, Quat4f> entry : limbRotations.entrySet()) {
         L limb = entry.getKey();
         Quat4f quatThis = entry.getValue();
         Quat4f quatTarget = target.limbRotations.get(limb);
         quatThis.unseal(limbRotations);
         quatThis.interpolate(quatTarget, amount);
         quatThis.seal(limbRotations);
      }
   }


Implementation:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
package madmath;

public abstract class Sealable {
    /**
     * Read-only forever tag.
     */

    private static final Object IMMUTABLE = new Object();
    /**
     * Read-only lock.
     */

    private transient Object key = null;

    public Sealable seal(Object key) {
        if (this.key != null && this.key != key)
            throw new IllegalArgumentException(getClass().getSimpleName() +
                    " instance already sealed with other key");
        if (key == null)
            throw new NullPointerException("key is null");
        this.key = key;
        return this;
    }

    public Sealable sealForever() {
        return seal(IMMUTABLE); // cannot remove this seal
   }

    public Sealable unseal(Object key) {
        if (this.key != null && this.key != key)
            throw new IllegalArgumentException("Wrong key");
        this.key = null;
        return this;
    }

    void _checkWritable() {
        if (key != null)
            throw new IllegalStateException(getClass().getSimpleName() + " instance is " +
                    (key == IMMUTABLE ? "immutable" : "read only"));
    }

}


Before modification, _checkWritable() is invoked.
For example,
1  
2  
3  
4  
5  
6  
7  
public abstract class Tuple3f extends Sealable implements Serializable {
    public final void set(float x, float y, float z) {
   _checkWritable();
   this.x = x;
   this.y = y;
   this.z = z;
    }


Here is the mem test program. I run it, and check the memory usage reported by the Netbans profiler. Hope results are reliable...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
public class MemTest {

   static class SmallVec3f {
      float x, y, z;
   }

   static class SmallQuat4f {
      float x, y, z, w;
   }

   static class SmallMat3f {
      float m00, m01, m02,
            m10, m11, m12,
            m20, m21, m22;
   }

   static class SmallMat4f {
      float m00, m01, m02, m03,
            m10, m11, m12, m13,
            m20, m21, m22, m23,
            m30, m31, m32, m33;
   }

   public static void main(String args[]) {

      int num = 10000;
      ArrayList<Object> objs = new ArrayList<Object>();

      for (int i = 0; i < num; ++i) {
         objs.add(new SmallVec3f());
         objs.add(new SmallQuat4f());
         objs.add(new SmallMat3f());
         objs.add(new SmallMat4f());

         // These 4 below have an additional field ``Object key''.
        objs.add(new Vector3f());
         objs.add(new Quat4f());
         objs.add(new Matrix3f());
         objs.add(new Matrix4f());
      }

      while (true) {
         // check profiler results
     }
   }
}



Regards, Magnus

Offline jezek2
« Reply #109 - Posted 2008-12-07 08:51:51 »

That's really interesting approach Smiley

I think that the overhead is minimal and shouldn't be problem because if you need to have many vectors (like 10000 or so), it's better to store them in float[] array or FloatBuffer and do bulk operations on it anyway.

I think it would be better to move the exception generation in _checkWritable() to own private method, so you get better chance to inline in HotSpot. Also for better clarity, it would be better to always use descriptive private static final field as key, instead of reusing some array, as it can get messy when the code evolves.

How do you handle direct operation on x,y,z fields? Did you make them protected and provide setter/getters or are they naked as in original vecmath?

I see slight problem with side effects in your approach. For example you return some vector, the caller is using it for some computation and calls some other method which changes the same instance and suddendly caller is using different data. This kind of unintuitive behaviour is very dangerous. Or when they store the instance somewhere else for later usage Smiley

On the other hand it gives nice degree of safety for performance sensitive code and could be fighted by stating everywhere that the returned vectors are meant only for intermediate usage.

Personally I still like better the output parameters and shifting up the care of allocation to the caller, as it's more intuitive and less error-prone, though some more copying will happen and you need to pass the out parameter which can be annoying sometimes Wink
Offline LeoMaheo

Senior Newbie





« Reply #110 - Posted 2008-12-07 22:01:26 »

How do you handle direct operation on x,y,z fields? Did you make them protected and provide setter/getters or are they naked as in original vecmath?

Package private, and getters and setters.
(But I just made them public again, for now, since JBullet does lots of direct access to x,y,z.)

I see slight problem with side effects in your approach. For example you return some vector, the caller is using it for some computation and calls some other method which changes the same instance and suddendly caller is using different data. This kind of unintuitive behaviour is very dangerous. Or when they store the instance somewhere else for later usage Smiley

That's a good point.

I don't, however, expose such function calls to the end users of my application (= artificial intelligence (AI) module writers).
((The KeyFrame code snippet in my previous post is from a game internal class (private class loader).))

However, the values of read-only variables (read-only from the AI module's point of view) do change. But at well-defined points in time:
In my application, the simulation state (rotations, locations etc. - lots of Matrix4f) is copied to a snapshot. The AI modules then do computations based on that snapshot of the simulation. After a while, the AI modules are done thinking. The snapshot is then updated with new simulation data: The same instance of e.g. a Vector3f is updated with new simulation data, although it is read only all the time, from the AI modules' point of view.

And you're right that other users of the math lib could write unintuitive code in the way you described.

Personally, when constructing game internal stuff visible to no one but me:
Were it not for read only instances, I might, for the sake of performance, or for the sake of laziness, expose mutable Vector3f:s etc., for read access only (without enforcing read-access-only). I believe I here would find the lock-unlock-lock approach safer.


Personally I still like better the output parameters and shifting up the care of allocation to the caller, as it's more intuitive and less error-prone, though some more copying will happen and you need to pass the out parameter which can be annoying sometimes Wink

Yes, I might actually also like the original vecmath approach better. After all, x,y,z are still directly accessible, and the code is simpler to understand.

Actually, since JBullet does lots of direct access to x,y,z and it seems to take long to rewrite and perhaps maintain all such changes in a separate vendor branch,
I'll probably ditch the read-only etc. stuff.
Then I'll save lots of time; I haven't really started using that read-only fancy-fancy stuff yet, only at one place (the code snippet in my previous post).

And in the future, when HotSpot does escape analysis, I suppose all such read only stuff will be fairly pointless.
Offline citizen.cane

Innocent Bystander





« Reply #111 - Posted 2008-12-31 22:51:46 »

hi guys,

I tried to add some restrictions to rigidBodies within an InternalTickCallback.
Especially I tried to restrict the Z-movement of moving sphere on a surface ground to avoid jumping because of xy-torque or gravity in combination with full restitution. Because I need full restitution for collsion with static objects with the xy-layer, but not in the z-layer.
But my tries-outs didn't work not or causing strange collision detection behavior after changing the interpolated transform of a rigid body. Perhaps the strange effects are caused, because the rigidBodies are overlaping before the moment of the transform is changed.
My current work around solution is to restrict the active transform not within the internal tick callback, instead I simply perform rigidBody.setWorldTransfrom() as postStep.

short reproducing source code snippet:

      world.setInternalTickCallback(
         new InternalTickCallback() {
            public void internalTick(DynamicsWorld world, float timeStep) {

                                                // any body that overlaps ...
                                                RigidBody rigidBody = ... ;
                  
                  Transform activeTransform = new Transform();
                  rigidBody.getInterpolationWorldTransform(activeTransform);
                    activeTransform.origin.set(activeTransform.origin.x, activeTransform.origin.y, 0);
                    
                    // DOES NOTHING:
                    //rigidBody.setWorldTransform(activeTransform);
                    //rigidBody.getMotionState().setWorldTransform(activeTransform);
                    //rigidBody.predictIntegratedTransform(1, activeTransform);
                    //rigidBody.predictIntegratedTransform(timeStep, activeTransform);

                    // CAUSES STRANGE COLLISION BEHAVIOR
                    rigidBody.setInterpolationWorldTransform(activeTransform);
               }
         }
      };

Q: How to change the active transform of a rigid body correctly within an internal tick callback (and probably at the situation that ridigBodies can overlap before I change the transform)?

thank you for any help or hint!
Offline LeoMaheo

Senior Newbie





« Reply #112 - Posted 2009-01-09 22:13:46 »

Hi citizen.cane,

Q: How to change the active transform of a rigid body correctly within an internal tick callback (and probably at the situation that ridigBodies can overlap before I change the transform)?

Perhaps setWorldTransform would work from inside the internal tick callback if you cease using MotionStates.

It seems to me that MotionStates are not intended for usage from within then internal step callback.

Details follow.

short reproducing source code snippet:

         ...                    
                    // DOES NOTHING:
                    //rigidBody.setWorldTransform(activeTransform);
                    //rigidBody.getMotionState().setWorldTransform(activeTransform);
                    //rigidBody.predictIntegratedTransform(1, activeTransform);
                    //rigidBody.predictIntegratedTransform(timeStep, activeTransform);

                    // CAUSES STRANGE COLLISION BEHAVIOR
                    rigidBody.setInterpolationWorldTransform(activeTransform);


Concerning predictIntegratedTransform.
I thing predictIntegratedTransform is a Bullet internal function that you should/need not use.

Concerning getMotionState().setWorldTransform.
Directly after internalSingleStepSimulation(),
(from which
internalTickCallback.internalTick(this, timeStep);
is invoked),
synchronizeMotionStates();
is invoked
-- and it overwites whatever you've written to your motion states.
So I think you cannot use getMotionState().setWorldTransform(activeTransform) from inside the internal tick callback.

Concerning CollisionObject.setWorldTransform.
It seems that before [the first time the actual step is done, and your-internal-tick-callback is invoked] each DynamicsWorld.step,
the CollisionObject.worldTransform is overwritten with the MotionState value (if you use MotionStates).
From inside DiscreteDynamicsWorld.saveKinematicState(...).
So, if you use MotionStates, and invoke CollisionObject.setWorldTransform from inside the internal tick callback, then I think the CollisionObject.setWorldTransform call has no effect (unless many internal ticks happens each DynamicsWorld.step; then, it'd have effects sometimes only), since whatever you've written to CollisionObject.worldTransform will be overwirtten by the MotionState's world transform in the next call to DynamicsWorld.step.

But it's late now and time to sleep, so I might be wrong.

Regards and sleep well,
Magnus
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #113 - Posted 2009-01-25 17:40:48 »

Quote
org.lwjgl.LWJGLException: Could not choose visual

I got this too. I changed the color depth from 24 to 16 in the LWGL.main() to fix it. I use a linux laptop without a working 3D gfx card so I use the software openGL implementation.

Tom

Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Offline jimbo8

Innocent Bystander





« Reply #114 - Posted 2009-03-10 11:16:59 »

CollisionDetectionDemo - Please can you help a complete newbie to get this code working

I have tried to implement the bullet CollisionDetectionDemo.cpp as a java demo along the lines of the other jbullet demos. Unfortunately I am new to jbullet, don't know either c++ or openGL, hence I am stuck!

Here is my code:

/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/

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.
*/


///
/// CollisionInterfaceDemo shows high level usage of the Collision Detection.
///
import com.bulletphysics.collision.shapes.BoxShape;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector3d;
import javax.vecmath.Matrix3f;
import javax.media.j3d.Transform3D;
import com.bulletphysics.collision.dispatch.CollisionDispatcher;
import com.bulletphysics.collision.dispatch.CollisionWorld;
import com.bulletphysics.collision.dispatch.CollisionObject;
import com.bulletphysics.collision.narrowphase.VoronoiSimplexSolver;
import com.bulletphysics.collision.broadphase.AxisSweep3;
import com.bulletphysics.collision.narrowphase.ManifoldPoint;
import com.bulletphysics.collision.narrowphase.SimplexSolverInterface;
import com.bulletphysics.collision.dispatch.CollisionDispatcher;
import com.bulletphysics.collision.narrowphase.PersistentManifold;
import com.bulletphysics.collision.dispatch.DefaultCollisionConfiguration;
import com.bulletphysics.linearmath.Transform;
import static com.bulletphysics.demos.opengl.IGL.*;
import com.bulletphysics.demos.opengl.GLDebugDrawer;
import com.bulletphysics.demos.opengl.IGL;
import com.bulletphysics.demos.opengl.LWJGL;
import org.lwjgl.LWJGLException;
import com.bulletphysics.demos.opengl.DemoApplication;
import com.bulletphysics.demos.opengl.*;


public class CollisionInterfaceDemo extends DemoApplication  {

   float yaw=0.f;
   float pitch=0.f;
   float roll=0.f;
   int maxNumObjects = 4;
   int numObjects = 2;
   GLDebugDrawer debugDrawer;
   CollisionObject[] objects = new CollisionObject[maxNumObjects];
   CollisionWorld   collisionWorld;
   
   static VoronoiSimplexSolver sGjkSimplexSolver; // HuhHuhHuhHuh?
   SimplexSolverInterface gGjkSimplexSolver = sGjkSimplexSolver; //?HuhHuhHuhHuh?

//GL_Simplex1to4 simplex; HuhHuhHuhHuhHuh

   public CollisionInterfaceDemo(IGL gl){
      super(gl);
      setDebugMode(Cool;
   }

   public static void main(String[] args)  throws LWJGLException {
      CollisionInterfaceDemo  collisionInterfaceDemo = new CollisionInterfaceDemo(LWJGL.getGL());
      collisionInterfaceDemo.initPhysics();
      collisionInterfaceDemo.clientResetScene();
      LWJGL.main(args, 800, 600, "Collision Interface Demo",collisionInterfaceDemo);
   }

    public void   initPhysics(){
      //m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
         
      Matrix3f basisA = new Matrix3f();
      basisA.setIdentity();
   
      Matrix3f basisB = new Matrix3f();
      basisB.setIdentity();
   
      objects[0] = new CollisionObject();
      objects[1] = new CollisionObject();
      objects[0].getWorldTransform(new Transform()).set(basisA);
      objects[1].getWorldTransform(new Transform()).set(basisB);
   
      //btPoint3   points0[3]={btPoint3(1,0,0),btPoint3(0,1,0),btPoint3(0,0,1)};
      //btPoint3   points1[5]={btPoint3(1,0,0),btPoint3(0,1,0),btPoint3(0,0,1),btPoint3(0,0,-1),btPoint3(-1,-1,0)};
      
      BoxShape boxA = new BoxShape(new Vector3f(1,1,1));
      BoxShape boxB = new BoxShape(new Vector3f(0.5f,0.5f,0.5f));
      //ConvexHullShape   hullA(points0,3);
      //hullA.setLocalScaling(btVector3(3,3,3));
      //ConvexHullShape   hullB(points1,4);
      //hullB.setLocalScaling(btVector3(4,4,4));
   
      objects[0].setCollisionShape(boxA);//&hullA;
      objects[1].setCollisionShape(boxB);//&hullB;
   
       DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
       CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
      Vector3f worldAabbMin = new Vector3f(-1000,-1000,-1000);
      Vector3f worldAabbMax = new Vector3f(1000,1000,1000);
   
      AxisSweep3   broadphase = new AxisSweep3(worldAabbMin,worldAabbMax);
      
      //SimpleBroadphase is a brute force alternative, performing N^2 aabb overlap tests
      //SimpleBroadphase*   broadphase = new btSimpleBroadphase;
   
      collisionWorld = new CollisionWorld(dispatcher,broadphase,collisionConfiguration);
         
      collisionWorld.addCollisionObject(objects[0]);
      collisionWorld.addCollisionObject(objects[1]);
      
for (int i=0;i<numObjects;i++){
System.out.println("Object=" + objects);      
System.out.println("Object collisionShape=" + objects.getCollisionShape());      
System.out.println("Object worldTransform=" + objects.getWorldTransform(new Transform()));      
}      
   }


//to be implemented by the demo

   public void clientMoveAndDisplay(){
      displayCallback();
   }

   public void displayCallback() {
       gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      gl.glDisable(GL_LIGHTING);
   
      collisionWorld.setDebugDrawer(new GLDebugDrawer(gl));
      
      if (collisionWorld != null) collisionWorld.performDiscreteCollisionDetection();
   
      ///one way to draw all the contact points is iterating over contact manifolds / points:
   
      int numManifolds = collisionWorld.getDispatcher().getNumManifolds();
System.out.println("numManifolds =" + numManifolds);
      for (int i=0;i<numManifolds;i++)
      {
         PersistentManifold contactManifold = collisionWorld.getDispatcher().getManifoldByIndexInternal(i);
System.out.println("ContactManifold =" + contactManifold);
         CollisionObject obA = (CollisionObject)(contactManifold.getBody0());
         CollisionObject obB = (CollisionObject)(contactManifold.getBody1());
         contactManifold.refreshContactPoints(obA.getWorldTransform(new Transform()),obB.getWorldTransform(new Transform()));
   
         int numContacts = contactManifold.getNumContacts();
System.out.println("numContacts =" + numContacts);
         for (int j=0;j<numContacts;j++)
         {
            ManifoldPoint pt = contactManifold.getContactPoint(j);
System.out.println("Manifold pt=" + pt);
            gl.glBegin(GL_LINES);
            gl.glColor3f(1, 0, 1);
            
            Vector3f ptA = pt.getPositionWorldOnA(new Vector3f());
            Vector3f ptB = pt.getPositionWorldOnB(new Vector3f());
   
            gl.glVertex3f(ptA.x,ptA.y,ptA.z);
            gl.glVertex3f(ptB.x,ptB.y,ptB.z);
            gl.glEnd();
         }
   
         //you can un-comment out this line, and then all points are removed
         //contactManifold->clearManifold();   
      }
   
      //GL_ShapeDrawer::drawCoordSystem();
   
      for (int i=0;i<numObjects;i++){         
         GLShapeDrawer.drawOpenGL(gl,objects.getWorldTransform(new Transform()),objects.getCollisionShape(),new Vector3f(1,1,1),getDebugMode());   
      }
   
      Quat4f orn = new Quat4f();
      Transform3D t=new Transform3D();
      t.setEuler(new Vector3d(new Vector3f(yaw,pitch,roll)));
      t.set(orn);
      Vector3f origin1 = objects[1].getWorldTransform(new Transform()).origin;
      origin1.add(new Vector3f(0f,-0.01f,0f));
      objects[1].getWorldTransform(new Transform()).transform(origin1);
   
      objects[0].getWorldTransform(new Transform()).setRotation(orn);
   
      pitch += 0.005f;
      yaw += 0.01f;
   
      //gl.glFlush();
       //gl.glutSwapBuffers();
   }

   public void clientResetScene(){
      objects[0].getWorldTransform(new Transform()).transform(new Vector3f(0.0f,3.f,0.f));
      objects[1].getWorldTransform(new Transform()).transform(new Vector3f(0.0f,9.f,0.f));
   }

}
Offline LeoMaheo

Senior Newbie





« Reply #115 - Posted 2009-03-16 18:55:18 »

Hi Jezek2

Any plans to upgrade JBullet to Bullet 2.74?
(That would mean lots of work, I suppose (?))

(Otherwise, current JBullet / Bullet 2.70-beta1 works just fine and seems very stable  :-)  )

Regards,
Magnus
Offline jezek2
« Reply #116 - Posted 2009-03-17 16:59:32 »

Hi all,

to improve JBullet development I've decided to raise funds using donations (using PayPal). This way I'll be able to work on JBullet more and catch-up with latest versions provided there will be enough money raised. For more information visit JBullet's homepage here.

Current plan is to port changes from current 2.70-beta1 to 2.70 final (this includes some classes still on 2.66). The next step will be porting changes from 2.70 to 2.74. This will very likely also include porting of soft bodies feature.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 801
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #117 - Posted 2009-03-17 17:34:39 »

You initial aim (€1000) will probably only be reached when devs absolutely need this work in they day job, and can convince their boss to invest in a risk: you might or might not be able to 'fix' it, in the timespan allocated for a specific phase in their project.

Don't get me wrong, (and I very well might be wrong...), but it might take a few... years?

As a reference, you might want to take a look here: http://lwjgl.org/donations.php - it's not exactly pouring in, unfortunately.

I certainly hope those generous devs find you and invest in your project!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline LeoMaheo

Senior Newbie





« Reply #118 - Posted 2009-03-17 18:47:19 »

@Jezek2

"The author created this library and is doing the porting for a reason: he uses it in his commercial projects."

May I ask, are those projects going well? You don't work with those projects for a living do you? (But on your spare time)
If you have a Web page it would be interesting and fun to read about them.
(But I understand that you might not want to publish information on those projects before they're finished.)

Best wishes with fund-raising anyway :-)
Offline jezek2
« Reply #119 - Posted 2009-03-17 21:32:47 »

May I ask, are those projects going well? You don't work with those projects for a living do you? (But on your spare time)
If you have a Web page it would be interesting and fun to read about them.
(But I understand that you might not want to publish information on those projects before they're finished.)

Yes they're going well so far (ok by schedule with "development overhead constant" accounted, which is about 2.5x than time previously thought, but as we're development company and have plenty of experience in other projects we knew this from beginning Smiley ) and I do them for living although we have to finance them from other income as they're in development few years and not really usable until nearly finished.

Currently no public information exist, but it's game related so I'll announce it here too when done Smiley
Pages: 1 2 3 [4] 5 6
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (37 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (60 views)
2014-09-21 02:42:18

BurntPizza (30 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (52 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!