Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
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  
  [LibGDX] Decals and Models  (Read 2095 times)
0 Members and 1 Guest are viewing this topic.
Offline Desttinghim

Junior Newbie

« Posted 2013-08-15 04:35:15 »

Okay, I'm kind of new to Java and LibGDX, but I decided to start out big and try doing 3d (Don't worry, I've had a few years of experience with GM, and my brother knows quite a bit about Java and LibGDX). The style of 3D I decided to go for was Paper Mario style.

To do that, I set up a a ModelBatch for the level and a DecalBatch for the entities. This works sort of, but the decals all render on top of the level. Does anyone know of a way to get the decals to be able to be obscured by the models, or am I going have to use a different method?
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 162
Projects: 5
Exp: 3 years

« Reply #1 - Posted 2013-08-15 05:04:53 »

No offense, but you're going in the wrong direction. First of all, you shouldn't try 3d first if you're new to libgdx, and especially if you're new to Java - if you're new to Java you shouldn't even be making games. Second, libGDX's 3d architecture is still quite underdeveloped, so for that I would recommend using LWJGL (if you can handle it) or something high-level like libgdx but intended for 3d (Ardor3d, JMonkeyEngine, etc). And finally, Game Maker experience is not going to help you at all, except possibly ideas about gameplay. Game Maker is way too high level, and even with the embedded C code, it's still too different from Java and libGDX.
Offline davedes
« Reply #2 - Posted 2013-08-15 12:29:00 »

Jimmt - it makes no sense to suggest LWJGL for a 3D game over LibGDX's 3D API. The whole point LibGDX is developing a 3D API is so that you don't need to build your own 3D scene graph, model loaders, animation system, material handlers, etc.

Also; the LibGDX 3D API is not really "underdeveloped." It's getting to be quite stable.

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

Junior Newbie

« Reply #3 - Posted 2013-08-15 13:03:34 »

While I haven't used anything extensively besides GameMaker, I have started many times with C++, C#, and Java, so I understand how to use them in their basic form. And, like I said, my brother has worked with Java for a while so it's easy for me to ask questions about how to use it when the need arises.

Back to the point at hand, I don't think I'm going to switch engines. I'm not doing anything that complicated with 3D. So far I have only used the 3D part to render the level. My only question is with Decal's and Models, and if it's possible to have them both be in the same depth buffer (Does this make any sense to anybody? Or should I make a picture of what I mean?).
Offline davedes
« Reply #4 - Posted 2013-08-15 15:40:22 »

You need to render the decals at a different Z than the models. Also make sure your near/far range is OK and your depth buffer is enabled.

Keep in mind there is only one depth buffer.

Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 162
Projects: 5
Exp: 3 years

« Reply #5 - Posted 2013-08-15 16:53:42 »

Jimmt - it makes no sense to suggest LWJGL for a 3D game over LibGDX's 3D API. The whole point LibGDX is developing a 3D API is so that you don't need to build your own 3D scene graph, model loaders, animation system, material handlers, etc.

Also; the LibGDX 3D API is not really "underdeveloped." It's getting to be quite stable.
True, I don't know why I suggested LWJGL, but it's going to be a while before the (2d-based) libgdx develops a 3d api better than other, 3d-only, engines/libraries (believe me I would love to have 3d with libgdx).
Offline Redocdam

Senior Devvie

Medals: 17

« Reply #6 - Posted 2013-08-15 20:18:01 »

The only 3D method I know for decals is using projective texture mapping. The end result mimics the way a projector would display an image in real life. The process however is a bit different.

It's hard to explain it in a brief description, but you basically use a biased matrix to convert a texture to the proper UV coordinates of a model. This is combined with a "look at" matrix. I should note any predefined UV coordinates for a model are not used nor needed for this. When I first started learning projective texture mapping, I often got tripped up thinking I needed to use the baked in UV coordinates of a model.

It's a technique often used in conjunction with shadow mapping to project the shadows on to objects, so you may find some useful information in tutorials which talk about shadow mapping.

Here are some further explanations about projective texture mapping. Projective Texture.html

Unfortunately, I found the most accurate and best explanation to come from a book: OpenGL 4.0 Shading Language Cookbook.

But before you go through all that, I would check through LibGDX to see if they've already got something to create the projective matrix for you. Maybe you'll get really lucky and find they've got something set up for projecting. If not, you're going to need to code your own shader.

Also Note: If you're maintaining an orthogonal view, then using a depth buffer as DaveDes alluded to, may be easier to understand instead of applying a full 3D solution.
Offline Desttinghim

Junior Newbie

« Reply #7 - Posted 2013-08-15 21:00:27 »

I don't think we're talking about the same decals here. In LibGDX, Decals are 2D sprites in 3D space. Essentially you have a flat plane with a texture on it. What I'm trying to do is make it so that these 'Decals' are able to go behind models. I think the problem has something to do with the Models and Decals not rendering in the same batch.

It might not be clear from this screenshot, but the guy is actually inside of the block. I don't want that to happen.

I probably should have posted this earlier. Also, here's most the code that has to do with rendering in case that helps (probably will):
Offline sirkarpfen

Junior Devvie

Medals: 2
Exp: 2 years

« Reply #8 - Posted 2013-08-16 07:54:50 »

I don't know much about libGDX's 3D API but some things were strange about your code.

  • First you don't use your decalBatch anywhere in your render method, or are you using it elsewhere?
  • Why are you ordering the Models you would like to draw?
  • What are you doing with the renderingOrder object?

Maybe i just need more context to fully understand what you're doing, but you can also take a look at this (If you have not allready done that):

Using the libgdx 3D API

Edit: I think i found something. Your depthBuffer is maybe not correctly initialised. You should use values between -1 and 1, als specified here: Most of the time you can set the depthBuffer like that:

1, 1.0f); //0 beeing the near plane and 1 beeing the far plane
Offline Geemili

Senior Devvie

Medals: 9
Projects: 1
Exp: 2 years

No Games Finished

« Reply #9 - Posted 2013-08-16 19:16:47 »

@sirkarpfen: To render with a decal batch you simply add a Decal, and then call DecalBatch.flush(), and it will render.

Also, decals are not automatically depth buffered, so he ordered them, not models.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (26 views)
2015-07-27 16:38:00

Riven (15 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (25 views)
2015-07-25 00:14:37

BurntPizza (38 views)
2015-07-24 22:06:39

BurntPizza (21 views)
2015-07-24 06:06:53

NoxInc (24 views)
2015-07-22 22:16:53

NoxInc (16 views)
2015-07-22 22:13:39

Jesse (38 views)
2015-07-22 03:10:36
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!