MCPcopy Create free account
hub / github.com/carbonengine/trinity / BuildFromGrannyVertexDecl

Function BuildFromGrannyVertexDecl

trinity/Tr2VertexDefinitionUtilities.cpp:69–135  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Converts Granny vertex definition to Trinity vertex definition. Arguments: grannyVertexDecl - Granny vertex definition Return Value: Trinity vertex definition corresponding to input Granny vertex definition --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

67// Trinity vertex definition corresponding to input Granny vertex definition
68// --------------------------------------------------------------------------------------
69Tr2VertexDefinition BuildFromGrannyVertexDecl( const granny_data_type_definition* grannyVertexDecl )
70{
71 Tr2VertexDefinition vd;
72
73 while( grannyVertexDecl->Type != GrannyEndMember )
74 {
75 const granny_data_type_definition& src = *grannyVertexDecl++;
76
77 Tr2VertexDefinition::Item item;
78
79 item.m_stream = 0;
80 item.m_offset = vd.m_nextOffset[0];
81 item.m_dataType = ConvertGrannyTypeToDataType( src );
82 item.m_usageIndex = 0;
83
84 vd.m_nextOffset[0] += vd.GetDataTypeSizeInBytes( item.m_dataType );
85
86 if( !strncmp( src.Name, GrannyVertexPositionName, strlen( GrannyVertexPositionName ) ) )
87 {
88 item.m_usage = vd.POSITION;
89 char C = src.Name[strlen( GrannyVertexPositionName )];
90 item.m_usageIndex = C ? unsigned( C - '0' ) : 0;
91 }
92 else if( !strncmp( src.Name, GrannyVertexDiffuseColorName, strlen( GrannyVertexDiffuseColorName ) ) )
93 {
94 item.m_usage = vd.COLOR;
95 char C = src.Name[strlen( GrannyVertexDiffuseColorName )];
96 item.m_usageIndex = C ? unsigned( C - '0' ) : 0;
97 }
98 else if( !strncmp( src.Name, GrannyVertexNormalName, strlen( GrannyVertexNormalName ) ) )
99 {
100 item.m_usage = vd.NORMAL;
101 char C = src.Name[strlen( GrannyVertexNormalName )];
102 item.m_usageIndex = C ? unsigned( C - '0' ) : 0;
103 }
104 else if( !strncmp( src.Name, GrannyVertexTangentName, strlen( GrannyVertexTangentName ) ) )
105 {
106 item.m_usage = vd.TANGENT;
107 char C = src.Name[strlen( GrannyVertexTangentName )];
108 item.m_usageIndex = C ? unsigned( C - '0' ) : 0;
109 }
110 else if( !strncmp( src.Name, GrannyVertexBinormalName, strlen( GrannyVertexBinormalName ) ) )
111 {
112 item.m_usage = vd.BITANGENT;
113 char C = src.Name[strlen( GrannyVertexBinormalName )];
114 item.m_usageIndex = C ? unsigned( C - '0' ) : 0;
115 }
116 else if( !strncmp( src.Name, GrannyVertexTextureCoordinatesName, strlen( GrannyVertexTextureCoordinatesName ) ) )
117 {
118 item.m_usage = vd.TEXCOORD;
119 char C = src.Name[strlen( GrannyVertexTextureCoordinatesName )];
120 item.m_usageIndex = C ? unsigned( C - '0' ) : 0;
121 }
122 else if( !strcmp( src.Name, GrannyVertexBoneIndicesName ) )
123 {
124 item.m_usage = vd.BLENDINDICES;
125 }
126 else if( !strcmp( src.Name, GrannyVertexBoneWeightsName ) )

Callers 6

DoSpawnMethod · 0.85
IsAreaMorphedMethod · 0.85
SetupMeshesMethod · 0.85
ExtractAudioGeometryMethod · 0.85
GetMeshVertexElementsMethod · 0.85

Calls 2

Tested by

no test coverage detected