14th back Mesh

Source: Internet
Author: User

This timeMesh, meshIs another basic resource.,Speaking of basic resources,There are still some more basic resources in the engine,For exampleItexture, ivertexbuffer, iindexbuffer, isurface,These are basicallyD3d9Encapsulation of provided resources,I will not talk about it here..

MeshResources contain something messy,Yes:

1).OneAABB,Indicates thisMeshSurrounded box of all vertices(Of course, it is in a local space.)

2).Number of bone weights contained in the vertex,That is, each vertex is affected by several bones..We can plot this based on this value.MeshWhich one to useShader.

3).Number of bones,ThisMeshHow many bones does the bound skeleton system contain?,Note that this value is notMeshActually used skeleton,Generally

ItemsMeshBind to a skeleton System,It only uses a part of the skeleton.We use this value for parameter verification.,IfMeshHour,If the size of the input Skeleton Matrix array is inconsistent with the value,We think the parameter is incorrect..

4) . Vertexbuffer,Records all vertex data,(AllLevelsVertex data is placed in the sameVertex bufferLi).Currently, the vertex formats include Position, normal, binormal, tangent, boneweight, boneindex,And multipleChannelOfUV coordinate,Not Supported currently MorphAnimation,Therefore, related vertex formats are not supported.

5). Levels of detail)Information,Each recordLevelsData Array,EachLevelsInclude:

A)Distance Value,How far can I switch to thisLevels

B)Indexbuffer,Record thisLevelsAll triangle PairsVertex bufferIndex value

C)Skeleton Index Array,Record the index of the Skeleton Matrix Array

D)Segment (Segment)Information,EachSegmentCorrespondingIndexbufferAnd the range of a skeleton index array.

LevelsSee:

 

This data storage method is used because,SubjectShaderRegister restrictions,The number of supported bones is limited.,

Therefore, we mustLevelsDivided into multipleSegment,And eachSegmentThe number of bones used cannot exceed the limit of the number of bones,The current limit value is23 (It's a little small for the current video card).

MeshThe rendering process:

*.BindVertexbuffer

*.AccordingMeshThe distanceLevels

*.Bind thisLevelsOfIndexbuffer

*.For thisLevelsEachSegment:

**.AccordingSegmentRange in the skeleton Index Array,ExtractsSegmentUsed Skeleton Matrix,Form(Sub-)Skeleton Matrix Array,Bind itShaderGo.

**.CallDrawindexprimitive (..),Draw thisSegmentCorrespondingPrimitives.

Of course, the limit on the number of bones,There is a simple solution: manual Cutting by Art,Make a singleMeshThe number of bones used is not exceeded. Overlimit,In this wayCodeIt's not that complicated..But for thisEngineEasy to use,Provide support in this aspect Holding.

MeshThis is roughly the content of the resource.,For more convenient useMeshResources,I also wrote a secondary tool class,CalledImeshsnapshot,

Main functions::

1. ) Is Mesh Binds a World Space matrix or a set of skeleton matrices. ,Then calculate the actual data of each vertex..The data can be used in some debugging functions.,Or very accurateHittest

2. ) Use the specifiedUV channel,ComputingMeshsample.For a setUV channel,Sometimes we need to map a pixel on the textureMeshOne on3DLocation,I call itMeshsample,This is generatedLightmapIs an important step.It can also be used inMeshOn the surface,It can be used for some special effects..

MeshHere is the resource.,Next, let's talk about the animation tree..

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.