Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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  
  Texturing Terrain  (Read 2610 times)
0 Members and 1 Guest are viewing this topic.
Offline EBTTRT

Senior Newbie





« Posted 2003-12-03 13:38:43 »

Does anybody know a surefire way to apply a texture to Terrain?

I've only seen one example & this doesn't seem to work.  


Thanks
Offline Daath

Junior Devvie




Java games rock!


« Reply #1 - Posted 2003-12-03 14:12:50 »

Depends which terrain you have in mind. If you refering to Terrain included in Xith3d then I cannot help you I guess only Dave would have something to say about that since he is author of it.
But I can tell you how I did it in my app.  I do use similar (even though) simplified hack at it. I use qudtree as well to get geometry, then I copythat geometry into smaller patches(tiles) and only then I start applaying textures. Each tile ends up being one shape3d object. Example you saw here put everything into one shape3d object and I assume that is just done to create demo - i dont see any way how one could do good looking texturing  but placing one huge texture on the top of it. Unless texture - or subpart is recreated every frame. That is just wild guess, maybe there is a intelligent way of doing that.
  Basically I am saying you most likely will have to twist demo a bit to get to point where you can start thinking of putting textures on it.
Offline mix

Senior Newbie




In the long run, we're all dead. - Keynes


« Reply #2 - Posted 2003-12-03 14:23:13 »

I'd like to know the explaination from the Xith Terrain side too... how does this work with one big Shape3D?

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

Senior Newbie





« Reply #3 - Posted 2003-12-03 18:28:08 »

Found this interesting post from 2/3 weeks ago which might help us a little:

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1069058608;start=5#5

I'm really looking to just place textures on the whole thing or better still have three different textures depending on the height, a bit like the results of terrain generators mojo created in his jME 0.1 that allowed you to do this.
Offline hawkwind

Junior Devvie




Java games rock!


« Reply #4 - Posted 2003-12-03 19:19:10 »

Don't forget that the Xith terrain system is a matrix of banks with 2(n-1) levels...I think! so you probably want several different textures based on resolution.
Offline DavidYazel

Junior Devvie




Java games rock!


« Reply #5 - Posted 2003-12-03 19:36:49 »

The Terrain system is a terrain geometry system.  The demo just demonstrates how to use that in the simplest possible scheme.

The way Magicosm uses this is as follows:

We create a logical quadtree which has as its smallest quad 100x100, which each subsequent level being doubled. We have a table which describes the minimum distance from a sphere surrounding the user that any particular level can be visible.

We preprocess a set of blending masks 64x64 for each level 0 quad and calculate, using those masks merged texture maps for the other levels.  The level 0 masks and the level 1+ textures are stored in a file.  

Every 10 meters of movement in the world we step through the quads and see if any quads need to be added or removed.  This builds a transaction which adds or removes QuadNodes.  A quad node is a branchgroup that has either a single shape + texture + detail, or a level 0 shape, which is an ordered group of SplatShapes.  Splat shapes use COMBINE mode to combine the mask and the texture and then merge it with the underlying texture.  There can be any number of splat shapes on one tile.

Each quad node needs geometry, but the geometry is being stored in a Terrain node and updated frequently.  What we do is when we call Terrain.render we pass it a callback.  This callback is called with chunks of geometry.  We sort this geometry into buckets and assign them to the appropriate QuadNode.  If a triangle spans two QuadNodes we split the triangle using a triangle splitter.  Thus each quad node has access to its geometry all the time and can still texture its piece itself.

David Yazel
Xith3D Project Founder
http://xith3d.dev.java.net

It may look complicated, but in the end it is just a bunch of triangles
Offline Daath

Junior Devvie




Java games rock!


« Reply #6 - Posted 2003-12-03 19:56:39 »

Quote
A quad node is a branchgroup that has either a single shape + texture + detail, or a level 0 shape, which is an ordered group of SplatShapes. ....


So you do use ordered group. Now that is at least for me the most valuable info.  Smiley
Offline tomcat

Senior Newbie




Java games rock!


« Reply #7 - Posted 2003-12-05 10:16:42 »

Quote


Tried this, but it only textures the lines between the triangles not the surfaces. Any idea how I can texture the surfaces Huh
tomcat
Offline tomcat

Senior Newbie




Java games rock!


« Reply #8 - Posted 2003-12-05 12:34:24 »

Ok, managed to workout how to fill the area with the texture map, but discovered that the example doesnt allow tiling of the texture. :-/

Is it possible to tile a texture to the terrain  Huh.
tomcat
Offline Daath

Junior Devvie




Java games rock!


« Reply #9 - Posted 2003-12-05 12:35:35 »

change  POLYGON_LINE to POLYGON_FILL .
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tomcat

Senior Newbie




Java games rock!


« Reply #10 - Posted 2003-12-05 12:41:56 »

Quote

change  POLYGON_LINE to POLYGON_FILL


I have done this. But this doesnt solve the tiling problem. I get the same texture stretched across the whole terrain instead of being tiled to each polygon. Any ideas whats happening?

tomcat
Offline Daath

Junior Devvie




Java games rock!


« Reply #11 - Posted 2003-12-05 12:57:55 »

sure it does that. Texture coord are stretched from 0-1 in xz plane. Thought that is what you want. If you wanna just repeat one tile dont set texture coord and that should do it.
Offline tomcat

Senior Newbie




Java games rock!


« Reply #12 - Posted 2003-12-05 13:28:19 »

Sorry for being a bit thick here, but I dont set the texture co-ordinates. I have used the Terrain example from sith3d and made some simple modifications. Here is some of the things I have done

Quote

             TextureLoader.tf.registerPath(".");
             TextureLoader.tf.registerPath("..");
             Texture2D texture = (Texture2D)TextureLoader.tf.getMinMapTexture("stonex.jpg");

                 pa = new PolygonAttributes(PolygonAttributes.POLYGON_FILL,PolygonAttributes.CULL_BACK,0);
                 Appearance a = new Appearance();

             mat = new Material();
                 mat.setAmbientColor(0.5F, 0.5F, 0.5F);
             mat.setLightingEnable(true);
                 //a.setMaterial(mat);
                 a.setTexture(texture);
                 a.setPolygonAttributes(pa);
           shape.setAppearance(a);
                 
                 shape.setBoundsAutoCompute(false);
                 shape.setBounds(new BoundingSphere(new Point3f(0.0F, 0.0F, 0.0F), 100000F));
                 addChild(shape);



Any ideas what I am doing wrong Huh
tomcat
Offline Daath

Junior Devvie




Java games rock!


« Reply #13 - Posted 2003-12-05 13:47:52 »

I thought you were refering to aforementioned example not to Terrain example. Sorry I have not looked at that one yet AFA texturing goes.
Offline hawkwind

Junior Devvie




Java games rock!


« Reply #14 - Posted 2003-12-05 21:09:55 »

By default the texture maps from 0,0 to 1.0,1.0 in S,T coordinates (think of this as 0 to 100% in each direction).  To tile the texture you can adjust the mapping to get NxN tiles.  

I have written a small tutorial over at xith.org with source showing just this.  Go to here to see how to adjust the coords

http://xith.org/tutes/GettingStarted/html/more_fun_with_textures.html

Use this WebStart (thanx Jens) to see the tiling update realtime

http://xith.org/jws/jws-org.xith3d.gsg.TextureFun1.jnlp
Offline tomcat

Senior Newbie




Java games rock!


« Reply #15 - Posted 2003-12-06 08:35:00 »

Thnx, it does make sense. I checked out your code sample, but I am not sure where I

Quote
To tile the texture you can adjust the mapping to get NxN tiles.  


should make the change.  Huh
tomcat
Offline hawkwind

Junior Devvie




Java games rock!


« Reply #16 - Posted 2003-12-06 13:15:44 »

Basically if you have the Shape you can grab the tex coords set them to different values.  The first arg of setFloats is the array index


GeomDataInterface texCrds1 = quad.getTexCoordData(0);

texCrds1.setFloats(0, 0.0f, 0.0f);
texCrds1.setFloats(2, 10.0f  , 0.0f);
texCrds1.setFloats(4, 10.0f , 10.0f );
texCrds1.setFloats(6, 0.0f, 10.0f );
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.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!