Engine Design tracking (IX. 14.2a) Export plug-in problem repair and tangent space crack repair

Source: Internet
Author: User

Due to busy work, I had no time to do it in my spare time for nearly half a year, but my work was almost done. I had time to fix some minor problems on the 11th day.

 

This update has nothing to do with the skeleton animation and fixes a previous problem about the tangent space crack:

Engine Design tracking (9) 3DS MAX export plug-in

Engine Design tracking () Max plug-in update, terrain issue memo

Here we will describe the solution and make a summary.

The previous practices are not correct, but they are not perfect. the reason is that the model of the war machine 3 has already copied the vertex (the left half and the right half are different mesh and overlap vertices ),

Although the coordinates at the seams are identical, they are "two completely different vertices". This is not a smoothing group, but a hard edge forced for splitting. the problem is that the export plug-in does not merge the normal at the seams,

That is to say, because there are two vertices at the joint and the normal is different, it is not smooth or seed no matter normal textures are used. This problem has nothing to do with image UV.

 

The solution is to merge (accumulate) The normal of the vertex at the same position. For example, the solution is to use vertex position as the key:

    struct VertexNormalLess    {        bool operator()(const Vertex& lhs, const Vertex& rhs) const        {            return (lhs.position.x < rhs.position.x)                || (lhs.position.x == rhs.position.x && lhs.position.y < rhs.position.y)                || (lhs.position.x == rhs.position.x && lhs.position.y == rhs.position.y && lhs.position.z < rhs.position.z);        }    };    typedef Map<Vertex, VertexNormal, VertexNormalLess> VertexNormalMap;

In this way, the normal is superimposed on the vertex with the same position by weight, and even if the vertex at the weld is repeated, their normal is still unique.

 

Summary:

In general, the vertices of Max are unique unless the vertices are intentionally not welded (in the above case. in the above case, the vertex is intentionally not welded, And the vertex coordinates are the same but not unique. as for why, I have asked about art and image UV processing, and some export plug-ins/engines do not have special processing (copy the vertices in the image and export different space switches ), therefore, the art must be manually hardened.

Max faces reference the model's vertices. These faces may share vertices, but UV and normal may be different. That is to say, the same vertex may have different UV and normal.

  • If the same vertex has a different normal, you can overlay the normal by weight if smooth processing is required; otherwise, you need to copy the vertex and store different normal.
  • If there are different Uvs, copy the vertex.
    For example, in the first two days, the UV distribution is roughly as follows:
    0.9 --- 1, 0 --- 0.1
    A B C
    Point B is at the UV joint and has two Uvs. If vertex B is not copied, a UV will be lost and the result will be 0.9 --- 0 --- 0.1.
    Note that 0.9 to 0 is equivalent to another UV range, and it is equivalent to Pasting another texture. For example, the entire face of the role appears in the middle of the back of the head after being stretched.
    So when storing the vertex, We need to copy different vertices of UV. For example, my processing is to take coordinates and UV as the key:
     inline bool operator<(const Vertex& rhs) const        {            const Vertex& lhs = *this;            return (lhs.position.x < rhs.position.x)                || (lhs.position.x == rhs.position.x && lhs.position.y < rhs.position.y)                || (lhs.position.x == rhs.position.x && lhs.position.y == rhs.position.y && lhs.position.z < rhs.position.z)                || (lhs.position.x == rhs.position.x && lhs.position.y == rhs.position.y && lhs.position.z == rhs.position.z && lhs.uv[0].x < rhs.uv[0].x)                || (lhs.position.x == rhs.position.x && lhs.position.y == rhs.position.y && lhs.position.z == rhs.position.z && lhs.uv[0].x == rhs.uv[0].x && lhs.uv[0].y < rhs.uv[0].y);        }
    To simplify the Code, only the first group of UV groups.
  • The UV image is slightly different. The image's vertex UV is usually the same, but the vertex's two sides have different U directions, that is, the tangent space is different because the tangent vector is different, we also need to copy the vertex. We have mentioned this before, but we will not talk about it much.
  • Because the exported vertex and the normal are multiple to one, the normal and the vertex should be stored separately, that is, the vertexnormalmap of the above independent line.

 

Finally, the export plug-in adds an additional step: First merge vertices by position to accumulate the normal, to ensure that there is a unique normal at the Joint

Then copy the vertex according to the image (the hand phase of the tagent space). In this way, the vertex at the joint has the same normal and different split spaces.

 

The last repaired image is compared with the previous one:

This is the normal output of the World Space in the normal map before:

This is the normal after repair. We can see the seams at the neck, and the seams at the waist and waist are gone:

 

In addition, the following issues have been fixed:

Engine Design tracking (9.2) 3DS MAX export plug-in continues

The previously encountered igame UV is incorrect and needs to be flipped manually. By carefully reading the document, we can solve the previous problem: only the coordinates obtained by gettexverts are the UV coordinate system set by igameconversionmanager,

However, I used getmapverts to obtain the coordinates. As mentioned in this document, it may be Vertex color, self-emitting, Alpha, or UV. Therefore, this mapverts is not converted.

    //! Get the active mapping channels    /*! Extracts the active mapping channels in use by the object.  Starting with 3DXI V2.0 this returns all active channels    including the standard ones such as Texture Coordinates, Vertex Colors, Illum, and Alpha.    \return A tab containing the active Mapping channels.      */    virtual Tab<int> GetActiveMapChannelNum() = 0;

In addition, this mapverts may not be UV, that is, the "UV" obtained by getmapverts is bad,

The solution is to check the uvgen of igametexturemap.

1     //!Access to the Coordinate Rollout2     /*!If the developer needs access to the transforms applied to the texture, then this can be accessed here.3     \returns A pointer to IGameUVGen4     */5     virtual IGameUVGen * GetIGameUVGen()=0;

If igameuvgen is empty, this channel is generally not UV. This method is found online.

 

In addition, a map does not contain a texture, but has a child map.

In this case, the texture string of this map is bad and needs to be skipped by calling isentitysupported.

However, after skipping, the sub-map cannot be exported. You need to skip the igame and use Max to find the sub-map:

 1     for (int texMapIdx = 0; texMapIdx < numTexMaps; texMapIdx++) 2     { 3         IGameTextureMap* map = material->GetIGameTextureMap(texMapIdx); 4         int mapType = map->GetStdMapSlot(); 5         const tchar* file = map->GetBitmapFileName(); 6  7         if(stdmat != NULL && !stdmat->MapEnabled(mapType) ) 8             continue; 9 10         bool mapValid = (map != NULL && map->IsEntitySupported());11 12         //find the first valid sub map if any. TODO: what if multiple sub maps exist?13         if( !mapValid && map != NULL )14         {15             Texmap* maxMap = map->GetMaxTexmap();16             int n = maxMap->NumSubTexmaps();17             for(int j = 0; j < n; ++j)18             {19                 Texmap* subMap = maxMap->GetSubTexmap(j);20                 if(subMap != NULL && subMap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0) && maxMap->SubTexmapOn(j) )21                 {22                     file = ((BitmapTex *)subMap)->GetMapName();23                     mapValid = true;24                     break;25                 }26             }27         }28 29         if( !mapValid )30             continue;31         //....32     }

 

The model export and split space are now falling, followed by the export of bones and animations.

Engine Design tracking (IX. 14.2a) Export plug-in problem repair and tangent space crack repair

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.