Exemplo n.º 1
0
 private static void scaleTime(uint millisPerTick, CameraPlan cameraPlan)
 {
     foreach (var block in cameraPlan.Blocks)
     {
         if (block.StoryTime.HasValue)
         {
             block.StoryTime = block.StoryTime.Value * millisPerTick;
         }
         foreach (var fragment in block.ShotFragments)
         {
             fragment.Duration *= millisPerTick;
         }
     }
 }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     CameraPlan plan = Parser.Parse("../../../../FireBoltUnity/cameraPlans/defaultCamera.xml");
 }
Exemplo n.º 3
0
        public static void CreateActions(Story <UintV, UintT, IIntervalSet <UintV, UintT> > story, CM.CinematicModel cinematicModel, string cameraPlanPath,
                                         out CameraActionList cameraActionList, out FireBoltActionList discourseActionList)
        {
            cameraActionList    = new CameraActionList();
            discourseActionList = new FireBoltActionList();
            CameraPlan cameraPlan = Oshmirto.Parser.Parse(cameraPlanPath);

            if (cinematicModel.MillisPerTick != 1)
            {
                scaleTime(cinematicModel.MillisPerTick, cameraPlan);
            }


            uint  currentDiscourseTime    = 0;
            float previousStoryTimeOffset = 0;

            foreach (Block block in cameraPlan.Blocks)
            {
                float blockStartTime = Single.MaxValue;
                float blockEndTime   = Single.MinValue;
                foreach (var fragment in block.ShotFragments)
                {
                    uint fragmentStartTime = currentDiscourseTime;//removing increment.  cameras always execute after discourse actions currentDiscourseTime++;
                    uint fragmentEndTime   = fragmentStartTime + fragment.Duration;

                    if (fragmentStartTime < blockStartTime) //assumes same time scale for discourse and story
                    {
                        blockStartTime = fragmentStartTime;
                    }
                    if (fragmentEndTime > blockEndTime)
                    {
                        blockEndTime = fragmentEndTime;
                    }

                    cameraActionList.Add(new ShotFragmentInit(fragmentStartTime, cameraRig, fragment.Anchor, fragment.Height, fragment.Pan,
                                                              fragment.Lens, fragment.FStop, fragment.Framings, fragment.Direction, fragment.Angle, fragment.FocusPosition));

                    var            movementStartTime = fragmentStartTime + 1; //force moves to sort after inits
                    RotateRelative rotateWith        = null;                  //collect all the relative rotations together for the camera so we can avoid representational nightmares
                    Rotate         rotateTo          = null;                  //similarly collect absolute rotations...eventually we should cross check and/or merge this stuff
                    foreach (var movement in fragment.CameraMovements)
                    {
                        switch (movement.Type)
                        {
                        case CameraMovementType.Dolly:
                            switch (movement.Directive)
                            {
                            case (CameraMovementDirective.With):
                                cameraActionList.Add(new TranslateRelative(movement.Subject, movementStartTime, fragmentEndTime, cameraRig, false, true, false));
                                break;

                            case (CameraMovementDirective.To):
                                Vector2 destination;
                                if (movement.Subject.TryParsePlanarCoords(out destination))
                                {
                                    cameraActionList.Add(new Translate(movementStartTime, fragmentEndTime, cameraRig,
                                                                       null, new Vector3Nullable(destination.x, null, destination.y)));
                                }
                                break;
                            }
                            break;

                        case CameraMovementType.Crane:
                            switch (movement.Directive)
                            {
                            case CameraMovementDirective.With:
                                break;

                            case CameraMovementDirective.To:
                                cameraActionList.Add(new Translate(movementStartTime, fragmentEndTime, cameraRig,
                                                                   null, new Vector3Nullable(null, float.Parse(movement.Subject), null)));
                                break;
                            }
                            break;

                        case CameraMovementType.Pan:
                            switch (movement.Directive)
                            {
                            case CameraMovementDirective.With:
                                if (rotateWith != null)
                                {
                                    rotateWith.AppendAxis(movement.Subject, cameraRig, true, false);
                                }
                                else
                                {
                                    rotateWith = new RotateRelative(movement.Subject, movementStartTime, fragmentEndTime, cameraRig,
                                                                    true, false);
                                }

                                break;

                            case CameraMovementDirective.To:
                                if (rotateTo != null)
                                {
                                    rotateTo.AppendAxisY(float.Parse(movement.Subject));
                                }
                                else
                                {
                                    rotateTo = new Rotate(movementStartTime, fragmentEndTime, cameraRig, new Vector3Nullable(null, float.Parse(movement.Subject), null), null);
                                }
                                break;
                            }
                            break;

                        case CameraMovementType.Tilt:
                            switch (movement.Directive)
                            {
                            case CameraMovementDirective.With:         // will this co-execute with pan-with? not currently
                                if (rotateWith != null)
                                {
                                    rotateWith.AppendAxis(movement.Subject, cameraRig, false, true);
                                }
                                else
                                {
                                    rotateWith = new RotateRelative(movement.Subject, movementStartTime, fragmentEndTime, cameraRig,
                                                                    false, true);
                                }
                                break;

                            case CameraMovementDirective.To:
                                if (rotateTo != null)
                                {
                                    rotateTo.AppendAxisX(float.Parse(movement.Subject));
                                }
                                else
                                {
                                    rotateTo = new Rotate(movementStartTime, fragmentEndTime, cameraRig, new Vector3Nullable(float.Parse(movement.Subject), null, null), null);
                                }
                                break;
                            }
                            break;

                        case CameraMovementType.Focus:
                            switch (movement.Directive)
                            {
                            case CameraMovementDirective.With:
                                cameraActionList.Add(new Focus(movementStartTime, fragmentEndTime, cameraName, movement.Subject, true));
                                break;
                            }
                            break;
                        }
                    }
                    if (rotateWith != null)
                    {
                        cameraActionList.Add(rotateWith);
                    }
                    if (rotateTo != null)
                    {
                        cameraActionList.Add(rotateTo);
                    }
                    // Shake it off
                    if (fragment.Shake > float.Epsilon)
                    {
                        cameraActionList.Add(new Shake(movementStartTime, fragmentEndTime, cameraName, fragment.Shake));
                    }

                    currentDiscourseTime = fragmentEndTime + 1; //set fragments to end and next to start on next tick
                }
                if (block.StoryTime.HasValue)
                {
                    float currentStoryTimeOffset = block.StoryTime.Value - blockStartTime;
                    discourseActionList.Add(new SetStoryTime(currentStoryTimeOffset, previousStoryTimeOffset, blockStartTime, blockEndTime));
                    previousStoryTimeOffset = block.StoryTime.Value;
                }
            }
            cameraActionList.EndDiscourseTime = currentDiscourseTime;
        }