Convert Figma logo to code with AI

keijiro logoPcx

Point cloud importer & renderer for Unity

1,337
194
1,337
22

Quick Overview

Pcx is a Unity package that provides point cloud rendering functionality. It allows users to import and visualize point cloud data in Unity projects, offering a simple and efficient way to work with large sets of 3D points.

Pros

  • Easy integration with Unity projects
  • Supports large point cloud datasets
  • Efficient rendering using GPU instancing
  • Compatible with both runtime and editor workflows

Cons

  • Limited to Unity engine, not usable in other game engines or standalone applications
  • Requires Unity 2018.3 or later
  • May have performance limitations with extremely large point clouds
  • Documentation could be more comprehensive

Code Examples

  1. Loading a point cloud file:
using Pcx;

public class PointCloudLoader : MonoBehaviour
{
    public string filePath = "Assets/PointClouds/example.ply";

    void Start()
    {
        var pointCloud = Pcx.PointCloudData.Load(filePath);
        var renderer = gameObject.AddComponent<Pcx.PointCloudRenderer>();
        renderer.sourceData = pointCloud;
    }
}
  1. Customizing point appearance:
using Pcx;
using UnityEngine;

public class PointCloudCustomizer : MonoBehaviour
{
    public PointCloudRenderer renderer;
    public float pointSize = 0.01f;
    public Color pointColor = Color.white;

    void Start()
    {
        renderer.pointSize = pointSize;
        renderer.pointColor = pointColor;
    }
}
  1. Runtime point cloud generation:
using Pcx;
using UnityEngine;

public class RuntimePointCloudGenerator : MonoBehaviour
{
    public int pointCount = 1000;

    void Start()
    {
        var points = new Vector3[pointCount];
        var colors = new Color32[pointCount];

        for (int i = 0; i < pointCount; i++)
        {
            points[i] = Random.insideUnitSphere;
            colors[i] = Random.ColorHSV();
        }

        var pointCloud = Pcx.PointCloudData.Create(points, colors);
        var renderer = gameObject.AddComponent<Pcx.PointCloudRenderer>();
        renderer.sourceData = pointCloud;
    }
}

Getting Started

  1. Install Unity 2018.3 or later.
  2. Clone the Pcx repository or download it as a ZIP file.
  3. Copy the Assets/Pcx folder into your Unity project's Assets folder.
  4. In your Unity project, create a new GameObject and add the PointCloudRenderer component to it.
  5. Assign a point cloud data file (e.g., .ply) to the Source Data field of the PointCloudRenderer component.
  6. Adjust the Point Size and Point Color properties as needed.
  7. Press Play to see the point cloud rendered in your scene.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Pcx - Point Cloud Importer/Renderer for Unity

GIF GIF

Pcx is a custom importer and renderer that allows for handling point cloud data in Unity.

System Requirements

  • Unity 2019.4

Supported Formats

Currently Pcx only supports PLY binary little-endian format.

How To Install

The Pcx package uses the scoped registry feature to import dependent packages. Please add the following sections to the package manifest file (Packages/manifest.json).

To the scopedRegistries section:

{
  "name": "Keijiro",
  "url": "https://registry.npmjs.com",
  "scopes": [ "jp.keijiro" ]
}

To the dependencies section:

"jp.keijiro.pcx": "1.0.1"

After changes, the manifest file should look like below:

{
  "scopedRegistries": [
    {
      "name": "Keijiro",
      "url": "https://registry.npmjs.com",
      "scopes": [ "jp.keijiro" ]
    }
  ],
  "dependencies": {
    "jp.keijiro.pcx": "1.0.1",
    ...

Container Types

Inspector

There are three types of container for point clouds.

Mesh

Points are to be contained in a Mesh object. They can be rendered with the standard MeshRenderer component. It's recommended to use the custom shaders included in Pcx (Point Cloud/Point and Point Cloud/Disk).

ComputeBuffer

Points are to be contained in a PointCloudData object, which uses ComputeBuffer to store point data. It can be rendered with using the PointCloudRenderer component.

Texture

Points are baked into Texture2D objects that can be used as attribute maps in Visual Effect Graph.

Rendering Methods

There are two types of rendering methods in Pcx.

Point (point primitives)

Points are rendered as point primitives when using the Point Cloud/Point shader.

Points Points

The size of points can be adjusted by changing the material properties.

Inspector

These size properties are only supported on some platforms; It may work with OpenGLCore and Metal, but never work with D3D11/12.

This method is also used when the point size is set to zero in PointCloudRenderer.

Disk (geometry shader)

Points are rendered as small disks when using the Point Cloud/Disk shader or PointCloudRenderer.

Disks

This method requires geometry shader support.

Acknowledgements

The point cloud files used in the examples of Pcx are created by authors listed below. These files are licensed under the Creative Commons Attribution license (CC BY 4.0). Please see the following original pages for further details.