• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
HarriPellikka

Duplicating vertices via indices causes weirdness [SOLVED]

6 posts in this topic

Okay, this is kind of a sequel to my last post: ( [url="http://www.gamedev.net/topic/630360-confused-about-vertices-indices-and-tex-coords-when-using-vboglsl/"]http://www.gamedev.n...-using-vboglsl/[/url] )

Basically, I'm trying to create the needed vertices from a set of base vertices, indices and UV coordinates. I just can't get it right. Let's take a simple cube for an example: I have 8 base vertex coordinates (read from a FBX file), 36 indices for triangles and 36 UV coordinates, one for each index. Now, I need a new set of vertices with the UV coordinates mapped to them.

Let's assume I have vertex coordinates like this:
[CODE]
(1, 1, -1)
(1, -1, -1)
(-1, -1, -1)
(-1, 1, -1)
(1, 1, 1)
(1, -1, 1)
(-1, -1, 1)
(-1, 1, 1)
[/CODE]

And indices list like this:
[CODE]
4,0,3
4,3,7
2,6,7
2,7,3
1,5,2
5,6,2
0,4,1
4,5,1
4,7,5
7,6,5
0,1,2
0,2,3
[/CODE]

I tried a simple code like this:
[CODE]
List<Vertex> tempVerts = new List<Vertex>();
for(int i = 0; i < indices.Count; ++i)
{
tempVerts.Add(vertices[indices[i]]); // 'vertices' is the list of the eight original vertices
}
vertices = tempVerts; // override the original list with the newly made one
[/CODE]

.. but it cause a hell of a mess:
[attachment=10985:cube_prob_2.jpg]

... while this is how it SHOULD be:
[attachment=10986:cube_correct.jpg]

I'm losing my head here, because I KNOW it's a simple thing, yet I cannot get my mind around it. Please help me before I go bald from pulling my hair! Also, someone told me last time that there should be 24 unique vertices in the final version, but I get 36. Huh?
0

Share this post


Link to post
Share on other sites
Why didn't you continue this discussion in that original thread ? .... It seems fairly relevant.

Anyway: The advice you were given, relating to 24 indices for 8 base vertices, assumes that you're drawing quads. So, for 8 vertices that specify the corners of some cube, you have a total of 6 faces, meaning that you need 24 indices to specify the 4 verts for each individual face (6 * 4 = 24).
0

Share this post


Link to post
Share on other sites
[quote name='Goran Milovanovic' timestamp='1346258708' post='4974483']
Why didn't you continue this discussion in that original thread ? .... It seems fairly relevant.

Anyway: The advice you were given, relating to 24 indices for 8 base vertices, assumes that you're drawing quads. So, for 8 vertices that specify the corners of some cube, you have a total of 6 faces, meaning that you need 24 indices to specify the 4 verts for each individual face (6 * 4 = 24).
[/quote]

This felt kind of a different problem, so I decided to pop up a new thread.

In fact, i'm using triangles as is the standard, quads are quite "dead" anyway.
0

Share this post


Link to post
Share on other sites
[quote name='Manabreak' timestamp='1346259201' post='4974486']
In fact, i'm using triangles as is the standard, quads are quite "dead" anyway.
[/quote]

Where is this written? I don't think it's true.

In either case, if you're intent on using triangles, you have to make sure that your texture coordinate buffer stores the proper values for that geometry type.
0

Share this post


Link to post
Share on other sites
[quote name='Goran Milovanovic' timestamp='1346266343' post='4974525']
[quote name='Manabreak' timestamp='1346259201' post='4974486']
In fact, i'm using triangles as is the standard, quads are quite "dead" anyway.
[/quote]

Where is this written? I don't think it's true.

In either case, if you're intent on using triangles, you have to make sure that your texture coordinate buffer stores the proper values for that geometry type.
[/quote]

There's a lot of discussion about triangles over quads: hardware optimization towards triangles, triangles being quaranteed to be on a single plane etc.

Anyway, you're not really answering to the original question here. The problem here is not about texture coordinates, but the geometry, and not about using triangles or quads. Help is appreciated, if given. :)
0

Share this post


Link to post
Share on other sites
[quote name='Manabreak' timestamp='1346267558' post='4974532']
There's a lot of discussion about triangles over quads: hardware optimization towards triangles, triangles being quaranteed to be on a single plane etc
[/quote]

Assuming that specifying your data in terms of triangles is more efficient then quads (and assuming that this efficiency gain is more than negligible): This doesn't make triangles "standard", and it certainly doesn't make quads "dead".

Did you try using quads? If not, you should, just to ensure that your general data pipeline is functioning properly.

[quote name='Manabreak' timestamp='1346267558' post='4974532']
Anyway, you're not really answering to the original question here.
[/quote]

The only question I noticed is "Huh?" - relating to your confusion about why people mentioned 24 indices. I think I explained that well enough, but if there's still something that you don't understand, feel free to ask additional questions. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

[quote name='Manabreak' timestamp='1346267558' post='4974532']
The problem here is not about texture coordinates, but the geometry, and not about using triangles or quads.
[/quote]

... Ok. I mean, it's hard for me to be sure (or, as sure as you appear to be), because looking at your rendering, it seems like the texture coordinates are wrong; Almost like someone tried to use a texcoord buffer intended for quads to texture triangles.

It would probably help if you could post the code that actually populates the vbo - Maybe you're loosing your ordering when data is passed from your high-level container structures.

Sorry I couldn't be more helpful.
0

Share this post


Link to post
Share on other sites
Umm, the problem is quite clear when you look the images - the geometry is f'd up. It's the same object from the exact same perspective.

The order stays the same, I've checked it a million times. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] I've even tried disabling texturing and texture coordinates alltogether, it didn't help, so I really doubt it's the texture coordinates messing up the geometry.

EDIT:

Ugh, I finally solved it. I didn't notice that after I duplicated the vertices they were already in the correct order and I still used the old index array. Duh. Well, it works now :D Edited by Manabreak
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0