public static void DrawSphere(Matrix World, Camera3D camera, Vector4 Color)
 {
     ColorEffectHolder.SetFromCamera(camera);
     ColorEffectHolder.SetWorld(World);
     ColorEffectHolder.MyEffect.Parameters["ObjectColor"].SetValue(Color);
     ColorEffectHolder.Apply();
     Game1.graphics.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>(
         PrimitiveType.LineList, SphereVerteces, 0, sphereLineCount * 2, SphereIndicies, 0, sphereLineCount);
 }
Beispiel #2
0
        public void Draw3D(Camera3D camera)
        {
            Camera3DObject c = (Camera3DObject)ParentScene.MyCamera.get();

            if (c != null)
            {
                Vector3 Result  = Vector3.Zero;
                bool    Success = false;
                Basic3DObject.GetAveragePosition(ParentScene.SelectedGameObjects, ref Result, ref Success);

                WorldMatrix = c.ScaleMatrix * Matrix.CreateTranslation(Result);
                ColorEffectHolder.SetWorld(WorldMatrix);
                ColorEffectHolder.SetFromCamera(camera);

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


                    Game1.graphics.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>(
                        PrimitiveType.LineList,
                        PointList,
                        0,             // vertex buffer offset to add to each element of the index buffer
                        PointCount,    // number of vertices in pointList
                        Indicies,      // the index buffer
                        0,             // first index element to read
                        PointCount / 2 // number of primitives to draw
                        );
                }


                ColorSetEffectHolder.Collection["Color"].SetValue(Color.LightGray.ToVector4());
                ColorSetEffectHolder.SetFromCamera(camera);
                ColorSetEffectHolder.SetWorld(WorldMatrix);
                Render.DrawModel(CubeModel, ColorSetEffectHolder.MyEffect);
                Vector3 ScreenPos = WorldViewer.self.MyViewport.Project(Vector3.Zero, camera.ProjectionMatrix, camera.ViewMatrix, WorldMatrix);
                ScreenPositions[3] = new Vector2(ScreenPos.X, ScreenPos.Y);


                Model EndModel = controlMode == ControlMode.Move ? ArrowModel :
                                 controlMode == ControlMode.Rotate ? BallModel : CubeModel;
                for (int i = 0; i < 3; i++)
                {
                    ColorSetEffectHolder.Collection["Color"].SetValue(PointColors[i].ToVector4());
                    ColorSetEffectHolder.SetWorld(ModelMatricies[i] * WorldMatrix);
                    Render.DrawModel(EndModel, ColorSetEffectHolder.MyEffect);
                    ScreenPos          = WorldViewer.self.MyViewport.Project(Vector3.Zero, camera.ProjectionMatrix, camera.ViewMatrix, ModelMatricies[i] * WorldMatrix);
                    ScreenPositions[i] = new Vector2(ScreenPos.X, ScreenPos.Y);
                }
            }
        }
 public static void DrawSphere(Matrix World, Camera3D camera, RenderTargetCube Cube)
 {
     CubeEffectHolder.SetFromCamera(camera);
     CubeEffectHolder.SetWorld(World);
     CubeEffectHolder.MyEffect.Parameters["ShadowReference"].SetValue(Cube);
     Render.DrawModel(CubeModel, CubeEffectHolder.MyEffect);
 }