Theres texture distortion on my cube : (

Started by
5 comments, last by Steve00000 13 years, 4 months ago
Hi, I'm trying to draw a texture on a large cube. The cube is loaded from a .vtx model file which is made with anim8or.

When the cube is drawn only two faces on the cube are displayed correctly. The sides of the cube that are not drawn correctly are distorted and look as though they have been stretched from the correctly drawn sides edge to other. This is the code that is meant to draw the cube:

          // 1 based arrayglBindTexture(GL_TEXTURE_2D, texture(1));glBegin(GL_TRIANGLES);//);GL_TRIANGLESfor(int iter = 0; iter < cubesy.index().size(); iter++) // 36 indices, 24 vertices{	int index = cubesy.index()[iter];	const cvertex& vertref = cubesy.vertex()[index];	const point3<short>& normref = cubesy.normal()[index];	glNormal3s(normref.x, normref.y, normref.z);	glTexCoord2s(vertref.u, vertref.v);	glVertex3f(vertref.x, vertref.y, vertref.z);}glEnd();


here is the data from the vtx file

// mesh01// 24 vertices// NOTE: first 3 are a vertex, second 3 are a normal, last 2 are a tex coord.Vertex-4.13221 -4.71958 -4.71959 0 0 -1 0 05.30695 -4.71958 -4.71959 0 0 -1 1 05.30695 4.71957 -4.71959 0 0 -1 1 1-4.13221 4.71957 -4.71959 0 0 -1 0 15.30695 -4.71958 4.71957 0 0 1 1 0-4.13221 -4.71958 4.71957 0 0 1 0 0-4.13221 4.71957 4.71957 0 0 1 0 15.30695 4.71957 4.71957 0 0 1 1 15.30695 -4.71958 -4.71959 1 0 0 1 05.30695 -4.71958 4.71957 1 0 0 1 05.30695 4.71957 4.71957 1 0 0 1 15.30695 4.71957 -4.71959 1 0 0 1 1-4.13221 4.71957 -4.71959 0 1 0 0 15.30695 4.71957 -4.71959 0 1 0 1 15.30695 4.71957 4.71957 0 1 0 1 1-4.13221 4.71957 4.71957 0 1 0 0 1-4.13221 -4.71958 -4.71959 -1 0 0 0 0-4.13221 4.71957 -4.71959 -1 0 0 0 1-4.13221 4.71957 4.71957 -1 0 0 0 1-4.13221 -4.71958 4.71957 -1 0 0 0 0-4.13221 -4.71958 -4.71959 0 -1 0 0 0-4.13221 -4.71958 4.71957 0 -1 0 0 05.30695 -4.71958 4.71957 0 -1 0 1 05.30695 -4.71958 -4.71959 0 -1 0 1 0// end of .Vertex// 12 faces.Index0 1 2 -10 2 3 -14 5 6 -14 6 7 -18 9 10 -18 10 11 -112 13 14 -112 14 15 -116 17 18 -116 18 19 -120 21 22 -120 22 23 -1// end if .Index


The source that I read about how to read from this file format said to draw as triangles, which is being done of course. However maybe I'm doing something wrong, even tho I did check that the data is being read in properly, and the drawing routine has the right stuff at the right time. Anyways for anyone who helps me, Thx : )
Advertisement
picture?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

I'll see if I can figure out how to upload one.


Your source data looks like garbage to me. If you look at the indices it is making a square out of every 4 vertices. If you break them out and look at the UV's for the individual faces, they look wrong.

Face 1:0 1 2 -10 2 3 -10: -4.13221 -4.71958 -4.71959 0 0 -1 0 01: 5.30695 -4.71958 -4.71959 0 0 -1 1 02: 5.30695 4.71957 -4.71959 0 0 -1 1 13: -4.13221 4.71957 -4.71959 0 0 -1 0 1// ok so far....Face 2: 4 5 6 -14 6 7 -14: 5.30695 -4.71958 4.71957 0 0 1 1 05: -4.13221 -4.71958 4.71957 0 0 1 0 06: -4.13221 4.71957 4.71957 0 0 1 0 17: 5.30695 4.71957 4.71957 0 0 1 1 1//still looking fine....Face 3: 8 9 10 -18 10 11 -18: 5.30695 -4.71958 -4.71959 1 0 0 1 09: 5.30695 -4.71958 4.71957 1 0 0 1 010: 5.30695 4.71957 4.71957 1 0 0 1 111: 5.30695 4.71957 -4.71959 1 0 0 1 1//incorrect!

If you look at the texcoords for this face, they are (1,0) (1,0) (1,1) (1,1). This is wrong for a square. I haven't gone through the rest of the faces but I'd bet they are the same.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
so maybe the problem is with the editor program i made the cube with? perhaps i'll try blender and see if it can output in vtx, then reload the program
I found that blender does not come ready with .vtx output. I did try to change some of the source data in my first post, and got *more correct results. Because of this odd situation, if ppl wouldn't mind suggesting a file format that blender comes ready with output for and providing a link to the format specs I'd be really greatful. I had a look at a few of the formats but couldn't find much info on em. I was being kinda picky I guess cause I wanted tex coords and vertex data together, but I thought the 3ds format looked interesting, but I didn't find a resource for its specs.

This topic is closed to new replies.

Advertisement