x


displaying part of texture

Ive got problem with a texture... There is a constant border around this texture (other object). But the problem is that i dont need to expand a texture within border as i always did, but i need to cut it somehow in parts (show a part of texture, depending of a non constant variable).

For example: if x=10, then show 10 percent of texture; if x=45, then show 45 percent of texture; and so on.

more ▼

asked Apr 02 '11 at 05:21 PM

Sacristan gravatar image

Sacristan
63 7 8 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The way to show only part of a texture is to change the UV coordinates of the Mesh the object is being applied to.

UVs work from 0 to 1, where 1 is 100%. So if you want to show 45% of the texture on a quad, you would have to change the UVs of the quad to:

Vector2[] UVs = new Vector2[]
{
    Vector2(0.0f,  0.0f),  // Bottom left
    Vector2(0.0f,  0.45f), // Top left
    Vector2(0.45f, 0.45f), // Top right
    Vector2(0.45f, 0.0f)   // Bottom right
};

This is assuming the quad you're applying it to's first vertex is the bottom left and runs clockwise through to the fourth vertex, which would be the bottom right.

more ▼

answered Apr 02 '11 at 05:41 PM

KeithK gravatar image

KeithK
862 2 3 13

THX a lot, dude!

Apr 02 '11 at 05:54 PM Sacristan

thats quite helpfull but cube is 6 sided which means it have 24 vertices and we have to give uvs for all 24 vertices is there an easy approch for doing this

Feb 13 '12 at 07:07 AM arslanmkhan
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2196
x57
x34
x12
x6

asked: Apr 02 '11 at 05:21 PM

Seen: 1559 times

Last Updated: Feb 13 '12 at 07:07 AM