Example #1
0
    // public URRealTime URRealTime { get; set; }

    internal RobotSystemUR(string name, RobotUR robot, IO io, Plane basePlane, Mesh?environment)
        : base(name, Manufacturers.UR, io, basePlane, environment, GetDefaultPose(robot))
    {
        Remote = new RemoteUR();
        Robot  = robot;
        DisplayMesh.Append(robot.DisplayMesh);
        DisplayMesh.Transform(BasePlane.ToTransform());
    }
Example #2
0
        public void SetBlock(Point point, Tile tile, State?state = null)
        {
            blocks[point.X, point.Y, point.Z] = new Block(
                tile,
                state ?? tile.DetectState(this)
                );

            mesh = null;
        }
Example #3
0
        public MeshTree(Mesh mesh, Vector3 center)
        {
            this.mesh   = mesh;
            this.center = center;

            this.children = new List <MeshTree>();
            this.centers  = new HashSet <Vector3>();
            this.centers.Add(center);
            this.centroid = center;
        }
        public async Task QueryInfo_FromSimpleMesh()
        {
            await TestUtilities.InitializeWithGraphicsAsync();

            using (var memRenderTarget = new MemoryRenderTarget(1024, 1024))
            {
                memRenderTarget.ClearColor = Color4.CornflowerBlue;

                // Get and configure the camera
                var camera = (PerspectiveCamera3D)memRenderTarget.Camera;
                camera.Position = new Vector3(0f, 5f, -7f);
                camera.Target   = new Vector3(0f, 0f, 0f);
                camera.UpdateCamera();

                // Define scene
                Mesh?newMesh = null;
                await memRenderTarget.Scene.ManipulateSceneAsync(manipulator =>
                {
                    var resGeometry = manipulator.AddResource(
                        _ => new GeometryResource(new CubeGeometryFactory()));
                    var resMaterial = manipulator.AddStandardMaterialResource();

                    newMesh = manipulator.AddMeshObject(resGeometry, resMaterial);
                    newMesh.RotationEuler = new Vector3(0f, EngineMath.RAD_90DEG / 2f, 0f);
                    newMesh.Scaling       = new Vector3(2f, 2f, 2f);
                    newMesh.Color         = Color4.RedColor;
                    newMesh.TrySetInitialVisibility(memRenderTarget.RenderLoop.ViewInformation, true);
                });

                await memRenderTarget.AwaitRenderAsync();

                // Query some information from the mesh
                var renderingChunkCount = newMesh !.TryGetRenderingChunkCount(memRenderTarget.Device !);
                var geoResource         = newMesh.TryGetGeometryResource(memRenderTarget.Device !);
                var materialResources   = newMesh.TryGetMaterialResources(memRenderTarget.Device !);

                // Take screenshot
                var screenshot = await memRenderTarget.RenderLoop.GetScreenshotGdiAsync();

                // TestUtilities.DumpToDesktop(screenshot, "Blub.png");

                // Calculate and check difference
                var isNearEqual = BitmapComparison.IsNearEqual(
                    screenshot, TestUtilities.LoadBitmapFromResource("Drawing3D", "SimpleObject.png"));
                Assert.IsTrue(isNearEqual, "Difference to reference image is to big!");

                // Check info from mesh
                Assert.IsTrue(renderingChunkCount == 1, "Invalid count of rendering chunks");
                Assert.IsTrue(geoResource != null, "Can not query GeometryResource");
                Assert.IsTrue(materialResources is { Length: 1 }, "Can not query MaterialResource");
Example #5
0
    static bool IsValidMesh(Mesh?mesh)
    {
        if (mesh is null)
        {
            return(true);
        }

        var p = MeshCheckParameters.Defaults();

        using var textLog = new TextLog();
        var isValid = mesh.Check(textLog, ref p);

        bool isReallyValid =
            // p.DuplicateFaceCount == 0;
            // p.DegenerateFaceCount == 0
            p.ExtremelyShortEdgeCount == 0;

        return(isReallyValid);
    }
Example #6
0
        public void Consume()
        {
            if (verticesModified)
            {
                Mesh.SetVertices(vertices);
            }
            if (colorsModified)
            {
                Mesh.SetColors(colors);
            }
            if (verticesModified || colorsModified)
            {
                text.UpdateGeometry(Mesh, 0);
            }

            verticesModified = false;
            colorsModified   = false;
            mesh             = null;
        }
Example #7
0
        /// <inheritdoc />
        internal override void ReadFromStream(BinaryReader reader, Version version)
        {
            Position = new Vector(reader.ReadDouble(), reader.ReadDouble(), reader.ReadDouble());
            Size     = new Vector(reader.ReadDouble(), reader.ReadDouble(), reader.ReadDouble());

            ReadVoxels(reader);

            if (version < Formplot.Version3)
            {
                return;
            }

            var shape = Mesh.Read(reader);

            if (shape.Indices.Length > 0)
            {
                Shape = shape;
            }
        }
Example #8
0
    void Start()
    {
        state.objects[Guid.NewGuid()] = new Draggable()
        {
            position = new Vector3(0, 0, 0),
            size     = 1.5f,
        };
        state.objects[Guid.NewGuid()] = new Draggable()
        {
            position = new Vector3(3, 0, 0),
            size     = 2,
        };
        state.objects[Guid.NewGuid()] = new Draggable()
        {
            position = new Vector3(-3, 0, 0),
            size     = 1f,
        };

        cubeMesh = BuildCubeMesh();
    }
Example #9
0
        public override async Task OnStartupAsync(RenderLoop mainRenderLoop, SampleSettings settings)
        {
            mainRenderLoop.EnsureNotNull(nameof(mainRenderLoop));

            _castedSettings = (FocusSampleSettings)settings;

            await mainRenderLoop.Scene.ManipulateSceneAsync(manipulator =>
            {
                // Create floor
                this.BuildStandardFloor(
                    manipulator, Scene.DEFAULT_LAYER_NAME);

                var defaultLayer = manipulator.GetLayer(Scene.DEFAULT_LAYER_NAME);

                // Create the focus effect and attach it to a new 'Focus' layer
                var keyPostprocess = manipulator.AddResource(
                    _ => new FocusPostprocessEffectResource());
                var focusLayer = manipulator.AddLayer("Focus");
                focusLayer.PostprocessEffectKey = keyPostprocess;

                var resGeometry = manipulator.AddResource(
                    _ => new GeometryResource(new CubeGeometryFactory()));
                var resMaterial = manipulator.AddStandardMaterialResource();

                var frontMesh      = manipulator.AddMeshObject(resGeometry, defaultLayer.Name, resMaterial);
                frontMesh.Color    = Color4.BlueColor;
                frontMesh.Scaling  = new Vector3(1f, 0.5f, 0.5f);
                frontMesh.Position = new Vector3(1f, 2f, 1f);

                var backMesh           = manipulator.AddMeshObject(resGeometry, defaultLayer.Name, resMaterial);
                backMesh.RotationEuler = new Vector3(0f, EngineMath.RAD_90DEG / 3f, 0f);
                backMesh.Scaling       = new Vector3(2f, 2f, 2f);
                backMesh.Color         = Color4.RedColor;

                // This mesh will render the focus effect itself (it is placed on the focus layer)
                _focusMesh = manipulator.AddMeshObject(resGeometry, focusLayer.Name, resMaterial);
                _focusMesh.TransformSourceObject = backMesh;
                _focusMesh.TransformationType    = SpacialTransformationType.TakeFromOtherObject;
                _focusMesh.Color = Color4.RedColor;
            });
        }
Example #10
0
        internal Geometry(XmlNode node)
        {
            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "box":
                    Box = new Box(child);
                    break;

                case "cylinder":
                    Cylinder = new Cylinder(child);
                    break;

                case "sphere":
                    Sphere = new Sphere(child);
                    break;

                case "mesh":
                    Mesh = new Mesh(child);
                    break;
                }
            }
        }
Example #11
0
#pragma warning disable IDE0060
    internal Collision(Program program, IEnumerable <int> first, IEnumerable <int> second, Mesh?environment, int environmentPlane, double linearStep, double angularStep)
    {
        throw NotImplemented();
    }
Example #12
0
    internal RobotCell(string name, Manufacturers manufacturer, List <MechanicalGroup> mechanicalGroups, IO io, Plane basePlane, Mesh?environment)
        : base(name, manufacturer, io, basePlane, environment, GetDefaultPose(mechanicalGroups))
    {
        MechanicalGroups = mechanicalGroups;
        foreach (var group in mechanicalGroups)
        {
            var movesRobot   = group.Externals.Find(m => m.MovesRobot);
            var robotDisplay = group.Robot.DisplayMesh;

            if (movesRobot is not null)
            {
                var movableBase = movesRobot.Joints.Last().Plane;
                movableBase.Orient(ref movesRobot.BasePlane);
                robotDisplay.Transform(movableBase.ToTransform());
            }

            DisplayMesh.Append(robotDisplay);

            foreach (var external in group.Externals)
            {
                DisplayMesh.Append(external.DisplayMesh);
            }
        }

        DisplayMesh.Transform(BasePlane.ToTransform());
    }
Example #13
0
 internal RobotCellKuka(string name, List <MechanicalGroup> mechanicalGroup, IO io, Plane basePlane, Mesh?environment) : base(name, Manufacturers.KUKA, mechanicalGroup, io, basePlane, environment)
 {
 }
Example #14
0
 internal RobotCellAbb(string name, List <MechanicalGroup> mechanicalGroups, IO io, Plane basePlane, Mesh?environment) : base(name, Manufacturers.ABB, mechanicalGroups, io, basePlane, environment)
 {
     Remote = new RemoteAbb(this);
 }
Example #15
0
 public Mesh GetMesh(ShaderProgram shader) =>
 mesh ?? (mesh = new Mesh(BuildMesh(), shader));
Example #16
0
 public Collision CheckCollisions(IEnumerable <int>?first = null, IEnumerable <int>?second = null, Mesh?environment = null, int environmentPlane = 0, double linearStep = 100, double angularStep = PI / 4.0)
 {
     return(new Collision(this, first ?? new int[] { 7 }, second ?? new int[] { 4 }, environment, environmentPlane, linearStep, angularStep));
 }
Example #17
0
 public MeshFilterComponent(Mesh?mesh = null, Func <Mesh>?meshConstructor = null)
 {
     this.mesh            = mesh;
     this.meshConstructor = meshConstructor;
 }
Example #18
0
 internal RobotCellStaubli(string name, List <MechanicalGroup> mechanicalGroups, IO io, Plane basePlane, Mesh?environment) : base(name, Manufacturers.Staubli, mechanicalGroups, io, basePlane, environment)
 {
 }
Example #19
0
 public void MeshAtPointsUpdate()
 {
     this.meshAtPoints = this.curve.GetMeshAtPoints();
 }
Example #20
0
    public Tool(Plane tcp, string name = "DefaultTool", double weight = 0, Point3d?centroid = null, Mesh?mesh = null, IList <Plane>?calibrationPlanes = null, bool useController = false, int?number = null)
        : base(name)
    {
        Weight        = weight;
        Centroid      = (centroid is null) ? tcp.Origin : (Point3d)centroid;
        Mesh          = mesh ?? new Mesh();
        UseController = number is not null || useController;
        Number        = number;

        if (number is not null && number.Value < 1)
        {
            throw new ArgumentOutOfRangeException(nameof(number), " Tool number out of range.");
        }

        if (calibrationPlanes is null || !calibrationPlanes.Any())
        {
            Tcp = tcp;
        }
Example #21
0
 public void Deconstruct(out Box?box, out Cylinder?cylinder, out Sphere?sphere, out Mesh?mesh) =>
 (box, cylinder, sphere, mesh) = (Box, Cylinder, Sphere, Mesh);
Example #22
0
 public void UpdateMesh() => mesh = null;