This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > April 2005 > Texture mapping





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Texture mapping
qwerty

2005-04-20, 12:44 pm

Hi,
I'd like put a texture on two solids in the same direction.
Why the texture seems works differently with D3 and D4 ?
here is the code.

Transform {

translation -50 0 -300
rotation 1 0 0 1.57
#-0.785

children [
DEF D4 Transform {
translation 58.42 0 57.29
children [
Shape {
appearance Appearance {
texture PixelTexture {image 138 1 3 0xEAFF00 0xEAFF00 0xEAFF00 0xEAFF00
0xEEFF00 0xEEFF00 0xEEFF00 0xEEFF00 0xF2FF00 0xF2FF00 0xF2FF00 0xF2FF00
0xF6FF00 0xF6FF00 0xF6FF00 0xF6FF00
0xF9FF00 0xF9FF00 0xF9FF00 0xF9FF00 0xFDFF00 0xFDFF00 0xFDFF00 0xFDFF00
0xFFFF00 0xFFFF00 0xFFFF00 0xFFFF00 0xFFFC00 0xFFFC00 0xFFFC00 0xFFFC00
0xFFFC00 0xFFF900 0xFFF900 0xFFF700 0xFFF700 0xFFF700 0xFFF700 0xFFF400
0xFFF400 0xFFF400 0xFFF400 0xFFF100 0xFFF100 0xFFF100 0xFFF100 0xFFED00
0xFFED00 0xFFED00 0xFFED00 0xFFEA00 0xFFEA00 0xFFE600 0xFFEA00 0xFFE600
0xFFE600 0xFFE600 0xFFE200 0xFFE200 0xFFDE00 0xFFDE00 0xFFDE00 0xFFDE00
0xFFDE00 0xFFD900 0xFFD900 0xFFD900 0xFFD900 0xFFD500 0xFFD500 0xFFD500
0xFFD200 0xFFCE00 0xFFD200 0xFFCE00 0xFFCE00 0xFFC900 0xFFC900 0xFFC900
0xFFC900 0xFFC500 0xFFC500 0xFFC500 0xFFC100 0xFFC100 0xFFC100 0xFFBD00
0xFFBD00 0xFFBD00 0xFFB900 0xFFB500 0xFFB500 0xFFB500 0xFFB200 0xFFB200
0xFFB200 0xFFAD00 0xFFAD00 0xFFAD00 0xFFA900 0xFFA900 0xFFA900 0xFFA500
0xFFA500 0xFFA200 0xFFA200 0xFFA200 0xFF9E00 0xFF9E00 0xFF9A00 0xFF9A00
0xFF9A00 0xFF9600 0xFF9600 0xFF9600 0xFF9100 0xFF9100 0xFF8E00 0xFF8E00
0xFF8E00 0xFF8900 0xFF8900 0xFF8900 0xFF8500 0xFF8500 0xFF8200 0xFF8200
0xFF7E00 0xFF7E00 0xFF7E00 0xFF7A00 0xFF7A00 0xFF7A00 0xFF7500 0xFF7500
0xFF7500 0xFF7100 0xFF7100 0xFF6D00 }
textureTransform TextureTransform {scale 1 1 rotation 3.14}}

geometry DEF D4-FACES IndexedFaceSet {
ccw TRUE
solid TRUE
coord DEF D4-COORD Coordinate { point [
2.378 3.079 -5.208, 3.525 1.156 -5.208, -4.935 1.116 -5.208,
0.4115 4.182 -5.208, 3.525 -1.156 -5.208, 2.378 -3.079 -5.208,
0.4115 -4.182 -5.208, -1.851 -4.171 -5.208, -4.935 -1.116 -5.208,
-3.807 -3.05 -5.208, -3.807 3.05 -5.208, -1.851 4.171 -5.208,
4.935 -1.16 5.208, 4.935 1.16 5.208, 3.844 2.902 5.208,
2.022 3.884 5.208, 2.022 -3.884 5.208, -0.05443 -3.848 5.208,
-0.05443 3.848 5.208, -2.868 1.024 5.208, -2.868 -1.024 5.208,
-1.84 2.803 5.208, -1.84 -2.803 5.208, 3.844 -2.902 5.208]
}
coordIndex [
0, 1, 2, -1, 0, 2, 3, -1, 1, 4, 2, -1, 4, 5, 2, -1, 5, 6, 2, -1,
6, 7, 2, -1, 8, 2, 9, -1, 10, 11, 2, -1, 11, 3, 2, -1,
9, 2, 7, -1, 4, 1, 12, -1, 1, 13, 12, -1, 13, 14, 12, -1,
15, 16, 14, -1, 16, 15, 17, -1, 15, 18, 17, -1, 19, 20, 21, -1,
20, 22, 21, -1, 22, 17, 21, -1, 16, 23, 14, -1, 23, 12, 14, -1,
17, 18, 21, -1, 1, 0, 13, -1, 13, 0, 14, -1, 11, 15, 3, -1,
15, 11, 18, -1, 2, 21, 10, -1, 21, 2, 19, -1, 9, 22, 8, -1,
22, 9, 17, -1, 6, 16, 7, -1, 16, 6, 23, -1, 4, 12, 5, -1,
12, 23, 5, -1, 5, 23, 6, -1, 16, 17, 7, -1, 7, 17, 9, -1,
22, 20, 8, -1, 20, 19, 8, -1, 8, 19, 2, -1, 21, 18, 10, -1,
10, 18, 11, -1, 15, 14, 3, -1, 3, 14, 0, -1]
}
}
]
}
DEF D3 Transform {
translation 56.6 0 46.87
children [
Shape {
appearance Appearance {
texture PixelTexture {image 138 1 3 0xEAFF00 0xEAFF00 0xEAFF00 0xEAFF00
0xEEFF00 0xEEFF00 0xEEFF00 0xEEFF00 0xF2FF00 0xF2FF00 0xF2FF00 0xF2FF00
0xF6FF00 0xF6FF00 0xF6FF00 0xF6FF00
0xF9FF00 0xF9FF00 0xF9FF00 0xF9FF00 0xFDFF00 0xFDFF00 0xFDFF00 0xFDFF00
0xFFFF00 0xFFFF00 0xFFFF00 0xFFFF00 0xFFFC00 0xFFFC00 0xFFFC00 0xFFFC00
0xFFFC00 0xFFF900 0xFFF900 0xFFF700 0xFFF700 0xFFF700 0xFFF700 0xFFF400
0xFFF400 0xFFF400 0xFFF400 0xFFF100 0xFFF100 0xFFF100 0xFFF100 0xFFED00
0xFFED00 0xFFED00 0xFFED00 0xFFEA00 0xFFEA00 0xFFE600 0xFFEA00 0xFFE600
0xFFE600 0xFFE600 0xFFE200 0xFFE200 0xFFDE00 0xFFDE00 0xFFDE00 0xFFDE00
0xFFDE00 0xFFD900 0xFFD900 0xFFD900 0xFFD900 0xFFD500 0xFFD500 0xFFD500
0xFFD200 0xFFCE00 0xFFD200 0xFFCE00 0xFFCE00 0xFFC900 0xFFC900 0xFFC900
0xFFC900 0xFFC500 0xFFC500 0xFFC500 0xFFC100 0xFFC100 0xFFC100 0xFFBD00
0xFFBD00 0xFFBD00 0xFFB900 0xFFB500 0xFFB500 0xFFB500 0xFFB200 0xFFB200
0xFFB200 0xFFAD00 0xFFAD00 0xFFAD00 0xFFA900 0xFFA900 0xFFA900 0xFFA500
0xFFA500 0xFFA200 0xFFA200 0xFFA200 0xFF9E00 0xFF9E00 0xFF9A00 0xFF9A00
0xFF9A00 0xFF9600 0xFF9600 0xFF9600 0xFF9100 0xFF9100 0xFF8E00 0xFF8E00
0xFF8E00 0xFF8900 0xFF8900 0xFF8900 0xFF8500 0xFF8500 0xFF8200 0xFF8200
0xFF7E00 0xFF7E00 0xFF7E00 0xFF7A00 0xFF7A00 0xFF7A00 0xFF7500 0xFF7500
0xFF7500 0xFF7100 0xFF7100 0xFF6D00 }
textureTransform TextureTransform {scale 1 1 rotation 3.14}}

geometry DEF D3-FACES IndexedFaceSet {
ccw TRUE
solid TRUE
coord DEF D3-COORD Coordinate { point [
3.934 1.143 -5.208, 3.934 -1.143 -5.208, 2.876 3.101 -5.208,
2.876 -3.101 -5.208, 1.018 4.352 -5.208, 1.018 -4.352 -5.208,
-3.318 -3.818 -5.208, -3.318 3.818 -5.208, -1.217 -4.611 -5.208,
-4.807 -2.155 -5.208, -5.344 0 -5.208, -4.807 2.155 -5.208,
-1.217 4.611 -5.208, 5.344 -1.156 5.208, 5.344 1.156 5.208,
4.197 3.079 5.208, 4.197 -3.079 5.208, -0.03177 4.171 5.208,
-0.03177 -4.171 5.208, 2.231 4.182 5.208, -1.988 -3.05 5.208,
-1.988 3.05 5.208, -3.116 -1.116 5.208, -3.116 1.116 5.208,
2.231 -4.182 5.208]
}
coordIndex [
0, 1, 2, -1, 1, 3, 2, -1, 2, 3, 4, -1, 3, 5, 4, -1, 6, 7, 8, -1,
6, 9, 7, -1, 10, 11, 9, -1, 11, 7, 9, -1, 7, 12, 8, -1,
12, 4, 8, -1, 8, 4, 5, -1, 1, 0, 13, -1, 0, 14, 13, -1,
14, 15, 13, -1, 13, 15, 16, -1, 17, 18, 19, -1, 18, 17, 20, -1,
17, 21, 20, -1, 22, 20, 23, -1, 18, 24, 19, -1, 24, 16, 19, -1,
19, 16, 15, -1, 20, 21, 23, -1, 0, 2, 14, -1, 14, 2, 15, -1,
12, 19, 4, -1, 19, 12, 17, -1, 11, 21, 7, -1, 21, 11, 23, -1,
9, 22, 10, -1, 22, 9, 20, -1, 8, 18, 6, -1, 18, 8, 24, -1,
3, 16, 5, -1, 1, 13, 3, -1, 13, 16, 3, -1, 16, 24, 5, -1,
5, 24, 8, -1, 18, 20, 6, -1, 6, 20, 9, -1, 22, 23, 10, -1,
10, 23, 11, -1, 21, 17, 7, -1, 7, 17, 12, -1, 19, 15, 4, -1,
4, 15, 2, -1]
}
}
]
}
]
}


simon

2005-04-20, 12:44 pm

well first off, you've got 140 colours defined in a 138x1 texture?

anyway, in VRML you can either specify how a texture is applied, which
you haven't, or allow a default algorithm to sort it out. see spec.

but you can basically visualise the algorithm, in 3d, as expanding the
texture at right angles to make a cubic solid that just encompasses the
geometry, ALIGNED with the current axis and then removing anything
outside the geometry, however the choice as to which axis, the texture
scales into, depends on which axis the geometry is widest in, and you
have two different geometries that nearly have the same extent in more
than one axis, so i guess one is wider/narrower in a different axis
than the other.

BTW generally v.good to use powers of two texture sizes, and also the
same in x and y, this is a graphics card/driver issue, which are
optimised for the more predictable textures used by games.

BTW2 if you are just looking for a smooth grade of colour check out
defining colours at vertexes, which would keep the file smaller, not
look wrong close up, be easier to maintain, and not suffer from this
alignment issue.

BTW3 if you don't have that flexibility, you could squeeze the geometry
before the texture is applied to force a consistent application of the
texture, then use Transform to scale it back. not tested be i think it
will work.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews