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]
  ignore  |  Print  
  [Odejava] OO Issues - round 3  (Read 1600 times)
0 Members and 1 Guest are viewing this topic.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Posted 2004-03-22 04:18:13 »

I wish to add multi-geom support to the API and have been discussing it with Jani over the last week.  I thought I would move the discussion here Smiley  When I looked into this I have thought up a few improvements to the API as well.

Here's a few things I think should be changed:

#1
Geom has a set/getBody methods - I think these should just be dropped as otherwise you can have this situation:

1  
2  
3  
4  
5  
6  
Geom g = new Geom ();
Body b1 = new Body (world);
Body b2 = new Body (world);

b1.setGeom(g);
g.setBody(b2)


which is very misleading (in actual fact - the setBody in this context means zip).

#2
Body needs to be expanded to support multiple Geom's.  This is fairly easy, we would just have a linked list of Geoms instead of one.

"setGeom" would be changed to "addGeom" - and
Iterator getGeomIterator() would replace getGeom.  set/getGeom could be retrofitted to simply add a Geom to the list - and return the first Geom in the list.


#3
Space shouldn't really know about Bodies - hence both "add" methods would be removed.

addGeom would be added to add a Geom to the space.
addBodyGeoms would be created as a conveniance method to add all the geoms in that body to the space (but not the body itself).

An assert would be added to ensure no Geom is added twice (Matt's problem in the other thread).

Instead of Space maintaining a list of Bodies - I think the World should.  So world could have:

addBody() and
Iterator getBodyIterator()


All of these suggested changes can be made without breaking the API as far as I can see.  The benifits are: basic multi-geom support and a less confusing API.

Full Multi-Geom's support will need a little more work but the basic support would be there.

Cheers,

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2004-03-22 10:35:51 »

I have gone ahead and made the changes so you can see what I mean.

If you don't like them they can easily be reversed.  Note:  Everything is backward compatable - the old demo's work fine unmodified.

Basically the changes are these:
* Avoid using set/getBody on Geom.
* Use World to manage your Bodies instead of Space (all Bodies are added to the master Body list in their world on creation).  This was changed to bring Odejava more inline with ODE regarding World and Body, Space and Geom.
* Use Space.addBodyGeoms(Body) instead of Space.add(Body) when you use point 2.
* You can now add multiple geoms to a body.

So long as these changes are ok - I'll convert the demos (very easy to convert I just want to make sure the changes are ok first).

I apologise for several recent API changes, I hope I am not out of line.  I am just trying to correct some problems that I see and add support for new features before we have too much legacy code to make it a real pain Smiley

Cheers,

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #2 - Posted 2004-03-24 06:10:44 »

nothing eh?

I guess that means people are either a) busy b) happy with the changes or c) pissed off at me for yet another change Wink

I've got some time tonight so I'll modify the demos.

Cheers,

Will.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Matt2000

Senior Newbie




Let's all help Java not suck.


« Reply #3 - Posted 2004-03-25 13:46:24 »


These changes sound good, any API changes we can make that direct people on how and where to use Geoms versus Bodies is going to really help people understand things better.  I'll have more concrete feedback once I work with the changes directly (which usually results in a couple rapid fire posts like last time  Wink)

Matt
Offline Jani Laakso

Junior Member




Do it with Java!


« Reply #4 - Posted 2004-03-25 18:01:29 »

Quote
nothing eh?

I guess that means people are either a) busy b) happy with the changes or c) pissed off at me for yet another change Wink


Heh, I'll choose option a, I'm pretty sure it will soon be option b Smiley

Seriously, I try to participate a bit more to discussions in the near future.
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #5 - Posted 2004-03-25 23:53:22 »

ok, cool Smiley

I'll change the demos.  These changes are actually very minor but I think they will help new users (and only confuse current users a little Wink)

Here's my cvs email (if you're not already on the cvs list I strongly urge you to join it!)

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  
User: willdenniss
Date: 04/03/25 18:25:51

Modified:
 /odejava/odejava/src/org/odejava/test/simple/
  HighLevelApiExample.java

Log:
 removed use of deprecated methods.
 
 Moving to the new way of using World for bodies and Space for geom is very easy
 just follow the example of this file.
 
 Change use of space.add(Body) to space.addBodyGeoms(Body)
 space.add(Geom) to space.addGeom(Geom)
 and the use of space.getBody() to world.getBody()
 
 Note - you don't need to manually add Bodies to World - they are added
 automatically in the constructor
 

File Changes:

Directory: /odejava/odejava/src/org/odejava/test/simple/
========================================================

File [changed]: HighLevelApiExample.java
Url: https://odejava.dev.java.net/source/browse/odejava/odejava/src/org/odejava/test/simple/HighLevelApiExample.java?r1=1.9&r2=1.10
Delta lines:  +4 -4
-------------------
--- HighLevelApiExample.java    29 Feb 2004 08:03:05 -0000      1.9
+++ HighLevelApiExample.java    26 Mar 2004 02:25:49 -0000      1.10
-158,7 +158,7 @@
                // Create a sphere geom and set it to body (dynamic object)
                // Sphere radius is 1. Position sphere above the ground
                sphere = new Body("sphere",world, new GeomSphere(1f));
-               space.add(sphere);
+               space.addBodyGeoms(sphere);
                sphere.setPosition(0f, 0f, 2f);
                sphere.adjustMass(1f);
                sphereId = sphere.getGeom().getNativeAddr();
-167,7 +167,7 @@
                // Box x,y,z lengths are 2,1,1. Position box above the sphere, slightly
                // right to sphere
                box = new Body("box",world, new GeomBox(2f, 1f, 1f));
-               space.add(box);
+               space.addBodyGeoms(box);
                box.setPosition(0.1f, 0f, 5f);
                box.adjustMass(1f);
                boxId = box.getGeom().getNativeAddr();
-192,9 +192,9 @@
                                System.out.println(", quaternion=" + box.getQuaternion());
                                // Another way of getting position and quaternion data
                                System.out.print(
-                                       "  Sphere pos=" + space.getBody("sphere").getPosition());
+                                       "  Sphere pos=" + world.getBody("sphere").getPosition());
                                System.out.println(
-                                       ", quaternion=" + space.getBody("sphere").getQuaternion());
+                                       ", quaternion=" + world.getBody("sphere").getQuaternion());
                        }
                }
        }


I'll update the other demos now Smiley

Cheers,

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2004-03-27 02:37:32 »

Everything in the API is now uptodate and inline with all my changes *phew*.

Both odejava and odejava-xith3d can be compiled with no deprecation warnings - so if you are getting them it is probably in your code.  I am happy to help anyone who is getting these warnings in converting their code if they don't understand what I have said and can't do the changes by looking at the official Odejava examples.  Email me or post in these forums if you need some help.

The only thing I ended up doing differently is that I have kept the setBody and getBody methods of Geom.  This is because ODE clearly has those methods and we want Odejava to be similar to ODE for compatability of the docs.

But what I did do is add a bunch of javadoc comments and asserts to warn and prevent people trying to give a Geom two parents (as this is not possible in ODE - but it was previously possible for the situation to exist in Odejava, even though in actual fact only the most recently set parent Body would have any affect).

It is still possible to give a Geom two parents if you are very sneaky but I have prevented the obvious cases - and warned about the sneaky ones in the javadocs.

Cheers,

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.

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

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

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

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

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

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

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

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

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

BurntPizza (54 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!