Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
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  
  AABB and transformations  (Read 3813 times)
0 Members and 1 Guest are viewing this topic.
Offline mudlee
« Posted 2019-11-09 19:26:39 »

Hi All.

I'm so humble that rather using Unity or Unreal, I still spend my spare time on poking my rendering whatever as I still have a Starcraft like RPG idea. Which will never be released if I progress as good as I do right now Cheesy

BUT, I'm at least learning and posting here.

The problem is a common one. I have AABB boxes around my models. If I rotate or scale the models, the AABB boxes rotate and scale as well, which is not good. I removed then the rotation and scaling part from the transformation matrix, hence the AABB boxes only move without scale and rotation, but obviously it's not perfect as the bounding box will not be accurate if the model is high and thin at the same time.

I found a great solution that I should store the original AABB and when a model is rotated or scaled, I should recalculate the AABB itself from the original AABB using the translation matrix. This is good, but the problem is that I not just use AABBs for calculations like ray tracing, but also for visualizing it with a renderer and I have problem there.

The rendering logic is based on batches and instanced rendering. Of course, I can change to simple draw calls per model when I render AABBs, but then I have to render AABBs per model, which will be slow if I have too much models.

I agree, that if I want a game ASAP out, I must skip this or choose an alternative path. The thing is that currently I'm more interested at solving this math-like problem instead of releasing anything.

So any idea?
Offline KaiHH

JGO Kernel

Medals: 820

« Reply #1 - Posted 2019-11-10 10:48:55 »

The rendering logic is based on batches and instanced rendering.
And what keeps you from doing it this way with the transformed AABBs as well? Just transform your AABBs, upload all of them into a single VBO and render all of them with a single draw call, if that is what you did with the untransformed AABBs.
Offline mudlee
« Reply #2 - Posted 2019-11-10 13:44:51 »

Hm, interesting. Don't know why this idea didn't pop into my head.
So basically the transformation is done on the Java side, I upload all entities' AABBs into a single VBO, draw it with a single (not even instanced) draw call, and if any of the entities' transformation matrix changed, I just use
and update the VBO I have.

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

JGO Kernel

Medals: 820

« Reply #3 - Posted 2019-11-10 13:48:55 »

You can use instancing as well, and just use the AABBs' buffer object as an instanced vertex attribute in the shader. The choice is yours. I mean, how did you render the untransformed AABBs in the first place? Just use the same mechanism for the transformed AABBs.
By the way, I added AABB.transform(Matrix4) to the latest 1.9.20-SNAPSHOT version of JOML, if you'd like to use that to transform the AABBs:
Offline mudlee
« Reply #4 - Posted 2019-11-10 13:53:39 »

I think you've saved some of my spare hours with this comment. Thanks! I'll get back to you when I tried it out Smiley
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

nelsongames (5501 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!