Texture in triangle and quad

57 views
Skip to first unread message

pri...@gmail.com

unread,
Aug 1, 2022, 3:10:47 PM8/1/22
to Glowscript Users

Bruce Sherwood

unread,
Aug 1, 2022, 7:30:28 PM8/1/22
to Glowscript Users
Here is the relevant documentation on textures with triangles or quads:

texpos: If you intend to apply a texture or bumpmap to a mesh object, you must specify in the mesh how you want the texture to be mapped onto your object. You might want the texture to occupy only a portion of the object, or be stretched or distorted in some way. This is done by specifying "texel" coordinates, given as texpos vectors in the vertex objects.

Texel coordinates for a surface texture are specified by an "x" and a "y", both ranging from 0 to 1 if the entire texture is to be displayed, left to right and bottom to top. (In many discussions texel coordinates are referred to as "u" and "v", or as "s" and "t".) In anticipation that WebGL will eventually enable 3D textures, which permit filling a textured volume, VPython requires that in texpos elements the third component must be zero.

For example, to fill a quad with a texture, the texpos vectors in the vertex objects v0, v1, v2, and v3 would be vec(0,0,0), vec(1,0,0), vec(1,1,0), vec(0,1,0), no matter what the 3D pos attributes are. If you want only the lower quarter of the texture to fill the quad, the texpos vectors would be vec(0,0,0), vec(0.5,0,0), vec(0.5,0.5,0), vec(0,0.5,0). Note that <0,0,0> is at the lower left, and <1,1,0> is at the upper right.

pri...@gmail.com

unread,
Aug 3, 2022, 9:24:44 AM8/3/22
to Glowscript Users
This is better - except that I should find a more homogeneous brick wall and take another picture.
Can I make the doors look better?


Poul Riis

Bruce Sherwood

unread,
Aug 3, 2022, 12:51:06 PM8/3/22
to Glowscript Users
I really like the roof. I'm not sure what you want to change about the doors. Perhaps you simply need to move them very slightly forward in z; perhaps they are currently "fighting" with a wall at the same z-location?

I note that you are using a very old version 3.0. Is there a reason that you can't use 3.2?

Bruce

pri...@gmail.com

unread,
Aug 8, 2022, 3:47:39 PM8/8/22
to Glowscript Users
I have now made procedures for building rectangular and triangular wall segments, see dummy examples here: 
When a texture material is not homogeneous in 3D it would require pictures from three directions to make the segments look perfectly natural. However, in most cases I don't think it would be worth the effort.
It would be highly desireable if it was possible to make compounds with the quads and triangles!

I wonder why I see a small discrepancy between my boxes and the built-in box command? Maybe I have a bug (or even several bugs) somewhere...

You can find a somewhat more elaborated example here (don't forget to drag the slider!):

Poul Riis

Reply all
Reply to author
Forward
0 new messages