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); }
/// <summary> /// Renders the outline of an oriented bounding box /// </summary> /// <param name="box">Oriented bounding box to render</param> /// <param name="color">Color of the box lines</param> public void DrawWireBox(NxOBB box, Color color) { DrawWireShape(box.GetCorners(), cubeIndices, color); }
public NxOBB UpdateOBB() { Quaternion a = Quaternion.CreateFromAxisAngle(Vector3.Up, MathHelper.ToRadians(mAngle.pan)); a *= Quaternion.CreateFromAxisAngle(Vector3.Right, MathHelper.ToRadians(mAngle.tilt)); a *= Quaternion.CreateFromAxisAngle(Vector3.Forward, MathHelper.ToRadians(mAngle.roll)); return mOBB = new NxOBB(mPos, mBoundingBox.Max, a); }