Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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 3D Multitextured Terrain  (Read 1593 times)
0 Members and 1 Guest are viewing this topic.
Offline KudoDEV

Senior Newbie





« Posted 2013-10-09 00:33:04 »

So I have researched a whole lot but I cannot find out how to do it.

I know it is possible through shaders but I haven't been able to find a tut on how to do it with more than 2 textures.

The result I'm looking for is this: http://www.youtube.com/watch?v=J-FFLSV1mKE

I need help on figuring out how to draw a tile on a 3D triangle mesh grid, almost like 2D game maps are made. Just 3D.


So I need help applying textures to range of squares(2 adjacent triangles)

I have this so far  THE GUI IS A WIP:


Offline HeroesGraveDev

JGO Kernel


Medals: 212
Projects: 11
Exp: 2 years


If it wasn't Awesome, it wasn't me.


« Reply #1 - Posted 2013-10-09 02:54:34 »

Use a texture atlas.

Offline KudoDEV

Senior Newbie





« Reply #2 - Posted 2013-10-09 02:57:42 »

How will a textureatlas texturize my mesh like tiles
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline KudoDEV

Senior Newbie





« Reply #3 - Posted 2013-10-11 02:29:57 »

Are you guys just trying to get posts? Seriously those comments mean nothing. How would I use a TextureAtlas, explain.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #4 - Posted 2013-10-11 02:38:07 »

Wow, that's not a good idea to insult someone.

Try actually thinking about the problem. Have you attempted anything? Its really simple, just use a texture atlas, and apply the large texture over a few vertices (your tiles). If you could actually tell us what you're having trouble with instead of assuming we know what you mean, we could help.

Offline KudoDEV

Senior Newbie





« Reply #5 - Posted 2013-10-11 02:59:12 »

Well I didn't mean to insult.

Just those answers aren't answering anything.

Its a 3D mesh. I want to texture it like a tile based game.

However, Its 3D.

I want to be able to draw a texture between two triangles that are forming a square.

A tile-based 3D map. Like in the video.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #6 - Posted 2013-10-11 03:20:31 »

Its easy, The tile coordinates range from 0 to 1. Tile coordinates are as big as you want, but are generally a power of 2 (2, 4, 8, 16, 32, 64, etc...). In your tile class, or whatever your mesh class is called, simply combine the vertex data for two triangles into one buffer, then draw it with the texture buffer. I believe your issue is you can't figure out how to draw two triangles together?

Offline KudoDEV

Senior Newbie





« Reply #7 - Posted 2013-10-11 03:33:06 »

I'm using LibGDX's Mesh class with verticeattribute for texcoords. And simply using mesh.render() with shaders applied. I have it working with 1 texture but since shaders bind using texCoords and the triangles touch texcoords are shared for example its not what I want: 

Offline KudoDEV

Senior Newbie





« Reply #8 - Posted 2013-10-11 19:18:59 »

Thanks, that answer clears a lot. And yeah, if you would like to share I would like to take a look.

Is the effect the one I spoke of?

With a mesh like that UV mapping certain corners of my mesh differently for tiles wouldn't have to be done. Since each set of triangles are symmetrical.
Offline davedes
« Reply #9 - Posted 2013-10-11 21:01:34 »

Quote
How would I use a TextureAtlas, explain.
Walk before you run...

Maybe start with a 2D game if concepts like a texture atlas are not yet within your grasp. 3D is very difficult, especially things like terrain.

In your case you should just use different texture coordinates. You need to render the "tile" (i.e. two triangles) with the calculated UVs from a TextureRegion. More info on this here:
https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures#texture-atlases

For more advanced terrain rendering techniques, check out this site:
http://www.zephyrosanemos.com/

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

Senior Newbie





« Reply #10 - Posted 2013-10-11 21:10:18 »

I know what a textureatlas is.

I just don't see how a TextureAtlas can draw on specified vertices of my mesh.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #11 - Posted 2013-10-11 21:32:04 »

... Its just a texture that contains sub textures so you only to load the texture file once. There's no difference between a texture from a texture atlas and a regular texture.

Offline davedes
« Reply #12 - Posted 2013-10-11 22:13:57 »

I know what a textureatlas is.

I just don't see how a TextureAtlas can draw on specified vertices of my mesh.
Did you read the links? Wink You need to use different texture coordinates for your tile vertices. These coordinates would be calculated for you by TextureRegion. TextureAtlas just stores a bunch of TextureRegions by key.

Offline KudoDEV

Senior Newbie





« Reply #13 - Posted 2013-10-12 02:04:09 »

Yes, I knew that. That's why I didn't know how a textureatlas helps me.
Offline KudoDEV

Senior Newbie





« Reply #14 - Posted 2013-10-13 19:11:17 »

Thanks! Terrain patch is exactly what I was looking for in an example. It cleared up what I didn't understand.
Offline KudoDEV

Senior Newbie





« Reply #15 - Posted 2013-10-14 07:34:21 »

Will do. And I have progressed a WHOLE lot now. I will be working on water and world objects soon. My problem before was just the shared vertices, it wouldn't let me UVMap effectively.
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.

xsi3rr4x (32 views)
2014-04-15 18:08:23

BurntPizza (29 views)
2014-04-15 03:46:01

UprightPath (44 views)
2014-04-14 17:39:50

UprightPath (27 views)
2014-04-14 17:35:47

Porlus (44 views)
2014-04-14 15:48:38

tom_mai78101 (65 views)
2014-04-10 04:04:31

BurntPizza (125 views)
2014-04-08 23:06:04

tom_mai78101 (225 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!