TransformVector() private method

private TransformVector ( float v ) : void
v float
return void
        /// <summary>
        ///		Internal method for parsing chosen entities.
        /// </summary>
        protected void LoadEntities(Quake3Level q3lvl)
        {
            Vector3 origin = new Vector3();
            float angle = 0;
            bool isPlayerStart = false;
            string[] entities = q3lvl.Entities.Split('\n');

            for(int i = 0; i < entities.Length; i++)
            {
                // Remove whitespace and quotes.
                entities[i] = entities[i].Trim().Replace("\"", "");

                if(entities[i].Length == 0)
                    continue;

                string[] paramList = entities[i].Split(' ');

                if(paramList[0] == "origin")
                {
                    float[] vector = new float[3];
                    for (int v = 0; v < 3; v++)
                        vector[v] = StringConverter.ParseFloat(paramList[v + 1]);

                    q3lvl.TransformVector(vector);

                    origin = new Vector3(vector[0], vector[1], vector[2]);
                }

                if(paramList[0] == "angle")
                    angle = StringConverter.ParseFloat(paramList[1]);

                if((paramList[0] == "classname") && (paramList[1] == "info_player_deathmatch"))
                    isPlayerStart = true;

                if(paramList[0] == "}")
                {
                    if(isPlayerStart)
                    {
                        ViewPoint vp = new ViewPoint();
                        vp.position = origin;

                        if (q3lvl.Options.setYAxisUp)
                            vp.orientation = Quaternion.FromAngleAxis(MathUtil.DegreesToRadians(angle), Vector3.UnitY);
                        else
                            vp.orientation = Quaternion.FromAngleAxis(MathUtil.DegreesToRadians(angle), Vector3.UnitZ);

                        playerStarts.Add(vp);
                    }

                    isPlayerStart = false;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///		Internal method for parsing chosen entities.
        /// </summary>
        protected void LoadEntities(Quake3Level q3lvl)
        {
            Vector3 origin        = new Vector3();
            float   angle         = 0;
            bool    isPlayerStart = false;

            string[] entities = q3lvl.Entities.Split('\n');

            for (int i = 0; i < entities.Length; i++)
            {
                // Remove whitespace and quotes.
                entities[i] = entities[i].Trim().Replace("\"", "");

                if (entities[i].Length == 0)
                {
                    continue;
                }

                string[] paramList = entities[i].Split(' ');

                if (paramList[0] == "origin")
                {
                    float[] vector = new float[3];
                    for (int v = 0; v < 3; v++)
                    {
                        vector[v] = StringConverter.ParseFloat(paramList[v + 1]);
                    }

                    q3lvl.TransformVector(vector);

                    origin = new Vector3(vector[0], vector[1], vector[2]);
                }

                if (paramList[0] == "angle")
                {
                    angle = StringConverter.ParseFloat(paramList[1]);
                }

                if ((paramList[0] == "classname") && (paramList[1] == "info_player_deathmatch"))
                {
                    isPlayerStart = true;
                }

                if (paramList[0] == "}")
                {
                    if (isPlayerStart)
                    {
                        ViewPoint vp = new ViewPoint();
                        vp.position = origin;

                        if (q3lvl.Options.setYAxisUp)
                        {
                            vp.orientation = Quaternion.FromAngleAxis(MathUtil.DegreesToRadians(angle), Vector3.UnitY);
                        }
                        else
                        {
                            vp.orientation = Quaternion.FromAngleAxis(MathUtil.DegreesToRadians(angle), Vector3.UnitZ);
                        }

                        playerStarts.Add(vp);
                    }

                    isPlayerStart = false;
                }
            }
        }