• 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
yasmin_bd

Texture mapping question

4 posts in this topic

Hi, I posted a question in OpenGL, but as it is a bit beginner's question, i think it is relevant to this topic.

I have a curved shell-like (hollow) cylindrical surface which has been defined in obj file format. Originally obj file does not have texture. I have a jpeg image file which I would like to map to the interior of the curved surface.

Now I know texture (u,v) values range from (0.0, 0.0) to (1.0, 1.0). How can I map (u,v) values to vertices defined in the obj file manually?

 

Please provide some suggestions.

 

0

Share this post


Link to post
Share on other sites

I'm not sure how far along you are on this but I would suggest tackling this step by step.

  1. Forget about obj files and cylinders.
  2. Draw an untextured quad on the screen. (Two triangles forming a square)
    1. Do this manually creating the vertex and index buffers and filling in the vertex data yourself.
  3. Load a texture.  In this case your jpeg.
  4. Now draw the quad with the texture mapped

At this point you will know what you need to deal with your problem. You'll know:

  1. How to deal with vertex and index buffers
  2. How to load an image and create a texture
  3. How to construct the vertex data and set UVs
  4. How to bind the texture and draw textured geometry.

Once you know all that, then all you have to do is find where the obj file is loaded and when it creates the vertex data from it.  Once you know that you can write your UVs into that data.  You may have to change the vertex type and declaration.  Then your last challenge would be to figure out the math to get your UVs correct.

 

However, even though I think you would learn alot from doing this I wouldn't suggest changing or adding UVs in this way.  I'm sure the obj file format can store your UVs and you should probably be setting up the UVs in the modeling package that exported the obj file.  

 

For simple shapes like boxes, quads, cylinders, spheres, I would suggest not using an obj file at all.  Create them yourself in code, if for no other reason other than to familiarize yourself with how to construct them and manipulate them.  

 

You would need this knowledge if you then wanted to go back and start manipulating the data from the obj file.

Edited by HAM
0

Share this post


Link to post
Share on other sites

In general any point on the surface of the cylinder (radius not being relevant here) can be uniquely identified by two numbers: the distance along the axis of the cylinder and the angle around the cylinder. Those coordinates will range from 0 to the length of the cylinder, and 0 to 2*pi in angle. If you scale them both by dividing by the relevant range you will get two coordinates running from 0 to 1. Those could be used as your texture coordinates to sample the image. You will need to make a choice of which end of the cylinder is the "bottom" (i.e. the end at u=0) and what angle should be the "seam" (i.e. at v=0 and v=2*pi). Notice that the angle coordinates will repeat at this seam, so your texture will have to repeat in the corresponding direction so as not to display a visible discontinuity.

 

For more info, see e.g. http://en.wikipedia.org/wiki/Cylindrical_coordinate_system

 

Hope that helps.

Edited by BarrySkellern
1

Share this post


Link to post
Share on other sites

Actually I was thinking whether the texture image can be mapped in a different way. The image can be divided into a number of contours as shown in the figure. Then grdually map it along the depth of the tube to get look alike effect. Can texture be mapped in that way?

 

 

 

0

Share this post


Link to post
Share on other sites

Hi Yasmin - sorry, I'd like to try to be more help but that picture has lost me a bit I'm afraid!

 

I think maybe you're thinking of an unconventional mapping of the image such that the middle of the image is the origin, and a point on the cylinder (z, w) where z is the distance from an end (normalized to 0,1 range) and w is the angle around the cylinder, will map directly to a point (r, a) in the image where r is the distance from the middle and a is the angle relative to, say, the +x axis.

 

While that is a valid mapping, it suffers one significant issue: the area of the cylinder surface that a given image pixel maps to is massively different depending on the value of z, the distance along the cylinder. In effect, for large z (i.e. at one end of the cylinder) you will get a high resolution texture *around* the cylinder, while at low z (the other end, mapping to the centre of the image) you will have a very low res texture. In the limit, the end of the cylinder at z=0 will have no angular resolution because all those points map to the same image pixel regardless of angle.

 

Anyway, sorry if I've completely misunderstood your image. In general, for consistent results across a model you should usually prefer texture mappings that are close to isotropic and constant resolution.

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