Confusion about plane UV’s (3D noob)

Software: Away3D 4.x

Dentaku, Newbie
Posted: 05 January 2013 07:37 PM   Total Posts: 8

Hello,

I am new to the whole 3D thing and need some help in the right direction to get me started. I have plenty of experience in actionscript and programming in general, so that won’t be a problem.

I’m trying to use a spritesheet on a plane, so I want to clip a small part of the texture and stick it on the plane. I’ve done some research on how exactly UV’s work, and it seemed pretty logical. Here is the example I used if anyone is curious; http://www.rozengain.com/blog/2007/08/26/uv-coordinate-basics/
It’s not away3D, but I understand the basic now.

Here is where it get’s confusing; When I apply a texture to a plane without modyfying the UV’s , the

plane.geometry.subGeometries[0]).UVData 

contains the following data:

-0.5
0
-0.5
0
1
0
1
0
0
0
1
0
0
0.5
0
-0.5
0
1
0
1
0
0
1
1
0
0
-0.5
0
0.5
0
1
0
1
0
0
0
0
0
0
0.5
0
0.5
0
1
0
1
0
0
1
0
0

Going by the tutorial, I would have guesse that it would have been something like this;

00,               01,                 10,                11

Any pointers on why the UV is like this?
I’m not worried about implementing a spritesheet feature yet, I want to get past this basic problem first.

   

Avatar
Fabrice Closier, Administrator
Posted: 05 January 2013 08:35 PM   Total Posts: 1265   [ # 1 ]

What you describe with your uv’s is a “quad” or 4 side polygon.
This is not the way Stage3D works. All needs to be defined as a series of triangles. Where a plane would be at least 2 triangles with either 4 vertices if shared, or 6 if unique. You can define a plane geometry with way more triangles, usually because you may want to alter the geometry later on…

You do not show your Plane constructor where you can define the subdivision, either on width or height. To get the smallest amount of data, 2 triangles, you need to pass w,h,1,1 to constructor. At 1/1 it should be very near/equivallent of your example.

The more triangles, the more uv’s. 1 uv per vertex.
This is made this way to fit gpu/stage3D requirements.
That’s why the indices values (3 per face/triangle) are always *3 to retreive a vertex.x and *2 to access the right uv.u.

Note that for 4.1 buffers are regrouped when possible to a single buffer, with all the vertices, indices, uvs etc… to improve performance by reducing calls to gpu.

   

Dentaku, Newbie
Posted: 05 January 2013 10:23 PM   Total Posts: 8   [ # 2 ]
Fabrice Closier - 05 January 2013 08:35 PM

What you describe with your uv’s is a “quad” or 4 side polygon.
This is not the way Stage3D works. All needs to be defined as a series of triangles. Where a plane would be at least 2 triangles with either 4 vertices if shared, or 6 if unique.

Specifying a rectangle as UV was easy to imagine, but I’m having a hard time imagining how a texture would be wrapped to a triangle. Would specifiying 2 rectangles just map the uv as if it were a square?

00, (topleft)
10, (topright)
10, (bottomleft)

01, (bottomleft)
10, (topright)
11, (bottom right

I’m still not sure how I should order te uv’s though. I guess I’m also wasting space by specifiying some double coordinates where the triangles overlap.

Fabrice Closier - 05 January 2013 08:35 PM

You do not show your Plane constructor where you can define the subdivision, either on width or height. To get the smallest amount of data, 2 triangles, you need to pass w,h,1,1 to constructor. At 1/1 it should be very near/equivallent of your example.

I was simply using a width/height of 1, leaving the segments to their default values (which are also 1).
var plane:Mesh = new Mesh(new PlaneGeometry(1, 1), textMat);

Another thingy I don’t get is why the UV data is using -0.5 and 0.5 values. I can’t see those being necessary when constructing a plane with 2 triangles.

I apologize for my slow understanding, all the little knowledge I had about uv’s seems to be wrong.

   

Dentaku, Newbie
Posted: 07 January 2013 01:41 AM   Total Posts: 8   [ # 3 ]

I guess this is all just a step too far for someone with so little 3D experience.
So I want to solve it the easy way ;

I am currently cropping the UV using plane.geometry.scaleUV. I can simply calculate the required scale for a certain frame and scale the whole thing.
I have no idea how to set the U and V offset though. I need those so I can skip to other frames.

SubMesh(plane.subMeshes[0]).offsetV and SubMesh(plane.subMeshes[0]).offsetU = 0.2 seem to do nothing.

   

Dentaku, Newbie
Posted: 16 January 2013 07:34 PM   Total Posts: 8   [ # 4 ]

Anyone? I think just knowing why there are 52 vertices for a plane would explain enough.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X