コード例 #1
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(ShapeCache cache, int shapeIndex, CreateMessage shapeData)
        {
            PointsComponent pointsComp = cache.GetShapeDataByIndex <PointsComponent>(shapeIndex);

            Shapes.PointCloudShape points = new Shapes.PointCloudShape(new MeshResourcePlaceholder(pointsComp.MeshID),
                                                                       shapeData.ObjectID,
                                                                       shapeData.Category,
                                                                       pointsComp.PointScale);
            points.SetAttributes(shapeData.Attributes);
            if (pointsComp.IndexCount > 0)
            {
                points.SetIndices(pointsComp.Indices);
            }
            return(points);
        }
コード例 #2
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);
        }