Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 3027 times)
0 Members and 1 Guest are viewing this topic.
Offline hawkwind

Junior Devvie

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());
       TextureAttributes textureAttributes = new 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);
       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);
       // there is only one polygon with 16 vertices
       int[] stripCounts = new int[1];
       stripCounts[0] = 16;
       // easy creation of other elements (normal, ...)
       new Triangulator().triangulate(geom);
       new NormalGenerator(Math.PI).generateNormals(geom);
       new Stripifier().stripify(geom);
       // create and return shape
       Shape3D shape = new Shape3D(geom.getIndexedGeometryArray(), app);
       return shape;

Offline pepe

Junior Devvie

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:
GoSub: java2D gamechmark
Offline hawkwind

Junior Devvie

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  

EgonOlsen (74 views)
2018-06-10 19:43:48

EgonOlsen (55 views)
2018-06-10 19:43:44

EgonOlsen (74 views)
2018-06-10 19:43:20

DesertCoockie (254 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (154 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (808 views)
2018-03-24 14:43:53

Solater (172 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!