//------------------------------------------------------------------------------------------ void CSkeleton::BuildBoneMatrices_Recursive ( u32 animationIdx, float fTimeRatio, const CBone* parent, const m4x4& TM ) { THOT_ASSERT(IsOrtho(TM)); u32 childCount = parent->GetChildCount(); for( u32 i=0; i<childCount; i++ ) { const CBone* childBone = parent->GetChild(i); THOT_ASSERT(childBone->m_boneIdx < m_boneMatrices.Size()); #ifdef DEBUG_BONE_UPDATE THOT_ASSERT( m_updatedBoneIndexes[childBone->m_boneIdx] == false ); m_updatedBoneIndexes[childBone->m_boneIdx] = true; #endif /*DEBUG_BONE_UPDATE*/ m4x4 childTM; childBone->GetBoneAndLocalMatrix( animationIdx, fTimeRatio, TM, m_boneMatrices[ childBone->m_boneIdx], childTM ); childTM*= TM; THOT_ASSERT(IsOrtho(childTM)); BuildBoneMatrices_Recursive( animationIdx, fTimeRatio, childBone, childTM ); } }
//--------------------------------------------------------------------------- void GrProjection::RecomputeMatrix() const { assert( m_bDirty ); if ( IsOrtho() ) { // orthographic. _glhOrthof2( (PxF32*)m.cProjMat.GetData(), m_fLeft, m_fRight, m_fBottom, m_fTop, m_fZNear, m_fZFar ); } else { // TODO: incorporate left/right/bottom/top to perform offcenter projection! assert( (m_fLeft == -1.0F) && (m_fRight == 1.0F) && (m_fBottom == -1.0F) && (m_fTop == 1.0F) ); if ( m_fZFar == 0.0F ) { // infinite perspective projection matrix. _glhPerspectiveInfiniteFarPlanef2( (PxF32*)m.cProjMat.GetData(), RadToDeg(m_fFovY), m_fAspect, m_fZNear ); } else { // regular perspective projection matrix. _glhPerspectivef2( (PxF32*)m.cProjMat.GetData(), RadToDeg(m_fFovY), m_fAspect, m_fZNear, m_fZFar ); } } }
//----------------------------------------------------------------------------------------------- void CRenderCamera::SetTM ( const m4x4& mTM ) { THOT_ASSERT(IsOrtho(mTM)); // only orhto matrix for viewing transforms; m_TM = mTM; RebuildMatrices(); }
void Camera::ShowGUIProperties(Editor* editor) { SceneNode::ShowGUIProperties(editor); std::string header = "Camera:" + GetName(); if (ImGui::TreeNode(header.c_str())) { auto zNear = GetZNear(); ImGui::DragFloat("##zNear", &zNear, 1.f, 0.1f, 10000.0f, "zNear %.1f"); SetNearClip(zNear); auto zFar = GetZFar(); ImGui::DragFloat("##zFar", &zFar, 1.f, 0.1f, 10000.0f, "zFar %.1f"); SetFarClip(zFar); auto isOrtho = IsOrtho(); ImGui::Checkbox("Ortho", &isOrtho); isOrtho ? EnableOrtho() : DisableOrtho(); if (!isOrtho) { auto fov = GetFOVRadians(); ImGui::SliderAngle("FOV", &fov, 0.f, CAMERA_MAX_FOV_DEGREES); SetFOVRadians(fov); } else { auto orthoScale = GetOrthoScale(); ImGui::DragFloat("##orthoScale", &orthoScale, 1.f, 0.f, MAX_WORLD_SIZE, "Size %.1f"); SetOrthoScale(orthoScale); } ImGui::TreePop(); } }