Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
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  
  Voxel engine: What's more efficient?  (Read 7411 times)
0 Members and 1 Guest are viewing this topic.
Offline RylandAlmanza

Junior Devvie

Medals: 3

« Posted 2012-03-05 05:50:13 »

So I'm making a voxel engine with lwjgl. Every entity is composed of a bunch of voxels. I'm wondering which of the following two methods is more efficient for moving around/rotating an entity (Or if there's a better method.)

Method 1: An entity has x, y, and z variables that I can change to move it around. These variables will be used for the offset of every voxel that the entity is composed of. The render function calculates where every quad of every voxel will be based on the x, y, and z variables of the entity. Upside: I can move the entire entity around by simply changing the x, y, and z variables. Downside: Many, many quad positions will have to be calculated every single render function!

Method 2: All the voxel quads of an entity are loaded into a display list when the game starts. I can move the entity around using glPushMatrix(), glTranslatef(), and glPopMatrix(). Upside: This means that the program doesn't have to do all those calculations every frame. Downside the voxel positions in the display list are fixed, so I can only move the entity around by pushing and popping the matrix. I heard that having to do this for every entity is a bad Idea.

I'm not even sure If everything I said is true, so correct me if I said something wrong, and I'll edit the post. 3D is a lot more confusing than 2D! Anyways, which method is more efficient? Are there other methods that might work better? Thanks!
Offline theagentd
« Reply #1 - Posted 2012-03-05 09:22:01 »

This all depends on the ratio between vertices and objects. If each object has very few vertices the OpenGL matrix calls will be a bottleneck, but if you have many vertices per object it's obviously faster to let OpenGL handle the translating. One of them depends on the number of objects, the other one on the total number of vertices. Also note that if you only have a handful of objects any of the two will be fast enough of course.

This is a known performance bottleneck, and is solved in a number of other ways too, depending on what you're drawing.

Offline Riven

« JGO Overlord »

Medals: 1371
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #2 - Posted 2012-03-05 09:25:56 »

How many voxels are moving? How many voxels are static?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen

JGO Kernel

Medals: 518

« Reply #3 - Posted 2012-03-05 11:09:22 »

There's been alot of recent research on voxels.  If you want ignore that and keep it simple, then leave the voxel model alone (in model space) and move the camera to reflect it's relative world position.
Offline RylandAlmanza

Junior Devvie

Medals: 3

« Reply #4 - Posted 2012-03-05 20:07:57 »

There will be many more vertices than there are objects. For example, each voxel has 24 vertices (I realize this isn't the most efficient way to do it.) and my player object is composed of 94 voxels (And that's after I hollowed out the inside of him!) And I don't plan to have too many objects on the screen, so it sounds like the matrix calls would be best then, right?
Offline theagentd
« Reply #5 - Posted 2012-03-05 20:24:17 »

94 isn't a lot, but in my opinion enough to use the matrix stack. You know, "a lot" in 3D games is usually 1000+, sometimes even 10 000+... xD

Pages: [1]
  ignore  |  Print  

Riven (581 views)
2019-09-04 15:33:17

hadezbladez (5510 views)
2018-11-16 13:46:03

hadezbladez (2402 views)
2018-11-16 13:41:33

hadezbladez (5772 views)
2018-11-16 13:35:35

hadezbladez (1223 views)
2018-11-16 13:32:03

EgonOlsen (4661 views)
2018-06-10 19:43:48

EgonOlsen (5682 views)
2018-06-10 19:43:44

EgonOlsen (3198 views)
2018-06-10 19:43:20

DesertCoockie (4095 views)
2018-05-13 18:23:11

nelsongames (5115 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 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‑
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!