示例#1
0
        protected Face CreateFace(Vector3D axis, Vector3D x, Vector3D y, Textures textures, string textureFileName)
        {
            Face face = new Face();

            // create verticies and texture coordinates
            face.Points.Add(axis + x + y);
            face.TextureCoords.Add(new Vector3D(255f / 256, 255f / 256, 1f / 256));
            face.Points.Add(axis - x + y);
            face.TextureCoords.Add(new Vector3D(255f / 256, 1f / 256, 1f / 256));
            face.Points.Add(axis - x - y);
            face.TextureCoords.Add(new Vector3D(1f / 256, 1f / 256, 1f / 256));
            face.Points.Add(axis + x - y);
            face.TextureCoords.Add(new Vector3D(1f / 256, 255f / 256, 1f / 256));

            face.Points.Reverse();
            face.TextureCoords.Reverse();

            face.Plane               = Plane3D.FromNormalAndPoint(-axis, axis);
            face.Texture             = textures.RequestTexture(textureFileName);
            face.Texture.Clamp       = true;
            face.Texture.InternalUse = true;
            //if( face.Texture.IsLoaded == false ) {
            //	face.Texture.Load();
            //	Debug.Assert( face.Texture.IsLoaded == true, "can not load texture: " + face.Texture.FileName );
            //}

            return(face);
        }
示例#2
0
        protected void  SyncFrustumPlanes()
        {
            if (_bFrustumPlanesDirty == false)
            {
                return;
            }

            Vector3D nearClipTranslation = _translation + _forwardAxis * _nearClipDistance;
            Vector3D farClipTranslation  = _translation + _forwardAxis * _nearClipDistance;

            _topPlane = Plane3D.FromNormalAndPoint(_forwardAxis, _translation + nearClipTranslation);
            _farPlane = Plane3D.FromNormalAndPoint(_forwardAxis, _translation + farClipTranslation);

            Vector3D viewportUpTranslation    = _upAxis * _viewportHeight / 2;
            Vector3D viewportRightTranslation = _rightAxis * _viewportWidth / 2;

            Vector3D topNormal = Vector3D.Cross(_rightAxis, nearClipTranslation + viewportUpTranslation).GetUnit();

            _topPlane = Plane3D.FromNormalAndPoint(topNormal, _translation + farClipTranslation);

            Vector3D bottomNormal = Vector3D.Cross(-_rightAxis, nearClipTranslation - viewportUpTranslation).GetUnit();

            _bottomPlane = Plane3D.FromNormalAndPoint(bottomNormal, _translation + farClipTranslation);

            Vector3D rightNormal = Vector3D.Cross(-_upAxis, nearClipTranslation + viewportRightTranslation).GetUnit();

            _rightPlane = Plane3D.FromNormalAndPoint(rightNormal, _translation + farClipTranslation);

            Vector3D leftNormal = Vector3D.Cross(_upAxis, nearClipTranslation - viewportRightTranslation).GetUnit();

            _leftPlane = Plane3D.FromNormalAndPoint(leftNormal, _translation + farClipTranslation);

            _bFrustumPlanesDirty = false;
        }