Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  How do online pool/billard games have 3D balls?  (Read 6973 times)
0 Members and 1 Guest are viewing this topic.
Offline Geeback

Junior Newbie





« Posted 2010-02-08 19:50:37 »

I know they must have like 50 different angles of the ball for its position but does anybody know EXACTLY how they do it ? im looking to do something similar.

Here is an example of what i mean.
http://www.youtube.com/watch?v=fZA9z6V5cI8

Its only a 2D game but when the balls are hit they dont just move flat they roll asif they would in real life/3D

Thanks!
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #1 - Posted 2010-02-08 21:41:41 »

Moved to Newless Cluebies and duplicate topic deleted.

Please only put a post once.

The effects in that link you provided appear to just be smart use of a sprite sheet. All you'd need would be about 32 different shots of the ball from different rotations, then calculate the actual rotation to apply to the sprite. I admit it would take a lot of tweaking to get it working as nice as they had it working in that video, but the actual process of doing so is not complicated.

I would personally just use 3D balls - that would make life a lot easier.

See my work:
OTC Software
Offline Geeback

Junior Newbie





« Reply #2 - Posted 2010-02-08 21:43:20 »

Sorry about double post, i thought both categorys fitted.

What do you mean just use 3D balls? can they be used in 2D pool games because thats what were looking to make but with rolling balls obviously

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

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #3 - Posted 2010-02-08 23:05:13 »

Sorry about double post, i thought both categorys fitted.

What do you mean just use 3D balls? can they be used in 2D pool games because thats what were looking to make but with rolling balls obviously

Cheers.
Just draw a sphere on top of your pool table. There are plenty of games that have 3D objects on top of 2D sprites. You'll need to use Java3D or OpenGL or something like that, though.

See my work:
OTC Software
Offline Nate

JGO Kernel


Medals: 129
Projects: 3
Exp: 14 years


Esoteric Software


« Reply #4 - Posted 2010-02-09 00:38:37 »

Even with a sphere your balls might not look quite right unless you implement spin on the ball, if only for aesthetics.

Offline Geeback

Junior Newbie





« Reply #5 - Posted 2010-02-09 11:56:56 »

Thanks for the replies. Basically im trying to create something like this http://www.funkypool.com/ If you just click play it loads up. Its a 2D pool game with rotating balls i doubt them use sprite sheet because they are perfect.

Would Java3D be the best way to achieve this if this is the way? Getting 3D balls is not the problem its just the method behind it because ive never seen anything like it before.

Thanks!
Offline steveyO
« Reply #6 - Posted 2010-02-09 12:15:26 »

I was investigating how to do this recently too, as am writing my own java pool game.  What makes you think you can't use spritesheets as Demonpants suggested?   I was going to use this method too for my game.  Basically for each ball generate a sprite sheet with all the different angles (the rotations/spin you can do in code).

A few ways to do this.. GIMP (loads of tutorials on the net how to create 3D Pool Balls, however will take f'in ages getting all the angles for each ball colour etc).. Generate sprite sheet using code, either Java2D or Java3D.  Generating SpriteSheets in Java2D is really easy, however for 3D balls with lighting/numbers etc.. may be tricky (didnt manage to find good tutorial, although still probably doable)... So personally will probably try and generate then with Java3D.. Should be doable juding by the Java3D tutorials I have seen!.  (eg. http://www.java2s.com/Code/Java/3D/AredsphereusingtheSphereutilityclass.htm)

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #7 - Posted 2010-02-09 16:03:46 »

I was investigating how to do this recently too, as am writing my own java pool game.  What makes you think you can't use spritesheets as Demonpants suggested?   I was going to use this method too for my game.  Basically for each ball generate a sprite sheet with all the different angles (the rotations/spin you can do in code).

A few ways to do this.. GIMP (loads of tutorials on the net how to create 3D Pool Balls, however will take f'in ages getting all the angles for each ball colour etc).. Generate sprite sheet using code, either Java2D or Java3D.  Generating SpriteSheets in Java2D is really easy, however for 3D balls with lighting/numbers etc.. may be tricky (didnt manage to find good tutorial, although still probably doable)... So personally will probably try and generate then with Java3D.. Should be doable juding by the Java3D tutorials I have seen!.  (eg. http://www.java2s.com/Code/Java/3D/AredsphereusingtheSphereutilityclass.htm)
Given that steveyO has actually tried implementing this in code and I'm only speculating, he'd definitely be a better person to listen to. Smiley

See my work:
OTC Software
Offline Geeback

Junior Newbie





« Reply #8 - Posted 2010-02-09 16:06:05 »

Yea thats my only problem its impossible to get EVERY angle of a pool ball using a sprite sheet and probably wouldnt be worth it. Funkypool must use something which allows them to import their 3D balls from photoshop or other 3D problems. Its just a case of finding out what.
Offline Nate

JGO Kernel


Medals: 129
Projects: 3
Exp: 14 years


Esoteric Software


« Reply #9 - Posted 2010-02-09 16:27:54 »

FunkyPool supports angular velocity since their GUI lets you give the ball "english" (hitting off center). They are definitely rendering 3D balls. There is no special tools they are using, just textured spheres.

Using sprite sheets you'd be faking it. You'd have one animation of a ball rolling for each numbered ball. You'd rotate the animation based on the direction the ball was traveling. You don't need every possible angle of the ball.

Again, unless you are simulating the ball's rotation, you'll be faking the ball rolling even if you are using 3D.

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

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #10 - Posted 2010-02-09 16:29:51 »

Yea thats my only problem its impossible to get EVERY angle of a pool ball using a sprite sheet and probably wouldnt be worth it. Funkypool must use something which allows them to import their 3D balls from photoshop or other 3D problems. Its just a case of finding out what.
Yeah, as Nate said, you're faking it either way. With a sprite sheet, you only need to fake enough rotations to where it gets to the point that it's not noticeable for the player anymore - probably like 32 or 64 frames per ball.

See my work:
OTC Software
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #11 - Posted 2010-02-09 16:35:27 »

>You'll need to use Java3D or OpenGL or something like that, though.

jPCT would be a good choice.

弾幕 ☆ @mahonnaiseblog
Offline Geeback

Junior Newbie





« Reply #12 - Posted 2010-02-09 17:16:01 »

Ok thanks for the replies ill look into all methods does anybody have an example of a pool ball sprite sheet with all the diff angles of a ball on ?

Thanks
Offline Geeback

Junior Newbie





« Reply #13 - Posted 2010-02-09 18:46:17 »

Hey guys, weve chosen to go the openGL, java way.

Im stuck for choice with these two, has anybody used either of them ? or know about them?

www.lwjgl.org

www.jpct.net

http://kenai.com/projects/jogl/pages/Home
Offline ShannonSmith
« Reply #14 - Posted 2010-02-09 19:01:08 »

I would personally try to do this in Java2D, OpenGL support is a pain. I would go for a sort of ray-tracing approach. This was done totally in 2D, using an elliptic lens distorted texture.

You could regenerated the image for every rotated ball every frame using a intelligently chosen texture and the right transform.

Offline Cluber

Junior Newbie





« Reply #15 - Posted 2010-02-09 20:04:58 »

I am also looking to this. One way suggested was BufferedImage and editing it this way. But it seems a lot of work.
Offline zoto

Senior Member


Medals: 4



« Reply #16 - Posted 2010-02-09 23:00:01 »

This it the best sprite sheet I could find to illustrate what they are talking about above.
http://www.emunix.emich.edu/~evett/GameProgramming/BookCode/chapter11.new/multithread/sphere.bmp
I would imagine you would create a sprite sheet similar to this for each ball with a 3d modeler program by running the models threw a script.
Offline steveyO
« Reply #17 - Posted 2010-02-10 00:03:42 »

Quote
I would personally try to do this in Java2D, OpenGL support is a pain. I would go for a sort of ray-tracing approach. This was done totally in 2D, using an elliptic lens distorted texture.
Actually, I was looking at the code on your website a couple of weeks ago when I was investigating how to do this myself..  Unfortunately, was a bit too complex for my simple mind, but if the lighting could be done in Java2D then obviously would be fantastic and loads easier than Java3D..

This is something I put together tonight in Java2D to give you an idea. (36K at the moment,  a proper sprite should should be less than 100K would guess).
http://www.bullsquared.com/pool/spriteSheet.png
All the balls are just drawn with g.drawOval(....)...  (Of course anti-aliasing turned on).  I am creating a texture with the numbers and circles (TexturePaint tp, and g.setPaint(tp) etc..).. I reckon I could fudge the number ovals and number text to make it look like they are spherical...  Of course I have missed all the vertical rotations for the striped balls too (I think that covers every angle??).

If anyone has any easy to understand links on how to make these 3D Looking (using Java2D) then let me know and will fix and post the code.   The ball shadows can easily be created using a seperate image..  Wont really be spending any more time on this till March, other game to finish before I do my pool game.

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline ShannonSmith
« Reply #18 - Posted 2010-02-12 05:55:04 »

As I said Java2D (source included):


Source uses Quaternions for rotation, let me know if you have any questions.

Note: Nerd Sniping not appreciated, on the plus side, new 4K idea!


Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #19 - Posted 2010-02-12 08:06:07 »

As I said Java2D (source included):


Source uses Quaternions for rotation, let me know if you have any questions.

Note: Nerd Sniping not appreciated, on the plus side, new 4K idea!



That's beauteous. Very well done. Smiley

See my work:
OTC Software
Offline ShannonSmith
« Reply #20 - Posted 2010-02-12 18:44:38 »

Added some proper lighting and shadows, I'm pretty sure this is how funky pool does it as well. The sprite sheet for all the orientations for all the balls for smooth animations would be way too big. You could get it to look really good and not so aliased by doing a linear interpolation of the texture (at the moment I'm just casting strait to ints).




Offline DzzD
« Reply #21 - Posted 2010-02-12 18:49:16 »

and I would use 3DzzD  Tongue , once on the website => click on the image at the top

Offline DzzD
« Reply #22 - Posted 2010-02-12 19:01:26 »

As I said Java2D (source included):


Source uses Quaternions for rotation, let me know if you have any questions.

Note: Nerd Sniping not appreciated, on the plus side, new 4K idea!



very nice !

Offline steveyO
« Reply #23 - Posted 2010-02-12 20:06:01 »

Yeah.  Does look pretty cool!!  Will give it a go in a few weeks..  Am doing my pool game in Pulpcore so will see if I can get this working (I did read in the Pulpcore Wiki  you can do Java2D stuff in Pulpcore, although havent tried it yet).. Will let you know soon. Tnx!

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline ShannonSmith
« Reply #24 - Posted 2010-02-12 20:28:51 »

Pulpcore will work exactly the same, just update a CoreImage (using getData()) instead of a BufferedImage.
Offline zoto

Senior Member


Medals: 4



« Reply #25 - Posted 2010-02-12 22:16:33 »

Great job Shannon, it looks even better now.

Could you please update the source code.
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #26 - Posted 2010-02-12 23:05:48 »

@Geeback

jPCT also supports rather fast software rendering. For something like this it would be fast enough. (Even on netbooks.)

@ShannonSmith

Awesome stuff. Shocked

弾幕 ☆ @mahonnaiseblog
Offline ShannonSmith
« Reply #27 - Posted 2010-02-12 23:36:58 »

Quote
Could you please update the source code.
Will do (when I get home from work), forgot about that.

Edit:
Up now.
Offline DzzD
« Reply #28 - Posted 2010-02-13 00:31:55 »

@Geeback

jPCT also supports rather fast software rendering. For something like this it would be fast enough. (Even on netbooks.)

@ShannonSmith

Awesome stuff. Shocked

barf.. I inded first recommended 3DzzD software, but... really.. after seiing ShannonSmith works this would be a very bad advice the way to go is definitly pulpcore + ShannonSmith algos and not a 3d engine

Offline Cluber

Junior Newbie





« Reply #29 - Posted 2010-02-13 21:26:21 »

Line 118: Type mismatch: cannot convert from element type Object to PoolTest.Ball
1  
2  
3  
for(Ball ball : balls){
   updateImage(ball);
}
Pages: [1] 2
  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.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!