1 Reply Latest reply on Sep 30, 2014 5:08 PM by James Hall

    Texture mapping orientation

    James Hall

      I have created a render material and added it to a face in a part

       

      RenderMaterial texRM = texRM = modelDoc.Extension.CreateRenderMaterial(AppearanceFilename);

      texRM.MappingType = 0;

      texRM.TextureFilename = textureImageFilePath;

      texRM.LinkToFile = false;

      texRM.FixedAspectRatio = true;

      texRM.FitHeight = true;

      texRM.FitWidth = true;

      texRM.WidthMirror = false;

      texRM.HeightMirror = false;

      texRM.RotationAngle = 0;

      texRM.Height = ipr.height;

      texRM.Width = ipr.width;

      texRM.Emission = 1.0;

      texRM.SetUDirection2(ipr.mappingUDir[0], ipr.mappingUDir[1], ipr.mappingUDir[2]);

      texRM.SetVDirection2(ipr.mappingVDir[0], ipr.mappingVDir[1], ipr.mappingVDir[2]);

      bool result = texRM.AddEntity(aFace2Object);

       

      This works most of the time but occasionally the texture image will be flipped horizontally and vertically.

      I cannot detect when this will occur so I can set the mirror properties.

       

      Furthermore, the functions SetUDirection2 and SetVDirection2  appears to have no impact on texture orientation, is this expected?

       

      I would like to know how textures are oriented by default and the proper way to position/orient them through the API

        • Re: Texture mapping orientation
          James Hall

          The function Surface.EvaluateAtPoint( ... )

           

          Provided the  relavent UV directions and "root" points required to position/orient  a texture using the surface mapping type

           

          And here is an answer from API support that helped me:

           

          >> Is there something like a "mapping normal"?

           

          IFace2::FaceInSurfaceSense will detect if the face normal and the surface normal are in opposite directions. This is assuming the texture is surface mapped to the face.  The surface can be oriented where its normal vector points toward or away from the body material and this could end up opposing the normal vector of the face. The exact circumstances why this would be different from the face vector, I am unsure. The reason might be in the Parasolid kernel (SolidWorks’ geometry engine) and I am unfortunately unfamiliar with that being that its intellectual property owned by Siemens and that SolidWorks licenses.

           

           

          >> Are the U, V direction and the center point RenderMaterial set/get functions relevant to the mapped image of the appearance at all?

           

          Those methods for UV directions are for projection, cylindrical and spherical mappings. For surface mappings, those are ignored because the UV directions of each face’s surface is used.

           

          -----------------------------------------------