Пример #1
0
 private void Init(SharpGL.OpenGLControl openGLControl, int interval, double eyex, double eyey, double eyez,
                   double centerx, double centery, double centerz,
                   double upx, double upy, double upz, double fovy, double aspect, double zNear, double zFar)
 {
     this.openGLControl      = openGLControl;
     this.interval           = interval;
     this.eye                = new TriTuple(eyex, eyey, eyez);
     this.center             = new TriTuple(centerx, centery, centerz);
     this.up                 = new TriTuple(upx, upy, upz);
     this.perspective        = new PerspectiveParam(fovy, aspect, zNear, zFar);
     this.updateViewDelegate = new Action(UpdateView);
 }
Пример #2
0
        public void GoRight(double step)
        {
            var diff = new TriTuple(this.center.X - this.eye.X,
                                    0,
                                    this.center.Z - this.eye.Z);
            var length2  = diff.X * diff.X + 0 + diff.Z * diff.Z;
            var radio    = Math.Sqrt(step * step / length2);
            var stepDiff = new TriTuple(-diff.Z * radio, 0, diff.X * radio);

            this.eye.Add(stepDiff);
            this.center.Add(stepDiff);
        }
Пример #3
0
        /// <summary>
        /// 正数向右转,负数向左转
        /// </summary>
        /// <param name="turnAngle">正数向右转,负数向左转</param>
        public void Turn(double turnAngle)
        {
            var diff = new TriTuple(this.center.X - this.eye.X,
                                    0,
                                    this.center.Z - this.eye.Z);
            var cos        = Math.Cos(turnAngle);
            var sin        = Math.Sin(turnAngle);
            var centerDiff = new TriTuple(diff.X * cos - diff.Z * sin,
                                          0,
                                          diff.X * sin + diff.Z * cos);

            this.center.X = this.eye.X + centerDiff.X;
            this.center.Z = this.eye.Z + centerDiff.Z;
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="staggerAngle"></param>
        private void Stagger(double staggerAngle)
        {
            var ceX        = this.center.X - this.eye.X;
            var ceZ        = this.center.Z - this.eye.Z;
            var distanceCE = Math.Sqrt(ceX * ceX + ceZ * ceZ);
            var diff       = new TriTuple(distanceCE, this.center.Y - this.eye.Y, 0);
            var cos        = Math.Cos(staggerAngle);
            var sin        = Math.Sin(staggerAngle);
            var centerDiff = new TriTuple(diff.X * cos - diff.Y * sin,
                                          diff.X * sin + diff.Y * cos,
                                          0);

            this.center.Y = this.eye.Y + centerDiff.Y;
            var percent = centerDiff.X / distanceCE;

            this.center.X = this.eye.X + percent * ceX;
            this.center.Z = this.eye.Z + percent * ceZ;
        }
Пример #5
0
 public CameraEventArgs(TriTuple eye, TriTuple center, TriTuple up, PerspectiveParam perspective)
 {
     this.eye         = eye; this.center = center; this.up = up;
     this.perspective = perspective;
 }
Пример #6
0
 internal void Add(TriTuple diff)
 {
     this.X = this.X + diff.X;
     this.Y = this.Y + diff.Y;
     this.Z = this.Z + diff.Z;
 }