public override void DrawViewportWires(IGH_PreviewArgs args)
        {
            if (autoColor)
            {
                gradientList = new System.Drawing.Color[_plan.getCells().Count];

                for (int i = 0; i < gradientList.Length; i++)
                {
                    var multiplier = sunAccess[i];

                    var gColor = new ColorHSL(multiplier, multiplier, 0, multiplier);
                    var rgb    = gColor.ToArgbColor();
                    gradientList[i] = (rgb);
                }
                for (int i = 0; i < rectangles.Count; i++)
                {
                    Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial(gradientList[i]);
                    mat.Shine = 0.25;
                    {
                        var curve = rectangles[i].ToNurbsCurve();
                        var pts   = rectangles[i].ToPolyline();
                        args.Display.DrawPolyline(pts, gradientList[i], 1);
                        var mesh = Mesh.CreateFromPlanarBoundary(curve, Rhino.Geometry.MeshingParameters.FastRenderMesh, 0.01);
                        args.Display.DrawMeshShaded(mesh, mat);
                    }
                }
            }
        }
 protected override void PostDrawObjects(Rhino.Display.DrawEventArgs e)
 {
   if (null != Mesh)
   {
     Rhino.Display.DisplayMaterial material = new Rhino.Display.DisplayMaterial();
     material.Diffuse = System.Drawing.Color.Blue;
     e.Display.DrawMeshShaded(Mesh, material);
   }
 }
Exemple #3
0
 protected override void PostDrawObjects(Rhino.Display.DrawEventArgs e)
 {
     if (null != Mesh)
     {
         Rhino.Display.DisplayMaterial material = new Rhino.Display.DisplayMaterial();
         material.Diffuse = System.Drawing.Color.Blue;
         e.Display.DrawMeshShaded(Mesh, material);
     }
 }
 public DrawBlueMeshConduit(Mesh mesh)
 {
     // set up as much data as possible so we do the minimum amount of work possible inside
     // the actual display code
     m_mesh = mesh;
     m_color = System.Drawing.Color.Blue;
     m_material = new DisplayMaterial();
     m_material.Diffuse = m_color;
     if (m_mesh != null && m_mesh.IsValid)
       m_bbox = m_mesh.GetBoundingBox(true);
 }
        public override void DrawViewportWires(IGH_PreviewArgs args)
        {
            if (showSOM)
            {
                if (display == 0)
                {
                    for (int i = 0; i < circles.Count; i++)
                    {
                        Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial(SOM.discreteCol[i]);
                        mat.Shine = 0.25;
                        //if(srMode == 0)
                        {
                            var curve = circles[i].ToNurbsCurve();
                            args.Display.DrawPolyline(circles[i], Color.Black, (int)(SOM.nodeWeights[i] * 3.0));

                            var mesh = Mesh.CreateFromPlanarBoundary(curve, Rhino.Geometry.MeshingParameters.FastRenderMesh, 0.01);
                            args.Display.DrawMeshShaded(mesh, mat);
                        }
                    }
                }

                else
                {
                    for (int i = 0; i < circles.Count; i++)
                    {
                        Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial(gradientList[i]);
                        mat.Shine = 0.25;
                        //if(srMode == 0)
                        {
                            var curve = circles[i].ToNurbsCurve();
                            args.Display.DrawPolyline(circles[i], Color.Black, (int)(SOM.nodeWeights[i] * 3.0));

                            var mesh = Mesh.CreateFromPlanarBoundary(curve, Rhino.Geometry.MeshingParameters.FastRenderMesh, 0.01);
                            args.Display.DrawMeshShaded(mesh, mat);
                        }
                    }
                }


                if (displayText)
                {
                    //program names
                    for (int i = 0; i < SOM.nodePoints.Count; i++)
                    {
                        var pos = SOM.nodePoints[i];
                        args.Display.Draw2dText(SOM.m_pNames[i], Color.Black, pos, true, (int)15.0);
                    }
                }
            }
        }
Exemple #6
0
        //Constructor
        internal Pong()
        {


            CreateBlades();
            CreatePlayGround();
            CreateBall();
            CreateAABB();


            _material = new DisplayMaterial();
            _player = new SoundPlayer();
            _bw = new BackgroundWorker { WorkerSupportsCancellation = true };
            _bw.DoWork += GameLoop;
            _bw.RunWorkerCompleted += GameFinish;
        }
Exemple #7
0
        /// <summary>
        /// Duplicate another material.
        /// </summary>
        public DisplayMaterial(DisplayMaterial other)
        {
            IntPtr ptr = other.ConstPointer();

            m_ptr = UnsafeNativeMethods.CDisplayPipelineMaterial_New(ptr);
        }
 /// <summary>
 /// Draws a shaded mesh representation of a brep.
 /// </summary>
 /// <param name="brep">Brep to draw.</param>
 /// <param name="material">Material to draw faces with.</param>
 public void DrawBrepShaded(Brep brep, DisplayMaterial material)
 {
   IntPtr pBrep = brep.ConstPointer();
   IntPtr pMaterial = IntPtr.Zero;
   if (null != material)
     pMaterial = material.ConstPointer();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawShadedBrep(m_ptr, pBrep, pMaterial);
 }
 /// <summary>
 /// Draws the shaded faces of a given mesh.
 /// </summary>
 /// <param name="mesh">Mesh to draw.</param>
 /// <param name="material">Material to draw faces with.</param>
 /// <param name="faceIndices">Indices of specific faces to draw</param>
 public void DrawMeshShaded(Mesh mesh, DisplayMaterial material, int[] faceIndices)
 {
   IntPtr pMesh = mesh.ConstPointer();
   IntPtr pMaterial = IntPtr.Zero;
   if (null != material)
     pMaterial = material.ConstPointer();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawShadedMesh2(m_ptr, pMesh, pMaterial, faceIndices.Length, faceIndices);
 }
 /// <summary>
 /// Duplicate another material.
 /// </summary>
 public DisplayMaterial(DisplayMaterial other)
 {
   IntPtr ptr = other.ConstPointer();
   m_ptr = UnsafeNativeMethods.CDisplayPipelineMaterial_New(ptr);
 }
Exemple #11
0
 public void AddGeoemtry(byte[] resource, DisplayMaterial material)
 {
     var mesh = MeshInfo.LoadMesh(resource);
     DisplayGeometry.Add(new Tuple<Mesh, DisplayMaterial>(mesh, material));
     Box.Union(mesh.GetBoundingBox(false));
 }
Exemple #12
0
 public GameObject(byte[] bytes, DisplayMaterial material)
 {
     AddGeoemtry(bytes, material);
 }
Exemple #13
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region INPUTS
            // INPUTS

            // import Silkworm Movement
            List<GH_ObjectWrapper> s_Movement = new List<GH_ObjectWrapper>();

            if (!DA.GetDataList(0, s_Movement)) { return; }

            int res = new int();
            //if (!DA.GetData(4, ref res)) { }

            double startPrev = 0.0;
            if (!DA.GetData(1, ref startPrev)) { }
            double endPrev = 1.0;
            if (!DA.GetData(2, ref endPrev)) { }

            bool showlogistics = false;
            if (!DA.GetData(3, ref showlogistics)) { }

            bool showvalues = false;
            if (!DA.GetData(4, ref showvalues)) { }

            bool showmesh = false;
            if (!DA.GetData(5, ref showmesh)) { }

            bool showprinter = false;
            if (!DA.GetData(6, ref showprinter)) { }
            #endregion

            //Initialise these properties as soon as solveinstance begins
            if (DA.Iteration == 0)
            {
                //Visualise Print Logistics
                displayLogistics = new bool();
                startPoints = new List<Line>();
                endPoints = new List<Line>();
                DelimitMarkers = new List<Line>();

                //Visualise Print Values
                displayValues = new bool();
                lineThicknesses = new List<double>();
                Colors = new List<Color>();
                Movements = new List<Line>();
                blobPts = new List<Point3d>();
                blobDiameter = new List<double>();

                //Visualise Print Realistic
                displayMesh = new bool();
                //m_meshes = new List<Mesh>();

                //Visualise Printer
                displayPrinter = new bool();
                bboxAll = new BoundingBox();
                extclearance = new Mesh();
                xcarriage = new List<Mesh>();
                vizmaterial = new DisplayMaterial(Color.Yellow, 0.5);
                printArea = new List<Point3d>();

            }

            //Output Holders

            Mesh sMesh = new Mesh();

            displayLogistics = showlogistics;
            displayValues = showvalues;
            displayMesh = showmesh;
            displayPrinter = showprinter;

            List<Point3d>  startPts = new List<Point3d>();
            List<Point3d> endPts = new List<Point3d>();

            //Sort through input geometry, check that it is a Silkworm Model
            foreach (GH_ObjectWrapper movement in s_Movement)
            {
                if (movement.Value is SilkwormModel)
                {
                    SilkwormModel sModel = (SilkwormModel)movement.Value;
                    printArea.Add(new Point3d(0,0,0));
                    printArea.Add(new Point3d(0, sModel.bed_size.Y, 0));
                    printArea.Add(new Point3d(sModel.bed_size.X, sModel.bed_size.Y, 0));
                    printArea.Add(new Point3d(sModel.bed_size.X, 0, 0));

                    bboxAll = new BoundingBox(new Point3d(0, 0, 0), new Point3d(sModel.bed_size.X, sModel.bed_size.Y, sModel.bed_size.Z));
                    sModel.displayModel(startPrev, endPrev, showmesh, res,
                        out Movements,
                        out lineThicknesses,
                        out DelimitMarkers,
                        out blobPts,
                        out blobDiameter,
                        out Colors,
                        out sMesh,
                        out startPts,
                        out endPts);

                    //Create Clearance Visualisation Geometry
                    Point3d endPt = Movements[Movements.Count - 1].To;

                    Plane plane = new Plane(endPt,Plane.WorldXY.ZAxis);
                    Cone extcl = new Cone(plane, sModel.extruder_clearance_height, sModel.extruder_clearance_radius);
                    extclearance = Mesh.CreateFromCone(extcl, 12, 30);

                    double roddiameter = 8;
                    Point3d PtA1 = new Point3d(0, endPt.Y + ((sModel.xbar_width / 2) - (roddiameter / 2)), endPt.Z + (roddiameter / 2) + sModel.extruder_clearance_height);
                    Point3d PtA2 = new Point3d(0, endPt.Y - ((sModel.xbar_width / 2) - (roddiameter / 2)), endPt.Z + (roddiameter / 2)+sModel.extruder_clearance_height);

                    Cylinder clyA = new Cylinder(new Circle(new Plane(PtA1, Plane.WorldYZ.ZAxis), roddiameter/2), sModel.bed_size.X);
                    Cylinder clyB = new Cylinder(new Circle(new Plane(PtA2, Plane.WorldYZ.ZAxis), roddiameter/2), sModel.bed_size.X);

                    Mesh cylA = Mesh.CreateFromCylinder(clyA,12,30);
                    Mesh cylB = Mesh.CreateFromCylinder(clyB, 12,30);
                    xcarriage.AddRange(new Mesh[] {cylA,cylB});

                    foreach (Point3d point in startPts)
                    {
                        startPoints.Add(new Line(point, Plane.WorldXY.ZAxis, 0.01));
                    }
                    foreach (Point3d point in endPts)
                    {
                        endPoints.Add(new Line(point, Plane.WorldXY.ZAxis, 0.01));
                    }

               }

                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please Input Only Silkworm Models");
                    continue;
                }

            }

            //GH_Mesh outPipes = new GH_Mesh(sMesh);

            //DA.SetData(0, outPipes);
        }
Exemple #14
0
 private void RunScript(Brep x, bool y, int v, int u, ref object A)
 {
     Mesh[] meshes = Mesh.CreateFromBrep(x, MeshingParameters.Smooth);
     Mesh M = new Mesh();
     foreach (Mesh partialMesh in meshes)
     {
         M.Append(partialMesh);
     }
     m_shapes.Add(M);
     InitializeStreamBitmap(u, v);
     Print(str);
     Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial();
     mat.SetTransparencyTexture(str, true);
     mat.BackTransparency = 0;
     m_materials.Clear();
     m_materials.Add(mat);
 }
    private void RunScript(Brep x, Curve y, int V, int U, ref object A)
    {
        Graphics g = Graphics.FromImage(bitmap1);
        g.FillRectangle(new SolidBrush(Color.White), 0, 0, u, v);
        System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(Color.Black);

        float step1 = u / U;
        float step2 = v / V;
        for (float i = 25; i < u - 25; i += step1)
        {
            for (float j = 25; j < v - 25; j += step2)
            {
                double Umin = x.Faces[0].Domain(0).Min;
                double Umax = x.Faces[0].Domain(0).Max;
                double Vmin = x.Faces[0].Domain(1).Min;
                double Vmax = x.Faces[0].Domain(1).Max;
                Point3d pos = x.Faces[0].PointAt(i / u * (Umax - Umin) + Umin, j / v * (Vmax - Vmin) + Vmin);
                double t; float R;
                if (y.ClosestPoint(pos, out t, 200))
                {
                    double dis = y.PointAt(t).DistanceTo(pos);
                    dis /= 200;
                    R = (float)(1 / dis * 2);
                    //  Print(R.ToString());
                    if (R > 40) R = 40;
                    ;
                }
                else { R = 20; }
                g.FillEllipse(myBrush, i - R, v - j - R, R * 2, R * 2);
            }
        }

        myBrush.Dispose();
        str = @"C:\maps\temp1.jpg";
        bitmap1.Save(str);
        Print(str);
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        Mesh[] meshes = Mesh.CreateFromBrep(x, MeshingParameters.Smooth);
        Mesh M = new Mesh();
        foreach (Mesh partialMesh in meshes)
        {
            M.Append(partialMesh);
        }
        m_shapes.Add(M);

        Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial();
        mat.SetTransparencyTexture(str, true);
        mat.BackTransparency = 0;
        m_materials.Clear();
        m_materials.Add(mat);
    }
    /// <summary>
    /// This procedure contains the user code. Input parameters are provided as regular arguments,
    /// Output parameters as ref arguments. You don't have to assign output parameters,
    /// they will have a default value.
    /// </summary>
    private void RunScript(Brep x, int y, int U, int u, int z, List<double> Colors, int stX, int stY, ref object A)
    {
        //  if(sign){sign = false;
        double Umin = x.Faces[0].Domain(0).Min;
        double Umax = x.Faces[0].Domain(0).Max;
        double Vmin = x.Faces[0].Domain(1).Min;
        double Vmax = x.Faces[0].Domain(1).Max;
        double t = (Vmax - Vmin) / (Umax - Umin) * u;
        v = (int)t;
        t = (Vmax - Vmin) / (Umax - Umin) * U;
        V = (int)t;
        bitmap1 = new Bitmap(u, v);
        m_shapes = new List<Mesh>();
        m_materials = new List<Rhino.Display.DisplayMaterial>();
        mappixel = new pixel[U, V];
        for (int i = 0; i < U; i++)
        {
            for (int j = 0; j < V; j++)
            {
                double posX = (double)i / (double)U * (double)u;
                double posY = (double)j / (double)V * (double)v;
                mappixel[i, j] = new pixel(posX, posY);
            }
        }
        // }

        Graphics g = Graphics.FromImage(bitmap1);
        g.FillRectangle(new SolidBrush(Color.Black), 0, 0, u, v);
        double iso = 0;
        Random Rnd = new Random();
        for (int j = 0; j < V; j++)
        {
            for (int i = 0; i < U; i++)
            {
                if (j <= y) { mappixel[i, j].color = Color.White; }
                else if (Rnd.NextDouble() > iso) { mappixel[i, j].color = Color.White; }
            }
            if (j > y) iso += 0.02;
        }
        //////////////////////////****************************************
        int count = 0;

        for (int j = stY + z; j > stY; j--)
        {
            for (int i = stX; i < stX + Colors.Count / z; i++)
            {

                if (count > Colors.Count - 1) break;
                if (Colors[count] != 1)
                {
                    mappixel[i, j].color = Color.Gray;
                }
                else
                {
                    //mappixel[i, j].color = Color.Green;
                }
                count++;
            }
        }
        ///////////////////////////////
        for (int i = 0; i < U; i++)
        {
            for (int j = 0; j < V; j++)
            {
                mappixel[i, j].Draw(ref g, (int)(u / 2 / U));
            }
        }
        g.Dispose();
        str = @"C:\maps\temp1.jpg";
        bitmap1.Save(str);
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        Mesh[] meshes = Mesh.CreateFromBrep(x, MeshingParameters.Smooth);
        Mesh M = new Mesh();
        foreach (Mesh partialMesh in meshes)
        {
            M.Append(partialMesh);
        }
        m_shapes.Add(M);
        Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial();
        //  mat.SetTransparencyTexture(str, true);
        // mat.BackTransparency = 0;
        mat.Diffuse = Color.White;
        mat.SetBitmapTexture(str, true);

        m_materials.Clear();
        m_materials.Add(mat);
    }