Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
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 / Game Mechanics / Re: Java port of Bullet Physics Library on: 2010-02-02 09:44:44
I don't like cross forum posting, but I tried over at bullet forums with no reply a couple of days ago. So I'm going to see if anyone here has a response Smiley


Hi, i'm having some troubles with the IDebugDraw.


here is the initialization code
1  
2  
3  
      iDebugDraw = new JPCTDebugDraw(world, buffer);
      iDebugDraw.setDebugMode(DebugDrawModes.DRAW_WIREFRAME);
      dynamicWorld.setDebugDrawer(iDebugDraw);


called in the draw loop
1  
                dynamicWorld.debugDrawWorld();


the implemented IDebugDraw
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  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
package jpctbullet;

import java.awt.Color;
import java.awt.Graphics;
import javax.vecmath.Vector3f;

import com.threed.jpct.*;

import com.bulletphysics.linearmath.IDebugDraw;
import com.bulletphysics.linearmath.VectorUtil;

public class JPCTDebugDraw extends IDebugDraw{
  private int _debugMode;
  private World _world;
  private FrameBuffer _buffer;
 
  private SimpleVector Vec3fToSVec(Vector3f vector)
  {
    // JPCT uses a inverted ZY axis and coordinates so flip them
    return new SimpleVector(vector.x, -vector.y, -vector.z);
  }
 
 
  public JPCTDebugDraw(World w, FrameBuffer b)
  {
    _world = w;
    _buffer = b;
  }
 
 
  public void setDebugMode(int debugMode)
  {
    _debugMode = debugMode;
  }
 
  public int getDebugMode()
  {
    return _debugMode;
  }
 
 
  public void drawLine(Vector3f from, Vector3f to, Vector3f color)
  {
    if(_debugMode > 0)
    {
      Camera cam = _world.getCamera();
      Graphics g = _buffer.getGraphics();
      Color lastColour = g.getColor();

      SimpleVector pointA = Interact2D.project3D2D(cam, _buffer, Vec3fToSVec(from));
      SimpleVector pointB = Interact2D.project3D2D(cam, _buffer, Vec3fToSVec(to));
     
      g.setColor(new Color(color.x, color.y, color.z));
     
      // do not know why, but some times pointB is null
      if(pointA != null && pointB != null){
        g.drawLine((int)pointA.x, (int)pointA.y, (int)pointB.x, (int)pointB.y);
      }
      g.setColor(lastColour);
    }
  }
 
 
  public void draw3dText(Vector3f location, String textString)
  {
    Camera cam = _world.getCamera();
    Graphics g = _buffer.getGraphics();
    SimpleVector loc = Interact2D.project3D2D(cam, _buffer, Vec3fToSVec(location));
   
    g.drawString(textString, (int)loc.x, (int)loc.y);
  }
 
 
  public void drawContactPoint(Vector3f pointOnB, Vector3f normalOnB, float distance, int lifeTime, Vector3f color)
  {
   
  }
 
 
  public void reportErrorWarning(String warningString)
  {
    System.out.println(warningString);
  }

}



It's not like the code doesn't do anything. I does. It draws RGB axis lines regardless of what I set it too. I would like to get it to work so I can see the wireframe rigid bodies. The fact that it does draw the RGB axis line means that at least my drawLine() method is working. Any ideas how I messed it up?
2  Game Development / Game Mechanics / Re: Phys2D setPosition() method on: 2009-01-30 04:06:17
Depends on your perspective. Object when created have a position 0,0. If you run with depending on how you render this could be the top left corner or center.

As an example.
I use an OffsetX = screenWidth /2;  when I draw the object based on it's current position. This makes the system use X0 representing the center of the world. So a X-20 would be screenWidth /2 - 20.

If I were to use a absolute screen position then if I wanted to put my box near the bottom of the screen I would
Body.setPosition(0, screenHeight - 5);
then when I draw the object from the position I wouldn't apply an offset. The body would be drawn near the bottom of the screen.

So X- is to the left of 0. and 0 is a representation of where your screen is relative to any offset.
3  Game Development / Game Mechanics / Phys2d: joint type problem on: 2009-01-19 20:39:40
ok having a joint problem.

Currently i'm testing with 4 objects.

convex/empty polygon circle. similiar to the gears demo on the webstart. except theres no inner teeth.
player which is at the moment a box.
playerGravityPoint which sits inside the polygon circle.
joint that connects the player and the playerGravityPoint.

the problem i'm having is that the various joints seem to have strange or behaviour that doesn't do what I either thought or just doesn't work.

ElasticJoint seems to cause some strange bouncing. Eventually causing the PlayerGP to shoot out of the empty circle.
SpringJoint some wierd jumping then eventualy causes the playerGP to shoot out
ConstrainingJoint doesn't do anything. Though this seems to be the more ideal joint. (apply force when greater than distance). when there is no gravity nothing happens. When there is gravity there is no sign of a joint or anything happening.


4  Game Development / Game Mechanics / Phys2d: Difficulties with accurate rotation on: 2009-01-19 09:28:32
Ok i'm having difficulties with Phys2D Body class. When rotating my graphical object I can't get any smooth accuracy.

Currently i'm using
1  
2  
3  
4  
5  
      playerAngle = playerBody.getAngularVelocity();
      if(lastPlayerAngle != playerAngle){
         player.rotateZ(lastPlayerAngle - playerAngle);
        lastPlayerAngle = playerAngle;
      }

This sorta works, but it has large noticible jumps in angle over a time period of seconds.

I tried using Body.getRotation(), but I found that getRotation() value keeps on ever increasing well past 500. This causes my grapical object to rotate extrmely fast. Which is innapropriate.

Is there some way to either get the absolute value of the rotated angle radian or a more precise change as of last getFoo() method call? or just get the rotation of the object smoother.
5  Games Center / Archived Projects / Re: DyMiX - 2D Physics Engine for J2ME on: 2007-09-18 05:38:37
I loved the demo video. That was some great stuff. Save me some time in the future.
6  Discussions / General Discussions / Re: LevelUp Episode 15 - Dr. Richard Marks interview on: 2007-09-18 05:28:31
Now that was some nostalgia. Though I read Rainbow magazine for my TRS80. Man I need to break into the industry, some of that paraphernalia is just cool.
7  Game Development / Networking & Multiplayer / Re: object store, groovy on: 2007-02-09 03:44:44
I have a simmilar wonder and request. It would be nice to have a scripting language runnable in a GLO. It would be a awsome way to chage GLO behaviour live.

This place looks so dead at the moment.
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.

BurntPizza (14 views)
2014-12-27 22:38:51

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (17 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

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

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

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

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

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

SHC (97 views)
2014-12-03 16:27:13
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

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