コード例 #1
0
ファイル: frmMain.cs プロジェクト: iManbot/monoslam
        /// <summary>
        /// turns a postion and quaternion based orientation into a matrix format
        /// </summary>
        /// <param name="position"></param>
        /// <param name="orientation"></param>
        /// <returns></returns>
        private Matrix QuaternionToMatrixLookAt(Vector3D position, SceneLibrary.Quaternion orientation)
        {
            Microsoft.DirectX.Quaternion q_orientation = 
                new Microsoft.DirectX.Quaternion((float)orientation.GetX(),
                                                 (float)orientation.GetY(),
                                                 (float)orientation.GetZ(),
                                                 (float)orientation.GetR());
            Matrix _matrixRotation = Matrix.RotationQuaternion(q_orientation);
            Vector3 camPos = new Vector3((float)position.GetX(), -(float)position.GetY(), (float)position.GetZ());
            Vector3 camTY = new Vector3(_matrixRotation.M21, _matrixRotation.M22, _matrixRotation.M23);
            Vector3 camTZ = new Vector3(-(_matrixRotation.M31), -(_matrixRotation.M32), -(_matrixRotation.M33));
            return (Matrix.LookAtLH(camPos, camPos + camTZ, camTY));

            //float yaw = 0, pitch = 0, roll = 0;
            //DecomposeRollPitchYawZXYMatrix(_matrixRotation, ref pitch, ref yaw, ref roll);

            //return (Matrix.RotationYawPitchRoll((float)yaw, (float)pitch, (float)roll) * Matrix.LookAtLH(camPos, camPos + camTZ, camTY));
            //return (Matrix.RotationYawPitchRoll(0, 0, (float)roll) * Matrix.LookAtLH(camPos, camPos + camTZ, camTY));
        }
コード例 #2
0
        // Populates the SceneLibrary with new StoryThreads from the CSV
        public static void ParseScenes(string resourcePath)
        {
            List <List <string> > csv = ParseCSV(resourcePath);
            StoryThread           pre;   // pre-scene in fights/flashbacks
            StoryThread           post1; // post-scene in fights (win)/flashbacks
            StoryThread           post2; // post-scene for lost fights
            List <Narration>      builder = new List <Narration>();

            for (int i = 0; i < csv.Count; i++)
            {
                if (csv[i][0] == "NULL")
                {
                    Debug.Log("We found a null!");
                }
                else
                {
                    switch (csv[i][1])
                    {
                    // Simple Story Thread
                    case "S":
                    case "s":
                        for (int j = 2; j < csv[1].Count; j += 2)
                        {
                            switch (csv[i][j])
                            {
                            case "Q":
                            case "q":
                                builder.Add(QuestionLibrary[csv[i][j + 1]]);
                                break;

                            case "D":
                            case "d":
                                builder.Add(DialogueLibrary[csv[i][j + 1]]);
                                break;
                            }
                        }
                        SceneLibrary.Add(csv[i][0], new StoryThread(builder.ToArray()));
                        builder = new List <Narration>();
                        break;

                    // Fight Story Thread
                    case "F":
                    case "f":
                        try
                        {
                            pre = SceneLibrary[csv[i][3]];
                        }
                        catch (Exception e)
                        {
                            pre = new StoryThread(new Narration[0]);
                        }

                        try
                        {
                            post1 = SceneLibrary[csv[i][7]];
                        }
                        catch (Exception e)
                        {
                            post1 = new StoryThread(new Narration[0]);
                        }

                        try
                        {
                            post2 = SceneLibrary[csv[i][9]];
                        }
                        catch (Exception e)
                        {
                            post2 = new StoryThread(new Narration[0]);
                        }

                        SceneLibrary.Add(csv[i][0], new FightThread(pre, SceneLibrary[csv[i][5]].thread, post1, post2));
                        break;

                    // Flashback Story Thread
                    case "M":
                    case "m":
                        try
                        {
                            pre = SceneLibrary[csv[i][3]];
                        }
                        catch (Exception e)
                        {
                            pre = new StoryThread(new Narration[0]);
                        }

                        try
                        {
                            post1 = SceneLibrary[csv[i][7]];
                        }
                        catch (Exception e)
                        {
                            post1 = new StoryThread(new Narration[0]);
                        }

                        SceneLibrary.Add(csv[i][0], new FlashbackThread(pre, SceneLibrary[csv[i][5]].thread, csv[i][4], post1));
                        break;
                    }
                }
            }
        }