mojo3d:Not understanding Texcoord on cube of quads

About Monkey 2 Forums Monkey 2 Programming Help mojo3d:Not understanding Texcoord on cube of quads

This topic contains 1 reply, has 2 voices, and was last updated by  Mark Sibly 1 year ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #14115

    Pakz
    Participant

    I have a hard time understanding how to texture a mesh cube. I have been at it for hours now. I have been able to get a few sides of a cube to be textured correctly(I think) but other sides do not seem to get set correctly.

    There is also texcoord1 and this seems to do not do anything. I have been at it with remapping the vertices but no succes yet.

    I have created the code below from code collected from this forum. Texturing and creating a quad.

     

     

    Cube setup

    #14116

    Mark Sibly
    Keymaster

    If you want unique texcoords for each face of the cube (which I’m guessing is what you’re after) you need to duplicate the ‘shared’ vertices (ie: vertices with the same position) so each vertex gets its own texcoords. This will allow vertex 0 above to have different tex coords when used in the front quad (eg: 0,0) than when used in the left quad( eg: 1,0) because it’s really 2 vertices.

    This goes for any vertex attribute you want to to be different depending on the polygon it’s used in. For example, to ahieve flat-shading, vertices will have a different normal for each triangle they are used in (ie” the triangle’s normal) so a flat shaded mesh can’t have *any* shared vertices.

    Anyway, this means you should end up with 24 vertices (6 faces * 4 vertices per face) altogether. This is what Mesh.CreateBox does, you might want to have a look at that…

    And note that texcoord1 is not used by the built in shader.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.