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.
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