Jump to content

  • Log In with Google      Sign In   
  • Create Account


What data is needed to draw multiple textures on a single mesh surface?

  • You cannot reply to this topic
4 replies to this topic

#1 primem0ver   Members   -  Reputation: 104

Like
0Likes
Like

Posted 07 August 2014 - 04:06 AM

I have experience with DirectX and am currently doing a project for a modding community (xlnation).  I am new to using multiple textures on a mesh and I need some help. (My only experience is using the old fashioned "1 size fits all" texture that covers the entire surface using u,v coordinates).  There are two things I am trying to figure out with this thread. 

 

  1. I may or may not be able to figure out how to do it on my own but I could use some pointers on where to start.
  2. I am trying to decipher the data in a file that contains texture data for a spherical object's surface.  I need to know what basic information is needed to draw a texture on a mesh surface; specifically a sphere (The texture does NOT cover the entire surface).

 

I am going to discuss the file first because in discussing it, I should be able to get answers to the first question.

 

The file contains the information necessary to draw the globe.  The file is a binary file and has 20 bytes of information stored with each texture followed by the name of the texture file. (I am not including the 4 byte int value describing the length of the string representing the file name).  

 

My guess is that the 20 byte section of information contains 5 floats.  What information would these floating point numbers represent so that they could be used to draw a texture on the sphere that does NOT fill the entire sphere?

 

My original guess was:

some kind of location, (possibly the coordinate of the center of the texture), X,Y,Z

a rotation value

a scale value.

 

The problem I am facing with my guess is that the necessary size of the rotation value (a single float if I have guessed correctly) does not (in my mind) fit with using an x,y,z coordinate system.

 

So what kind of information is necessary to correctly draw a texture over a small section of a globe (or any surface for that matter)?


Edited by primem0ver, 07 August 2014 - 04:08 AM.


Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 4393

Like
0Likes
Like

Posted 07 August 2014 - 05:31 AM

First: welcome to the gamedev community.

 

Second: Take a read through this article. It should help you making posts which may get you better responses.

 

Third: You've asked several unrelated questions. You'll get better responses if you confine yourself to a single technically specific question.

 

That being said:

 

With regard to pointers for rendering meshes with textures, take a look at documentation and examples for ID3DXBaseMesh (more specifically DrawSubset), ID3DXMesh (inherits from ID3DXBaseMesh), the D3DXMESHOPT enumeration, D3DXMATERIAL, and ID3DXEffect. Googling for "d3d9 drawing a sphere" results in ~49000 hits. Does any of that information help?

 

With regard to rendering all or a portion of a sphere - what have you tried? Sounds like a simple vertex grid with positions, texture coords and possibly normals.

 

With regard to hacking a binary file: is it copyrighted material?

 

What's the file extension? What are the formats of the images - PNG, JPG, BMP?


Edited by Buckeye, 07 August 2014 - 05:32 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 primem0ver   Members   -  Reputation: 104

Like
0Likes
Like

Posted 08 August 2014 - 07:28 AM

Well maybe the nature of my problem extends to several topics but the basic question is this... How do I draw multiple textures onto a single mesh when those textures need to be drawn to different parts of the mesh? There are several different types of textures being used but that doesn't matter right now.  What is important is that one type of texture (the most important one) is the outline (shape) of a continent.  (The continent is white on a black background).  These continents need to be drawn to the right part of the globe.

 

All I am finding when I search is how to use UV coordinates and to set textures.  However, this problem is more about finding out which vertices to use... because not all vertices in the mesh will be using the same texture (or texture set).   

 

I have read that it is possible to "render" to a "surface" rather than the backbuffer and then use that surface as a texture.  If that is true then I can make some sense of the 20 bytes.

 

4 floats (or ints) describe the location and size of a rectangle (2 each) on the surface.

1 float describing the orientation (angle).  

 

However I am having trouble locating a tutorial on how to do this. PLUS, I don't think that this is the method used.  The problem with this method is that by using it, the textures will become severely distorted near the poles of the sphere. That doesn't happen.  So there needs to be another way to do this that doesn't create distortion.

 

As far as copyrights.  Yes, the material is copyrighted but the game (CitiesXL) was intentionally made to be moddable.  There are 4 modding communities that exist for this game, one of which is on the games original website.  I will be creating a new tool for modding and that tool needs to be able to draw the world on which the cities exist.  

 

All I am interested in right now is the basic method (outline of steps) on how to do this (draw the texture to the right part of the globe).  I can probably look up the details of each step myself.


Edited by primem0ver, 08 August 2014 - 07:33 AM.


#4 Buckeye   Crossbones+   -  Reputation: 4393

Like
0Likes
Like

Posted 08 August 2014 - 08:11 AM


the basic question is this... How do I draw multiple textures onto a single mesh when those textures need to be drawn to different parts of the mesh?

 

The most common approach is to setup a mesh material list for a mesh, where each material may specify a texture (as well as other attributes). An attribute table is then setup which specifies which mesh faces are to have which attributes (material) applied when rendered.

 

This article, though it's based on DX8, describes the process of setting up attribute groups.

 

As mentioned above, take a look at ID3DXBaseMesh, in particular, DrawSubset(). The basic sequence involved is:

 

1. set the material (including texture) associated with an attribute group.

2. render the vertices in that group.

3. repeat for each attribute group.

 

IF (and that's a big IF) the mesh is rendered using DrawSubset, I would guess (and just a guess) that the mesh itself is in a specific order (by either vertex+uv or index) by attribute, and individual textures in the file have a specified attribute number, starting index or vertex number, and number of indices, vertices or faces.

 

It may well be (as you intimate) that a different rendering scheme is used, in which case, all bets are off. Without knowing how the mesh is rendered, it's extremely difficult at best to determine what data is needed to perform the rendering.

 

EDIT:

 

 


So there needs to be another way to do this that doesn't create distortion.

 

Not true. Take a look at "Mercator projection." Images of that projection could be used and would be specifically designed for "distortion." Examining the textures themselves may give you a clue as to how they are rendered.


Edited by Buckeye, 08 August 2014 - 08:19 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#5 primem0ver   Members   -  Reputation: 104

Like
0Likes
Like

Posted 10 August 2014 - 08:52 AM

I will take a look at this possibility.  Thanks

 

 


So there needs to be another way to do this that doesn't create distortion.

 

Not true. Take a look at "Mercator projection." Images of that projection could be used and would be specifically designed for "distortion." Examining the textures themselves may give you a clue as to how they are rendered.

 

 

Except that none of the files that contain the continent textures have any kind of distortion. (EDIT) Including the black and white continent outline masks (/EDIT).  There is a mercator projection that has distortion but it is a black and green targa file.  


Edited by primem0ver, 10 August 2014 - 08:54 AM.






PARTNERS