Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Shared Code / Re: JStackAlloc - stack allocation of "value" objects in Java on: 2009-08-29 20:51:36
This is a patch for JStackAlloc to work with Maven.
[...]
For this to work, I had to modify JStackAllock,
because the method FileSet.getDirectoryScanner()
doesn't exist in the Ant-stuff provided by the Maven AntRun plugin.
[...]

Instead I could simply specify that version 1.3 of the Maven AntRun plugin be used.
This AntRun version uses another version of Ant,
in which the above method is present, and so my patch is not needed.

In case anyone wants to build JStackAllock / JBullet with Maven,
below are some POM snippents.

(I hope it's fine by you, Jezek2, with Jezek2 as group ID?)

Regards, Magnus

Build JStackAlloc:  (Works with Maven 2.0.9)
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  
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>jezek2</groupId>
  <artifactId>jstackalloc</artifactId>
  <packaging>jar</packaging>
  <version>20080716</version>
  <name>jstackalloc</name>
  <url>http://www.java-gaming.org/topics/jstackalloc-stack-allocation-of-objects-in-java/18843/view.html</url>
  <dependencies>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
      <version>1.7.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm-all</artifactId>
      <version>3.1</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>


Instrument JBullet: (works for me with Maven 2.0.9)
(Notice the <version>1.3</version> element.)
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  
[...]
    <dependency>
      <groupId>jezek2</groupId>
      <artifactId>jstackalloc</artifactId>
      <version>20080716</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
[...]
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <configuration>
              <tasks>
                <property name="compile_classpath" refid="maven.compile.classpath"/>
                <taskdef name="instrument-stack"
                    classname="cz.advel.stack.instrument.InstrumentationTask"
                    classpath="${compile_classpath}"/>
                <instrument-stack dest="${project.build.outputDirectory}" packageName="com.bulletphysics" isolated="true" singlethread="true">
                    <fileset dir="${project.build.outputDirectory}" includes="**/*.class"/>
                </instrument-stack>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
[...]

2  Game Development / Shared Code / Re: JStackAlloc - stack allocation of "value" objects in Java on: 2009-08-29 14:32:44
Hi Jezek2!

EDIT: Forget this, this is not needed. Please refer to my next post instead.

This is a patch for JStackAlloc to work with Maven.

I'm building my project with Maven, hence I also build JBullet with Maven (version 2.0.9).
Hence I added an AntRun task to Maven's POM file to let JStackAlloc instrument JBullet.

For this to work, I had to modify JStackAllock,
because the method FileSet.getDirectoryScanner()
doesn't exist in the Ant-stuff provided by the Maven AntRun plugin.
Instead, getDirectoryScanner(Project) can be used.
Also a getDir() needs to be replaced by getDir(getProject()).

Here's the patch:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
--- /home/magnus/tmp/InstrumentationTask.java   2008-07-16 19:43:34.000000000 +0200
+++ /home/magnus/dev/dev/madmind/master.git/jstackalloc-20080716/src/cz/advel/stack/instrument/InstrumentationTask.java   2009-08-29 11:51:33.000000000 +0200
-105,13 +105,14 @@
    @Override
    public void execute() throws BuildException {
       try {
          List<File> files = new ArrayList<File>();
          for (FileSet fs : fileSets) {
-            String[] fileNames = fs.getDirectoryScanner().getIncludedFiles();
+            String[] fileNames = fs.getDirectoryScanner(
+                  getProject()).getIncludedFiles();
             for (String fname : fileNames) {
-               File file = new File(fs.getDir(), fname);
+               File file = new File(fs.getDir(getProject()), fname);
                if (file.getName().endsWith(".class")) {
                   files.add(file);
                }
             }
          }


Without above patch, the Maven AntRun task fails with a NoSuchMethodError:

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  
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org.apache.tools.ant.types.FileSet.getDirectoryScanner()Lorg/apache/tools/ant/DirectoryScanner;
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NoSuchMethodError: org.apache.tools.ant.types.FileSet.getDirectoryScanner()Lorg/apache/tools/ant/DirectoryScanner;
   at cz.advel.stack.instrument.InstrumentationTask.execute(InstrumentationTask.java:110)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
   at org.apache.tools.ant.Task.perform(Task.java:364)
   at org.apache.tools.ant.Target.execute(Target.java:341)
   at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
   at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
   at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
   at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
   at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
   at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
   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 org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
   at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
   at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
   at org.codehaus.classworlds.Launcher.main(Launcher.java:375)


Kind regards, Magnus
3  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 2009-05-22 23:23:01
Hi, some of you wanted to know more about the projects I'm doing with JBullet. Recently I've implemented ragdoll into my engine and created video of it

Those were beautiful ragdolls.

That was 3DzzD? May I ask, any reason you've chosen 3DzzD not jPCT? I can think of one, that 3DzzD is open source?
4  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 2009-05-17 18:58:13
Hi NewbTon,

OK that sounds logical..may I ask what kind of constraints (joints ) you use ? Is it hinge or ball ?

Both hinge and ball.

Bullet Physics has recently made improvements to the ConeTwist joint. 
(http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=18&t=3177)
Had these improvements been available in JBullet, I'd preferred to use
the new ConeTwist constraint, instead of my current approach,
with 2 constraints per biped parent-child limb joint.

My current approach:
Each joint has 2 constraints: (1) A passive ConeTwist or HingeJoint
constraints that restricts movement,  and (2) a Generic6DoFConstraint,
that applies muscle actuation. To apply muscle actuation, I rotate the
frame of the 2nd body attached to the Generic6DofConstraint. I
don't use the setAngular{Lower/Upper}Limit functions.
(I had to add a function that allows modifying this second frame
after the creation of the Generic6DofConstraint.)

(I think the reason I used 2 constraints was:
1. Easier to define max-rotation-limits using ConeTwistConstraint
   (than with Generic6DofConstraint).
2. (JBullet's current version of) ConeTwistConstraint doesn't allow defining both
    max-rotation-limits and a different desired rotation. So
    I used a second constraint, the Generic6DofConstraint, for this.
    (I.e. for muscle actuation.))

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  
   // Below, childPart might be an upper arm,
   // and parentPart would then be the torso.
   // Or the child part could be the left shin leg;
   // the parent part would then be the left thigh.)

   // The constraint that just limits movement.
   if (constraintType == HINGE_CONSTRAINT_TYPE) {
      childPart.joint = new HingeConstraint(
            parentPart.physics(), childPart.physics(),
            new Transform(parentFrame), new Transform(childFrame));
   }
   else if (constraintType == CONETWIST_CONSTRAINT_TYPE) {
      childPart.joint = new ConeTwistConstraint(
            parentPart.physics(), childPart.physics(),
            new Transform(parentFrame), new Transform(childFrame));
   }
   ...
 
   // The muscle actuation constraint.
   childPart.motor = new Generic6DofConstraint(
         parentPart.physics(), childPart.physics(),
         new Transform(parentFrame), new Transform(childFrame), true);
 
   // To apply muscle actuation, the motor child frame is rotated
   // (relative the parent frame); the motor limits remain 0, always.
   childPart.motor.setLimit(3 + 0, 0, 0);
   childPart.motor.setLimit(3 + 1, 0, 0);
   childPart.motor.setLimit(3 + 2, 0, 0);


// And in some function, to rotate the child body part
// relative the parent body part:

   childPart.motor.setFrameBaseB(newRotation);
   // Function is not present in JBullet, but see below:


public class Generic6DofConstraint extends TypedConstraint {
   ...
   public void setFrameBaseB(Quat4f basis) {
      frameInB.basis.set(basis);
   }
   ...
}


And then there are functions that set the childPart.joint limits.



I have this game in PhysX and I'd like to know if it's possible to port it to jbullet:

http://www.youtube.com/watch?v=0wFdmVbFRw8

I've seen that game before :-) (You're the author, I gather?) I like
that approach, mainly physics and gameplay, rather than graphics.


What's you're opinion on that ?

My bipeds only walk forwards, slowly. No quick movements, as of now. 
So I do not know if it's possible.  But I guess it is, and that it
would work as well as with PhysX.
5  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 2009-05-14 17:45:54
Hi NewbTon,

If you google for "walk cycle", you might find 4 + 4 images (left leg walking + right leg walking) illustrating 4 + 4 poses a biped takes whilst walking (for example, http://www.idleworm.com/how/anm/02w/walk1.shtml). If you drive the limb-joint-motors towards these poses, and at the same time apply a torque so the biped doesn't fall, then friction feet-ground will entail it moves forwards.

(So, first I try to orient the biped's limb after the first pose. Then, when the biped is reasonably close to this pose, I switch target pose: I apply motor torques to reach the second pose instead. And so on. To determine whether the biped is reasonably close to one pose: One could sum angle errors. Or simply assume it's close enough after having tried to reach that pose in 100 ms. And then switch to the next target pose. For some poses, I switch to the next pose when the appropriate leg makes ground contact.)

I don't know, however, how to make the biped turn around. It's much more complicated movements I think. Perhaps it's better simply to apply a fairly huge cheat torque to the pelvis and head, so that the whole biped rotates (in an unrealistic manner). Then perhaps I should do what you have done, make the biped's feet super slippery, so the feet doesn't get stuck whilst the head and torso rotates 180'.  :-)
6  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 2009-05-13 17:27:51
I also have a question : do your version support joint motors ? (so that I can animate ragdolls)

I also use JBullet for ragdoll animation. Works fine, they walk.
Although took long to program them to move their legs somewhat reasonably.
I apply a cheat torque to their pelvis, else they fall.
Initially my ragdolls had no elbow or knee joints. (I thought I should save some CPU by reducing the number of bodies and joints.) This did not work well.

Regards, Magnus
7  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 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 :-)
8  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 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
9  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 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
10  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 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.
11  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 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

12  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 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
13  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 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
14  Game Development / Game Mechanics / Re: Viagra ? on: 2008-03-19 02:24:53
It's there again. How annoying.
15  Game Development / Performance Tuning / Re: Avoiding extremely slow debugging? on: 2007-08-31 00:36:19
Hi all,

I think it seems to be an IDE issue, as `irrisor' suggested. Sometimes the Netbeans 6 beta version Milestone 10 debugger runs extremely slowly, sometimes as quickly as one would expect it to do. Recently it started to run so very slowly when I modified the source code of a program and rebuilt it although one instance of it was running, and then I started a new instance (whilst the old was still running). This time however it was a Swing application; after this, Swing run extemely slowly (when debugging) until after a restart of Neteans 6 M10.

So, right now I feel I need not have posted about this. Thanks however for all answers :-)

( Hmm, if someone wants to, perhaps it could be appropriate that this thread be renamed so it does not accidentally cause anyone to believe that debugging Java apps is something inherently slow. I don't know, perhaps append "not an issue" or "irrelevant" or "solved" to the title? )

( I choose Netbeans 6 beta version because I thought I wanted to use it's Ruby support but I haven't used Ruby at all and I guess I should've choosen a stable release instead :-/  )


> if your code is enough to debug itself you'd be able to face the lack of speed encountered

I hope I'll write lots of unit tests :-)


> Which profiler are you using.

The Neteans 6 Milestone 10 debugger; I haven't used the profiler.


Thanks,
Magnus
16  Game Development / Performance Tuning / Avoiding extremely slow debugging? on: 2007-08-26 17:20:41
Hi anyone,

I'm debugging my jMonkeyEngine 3d application and achieve perhaps
3 frames per second, sometimes 1/15 frames per second.

When I run the application with the debugger disabled, I achieve
perhaps 100 or 200 fps.

I'm new to Java. How do people debug Java games? It seems
impossible -- if I achieve a framerate of 1/15 fps now, then how
am I going to debug the application when it's become 100
times more complex than as of today.

Is there perhaps a way to tell the Java debugger to debug only
my own source, not the middleware I'm using?
(I mean perhaps in the same way as with the -ea flag that can
enable assertions in certain packages only.)

(I've built jMonkeyEngine and jME-Physics_2 *without* debugging information;
nevertheless, when I run my application with debugging enabled I achieve
the above-mentioned rather unbearably slow framerate.)

(The game is currently sometimes 1 sometimes 100 boxes that falls on
a floor, bounce, and then rest. My own game does almost nothing;
jMonkeyEngine and jME-Physics_2 do all rendering and physics
computations. 3 fps with 1 box; perhaps 1/15 fps with 100 boxes.
I intended to use > 100 objects, more complicated than boxes...)

(I'm using Netbeans M10, Java 1.6 and Linux (Ubuntu). My machine
is a dual core 2 GB ram.)

Kind regards, Magnus
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!