Exemplo n.º 1
0
        // Use this for initialization
        private void Start()
        {
            InstanceMeshDeltaBuffer <instancemesh.instance_delta> .InstanceMeshIndirectIDBuffer.test();

            InstanceHierarchyMap.test();

            imesher = new MeshInstancer();

            //initialize
            imesher.Initialize();
            imesher.FrustumCamera = frustum_culling ? GameObject.Find("Main Camera").GetComponent <Camera>() : null;

            parent = new InstanceData(imesher.Default); parent.props_color32 = Color.red;
            child1 = new InstanceData(imesher.Default); child1.props_color32 = Color.green;
            child2 = new InstanceData(imesher.Default); child2.props_color32 = Color.blue;

            imesher.Initialize(ref parent);
            imesher.Initialize(ref child1);
            imesher.Initialize(ref child2);

            parent.parentID = instancemesh.NULL_ID;
            child1.parentID = parent.id;
            child2.parentID = child1.id;

            child1.position = new Vector3(2, 2, 2);
            child2.position = new Vector3(2, 2, 2);

            imesher.Append(ref parent);
            imesher.Append(ref child1);
            imesher.Append(ref child2);

            imesher.Update(0);
        }
Exemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            Mesh     mesh     = BaseMeshLibrary.CreateDefault();
            Material material = new Material(Shader.Find("Instanced/instancemeshdefault_Transparent"));

            material.enableInstancing = true;

            imesher = new MeshInstancer();

            imesher.Initialize(64, 64, override_mesh: BaseMeshLibrary.CreatePlane2Sides(), override_material: BaseMaterialLibrary.CreateDefault(), max_parent_depth: 1, num_skeleton_bones: 1);
            var keys = Texture2MeshType.Textures2MeshType(this.Textures, mesh, material);

            foreach (var key in keys)
            {
                imesher.AddNewMeshType(key.mesh_key, key.material_key);
            }

            imesher.FrustumCamera = frustum_culling ? GameObject.Find("Main Camera").GetComponent <Camera>() : null;

            var udat = keys.Where(x => x.material_key.mainTexture.name == "clear3").First();

            InstanceData d1 = new InstanceData(imesher.GetMeshType(udat.mesh_key, udat.material_key));

            d1.props_color32 = new Color32(0, 0, 255, 90);
            d1.position      = new Vector3(0.5f, 0, 0);
            d1.rotation      = Quaternion.Euler(-90, 0, 0);
            d1.props_color32 = Color.blue;
            imesher.Initialize(ref d1);
            imesher.Append(ref d1);

            InstanceData d2 = new InstanceData(imesher.GetMeshType(udat.mesh_key, udat.material_key));

            d2.props_color32 = new Color32(0, 0, 255, 90);
            d2.position      = new Vector3(0, 0, 0);
            d2.rotation      = Quaternion.Euler(-90, 0, 0);
            d2.props_color32 = Color.blue;
            imesher.Initialize(ref d2);
            imesher.Append(ref d2);

            InstanceData d3 = new InstanceData(imesher.GetMeshType(udat.mesh_key, udat.material_key));

            d3.props_color32 = new Color32(0, 0, 255, 90);
            d3.position      = new Vector3(-0.5f, 0, 0);
            d3.rotation      = Quaternion.Euler(-90, 0, 0);
            d3.props_color32 = Color.blue;
            imesher.Initialize(ref d3);
            imesher.Append(ref d3);
        }
Exemplo n.º 3
0
        private void Update()
        {
            parent.position   = position;
            parent.scale      = scale;
            parent.DirtyFlags = parent.DirtyFlags | DirtyFlag.Scale | DirtyFlag.Position;
            imesher.Append(ref parent);

            imesher.Update(Time.deltaTime);
        }
Exemplo n.º 4
0
        void Update()
        {
            imesher.FrustumCamera = FrustumCullingCamera;

            // Update parent instance
            parent.position   = position;
            parent.scale      = scale;
            parent.rotation   = Quaternion.Euler(rotation);
            parent.DirtyFlags = DirtyFlag.Position | DirtyFlag.Rotation | DirtyFlag.Scale;
            imesher.Append(ref parent);

            // do gpu instance update
            imesher.Update(Time.deltaTime);
        }