Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
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  
  Ot - 3D voxel engine  (Read 19269 times)
0 Members and 1 Guest are viewing this topic.
Offline buddyBro
« Posted 2016-12-31 19:39:51 »

I'll most likely be stopping working on this project as I've achieved all the goals I wanted to reach with it in terms of rendering optimizations and algorithms. Thank you to everyone for the feedback!  Smiley

Feel free to post further feedback, or ask any questions about the project.

git: https://github.com/mahhov/ot-voxel-engine

<a href="http://www.youtube.com/v/5Nw9JopHREc?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/5Nw9JopHREc?version=3&amp;hl=en_US&amp;start=</a>


<a href="http://www.youtube.com/v/Vuf5CngovKY?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/Vuf5CngovKY?version=3&amp;hl=en_US&amp;start=</a>



Note about running the code: there are 3 main methods, Engine.main will just run sandbox mode, EditorEngine.main will run just the editor mode, and Client.main will run them both (toggling back and forth via the 'm' key).

Sandbox Controls:
w, a, s, d, space, and shift - accelerate ship forward, left, backward, right, up, and down
z, x - zoom camera in and out
move mouse - change camera orientation
p - pause
enter - toggle between free-camera (controlled by mouse movement) and follow-camera (always looks towards your ship)
m - to toggle between sandbox and editor

Editor Controls:
w, a, s, d, space, and shift - to move camera
i, j, k, l, u, o - to change selected direction
1, 2, 3, 4, 0 - to change selected piece (1=hull, 2=rotor/thruster, 3=helium, 4=blade/wing, 0=delete)
mouse move - to change selected location
mouse click - to place selected piece with selected direction at selected location
enter - to reset camera to default location and orientation
\ - to load ship from file
/ - to save ship to file
m - to toggle to sandbox mode and try out your creation! (be sure to save before going to sandbox mode. sandbox mode will load from file, not from whatever is in your editor)

----------------------------------------------------------------------------------------------------------------------------------------
Original Post:


Hello,

Back in 2013, I posted of a 3d engine I had been working on but had to stop due to schoolwork. Well, this Christmas, I began a total fresh remake of the engine; this time focusing on optimizations for extremely vast terrains (rather than dense environments like my previous engine had focused on). My plans are to eventually make it support some kind of pirates battles in the sky game where you create your ships with blocks (kind of like robocraft), though I'm still considering some other ideas as well - if anyone wants to make suggestions, please go ahead Smiley

For drawing, it uses Java.Graphics2D and BufferedImage.

Here's a quick demo 1 week in.

(if anyone can help if there's an easy way to shrink the embedded image, thank you)
zip: https://www.dropbox.com/s/k0ju5zp2ijka7wl/ot.jar - outdated
git: https://github.com/mahhov/ot-voxel-engine
<a href="http://www.youtube.com/v/SDw4UxfbeQ0?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/SDw4UxfbeQ0?version=3&amp;hl=en_US&amp;start=</a>




Offline kevglass

« JGO Spiffy Duke »


Medals: 319
Projects: 25
Exp: 22 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2016-12-31 19:41:50 »

This video is private Sad

Kev

Offline VaTTeRGeR
« Reply #2 - Posted 2017-01-01 11:51:57 »

1  
[img width=800]...[/img]


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline buddyBro
« Reply #3 - Posted 2017-01-01 21:20:38 »

Thank you both. The video should be public now.
Here's another demo showing it in a much larger map
<a href="http://www.youtube.com/v/v4VnHYtDSSM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/v4VnHYtDSSM?version=3&amp;hl=en_US&amp;start=</a>
Offline Archive
« Reply #4 - Posted 2017-01-01 22:38:19 »

Nice job. I'm curious to see where this goes!

Offline ShadedVertex
« Reply #5 - Posted 2017-01-02 11:11:04 »

This looks really cool! It kinda reminds me of my ol' game, Indago (http://www.java-gaming.org/topics/indago-the-search/36948/view.html), haha  Grin
Offline TGStudiosDE

JGO Coder


Medals: 14
Projects: 3
Exp: 3 years


17 Years Old Developer from Germany :)


« Reply #6 - Posted 2017-01-02 11:36:02 »

Looks cool and I'm interested how it will change in the Future Smiley

Contact me about Bugs: TGStudiosDE@gmail.com
Offline orange451

JGO Kernel


Medals: 345
Projects: 6
Exp: 6 years


Your face. Your ass. What's the difference?


« Reply #7 - Posted 2017-01-03 18:57:23 »

i really like the fps on the video Smiley

Joking aside, looks like a cool project!

First Recon. A java made online first person shooter!
Offline buddyBro
« Reply #8 - Posted 2017-01-04 05:25:46 »

Thank you all very much for the encouragement! Yes, the fps is pretty low at the moment, but note that I had not finished implementing all the optimization strategies I'd planned, plus that's a lot more objects on screen than will actually be required. I'm finishing up the final optimization algorithms at the moment and I expect 10-15 fps with that density, map size, and draw distance. I'll upload another video once I've completed the optimizations, maybe with a more toned down density.
Offline J0
« Reply #9 - Posted 2017-01-09 21:40:11 »

I'm sorry but how can you be using Graphics2D for a 3D renderer? persecutioncomplex

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kingroka123
« Reply #10 - Posted 2017-01-09 22:26:58 »

Hes doing 3D math on the cpu. It's much slower than using OpenGL or DirectX because those use the graphics card for their calculations.
Offline Archive
« Reply #11 - Posted 2017-01-09 23:51:52 »

I'm sorry but how can you be using Graphics2D for a 3D renderer? persecutioncomplex
He's doing what I'm doing but using java's polygon rasterization vs. making his own.

Offline buddyBro
« Reply #12 - Posted 2017-01-10 04:36:07 »

Yep pretty much. I'm calculating the screen location, color/shade, order of all the shapes needed to be drawn and just telling some graphics2D instance to drawPolygon / drawString.

I've been working on all the optimization algorithms lately, so haven't had much to show. But I'm pretty much done for now with optimizations, and added support for rotated cubes just to have something new to show.

If anyone's interested, here's an generic overview of the optimization steps I take. Feel free to add suggestions.
1) determine max draw distance (the distance after which even the brightest 1x1x1 object would be too dark / small to be noticeable anyways)
2) determine the coordinates of the minimum-bounding-axis-aligned-rectangular-prism encompassing the camera field of view.
3) iterate through these coordinates (left -> center, then right -> center, then center, so we don't have to worry about draw-order or zbuffering)
4) for each non-empty coordinate, check if it is within the camera field of view via a simple dot product and distance check (since the minimum bounding rectangular prism is larger than the fov, and since this check is very low-cost)
5) get the surfaces of that coordinate that have normals facing the camera (again via dot product)
6) convert the surface coordinates to screen coordinates. As a final check, make sure at least one of the surface's screen x,y coordinates are within [-.5, .5] and if so, draw it

On top of this, in order to support vast areas, with potentially low-density, the world is divided into chunks, so that chunks aren't initialized unless they contain at least one surface, and they are skipped over in the drawing algorithm if empty.

The only additional major optimization plan I have, I plan not to update (remove & add) surfaces as they move, unless they are in view. Instead, I'll "expire" the surface's old location via some counter, and add "trigger-points" bounding clusters of surfaces which move together so that the actual surfaces are added to the world only if the trigger points are visible.

Here's a new 30-sec screen-capture.

<a href="http://www.youtube.com/v/Oes6N6I4pjs?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/Oes6N6I4pjs?version=3&amp;hl=en_US&amp;start=</a>
Offline J0
« Reply #13 - Posted 2017-01-10 08:36:07 »

Shouldn't it be painfully slower? I'm impressed that you can do that heheh

Offline buddyBro
« Reply #14 - Posted 2017-01-10 14:37:16 »

Shouldn't it be painfully slower? I'm impressed that you can do that heheh

For a  simple use case like this (i.e. no textures, hard shadows, gloss, reflections, etc) the most computationally heavy part with traditional rendering tends to be determining draw order (via z buffering for example). And one of the main trade offs of voxel rendering is that ordering becomes really computationally cheap at the cost of dramatically increasing the number of polygons you have to deal with. But that's where all these optimization algorithms come in, they all try to minimize the number of "qualified" polygons we have to consider. As for the actual drawing pixels on screen, I'm not sure whether graphics2d instructions still eventually get converted to graphics card instructions or whether they are completed by the CPU, but I do know for my previous rendering project, switching to jogl was only a 10 or so fps gain.
Offline buddyBro
« Reply #15 - Posted 2017-01-15 19:00:21 »

Added ships, i.e. moving cluster of blocks. There's graphical bug with some surfaces being drawn on top of other surfaces when they shouldn't be, but I hope to fix that soon.

<a href="http://www.youtube.com/v/fsdF4Uid7BM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/fsdF4Uid7BM?version=3&amp;hl=en_US&amp;start=</a>
Offline Archive
« Reply #16 - Posted 2017-01-15 19:05:11 »

Added ships, i.e. moving cluster of blocks. There's graphical bug with some surfaces being drawn on top of other surfaces when they shouldn't be, but I hope to fix that soon.
You don't have a z-buffer?

Edit: just remembered that you use java2d

Offline buddyBro
« Reply #17 - Posted 2017-01-18 16:44:33 »

Yep, no zbuffer. Just a small update, trailing camera done. Next step, allowing user to control the ship.

<a href="http://www.youtube.com/v/2yQoAaePREA?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/2yQoAaePREA?version=3&amp;hl=en_US&amp;start=</a>
Offline Archive
« Reply #18 - Posted 2017-01-18 19:12:46 »

To be honest, your renderer would be faster if you didn't use Java2D and it would look much better too :p
But I'm not going to force you to do anything, it's your engine Smiley


Offline buddyBro
« Reply #19 - Posted 2017-02-04 00:08:54 »

Sure, using jogl or lwjgl would make it faster, but it doesn't really affect the code at all. Maybe later I'll just swap out Java2d for one of those.

I've completed controls; here's a quick video demonstration. Next step is to make the ship modular, as in built from different pieces such as hull, thruster, helium, etc.

<a href="http://www.youtube.com/v/gusWNdKVUiM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/gusWNdKVUiM?version=3&amp;hl=en_US&amp;start=</a>
Offline buddyBro
« Reply #20 - Posted 2017-02-11 12:34:42 »

Here's a quick update of the new rotor components added. The ship is now modular, i.e. depending on how it's made up of hull and rotor components, it will have different mass, angular inertia, and acceleration. Next steps, adding a 3rd component (blades / wings) and then adding non-cubic shapes. Here's 2 different ship configurations:
<a href="http://www.youtube.com/v/Pi7JR8kDpIk?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/Pi7JR8kDpIk?version=3&amp;hl=en_US&amp;start=</a>
<a href="http://www.youtube.com/v/iijK48PYLCo?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/iijK48PYLCo?version=3&amp;hl=en_US&amp;start=</a>
Offline buddyBro
« Reply #21 - Posted 2017-02-26 02:12:11 »

I've added 2 more components. Helium component which applies an up force, and a blade/wing component which demonstrates sub-cube geometry. Next steps to make a ship editor so they can be built and customized without writing lines of code.

I've also added a link to the github repo, https://github.com/mahhov/ot-voxel-engine

<a href="http://www.youtube.com/v/_M-LvFoPrGo?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/_M-LvFoPrGo?version=3&amp;hl=en_US&amp;start=</a>
<a href="http://www.youtube.com/v/0xAV5HDiWlw?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/0xAV5HDiWlw?version=3&amp;hl=en_US&amp;start=</a>
Offline buddyBro
« Reply #22 - Posted 2017-03-12 00:00:55 »

The visual editor is now complete. Here's a ~7 min demo. Feel free to try it out (via the github link, since I haven't updated dropbox link since the first post), and post your creations or private message your creations to me if you prefer.

Sandbox Controls:
w, a, s, d, space, and shift - accelerate ship forward, left, backward, right, up, and down
z, x - zoom camera in and out
move mouse - change camera orientation
p - pause
enter - toggle between free-camera (controlled by mouse movement) and follow-camera (always looks towards your ship)
m - to toggle between sandbox and editor

Editor Controls:
w, a, s, d, space, and shift - to move camera
i, j, k, l, u, o - to change selected direction
1, 2, 3, 4, 0 - to change selected piece (1=hull, 2=rotor/thruster, 3=helium, 4=blade/wing, 0=delete)
mouse move - to change selected location
mouse click - to place selected piece with selected direction at selected location
enter - to reset camera to default location and orientation
\ - to load ship from file
/ - to save ship to file
m - to toggle to sandbox mode and try out your creation! (be sure to save before going to sandbox mode. sandbox mode will load from file, not from whatever is in your editor)

<a href="http://www.youtube.com/v/5Nw9JopHREc?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/5Nw9JopHREc?version=3&amp;hl=en_US&amp;start=</a>
Offline buddyBro
« Reply #23 - Posted 2017-03-15 14:29:21 »

Here's a final video showing off how the engine handles some simple map (generated using the square and diamond algorithm).
There's also a pink block you may notice that's shooting out small projectiles every few seconds, it's the gun module.
Next steps if I continued to the project would have been to make the world destructible and collision detection and such.
However, I'll most likely be stopping working on this project as I've achieved all the goals I wanted to reach with it in terms of rendering optimizations and algorithms.

By the way, if trying to run the code in the git hub repository, there are 3 main methods, Engine.main will just run sandbox mode, EditorEngine.main will run just the editor mode, and Client.main will run them both (toggling back and forth via the 'm' key).

I'll update the top post to include the 2 latest videos.

Thanks guys for all the feedback.

<a href="http://www.youtube.com/v/Vuf5CngovKY?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/Vuf5CngovKY?version=3&amp;hl=en_US&amp;start=</a>
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
Ecumene (51 views)
2017-09-30 02:57:34

theagentd (76 views)
2017-09-26 18:23:31

cybrmynd (183 views)
2017-08-02 12:28:51

cybrmynd (182 views)
2017-08-02 12:19:43

cybrmynd (189 views)
2017-08-02 12:18:09

Sralse (197 views)
2017-07-25 17:13:48

Archive (747 views)
2017-04-27 17:45:51

buddyBro (881 views)
2017-04-05 03:38:00

CopyableCougar4 (1429 views)
2017-03-24 15:39:42

theagentd (1319 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!