示例#1
0
        public Viewpoint(Base_Entity boundEnt)
        {
            BindToEntity(boundEnt);

            mPos = boundEnt.mPosition;
            mAngles = boundEnt.mAngles;
        }
示例#2
0
        public Viewpoint()
        {
            mBoundEnt = null;
            mBoundToEnt = false;

            mPos = new Vector2(2.5f, 2.5f);
            mAngles = new Angle2D(-1, 0);
        }
示例#3
0
        public void UpdatePositions()
        {
            if (!mBoundToEnt) return;

            //if(mPos != mBoundEnt.mPosition)
                mPos = mBoundEnt.mPosition;

            //if(mAngles != mBoundEnt.mAngles)
                mAngles = mBoundEnt.mAngles;

            //double angDiff = mAngles.GetRadians() - mBoundEnt.mAngles.GetRadians();
        }
示例#4
0
 public Angle2D Right()
 {
     Angle2D ang = new Angle2D(this.x, this.y);
     ang.Add(90);
     return ang;
 }
示例#5
0
 public player(Vector2 pos)
     : base()
 {
     mPosition = pos;
     mAngles = new Angle2D(90);
 }
示例#6
0
        /// <summary>
        /// New raycast code; Optimized
        /// </summary>
        public void RayCast2()
        {
            //Get viewport's FOV, determine fov's start and end angles relative to the viewpoint's angles
            //Interpolate between the start and end angles, casting a ray each interval
            int fovDegrees = 75;

            Angle2D minAng = this.mViewpoint.mAngles; minAng.Add((float)-(fovDegrees / 2));
            Angle2D maxAng = this.mViewpoint.mAngles; maxAng.Add((float)(fovDegrees / 2));

            //Column Buffer loop
            for (int x = 0; x < mViewportBounds.Width; x++)
            {
                float scalar = x / mViewportBounds.Width;
                Angle2D ang = new Angle2D(0) { x = minAng.x + (minAng.x - maxAng.x) * scalar, y = minAng.y + (minAng.y - maxAng.y) * scalar };

                //bool geomDone = false;

                Vector2 startPos = mViewpoint.mPos;
                Vector2 endPos = startPos + ang.ToVector2() * 100;

                Vector2 curPos = startPos;

                World.base_geom_entity geom = null;

                for (float sc = 0.0f; sc < 1; sc += 0.01f)
                {
                    curPos = startPos + ((startPos - endPos) * sc);

                    geom = Engine.mWorld.mGeometry.Find(i => i.mBounds.intersectsRadius(curPos, 0.01f));

                    if (geom != null)
                    {
                        int dist = (int)(startPos.DistTo(curPos));

                        if (dist <= 0)
                            break;

                        int drawHeight = (int)(this.mViewportBounds.Height / dist);

                        Point pDrawStart = new Point(x, (this.mViewportBounds.Height / 2) - (drawHeight / 2));
                        Point pDrawEnd = new Point(x, (this.mViewportBounds.Height / 2) + (drawHeight / 2));

                        mViewportSurface.Draw(new Line(pDrawStart, pDrawEnd), Color.Red);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }