Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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  
  Phys2D Constructive Solid Geometry  (Read 2990 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Posted 2008-05-12 02:02:01 »

As I was thinking of ways to separate my destructible Body hack for Phys2D into something more robust, efficient, and less hacky, I thought that maybe Constructive Solid Geometry would be a good choice. I would add a new type of Body to Phys2D that would have a binary tree of operations (Body's  added or subtracted). The actual used collision would be the union of the added shapes minus the union of the subtracted shapes. This would allow for much more intelligent destructible terrain without removing any of Phys2D's robustness or efficiency. It also allows absolutely any type of shape to be constructed with minimal fuss and a simplistic view of geometry.

I'm pretty sure I have the know-how to do this, but before I delve in... any reason why this might be a silly idea?

See my work:
OTC Software
Offline kevglass

« JGO Spiffy Duke »


Medals: 212
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2008-05-12 06:06:02 »

It's a sound idea, I use it for terrain in Mootox (though I use Slick's geometry operations first then convert into a phys2d body afterwards).

Kev

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2008-05-12 18:48:29 »

My one question for this would be how I could use the "reverse side" of a shape's geometry. What that means, basically, is say there is a box and it has a circle subtracted out of it. I now want to use the inside of the circle for collision, rather than the outside.

Any obvious ways to do this or am I going to need to use instanceof in a lot of places?

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »


Medals: 212
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2008-05-12 18:51:03 »

Quote
My one question for this would be how I could use the "reverse side" of a shape's geometry. What that means, basically, is say there is a box and it has a circle subtracted out of it. I now want to use the inside of the circle for collision, rather than the outside.

Sorry, couldn't get that. Maybe a picture?

Kev

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #4 - Posted 2008-05-12 22:01:59 »

Sure. If you take a look at the first image in this Wikipedia entry:

http://en.wikipedia.org/wiki/Constructive_solid_geometry

You can see that the curve along the inside of the cube is determined by the geometry of the sphere that subtracted from it. Normally, you would factor collision using the outside of the sphere, but once it is used as a subtracted shape you're actually using its inside - basically it's the opposite. I've messed around with Phys2D geometry a bit, obviously, and doing things like reversing the direction of the Polygons resulted in some very messed up collision. As such, I assume there's something I need to change in order to collide with the inside of the sphere rather than the outside.

See my work:
OTC Software
Offline kevglass

« JGO Spiffy Duke »


Medals: 212
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2008-05-12 22:35:00 »

Oh, right, you just want to get trapped inside a shape? If they're polygons reversing the order of the vertices should do this - but only for polygons against polygons.

Kev

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2008-05-13 04:01:14 »

Cool, I thought so.

I suppose I can make the CSG Body require Polygons in its binary tree, rather than generic Shapes. Then other people (or me, later) can do the math involved for calculating collision along the inside rather than the outside of the other Shapes.

See my work:
OTC Software
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 (37 views)
2014-12-15 09:26:44

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

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

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

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

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

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

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

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

toopeicgaming1999 (38 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!