Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
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  
  Texture coords and vertex arrays question.  (Read 1302 times)
0 Members and 1 Guest are viewing this topic.
zahl2001
Guest
« Posted 2004-01-29 12:39:09 »

1) Assume the object having textures mapped to it
   is a cube, so there are 6 verticies involved.
2) Assume I'm going to use one texture for all sides.

My problem is this:
1) Every vertex is shared by 3 faces of the cube.
2) It seems you can only map ONE texture corner
   to each vertex.
3) Because of this, one of the 3 faces has the correct
   corner of the texture mapped to it, and the other
   2 faces which share the vertex have the incorrect
   corneer of the texture mapped to it.

In short, how do you use vertex arrays to achieve the same results as using glBegin() and glEnd() as in NeHe's lesson 6? with the wooden box?

Thanks Smiley
Offline jeickmann

Senior Newbie




Java games rock!


« Reply #1 - Posted 2004-01-29 12:41:43 »

As far as I can see, the only way is to duplicate the vertices. Btw: thats pretty much what happens when using glVertex3f anyway.

Jan
zahl2001
Guest
« Reply #2 - Posted 2004-01-29 13:32:35 »

Wouldn't duplicating the verticies defeat the purpose of using vertex arrays (re-using already stored verticies)?

I'm a newbie, so maybe I just don't get it:)

What does everyone else do?  
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline HamsterofDeath

Junior Member




Java games rock!


« Reply #3 - Posted 2004-01-29 13:47:25 »

had that problem too.

what you could try is to re-render the texture so that every vertex only needs one texcoord. make one texture cover the whole box (the texture would look like a "+" made out of 6 boxes), so you can wrap it around.
i didn't try it, but it may be possible to do this via texcoords > 1
Offline jeickmann

Senior Newbie




Java games rock!


« Reply #4 - Posted 2004-01-29 14:37:00 »

Quote
Wouldn't duplicating the verticies defeat the purpose of using vertex arrays (re-using already stored verticies)?

I'm a newbie, so maybe I just don't get it:)

What does everyone else do?  


Since you need several texCoord, your only option is using several vertices. (Multitexturing won't help you here - at least not performance-wise - since then, you are applying all six textures to all faces).

If you don't use lighting, the vertex-processing part is very small anyway and if you use lighting, you would need several normals per vertex as well (one for each face the vertex is part of), if you want to keep the edges and not have something that has the outline of a box but the shading of a very weird sphere.

The reuse only makes sense, if the vertices don't mark hard edges but rather support a curved surface (NOT in the NURBS meaning) or if you want to tesselate a plane in order to get better specular hightlight.

Concerning HamsterofDeath's suggestions, yep you could just use one single texture for all faces, where you set up your texture-coordinate up accordingly. This is what you would for example do with more complex models anyway, you don't have a texture for every face. The only drawback is of course, that your texture-resolution is more limited, but unless you want your cube to fill almost the entire screen, no problem there.

Jan
zahl2001
Guest
« Reply #5 - Posted 2004-01-29 15:16:06 »

Well, there you have it: a clear explaination, and another of my problems solved.

Thank you, sir Smiley
Offline jeickmann

Senior Newbie




Java games rock!


« Reply #6 - Posted 2004-01-29 15:18:06 »

No problem  Grin
Offline quintesse

Junior Member




Java games rock!


« Reply #7 - Posted 2004-01-30 11:00:07 »

Thanks from me too, because this had been bugging me for some time as well Smiley
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.

pw (12 views)
2014-07-24 01:59:36

Riven (10 views)
2014-07-23 21:16:32

Riven (11 views)
2014-07-23 21:07:15

Riven (12 views)
2014-07-23 20:56:16

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

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

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

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

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

Riven (50 views)
2014-07-14 18:02:53
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!