Esempio n. 1
0
        /// <summary>
        /// Creates a mesh shape for serialising <paramref name="shapeComponent"/> and its associated mesh data.
        /// </summary>
        /// <param name="shapeComponent">The component to create a shape for.</param>
        /// <returns>A shape instance suitable for configuring to generate serialisation messages.</returns>
        protected override Shapes.Shape CreateSerialisationShape(ShapeComponent shapeComponent)
        {
            MeshDataComponent meshData = shapeComponent.GetComponent <MeshDataComponent>();

            if (meshData != null)
            {
                ObjectAttributes attr = new ObjectAttributes();
                EncodeAttributes(ref attr, shapeComponent.gameObject, shapeComponent);

                Shapes.MeshShape mesh = new Shapes.MeshShape(meshData.DrawType,
                                                             Maths.Vector3Ext.FromUnity(meshData.Vertices),
                                                             meshData.Indices,
                                                             shapeComponent.ObjectID,
                                                             shapeComponent.Category,
                                                             Maths.Vector3.Zero,
                                                             Maths.Quaternion.Identity,
                                                             Maths.Vector3.One);
                mesh.SetAttributes(attr);
                mesh.CalculateNormals = meshData.CalculateNormals;
                if (!meshData.CalculateNormals && meshData.Normals != null && meshData.Normals.Length > 0)
                {
                    mesh.Normals = Maths.Vector3Ext.FromUnity(meshData.Normals);
                }

                return(mesh);
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a text shape for serialisation.
        /// </summary>
        /// <param name="shapeComponent">The component to create a shape for.</param>
        /// <returns>A shape instance suitable for configuring to generate serialisation messages.</returns>
        protected override Shapes.Shape CreateSerialisationShape(ShapeComponent shapeComponent)
        {
            TextMesh text = shapeComponent.GetComponent <TextMesh>();

            if (text != null)
            {
                Shapes.Shape shape = new Shapes.Text3D(text.text);
                ConfigureShape(shape, shapeComponent);
                return(shape);
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a point cloud shape for serialising <paramref name="shapeComponent"/> and its point data.
        /// </summary>
        /// <param name="shapeComponent">The component to create a shape for.</param>
        /// <returns>A shape instance suitable for configuring to generate serialisation messages.</returns>
        protected override Shapes.Shape CreateSerialisationShape(ShapeComponent shapeComponent)
        {
            PointsComponent pointsComp = shapeComponent.GetComponent <PointsComponent>();

            if (pointsComp != null)
            {
                ObjectAttributes attr = new ObjectAttributes();
                EncodeAttributes(ref attr, shapeComponent.gameObject, shapeComponent);

                Shapes.PointCloudShape points = new Shapes.PointCloudShape(new MeshResourcePlaceholder(pointsComp.MeshID),
                                                                           shapeComponent.ObjectID,
                                                                           shapeComponent.Category,
                                                                           (byte)pointsComp.PointSize);
                points.SetAttributes(attr);

                return(points);
            }
            return(null);
        }