Beispiel #1
0
        /// <summary>
        /// if sub-class really wants to, can override this and determines how to draw
        /// </summary>
        /// <param name="graphicsDevice"></param>
        virtual public void Draw(GraphicsDevice graphicsDevice, ContentManager cm, Camera camera, MatrixStack stack)
        {
            BasicEffect effect = LoadEffect(graphicsDevice);

            stack.Push();
            {
                Xform.ComputeWorldTransform(stack);

                effect.View       = camera.ViewMatrix();
                effect.Projection = camera.ProjectionMatrix();
                effect.World      = stack.GetTopOfStack();
                effect.CurrentTechnique.Passes[0].Apply();

                SetCurrentColor();
                DrawPrimitive(graphicsDevice, cm);
            }
            stack.Pop();

            if (mDrawPivot)
            {
                if (null == mPivot)
                {
                    mPivot = new AxisShape();
                }

                mPivot.DrawPivot         = false; // to ensure no infinite recursion!
                mPivot.Xform.Translation = Xform.Translation + Xform.Pivot;
                mPivot.Xform.Rotation    = Xform.Rotation;
                mPivot.Draw(graphicsDevice, cm, camera, stack);
            }
        }
Beispiel #2
0
        public SceneNode(String name = "scene node")
        {
            mName     = name;
            mXform    = new XformInfo();
            mShapes   = new List <Shape>();
            mChildren = new List <SceneNode>();

            mShowPivot              = false;
            mPivotShape             = new AxisShape();
            mPivotShape.Xform.Scale = new Vector3(5f);
        }
Beispiel #3
0
        public Shape()
        {
            mCenter = Vector3.Zero;
            mColor  = Color.Red;

            mXform     = new XformInfo();
            mPivot     = null; // only allocate if wants to draw, instantiate now creates a infinite construction
            mDrawPivot = false;

            AllocateVertices();
            ComputeVertexPosition();

            mEffectOnDevice = new Dictionary <GraphicsDevice, BasicEffect>();
        }