Exemplo n.º 1
0
        public override void UpdateTransform()
        {
            tmpMpos.Set(modelPos);
            tmpMpos.MultiplyStore(-1f);
            rotMatrix.SetToTranslation(tmpMpos);

            tmpRot.Set(modelRot);
            tmpRot.MultiplyStore(poseRot);
            tmpRot.MultiplyStore(localRotation);
            tmpRot.MultiplyStore(invBindRot);

            tmpMatrix.SetToRotation(tmpRot);
            rotMatrix.MultiplyStore(tmpMatrix);
            tmpMpos.MultiplyStore(-1f);
            tmpMatrix.SetToTranslation(tmpMpos);
            rotMatrix.MultiplyStore(tmpMatrix);
            tmpMatrix.SetToTranslation(localTranslation);
            rotMatrix.MultiplyStore(tmpMatrix);
            boneMatrix.Set(rotMatrix);
            if (parentBone != null)
            {
                boneMatrix.MultiplyStore(parentBone.boneMatrix);
            }
            for (int i = 0; i < children.Count; i++)
            {
                if (children[i] is Bone)
                {
                    Bone b = (Bone)children[i];
                    b.UpdateTransform();
                }
            }
        }
Exemplo n.º 2
0
 public void Update()
 {
     UpdateFrustumPoints(fPoints);
     centerPos.Set(0, 0, 0);
     frustumCornersWS = fPoints;
     for (int i = 0; i < 8; i++)
     {
         centerPos.AddStore(frustumCornersWS[i]);
     }
     centerPos.DivideStore(8f);
     newView.SetToLookAt(tmpVec.Set(centerPos).SubtractStore(lightDirection), centerPos, Vector3f.UnitY);
     Transform(ref frustumCornersWS, ref frustumCornersLS, ref newView);
     maxes.Set(float.MinValue, float.MinValue, float.MinValue);
     mins.Set(float.MaxValue, float.MaxValue, float.MaxValue);
     for (int i = 0; i < frustumCornersLS.Length; i++)
     {
         if (frustumCornersLS[i].x > maxes.x)
         {
             maxes.x = frustumCornersLS[i].x;
         }
         else if (frustumCornersLS[i].x < mins.x)
         {
             mins.x = frustumCornersLS[i].x;
         }
         if (frustumCornersLS[i].y > maxes.y)
         {
             maxes.y = frustumCornersLS[i].y;
         }
         else if (frustumCornersLS[i].y < mins.y)
         {
             mins.y = frustumCornersLS[i].y;
         }
         if (frustumCornersLS[i].z > maxes.z)
         {
             maxes.z = frustumCornersLS[i].z;
         }
         else if (frustumCornersLS[i].z < mins.z)
         {
             mins.z = frustumCornersLS[i].z;
         }
     }
     s_cam.ViewMatrix = newView;
     s_cam.ProjectionMatrix.SetToOrtho(mins.x, maxes.x, mins.y, maxes.y, -splits[3], splits[3]);
     viewProjectionMatrix.Set(s_cam.ViewMatrix);
     viewProjectionMatrix.MultiplyStore(s_cam.ProjectionMatrix);
     s_cam.ViewProjectionMatrix.Set(s_cam.ViewMatrix);
     s_cam.ViewProjectionMatrix.MultiplyStore(s_cam.ProjectionMatrix);
     s_cam.InverseViewProjectionMatrix.Set(s_cam.ViewProjectionMatrix);
     s_cam.InverseViewProjectionMatrix.InvertStore();
 }