Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  java3d polygon_array  (Read 1826 times)
0 Members and 1 Guest are viewing this topic.
Offline hawkwind

Junior Member




Java games rock!


« Posted 2003-05-11 13:39:36 »

I am confused...perhaps youse guys can help...The code below is from a java3d terrain applet i once saw.  He is setting up his floor terrain as a polygon array, roughly U shaped,  and texturing with a grass image.   What I don't understand is the use of greater than 0 texture coord's.  I thought that these were required to range twixt 0 and 1 and yet this produces a nice ground floor.  Any ideas what is happening here??


Appearance app = new Appearance();
       app.setMaterial(new Material());
       app.setTexture(texture);
       TextureAttributes textureAttributes = new TextureAttributes();
       textureAttributes.setTextureMode(TextureAttributes.MODULATE);
       app.setTextureAttributes(textureAttributes);
       
       // create geometry
       GeometryInfo geom = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
       Point3f[] coords = new Point3f[16];
       coords[0] =  new Point3f(-12.0f, 1.2f, -35.0f);
       coords[1] =  new Point3f(-12.0f, 1.0f, -18.0f);
       coords[2] =  new Point3f(-12.0f, 0.0f, -10.0f);
       coords[3] =  new Point3f(-12.0f, 0.0f,   0.0f);
       coords[4] =  new Point3f( -1.5f, 0.0f,   0.0f);
       coords[5] =  new Point3f( -0.5f, 0.0f, -10.0f);
       coords[6] =  new Point3f( -0.5f, 1.0f, -18.0f);
       coords[7] =  new Point3f(-0.25f, 1.0f, -30.0f);
       coords[8] =  new Point3f( 0.25f, 1.0f, -30.0f);
       coords[9] =  new Point3f(  0.5f, 1.0f, -18.0f);
       coords[10] = new Point3f(  0.5f, 0.0f, -10.0f);
       coords[11] = new Point3f(  1.5f, 0.0f,   0.0f);
       coords[12] = new Point3f( 12.0f, 0.0f,   0.0f);
       coords[13] = new Point3f( 12.0f, 0.0f, -10.0f);
       coords[14] = new Point3f( 12.0f, 1.0f, -18.0f);
       coords[15] = new Point3f( 12.0f, 1.2f, -35.0f);
       geom.setCoordinates(coords);
       Point2f[] text = new Point2f[16];
       text[0] =  new Point2f(  -6.0f, -17.5f);
       text[1] =  new Point2f(  -6.0f,  -9.0f);
       text[2] =  new Point2f(  -6.0f,  -5.0f);
       text[3] =  new Point2f(  -6.0f,   0.0f);
       text[4] =  new Point2f( -0.75f,   0.0f);
       text[5] =  new Point2f( -0.25f,  -5.0f);
       text[6] =  new Point2f( -0.25f,  -9.0f);
       text[7] =  new Point2f(-0.125f, -15.0f);
       text[8] =  new Point2f( 0.125f, -15.0f);
       text[9] =  new Point2f(  0.25f,  -9.0f);
       text[10] = new Point2f(  0.25f,  -5.0f);
       text[11] = new Point2f(  0.75f,   0.0f);
       text[12] = new Point2f(   6.0f,   0.0f);
       text[13] = new Point2f(   6.0f,  -5.0f);
       text[14] = new Point2f(   6.0f,  -9.0f);
       text[15] = new Point2f(   6.0f, -17.5f);
       geom.setTextureCoordinates(text);
       // there is only one polygon with 16 vertices
       int[] stripCounts = new int[1];
       stripCounts[0] = 16;
       geom.setStripCounts(stripCounts);
       // easy creation of other elements (normal, ...)
       new Triangulator().triangulate(geom);
       geom.recomputeIndices();
       new NormalGenerator(Math.PI).generateNormals(geom);
       geom.recomputeIndices();
       new Stripifier().stripify(geom);
       geom.recomputeIndices();
       
       // create and return shape
       Shape3D shape = new Shape3D(geom.getIndexedGeometryArray(), app);
       return shape;

Offline pepe

Junior Member




Nothing unreal exists


« Reply #1 - Posted 2003-05-11 15:02:31 »

An image always have coordinates between 0 and 1.
Nevertheless, when you map it, you can use coordinates greater than that, if you want a polygon to show the same texture many times in it.  For example, if you set a polygon with a 0.0 and 2.0 coordinates for two different points, the texture will be repeated two times from its beginning to its end. If you set .5 and 10, it will be repeated 9.5 times, beginning in the middle of the texture.
Did i make it clearer?

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Offline hawkwind

Junior Member




Java games rock!


« Reply #2 - Posted 2003-05-11 20:07:57 »

i read
i learn
i read again
and I am still surprised!!!! Thanx alot.

So I could use a single 'grass' image and give N different appearence just by change this repeat count...cooll

thanx again
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.

BurntPizza (14 views)
2014-09-21 02:42:18

BurntPizza (13 views)
2014-09-21 01:30:30

moogie (13 views)
2014-09-21 00:26:15

UprightPath (24 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (96 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!