Beispiel #1
0
        public NxEntity(Model m, NxCamera cam,
            ContentManager c, GraphicsDevice g,
            Texture2D Texture)
        {
            mTexture = Texture;
            InitMotionBlurRTs(g);

            DrawQuad = new Rectangle(0, 0, mRTColor.Width, mRTColor.Height);
            if (mBasicEffect == null)
                mBasicEffect = new BasicEffect(g);
            if (mMotionBlurEffect == null)
                mMotionBlurEffect = c.Load<Effect>("PixelMotionBlurNoMRT");
            InitMotionParams();
            mScale = Vector3.One;
            mCam = cam;
            mModel = m;
            mWorld = Matrix.CreateRotationX(MathHelper.ToRadians(mAngle.tilt))
                        * Matrix.CreateRotationY(MathHelper.ToRadians(mAngle.pan))
                        * Matrix.CreateRotationZ(MathHelper.ToRadians(mAngle.roll))
                        * Matrix.CreateTranslation(mPos);
            Matrix[] transforms = new Matrix[mModel.Bones.Count];
            mModel.CopyAbsoluteBoneTransformsTo(transforms);
            foreach (ModelMesh mesh in mModel.Meshes)
            {

                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = transforms[mesh.ParentBone.Index] * mWorld;
                    mWorldMat = effect.World;
                }

            }

            mBoundingBox = UpdateBoundingBox();
            mOBB = UpdateOBB();

            Viewport viewport = g.Viewport;

            Matrix projection = Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, 0, 1);
            Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
            mMotionBlurMatrixTransform.SetValue(halfPixelOffset * projection);
        }
Beispiel #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //MessageBox.Show(Environment.CurrentDirectory);
            mLoader = new NxContentLoader(this);//Content.Load<Model>("cent");
            mdl =   mLoader.LoadModel(Environment.CurrentDirectory + "\\obo.fbx");
            cam = new NxCamera(GraphicsDevice.Viewport, new Vector3(0, 0, -500), Vector3.Zero, NxCamera.CameraType.Targeted);

            nInput = new NxInput(GraphicsDevice.Viewport);
            myFont = Content.Load<SpriteFont>("SpriteFont1");
            nDebug = new NxDebugDraw(GraphicsDevice);
            ef = Content.Load<Effect>("PixelMotionBlurNoMRT");
            basiceff = Content.Load<Effect>("Effect1");
            tex = Content.Load<Texture2D>("10220");
            ba = new BasicEffect(GraphicsDevice);
            mEnt = new NxEntity(mdl, cam,Content,GraphicsDevice,tex);
            // TODO: use this.Content to load your game content here
        }