Exemplo n.º 1
0
        public CylinderSO Create(SOMaterial defaultMaterial)
        {
            cylinder = new GameObject(UniqueNames.GetNext("Cylinder"));
            AssignSOMaterial(defaultMaterial);       // need to do this to setup BaseSO material stack

            Material useMaterial = CurrentMaterial;

            topCap = AppendMeshGO("topCap",
                                  MeshGenerators.CreateDisc(radius, 1, 16),
                                  useMaterial, cylinder);
            topCap.transform.localPosition += 0.5f * height * Vector3.up;

            bottomCap = AppendMeshGO("bottomCap",
                                     MeshGenerators.CreateDisc(radius, 1, 16),
                                     useMaterial, cylinder);
            bottomCap.transform.RotateAround(Vector3.zero, Vector3.right, 180.0f);
            bottomCap.transform.localPosition -= 0.5f * height * Vector3.up;

            body = AppendMeshGO("body",
                                MeshGenerators.CreateCylider(radius, height, 16),
                                useMaterial, cylinder);
            body.transform.localPosition -= 0.5f * height * Vector3.up;

            update_shift();
            cylinder.transform.position += centerShift;

            increment_timestamp();
            return(this);
        }
Exemplo n.º 2
0
        public void Create(Material defaultMaterial)
        {
            cylinder = new GameObject("f3Cylinder");

            topCap = AppendMeshGO("topCap",
                                  MeshGenerators.CreateDisc(radius, 2, 16),
                                  defaultMaterial, cylinder);
            topCap.transform.position += 0.5f * height * Vector3.up;

            bottomCap = AppendMeshGO("bottomCap",
                                     MeshGenerators.CreateDisc(radius, 2, 16),
                                     defaultMaterial, cylinder);
            bottomCap.transform.RotateAround(Vector3.zero, Vector3.right, 180.0f);
            bottomCap.transform.position -= 0.5f * height * Vector3.up;

            body = AppendMeshGO("body",
                                MeshGenerators.CreateCylider(radius, height, 16),
                                defaultMaterial, cylinder);
            body.transform.position -= 0.5f * height * Vector3.up;

            cylinder.transform.position += 0.5f * height * Vector3.up;
        }
Exemplo n.º 3
0
        override public void UpdateGeometry()
        {
            if (cylinder == null)
            {
                return;
            }

            topCap.GetComponent <MeshFilter>().sharedMesh = MeshGenerators.CreateDisc(radius, 1, 16);
            topCap.transform.localPosition = 0.5f * height * Vector3.up;

            bottomCap.GetComponent <MeshFilter>().sharedMesh = MeshGenerators.CreateDisc(radius, 1, 16);
            bottomCap.transform.localPosition = -0.5f * height * Vector3.up;

            body.SetMesh(MeshGenerators.CreateCylider(radius, height, 16));
            body.transform.localPosition = -0.5f * height * Vector3.up;

            // if we want to scale away/towards bottom of cylinder, then we need to
            //  translate along axis as well...
            Frame3f f      = GetLocalFrame(CoordSpace.ObjectCoords);
            float   fScale = cylinder.transform.localScale[1];

            f.Origin -= f.FromFrameV(fScale * centerShift);
            update_shift();
            f.Origin += f.FromFrameV(fScale * centerShift);
            SetLocalFrame(f, CoordSpace.ObjectCoords);

            // apparently this is expensive?
            if (DeferRebuild == false)
            {
                topCap.GetComponent <MeshCollider>().sharedMesh    = topCap.GetComponent <MeshFilter>().sharedMesh;
                bottomCap.GetComponent <MeshCollider>().sharedMesh = bottomCap.GetComponent <MeshFilter>().sharedMesh;
                body.GetComponent <MeshCollider>().sharedMesh      = body.GetComponent <MeshFilter>().sharedMesh;
            }

            increment_timestamp();
        }