Example #1
0
        public IEnumerator UpdateGeometryOnMainThread()
        {
            if (InteriorComponents == null)
            {
                yield break;
            }
            if (is_disconnected)
            {
                yield break;
            }
            ComponentData interior = InteriorComponents;

            // if mesh was modified before we got here, push it back onto dirty list
            if (interior.timestamp != SO.Mesh.ShapeTimestamp)
            {
                OnComputeUpdateRequired?.Invoke(this);
                yield break;
            }

            foreach (DMesh3 mesh in interior.InteriorMeshes)
            {
                if (is_disconnected || interior.timestamp != SO.Mesh.ShapeTimestamp)
                {
                    yield break;
                }
                fMeshGameObject go = GameObjectFactory.CreateMeshGO("interior_comp", new fMesh(mesh), false, true);
                SO.RootGameObject.AddChild(go, false);
                go.SetMaterial(CavityMaterial, true);
                go.SetLayer(FPlatform.WidgetOverlayLayer);
                MeshGOs.Add(go);
                yield return(null);
            }
        }
        protected override void on_curve_validated()
        {
            if (previewGO != null)
            {
                RemoveGO((fGameObject)previewGO);
                previewGO.Destroy();
            }


            if (EnableRegionOverlay)
            {
                if (TargetModelSO == null)
                {
                    throw new InvalidOperationException("EnclosedPatchSO.on_curve_validated: curve is not connected to a Target");
                }
                if (TransformMode != OutputCurveTransform.ToTargetSO)
                {
                    throw new InvalidOperationException("EnclosedPatchSO.on_curve_validated: curve is not transformed to TargetSO");
                }

                DCurve3           target_curve = RequestCurveCopyFromMainThread();
                MeshFacesFromLoop loop         = new MeshFacesFromLoop(TargetModel.SourceMesh,
                                                                       target_curve, TargetModel.SourceSpatial);
                MeshFaceSelection face_selection = loop.ToSelection();

                DSubmesh3 submesh = new DSubmesh3(TargetModel.SourceMesh, face_selection, face_selection.Count);

                MeshNormals normals = new MeshNormals(submesh.SubMesh);
                normals.Compute();
                foreach (int vid in submesh.SubMesh.VertexIndices())
                {
                    Vector3d n = normals.Normals[vid];
                    Vector3d v = submesh.SubMesh.GetVertex(vid);
                    v += 0.1 * n;
                    v  = SceneTransforms.TransformTo(v, TargetModelSO, this);
                    submesh.SubMesh.SetVertex(vid, v);
                }

                previewGO = GameObjectFactory.CreateMeshGO("patch",
                                                           new fMesh(submesh.SubMesh), false, true);
                previewGO.SetMaterial(previewMaterial, true);
                previewGO.SetLayer(FPlatform.WidgetOverlayLayer);
                previewGO.SetIgnoreMaterialChanges();
                AppendNewGO(previewGO, root, false);
            }
        }
Example #3
0
        public void Create(SOMaterial useMaterial, fGameObject parent, int nLayer = -1)
        {
            if (curve == null)
            {
                curve = new DCurve3();
            }
            axis = Frame3f.Identity;

            meshObject = GameObjectFactory.CreateMeshGO("revolve_preview");
            meshObject.SetMaterial(MaterialUtil.ToMaterialf(useMaterial), true);
            if (nLayer != -1)
            {
                meshObject.SetLayer(nLayer);
            }

            bUpdatePending = true;

            meshObject.SetParent(parent, false);
            meshObject.SetLocalScale(1.001f * Vector3f.One);
        }