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 (600)
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 1312 times)
0 Members and 1 Guest are viewing this topic.
Offline t_larkworthy

Senior Devvie


Medals: 1
Projects: 1


Google App Engine Rocks!


« Posted 2004-08-03 12: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 10: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 Devvie


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #2 - Posted 2004-08-05 12: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!
Legends of Yore - The Casual Retro Roguelike
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #3 - Posted 2004-08-06 04: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.

 

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 (29 views)
2014-12-15 09:26:44

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

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

BurntPizza (75 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 (47 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!