void RenderWindowControl::updateInfo() { auto model = HonViewerApp::GetViewerApp()->GetModelViewer(); if (!model) return; int numVerts = model->GetNumVertices(); int numFaces = model->GetNumFaces(); int numSubMods = model->GetNumSubModels(); int numBones = model->GetNumBones(); DiString info; info.Format("%d\n%d\n%d\n%d", numVerts, numFaces, numSubMods, numBones); mInfo->setCaption(info.c_str()); }
void Ragdoll::UpdateAnimationFromPhysics() { #if RESET_WORLD_TRANSFORM //* ...trying it first... (seems to have an effect, but not quite correct) // (hrm, now this seems to fly away...) // now find a position and orientation for the body at large { // find position and orientation of the body at large by finding position // and orientation of a bone at the root, and subtracting out its offset // in model space const osg::Matrix bodyWorldTransform = CalculateRagdollWorldTransformFromBones(); // now set it for the rag doll at large mpRagdoll->SetWorldTransform(bodyWorldTransform); } //*/ #endif for (size_t i = 0; i < mRagdollBones.size(); ++i) { RagdollBone* bone = GetBoneByIndex(i); bone->UpdateAnimationFromPhysics(); } // now call CalSkeleton::calculateState to finish bone settings if (GetNumBones() > 0 && mRagdollBones[0]->GetBridgeCAL3D()) { mRagdollBones[0]->GetBridgeCAL3D()->GetCalModel()->getSkeleton()->calculateState(); } /* (doing second seems to have no effect) // now find a position and orientation for the body at large { // find position and orientation of the body at large by finding position // and orientation of a bone at the root, and subtracting out its offset // in model space const osg::Matrix bodyWorldTransform = CalculateRagdollWorldTransformFromBones(); // now set it for the rag doll at large mpRagdoll->SetWorldTransform(bodyWorldTransform); } //*/ }
const RagdollBone* Ragdoll::GetBoneByIndex(unsigned int index) const { const RagdollBone* bone = (index >= 0 && index < GetNumBones()) ? mRagdollBones[index] : NULL; return bone; }
const Bone* Skeleton::GetBoneByIndex(unsigned int index) const { const Bone* bone = (index >= 0 && index < GetNumBones()) ? mBones[index] : NULL; return bone; }
void CInstance::Transform( uint32 flags, ROMtx * p_mtx_buffer, Mth::Matrix *p_mtx_last ) { //# ifdef __USE_PROFILER__ //// Sys::VUProfiler->PushContext( 128,0,0 ); //# endif // __USE_PROFILER__ // if ( gNewRender ) render_flags |= NxNgc::vRENDER_NEW_TEST; if( GetBoneTransforms() && ( GetScene()->m_numHierarchyObjects == 0 ) ) { // Has bone transforms, is therefore an animated object such as a skater, pedestrian etc. mp_posNormRenderBuffer = GetPosNormalBuffer( 0 ); if ( !p_mtx_last || ( GetBoneTransforms() != p_mtx_last ) ) { float * ps; float * pd; for( int i = 0; i < GetNumBones(); ++i ) { ps = (float*)&GetBoneTransforms()[i]; pd = (float*)&p_mtx_buffer[i][0][0]; *pd++ = *ps++; *pd++ = *ps++; *pd++ = *ps++; ps++; *pd++ = *ps++; *pd++ = *ps++; *pd++ = *ps++; ps++; *pd++ = *ps++; *pd++ = *ps++; *pd++ = *ps++; ps++; *pd++ = *ps++; *pd++ = *ps++; *pd++ = *ps++; } } // Setup some required pointers for both transforms. // sMesh* p_mesh = GetScene()->mpp_mesh_list[0]; // if ( GetScene()->m_num_opaque_entries ) // { // p_mesh = GetScene()->m_opaque_meshes[0]; // } // else if ( GetScene()->m_num_semitransparent_entries ) // { // p_mesh = GetScene()->m_semitransparent_meshes[0]; // } // else // { // Dbg_MsgAssert(0, ("No meshes in scene.")); // p_mesh = NULL; // } // Transform the single lists. uint32* p32 = (uint32 *)GetScene()->mp_dl->mp_object_header->m_skin.p_data; s16* p_pos = mp_posNormRenderBuffer; for ( uint32 lp = 0; lp < GetScene()->mp_dl->mp_object_header->m_num_single_lists; lp++ ) { uint32 pairs = *p32++; uint32 mtx = *p32++; s16* p_pn = (s16 *)p32; ROMtxPtr p_bone = p_mtx_buffer[mtx]; TransformSingle( p_bone, p_pn, p_pos, pairs == 1 ? 2 : pairs ); p_pos += (6 * pairs); p32 = (uint32 *)&p_pn[pairs*6]; } // Transform the double lists. for ( uint32 lp = 0; lp < GetScene()->mp_dl->mp_object_header->m_num_double_lists; lp++ ) { uint32 pairs = *p32++; uint32 mtx = *p32++; s16* p_pn = (s16 *)p32; ROMtxPtr p_bone0 = p_mtx_buffer[mtx&255]; ROMtxPtr p_bone1 = p_mtx_buffer[(mtx>>8)&255]; s16* p_weight = (s16 *)&p_pn[(6*pairs)]; TransformDouble( p_bone0, p_bone1, p_weight, p_pn, p_pos, pairs == 1 ? 2 : pairs ); p_pos += (6 * pairs); p32 = (uint32 *)&p_weight[pairs*2]; } // Transform the acc lists. for ( uint32 lp = 0; lp < GetScene()->mp_dl->mp_object_header->m_num_add_lists; lp++ ) { uint32 singles = *p32++; uint32 mtx = *p32++; s16* p_pn = (s16 *)p32; ROMtxPtr p_bone = p_mtx_buffer[mtx]; s16* p_weight = (s16 *)&p_pn[(6*singles)]; uint16* p_index = (uint16 *)&p_weight[singles]; TransformAcc( p_bone, singles, p_pn, mp_posNormRenderBuffer, p_index, p_weight ); // p32 = (uint32 *)&p_index[singles+(singles&1)]; p32 = (uint32 *)&p_index[singles]; } // int num_vertex; // if ( mp_scene->m_num_opaque_entries ) // { // num_vertex = mp_scene->m_opaque_meshes[0]->m_num_vertex; // } // else if ( mp_scene->m_num_semitransparent_entries ) // { // num_vertex = mp_scene->m_semitransparent_meshes[0]->m_num_vertex; // } // else // { // Dbg_MsgAssert(0, ("No meshes in scene.")); // num_vertex = 0; // } // int num_vertex = GetScene()->mp_dl->mp_object_header->m_num_skin_verts; DCFlushRange ( mp_posNormRenderBuffer, sizeof ( s16 ) * 6 * ( num_vertex + 1 ) ); }