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

Method RenderBones

trinity/Tr2GrannyAnimation.cpp:1023–1113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1021}
1022
1023void Tr2GrannyAnimation::RenderBones( const Matrix& modelTransform, const Tr2AnimationMeshBinding* meshBinding )
1024{
1025 if( IsUsingCMF() )
1026 {
1027 const int* bi = nullptr;
1028 size_t boneCount = 0;
1029 if( meshBinding )
1030 {
1031 bi = meshBinding->GetAnimBoneIndices().data();
1032 boneCount = meshBinding->GetAnimBoneIndices().size();
1033 }
1034 else
1035 {
1036 bi = m_skeletonBoneIndices.data();
1037 boneCount = m_skeletonBoneIndices.size();
1038 }
1039
1040 if( !bi )
1041 {
1042 return;
1043 }
1044
1045 auto& skeleton = GetCMFData()->skeletons[m_modelIndex];
1046
1047 for( int boneIdx = 0; boneIdx < boneCount; boneIdx++ )
1048 {
1049 if( bi[boneIdx] < 0 )
1050 {
1051 continue;
1052 }
1053
1054 Matrix mat = m_worldTransforms[bi[boneIdx]] * modelTransform;
1055 Vector4 pos( 0, 0, 0, 1 );
1056 pos = Transform( pos, mat );
1057 pos.w = 2;
1058 Tr2Renderer::DrawSphere( pos, 1, 0xffffffff );
1059 std::string tmp = cmf::ToStdString( skeleton.bones[bi[boneIdx]] );
1060 Tr2Renderer::Printf( static_cast<TriDebugFont>( g_debugBoneLabelFont ), Vector3( pos.x, pos.y, pos.z ), 0xffffffff, " %s : %d", tmp.c_str(), boneIdx );
1061
1062 int32_t parent = (int32_t)skeleton.parents[bi[boneIdx]];
1063 if( parent > 0 )
1064 {
1065 Matrix pmat = m_worldTransforms[parent] * modelTransform;
1066 Vector3 ppos = TransformCoord( Vector3( 0, 0, 0 ), pmat );
1067 Tr2Renderer::DrawLine( pos.GetXYZ(), ppos, 0x88888888 );
1068 }
1069 }
1070 }
1071#if WITH_GRANNY
1072 else
1073 {
1074 auto binding = meshBinding ? meshBinding->GetGrannyMeshBinding() : m_meshBinding;
1075 if( !binding )
1076 {
1077 return;
1078 }
1079
1080 Vector3 initialPlacement( 0, 0, 0 );

Callers 2

RenderDebugInfoMethod · 0.45
RenderDebugInfoMethod · 0.45

Calls 6

IsUsingCMFFunction · 0.85
GetViewTransformFunction · 0.85
GetProjectionTransformFunction · 0.85
sizeMethod · 0.80
GetGrannyMeshBindingMethod · 0.80
Vector3Class · 0.70

Tested by

no test coverage detected