I'm tripping up on getting a texture to behave using UV.
I've designed a digital display for a control panel. Each digit is a
simple flat rectangle. The digit texture is a tall image with numbers,
numbers preceded with decimal points, a negative sign and a blank:
0
1
2
3
4
5
I wanted to index into this texture using UV coordinates. U would
always be the same and V would be the number * the height of each image
section. (ignoring the space, negative sign and decimal point versions
for now)
So...
I build a rectangle out of trimesh, for now a 1 to 1 size with a digit
section of the texture image:
h = texture.Height / 23 // number of digit variations on texture image
w = texture.Width
// define the vertices
t.VertexCount = 4
t.VertexPositions.SetXYZ(0, 0, 0, 0 )
t.VertexPositions.SetXYZ(1, 0, h, 0 )
t.VertexPositions.SetXYZ(2, w, h, 0 )
t.VertexPositions.SetXYZ(3, w, 0, 0 )
// define the triangles
t.TriangleCount = 2
t.Triangles.SetABC(0, 2, 1, 0)
t.Triangles.SetABC(1, 0, 3, 2)
// add texture and indicate using UV
t.Material.Texture = texture
t.HasVertexUVs = True
I see the digit area, but assumed that I should see "0" since that is
the first of the texture image.
In my update method:
Trimesh.VertexUVs.SetUV(0,0,digitvalue * offset)
where digit value is 0 through 9 and offset is the height of each digit
section in the texture image.
I see some change in color, but nothing recognizable.
Questions:
1. in the world of UVList, where is 0,0 located (top left or bottom
left)?
2. Given a two triangle trimesh and one material added, am I correct in
assuming that there is only one entry in the UVList? Or is there
another relationship I am missing.
TIA,
Joe
--
Joseph Nastasi
Pyramid Design - a software development firm
http://www.pyramiddesign.us
Voice 609 601-0814 Fax 609 601-0815
Products:
A-OK! Spacecraft Simulation System - http://aok.pyramiddesign.us
A-OK! The Wings of Mercury
FTP Suite for REALbasic - http://ftpsuite.pyramiddesign.us
Proud Sponsors of REALbasic Olympics 2005
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|