Beispiel #1
0
        public void Draw(GraphicsDevice graphics, ArcBallCamera camera)
        {
            if(effect == null)
            {
                effect = new BasicEffect(graphics);
                effect.VertexColorEnabled = true;
            }

            effect.Projection = camera.Projection;
            effect.View = camera.View;

            effect.CurrentTechnique.Passes[0].Apply();
            for(int i = 0; i < 3; i++)
                graphics.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices[i], 0, 1);
        }
        public void Draw(ArcBallCamera camera)
        {
            if (!initialized || !Enabled) return;

            effect.Projection = camera.Projection;
            effect.View = camera.View;

            effect.CurrentTechnique.Passes[0].Apply();
            device.DrawUserIndexedPrimitives(
                PrimitiveType.LineList,
                verts,
                0,
                8,
                indices,
                0,
                indices.Length / 2);
        }
Beispiel #3
0
        public void Draw(ArcBallCamera camera)
        {
            Vector3 scale;
            Vector3 translation;
            Quaternion rotation;
            camera.View.Decompose(out scale, out rotation, out translation);
            Matrix mRotation = Matrix.CreateFromQuaternion(rotation);

            Matrix mInv =  Matrix.Invert(camera.Projection)*
                Matrix.Invert(Matrix.CreateTranslation(translation));

            effect.Projection = projection;
            effect.View = camera.View * Matrix.Invert(Matrix.CreateTranslation(translation)) * offset;

            effect.CurrentTechnique.Passes[0].Apply();
            for (int i = 0; i < 3; i++)
                device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices[i], 0, 1);
        }
        protected override void Initialize()
        {
            input = new Input();
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ContentManager Content = new ContentManager(Services, "Content");

            ViewModeLabel.Instance.Initialize(Content);
            Message.Instance.Initialize(Content);
            ReferenceAxis.Instance.Initialize(GraphicsDevice);

            camera = new ArcBallCamera();
            camera.FieldOfView = MathHelper.Pi / 3;
            ResetView();

            worldAxes = new WorldAxes();
            worldAxes.Size = 20;

            gridXY = new Grid(this);

            rsWireframe = new RasterizerState();
            rsWireframe.FillMode = FillMode.WireFrame;
            rsWireframe.CullMode = CullMode.None;
            rsSolid = new RasterizerState();
            rsSolid.FillMode = FillMode.Solid;
        }
        public void Render(ArcBallCamera camera)
        {
            if (vertBuffer == null || !Enabled)
                return;

            graphicsDevice.SetVertexBuffer(vertBuffer);

            effect.World = Matrix.CreateScale(sphere.Radius) *
                            Matrix.CreateTranslation(sphere.Center);

            effect.View = camera.View;
            effect.Projection = camera.Projection;
            effect.DiffuseColor = Color.Red.ToVector3();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                //render each circle individually
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, sphereResolution);
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, sphereResolution + 1, sphereResolution);
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, (sphereResolution + 1) * 2, sphereResolution);

            }
        }