Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Texture object unsucessful

Author
Message
Carl CLD
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Watch your back!
Posted: 7th Jan 2009 19:44 Edited at: 7th Jan 2009 19:45
Hi,

I want to texture with an image my own .X object (made with 3D Canvas) in DBP. When I use texture object objnum, imgnum, my object becomes black, untextured.

What should I do?

Ne pas mélanger périphérique et féerique, car l'informatique n'est pas du tout un conte de fées...
Veron
17
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 7th Jan 2009 19:49
I've had similar problems, and it turned out that it was a problem with the model, although I never ended up fixing it.

Carl CLD
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Watch your back!
Posted: 7th Jan 2009 19:54 Edited at: 7th Jan 2009 22:30
Thanks for your answer, but I cannot find the solution.

Can someone help me?

Ne pas mélanger périphérique et féerique, car l'informatique n'est pas du tout un conte de fées...
Encrypto Studios
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: Virginia
Posted: 8th Jan 2009 21:59
could you supply the media\code please?

Carl CLD
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Watch your back!
Posted: 9th Jan 2009 04:34
Sure, here is a code:


Use any image to texture, the model is attached to this post.
Thanks a lot!

Ne pas mélanger périphérique et féerique, car l'informatique n'est pas du tout un conte de fées...

Attachments

Login to view attachments
Dabbler
17
Years of Service
User Offline
Joined: 3rd Mar 2007
Location: Minnesota
Posted: 9th Jan 2009 14:31
Your model's uv values are all set to zero.


Whatever...
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 9th Jan 2009 14:51
UV data is data in the model that tells DirectX where to get the image information from the 'image.jpg' in order to display it on the polygon. In the default Flexible Vertex Format (FVF) the UV data is included with each vertex of every polygon as the last two FLOATS. UV data is in the range of 0.0 to 1.0, so its normalized.

U is the distance of a pixel from the left side of the image divided by the image's width.
V is the distance from the top divided by the height.

Ideally you need to figure out how to modify the texture coordinates within the modeling program. Though with a simple model you could modify it in notepad if you can figure out which part is UV.
Carl CLD
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Watch your back!
Posted: 9th Jan 2009 23:38
Thanks Dabbler and Pillarofire for the diagnosis!
I've posted on the technical support of 3D Canvas.

If someone knows the solution, it would be very nice to know it!
Thanks a lot!

Ne pas mélanger périphérique et féerique, car l'informatique n'est pas du tout un conte de fées...
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 10th Jan 2009 06:54 Edited at: 10th Jan 2009 06:58


Here is your model in 'notepad.exe' Notice how the MeshTextureCords are paired, and they are both zero. This tells DirectX that when a texture is applied, the polygons are not supposed to be textured (they get color from pixels(0,0)), so in order to fix this simple model, you could modify it in notepad and save it. You just need to understand how this model data is going to render the model.

So lets see:


This section says that your model has 8 vertices.
Right after the number 8 are listed the model's vertex positions, (x,y,z) respectively. Notice how there are eight lines...
The next section is the number of polygons/faces. There are 6 of these. They each consist of 4 vertices. The first one is the group of vertices 0,1,2, and 3; ... etc. This is a clue, this is called an 'indexed mesh', because there is vertex sharing for each vertex. EDIT:"for each face not vertex".

You now have what you needed to know to begin calculating the texture coordinates. You see:


means that for each vertex there is a UV data, and each one is set to zero just like Dabbler pointed out previously. What you want is for them to be something other than zero, right? So that the model will render some color from an image when its drawn in DirectX.

So first things first, open the file in notepad.


So since the first set of data [U; V;,] corresponds to the first vertex (vertex 0), we don't need to modify any portion of the data for this one because the first vertex should start getting information starting from the upper left corner (U=0.0;V=0.0). Now let us look back so see what number the next vertex is:


So the next vertex in the polygon is vertex 1. We want this one to be the upper right corner of our image, so its data needs to be (U=1.0,V=0.0). So here we change the second line: 0.00E+00; 0.00E+00;, to -> 1.00E+00; 0.00E+00;,

The next vertex is vertex 2. We want this to be the the lower right corner this time, so set it to (U=1.0,V=1.0) following the same step as before.

The next vertex is vertex 3. Again we set this only this time to (U=0.0,V=1.0).

Now lets check to see if we are on the right track.

Save the file in notepad. And then launch your DBPro application.

Let me know what you see.
Carl CLD
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Watch your back!
Posted: 10th Jan 2009 15:32 Edited at: 10th Jan 2009 15:43
That was successful! Except one thing: my texture was rotated -90 degrees on the face.
I changed:

to:

And it worked.
Actually, the first vertex in the UV list was the bottom-left. So I attributed it (0.00, 1.00), and I ajusted the others.

Thanks for that technique! It seems that I well understood it!
I will use this until I will be able to correct that in my modelling program...

Best wishes,
Carl

You should read the messages instead of the signatures...
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 11th Jan 2009 03:22
Brilliant!

Login to post a reply

Server time is: 2024-09-28 00:24:16
Your offset time is: 2024-09-28 00:24:16