Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 1247 times)
0 Members and 1 Guest are viewing this topic.
Offline Desttinghim

Junior Newbie





« Posted 2013-08-15 06: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: 128
Projects: 4
Exp: 3 years



« Reply #1 - Posted 2013-08-15 07: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 14: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 15: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 17: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.
http://tomdalling.com/blog/modern-opengl/03-matrices-depth-buffering-animation/
http://www.opengl.org/archives/resources/faq/technical/depthbuffer.htm

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #5 - Posted 2013-08-15 18: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 Member


Medals: 17



« Reply #6 - Posted 2013-08-15 22: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.
http://blog.wolfire.com/2009/06/how-to-project-decals/
www.arcsynthesis.org/gltut/Texturing/Tut17 Projective Texture.html

Unfortunately, I found the most accurate and best explanation to come from a book: OpenGL 4.0 Shading Language Cookbook.
http://www.packtpub.com/opengl-4-0-shading-language-cookbook/book

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 23: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): http://pastebin.java-gaming.org/a12e3368f67
Offline sirkarpfen

Junior Member


Medals: 2
Exp: 2 years



« Reply #8 - Posted 2013-08-16 09: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: http://www.opengl.org/sdk/docs/man/xhtml/glDepthRange.xml. Most of the time you can set the depthBuffer like that:

1  
Gdx.gl.glDepthRangef(0f, 1.0f); //0 beeing the near plane and 1 beeing the far plane
Offline Geemili

Senior Member


Medals: 9
Projects: 1
Exp: 2 years


No Games Finished


« Reply #9 - Posted 2013-08-16 21: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (34 views)
2014-07-18 06:55:21

Zero Volt (30 views)
2014-07-17 23:47:54

danieldean (25 views)
2014-07-17 23:41:23

MustardPeter (27 views)
2014-07-16 23:30:00

Cero (42 views)
2014-07-16 00:42:17

Riven (44 views)
2014-07-14 18:02:53

OpenGLShaders (32 views)
2014-07-14 16:23:47

Riven (34 views)
2014-07-14 11:51:35

quew8 (30 views)
2014-07-13 13:57:52

SHC (66 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!