Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  No contact information returned  (Read 1034 times)
0 Members and 1 Guest are viewing this topic.
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Posted 2004-08-03 14:06:39 »

My contacts seem to have stoped working :-(
Here is my code if anyone spots I have missed something stupid.
The contacts that come always have id's of 0. Body id's or geom id's. The collisions work fine though in the actual simulator.
I am using the new BulkContact but it still does not work with the old one

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  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
package odeAbstraction;

import org.odejava.Space;
import org.odejava.Geom;
import org.odejava.ode.Ode;
import org.odejava.collision.BulkContact;
import org.odejava.collision.JavaCollision;
import org.odejava.collision.Contact;

import java.util.Observable;

import odeAbstraction.events.ObjectManagerEvents.SimObjectEventListener;
import odeAbstraction.events.ObjectManagerEvents.DynamicObjectEvent;
import odeAbstraction.events.ObjectManagerEvents.StaticObjectEvent;
import odeAbstraction.collision.CollisionRuleManager;
import model.geometry.RelativePrimative;

/**
 * User: ttl0
 * Date: 02-Aug-2004
 * Time: 15:37:07
 */

public class CollisionManager implements SimObjectEventListener {
    private final SimWorld world;
    private CollisionRuleManager ruleManager = new CollisionRuleManager();

    Space space = new Space();
    JavaCollision collision = new JavaCollision();
    BulkContact contact = new BulkContact(collision.getContactIntBuffer(),
            collision.getContactFloatBuffer());

    public CollisionManager(SimWorld world) {
        setupDefaultCollision();

        this.world = world;
    }

    private void setupDefaultCollision() {
        // Setup some surface parameters
       collision.setSurfaceMu(1000f);
        collision.setSurfaceBounce(0.14f);
        collision.setSurfaceBounceVel(0.1f);
        collision.setSurfaceMode(Ode.dContactBounce | Ode.dContactApprox1);
    }

    public void handleCollisions() {
        //collision.emptyContactGroup();    allready done in collide
       // Collide objects in given space
       collision.collide(space);
        // Read & modify contact information
       iterateContacts();

        //update all the contact buffers in one call
       contact.commit();
        // Add all contacts to contact jointGroup
       collision.applyContacts();
    }

    private void iterateContacts() {
        for (Object o : space.getGeoms()) {
            Geom geom = (Geom) o;
            System.out.println("geom.getNativeAddr() = " + geom.getNativeAddr());
        }
        for (int i = 0; i < collision.getContactCount(); i++) {
            contact.setIndex(i);
            System.out.println("contact.getGeomID1() = " + contact.getGeomID1());
            System.out.println("contact.getGeomID2() = " + contact.getGeomID2());
            System.out.println("contact.getBodyID1() = " + contact.getBodyID1());
            System.out.println("contact.getBodyID2() = " + contact.getBodyID2());

            ruleManager.process(contact, world);
        }
    }


    public void dynamicObjectListChange(DynamicObjectEvent evt) {
        for (RelativePrimative primative : evt.getSimObject().getInfo().getPrimatives()) {
            if (evt.getType() == (DynamicObjectEvent.ADDED)) {
                space.add(primative.getGeom());
            } else if (evt.getType() == (DynamicObjectEvent.REMOVED)) {
                space.remove(primative.getGeom());
            }
        }
    }

    public void staticObjectListChange(StaticObjectEvent evt) {
        //System.out.println("static added to collision");
       if (evt.getType() == (StaticObjectEvent.ADDED)){
            space.add(evt.getSimObject().getPrimative().getGeom());
        }
        else if (evt.getType() == (StaticObjectEvent.REMOVED)) {
            space.remove(evt.getSimObject().getPrimative().getGeom());
        }
    }

    public CollisionRuleManager getRuleManager() {
        return ruleManager;
    }
}

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

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2004-08-05 12:52:57 »

what happened when they stopped working?  did you upgrade the version of Odejava (more notably the native library version)?

Are you using version control software on your own code - can you recover the last good version?

I find using some sort of versioning system even on personal projects is pretty much essential, especially when you are using API's prone to nasty silent bugs (like Odejava...).

Are using the debug version of the native library?  If not, can you give that a try?

Will.

Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #2 - Posted 2004-08-05 14:41:04 »

Wise words, and yes indeed I have version control. Unfortunately last Friday my 2 hard drives blew up so I have lost all data I ever owned. Including all my work on ode (which by the way is for a masters thesis) So no rollbacks.
So yeah previously contacts were working fine and now they have dissapeared since getting the latest package of odejava. I shall try putting debug mode on ode, all my non-deterministic crashes have dissapeared though since restarting (and I havn't reimplemented the thread safty thing yet)


Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #3 - Posted 2004-08-06 06:52:01 »

ouch! you lost two hard drives?

I definitally recommend debug mode - it warns you about stuff you may not think is important but can cause unexplained to happen things down the track.

Will.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (85 views)
2013-05-17 21:29:12

alaslipknot (93 views)
2013-05-16 21:24:48

gouessej (125 views)
2013-05-16 00:53:38

gouessej (118 views)
2013-05-16 00:17:58

theagentd (128 views)
2013-05-15 15:01:13

theagentd (115 views)
2013-05-15 15:00:54

StreetDoggy (159 views)
2013-05-14 15:56:26

kutucuk (181 views)
2013-05-12 17:10:36

kutucuk (181 views)
2013-05-12 15:36:09

UnluckyDevil (188 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.129 seconds with 21 queries.