public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_so_to_scene; } if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateFlatShaded("tool_generated", Colorf.DimGrey); } // clear selection here inputSelection = new List <SceneObject>(Scene.Selected); set_allow_selection_changes(true); Scene.ClearSelection(); set_allow_selection_changes(false); cache_brim_polys(); PreviewSO = new DMeshSO(); PreviewSO.Create(new DMesh3(), PreviewMaterial); Scene.AddSceneObject(PreviewSO); PreviewSO.Name = "Generated Brim"; initialize_parameters(); }
virtual public void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); brushIndicator = new BrushCursorSphere() { PositionF = () => { return(Scene.ToWorldP(lastBrushPosS.Origin)); }, Radius = fDimension.World(() => { return(radius.WorldValue); }) }; Indicators.AddIndicator(brushIndicator); brushIndicator.material = MaterialUtil.CreateTransparentMaterialF(Colorf.DarkRed, 0.8f); if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateFlatShaded("MeshEditor_generated", Colorf.DimGrey); } previewSO = new DMeshSO(); previewSO.EnableSpatial = false; previewSO.Create(new DMesh3(Target.Mesh), PreviewMaterial); previewSO.Name = "MeshEditorTool_preview"; previewSO.SetLocalFrame(Target.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); previewSO.SetLocalScale(Target.GetLocalScale()); Scene.AddSceneObject(previewSO); PreviewSpatial = new EditMeshSpatial() { SourceMesh = Target.Mesh, SourceSpatial = Target.Spatial, EditMesh = PreviewMesh }; }
virtual public void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateFlatShaded("holefill_preview", Colorf.DimGrey); } if (HoleBoundaryMaterial == null) { HoleBoundaryMaterial = SOMaterial.CreateStandard("holefill_boundary", Colorf.PivotYellow); } previewSO = new DMeshSO(); previewSO.EnableSpatial = false; previewSO.Create(new DMesh3(Target.Mesh), PreviewMaterial); previewSO.Name = "HoleFillTool_preview"; previewSO.SetLocalFrame(Target.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); previewSO.SetLocalScale(Target.GetLocalScale()); previewSO.OnMeshModified += PreviewSO_OnMeshModified; Scene.AddSceneObject(previewSO); sceneToObjUnitScale = SceneTransforms.SceneToObject(Target, 1.0f); Loops = new MeshBoundaryLoops(previewSO.Mesh); boundaryGeom = new BoundaryCurveSet(previewSO.RootGameObject, HoleBoundaryMaterial.ToFMaterial()); boundaryGeom.Radius = BorderRadius.SceneValue * sceneToObjUnitScale; boundaryGeom.Initialize(Loops); }
void initialize_cut_op() { if (MeshSourceOp != null) { return; } MeshSourceOp = new WrapDMeshSourceOp() { MeshSourceF = () => { return(InputMeshSO.Mesh); }, SpatialSourceF = () => { return(InputMeshSO.Spatial); } }; CutOp = new CutPolygonHoleOp() { MeshSource = MeshSourceOp }; ComputeOp = new ThreadedMeshComputeOp() { MeshSource = CutOp }; if (CutPreviewMaterial == null) { CutPreviewMaterial = SOMaterial.CreateFlatShaded("add_hole_cut", Colorf.DimGrey); } CutPreviewSO = new DMeshSO() { EnableSpatial = false }; CutPreviewSO.Create(new DMesh3(), CutPreviewMaterial); Scene.AddSceneObject(CutPreviewSO); CutPreviewSO.SetLocalFrame(InputMeshSO.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); CutPreviewSO.SetLocalScale(InputMeshSO.GetLocalScale()); }
public override PolyCurveSO Create(SOMaterial defaultMaterial) { EnclosedPatchSO so = (EnclosedPatchSO)base.Create(defaultMaterial); previewMaterial = MaterialUtil.CreateTransparentMaterialF(Colorf.ForestGreen, 0.1f); return(so); }
public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_so_to_scene; } if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateFlatShaded("tool_generated", Colorf.DimGrey); } // clear selection here inputSelection = new List <SceneObject>(Scene.Selected); set_allow_selection_changes(true); Scene.ClearSelection(); set_allow_selection_changes(false); scene_bounds = AxisAlignedBox3d.Empty; foreach (var so in CC.Objects.PrintMeshes) { if (so.Settings.ObjectType == PrintMeshSettings.ObjectTypes.Solid || so.Settings.ObjectType == PrintMeshSettings.ObjectTypes.Support) { var seq = SceneTransforms.ObjectToSceneXForm(so); foreach (Vector3d p in so.Mesh.Vertices()) { Vector3d ps = seq.TransformP(p); if (ps.y >= 0) { scene_bounds.Contain(ps); } } } } scene_bounds.Min.y = 0; if (scene_bounds.Width <= 0) { scene_bounds.Min.x = scene_bounds.Max.x = 0; } if (scene_bounds.Depth <= 0) { scene_bounds.Min.z = scene_bounds.Max.z = 0; } Height = scene_bounds.Height; PreviewSO = new DMeshSO(); PreviewSO.Create(new DMesh3(), PreviewMaterial); Scene.AddSceneObject(PreviewSO); PreviewSO.Name = "Purge Spiral"; initialize_parameters(); }
public static void InitializeMaterials() { PreviewTransparentMaterial = SOMaterial.CreateTransparent("preview_trans", new Colorf(Colorf.SelectionGold, 0.2f)); PathMaterial_Extrude = MaterialUtil.CreateFlatMaterial(Colorf.VideoBlack); PathMaterial_Support = MaterialUtil.CreateFlatMaterial(Colorf.VideoMagenta); PathMaterial_Travel = MaterialUtil.CreateFlatMaterial(Colorf.VideoGreen, 0.5f); PathMaterial_PlaneChange = MaterialUtil.CreateFlatMaterial(Colorf.VideoBlue, 0.5f); PathMaterial_Default = MaterialUtil.CreateFlatMaterial(Colorf.VideoRed, 0.5f); }
public void NameTest() { SOMaterial material = new SOMaterial("steel"); // The material should exist Assert.NotNull(material); // The name should be equal to "steel" Assert.AreEqual("steel", material.Name); }
public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_so_to_scene; } if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateMesh("tool_generated", Colorf.DimGrey); } if (ErrorMaterial == null) { ErrorMaterial = SOMaterial.CreateMesh("tool_generated_error", Colorf.VideoRed); } // clear selection here so that multi-select GroupSO goes away, otherwise // when we copy frmaes below, they are relative to that GroupSO, and things move inputSelection = new List <SceneObject>(Scene.Selected); set_allow_selection_changes(true); Scene.ClearSelection(); set_allow_selection_changes(false); MeshSourceOps = new List <ConstantMeshSourceOp>(); SceneMeshes = new List <DMesh3>(); foreach (var so in InputSOs) { var xform = SceneTransforms.ObjectToSceneXForm(so); DMesh3 sceneMesh = new DMesh3(so.Mesh); MeshTransforms.PerVertexTransform(sceneMesh, xform); SceneMeshes.Add(sceneMesh); MeshSourceOps.Add( new ConstantMeshSourceOp(sceneMesh, false, true)); } EditOp = edit_op_factory(MeshSourceOps.Cast <DMeshSourceOp>()); ComputeOp = new ThreadedMeshComputeOp() { MeshSource = EditOp }; PreviewSO = new DMeshSO() { EnableSpatial = EnablePreviewSpatial }; PreviewSO.Create(new DMesh3(), PreviewMaterial); Scene.AddSceneObject(PreviewSO); postprocess_target_objects(); base_initialize_parameters(); }
int hole_start_id; // this is MultiPointTool point ID of hole public override void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); base.Setup(); // shut off transform gizmo Scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType); InputMeshSO = TargetSO as DMeshSO; // create preview obj if (HolePreviewMaterial == null) { HolePreviewMaterial = SOMaterial.CreateMesh("tool_generated", Colorf.DimGrey.WithAlpha(0.5f)); } if (CutPreviewMaterial == null) { CutPreviewMaterial = SOMaterial.CreateMesh("tool_generated", Colorf.DimGrey); } if (ErrorMaterial == null) { ErrorMaterial = SOMaterial.CreateMesh("tool_generated_error", Colorf.VideoRed); } // clear selection here so that multi-select GroupSO goes away, otherwise // when we copy frmaes below, they are relative to that GroupSO, and things move inputSelection = new List <SceneObject>(Scene.Selected); set_allow_selection_changes(true); Scene.ClearSelection(); set_allow_selection_changes(false); // create preview hole object CavityPreviewSO = new DMeshSO(); CavityPreviewSO.Create(new DMesh3(), HolePreviewMaterial); update_hole_mesh(); Scene.AddSceneObject(CavityPreviewSO); CavityPreviewSO.SetLayer(FPlatform.WidgetOverlayLayer); // initialize cut op initialize_cut_op(); // nooooo Vector3d posL = InputMeshSO.Mesh.GetVertex(0); hole_start_id = base.AppendSurfacePoint("hole_point", Colorf.ForestGreen, 2.0f); SetPointPosition(hole_start_id, new Frame3f(posL), CoordSpace.ObjectCoords); SetPointColor(hole_start_id, Colorf.ForestGreen, FPlatform.WidgetOverlayLayer); // init params initialize_parameters(); }
public void Create(SOMaterial useMaterial, fGameObject parent) { if (curve == null) { curve = new DCurve3(); } meshObject = GameObjectFactory.CreateMeshGO("mesh_tube_preview"); //meshObject.SetMesh(new fMesh()) meshObject.SetMaterial(MaterialUtil.ToMaterialf(useMaterial)); bUpdatePending = true; parent.AddChild(meshObject, false); }
public static void InitializeMaterials() { ScanMaterial = new SOMaterial() { Name = "ScanMaterial", Type = SOMaterial.MaterialType.FlatShadedPerVertexColor }; LegMaterial = new SOMaterial() { Name = "LegDepthOnly", Type = SOMaterial.MaterialType.DepthWriteOnly }; LegMaterial.RenderQueueShift = 50; RectifiedLegMaterial = new SOMaterial() { Name = "RectifiedLegMat", Type = SOMaterial.MaterialType.FlatShadedPerVertexColor }; SocketMaterial = new SOMaterial() { Name = "SockeTMat", Type = SOMaterial.MaterialType.FlatShadedPerVertexColor, RGBColor = Colorf.White }; TrimLoopMaterial = new SOMaterial() { Name = "TrimLoopMat", Type = SOMaterial.MaterialType.UnlitRGBColor, RGBColor = Colorf.VideoBlue }; OffsetRegionMaterial = new SOMaterial() { Name = "OffsetRegionMat", Type = SOMaterial.MaterialType.UnlitRGBColor, RGBColor = Colorf.ForestGreen }; PlaneCurveMaterial = new SOMaterial() { Name = "PlaneCurveMat", Type = SOMaterial.MaterialType.UnlitRGBColor, RGBColor = Colorf.DarkYellow }; PlaneCurveMaterial.RenderQueueShift = 100; }
public override void postprocess_target_objects() { if (HiddenPreviewMaterial == null) { HiddenPreviewMaterial = SOMaterial.CreateTransparent("remove_hidden_generated", new Colorf(Colorf.VideoRed, 0.5f)); } RemovedSO = new DMeshSO(); RemovedSO.Create(new DMesh3(), HiddenPreviewMaterial); RemovedSO.SetLayer(FPlatform.WidgetOverlayLayer); RemovedSO.DisableShadows(); Scene.AddSceneObject(RemovedSO); RemovedSO.SetLocalFrame(PreviewSO.GetLocalFrame(CoordSpace.SceneCoords), CoordSpace.SceneCoords); RemovedSO.SetLocalScale(PreviewSO.GetLocalScale()); }
public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_to_scene; } combineMesh = new DMesh3(); MeshEditor editor = new MeshEditor(combineMesh); foreach (var so in InputSOs) { DMesh3 inputMesh = so.Mesh; int[] mapV; if (editor.AppendMesh(so.Mesh, out mapV)) { MeshTransforms.PerVertexTransform(combineMesh, inputMesh, mapV, (v, old_id, new_id) => { return(SceneTransforms.ObjectToSceneP(so, v)); }); } } ; MeshSourceOp = new ConstantMeshSourceOp(combineMesh, true, true); SeparateOp = new SeparateSolidsOp() { MeshSource = MeshSourceOp }; ComputeOp = new ThreadedResultComputeOp <List <DMesh3> >() { ResultSource = SeparateOp }; if (HiddenPreviewMaterial == null) { HiddenPreviewMaterial = SOMaterial.CreateTransparent("remove_hidden_generated", new Colorf(Colorf.DimGrey, 0.5f)); } if (KeepPreviewMaterial == null) { KeepPreviewMaterial = SOMaterial.CreateFlatShaded("remove_keep_generated", Colorf.DimGrey); } }
public LegModel(LegSO legIn, SOMaterial rectifiedMaterial) : base(legIn.Mesh, false, legIn.Spatial) { leg = legIn; leg.Name = "InitialLeg"; legIn.OnMeshModified += on_leg_scan_modified; rectified_leg = leg.DuplicateSubtype <RectifiedLegSO>(); rectified_leg.EnableSpatial = false; leg.GetScene().AddSceneObject(rectified_leg, false); rectified_leg.AssignSOMaterial(rectifiedMaterial); rectified_leg.Name = "RectifiedLeg"; //SOMeshSource = new ConstantMeshSourceOp(legIn.Mesh, true, false); SOMeshSource = new ConstantMeshSourceOp(); SO_Op = new UniquePairSet <SceneObject, ModelingOperator>(); Combiner = new DisplacementCombinerOp(); VertexDisplace = new MeshVertexDisplacementOp() { MeshSource = SOMeshSource, DisplacementSource = Combiner }; PostScale = new MeshScaleOp() { MeshSource = VertexDisplace }; Compute = new ThreadedMeshComputeOp() { MeshSource = PostScale }; // add global brush layer BrushLayer = new VectorDisplacementMapOp() { MeshSource = SOMeshSource }; Combiner.Append(BrushLayer); SOMeshSource.SetMesh(legIn.Mesh, true, false); }
public static TrimLoopSO CreateFromPlane(DMeshSO TargetSO, Frame3f PlaneS, SOMaterial material, FScene scene, double fNormalOffset = 0.0f) { Frame3f PlaneO = SceneTransforms.SceneToObject(TargetSO, PlaneS); PlaneIntersectionCurves curves = new PlaneIntersectionCurves(TargetSO.Mesh, PlaneO, 1) { NormalOffset = fNormalOffset }; curves.Compute(); if (curves.Loops.Length != 1) { throw new Exception("TrimLoopSO.CreateFromPlane: got more than one cut loop?"); } DCurve3 loop = curves.Loops[0]; // map loop back into plane frame for (int i = 0; i < loop.VertexCount; ++i) { loop[i] = PlaneO.ToFrameP(loop[i]); } TrimLoopSO curveSO = new TrimLoopSO() { Curve = loop }; curveSO.Create(material); Frame3f curveFrame = SceneTransforms.ObjectToScene(TargetSO, PlaneO); curveSO.SetLocalFrame(curveFrame, CoordSpace.ObjectCoords); scene.History.PushChange( new AddSOChange() { scene = scene, so = curveSO, bKeepWorldPosition = false }); scene.History.PushInteractionCheckpoint(); return(curveSO); }
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); }
public static TrimLoopSO CreateFromPreview(CurvePreview preview, SOMaterial material, FScene scene) { TrimLoopSO curveSO = (TrimLoopSO)preview.BuildSO( (curve) => { TrimLoopSO so = new TrimLoopSO() { Curve = curve }; so.Create(material); return(so); }, material, 1.0f); scene.History.PushChange( new AddSOChange() { scene = scene, so = curveSO, bKeepWorldPosition = false }); scene.History.PushInteractionCheckpoint(); return(curveSO); }
public DMeshSO BuildSO(FScene scene, SOMaterial material) { DMesh3 revolveMesh = UnityUtil.UnityMeshToDMesh(meshObject.GetSharedMesh(), false); // move axis frame to center of bbox of mesh, measured in axis frame Frame3f useF = OutputFrame; AxisAlignedBox3f boundsInFrame = (AxisAlignedBox3f)BoundsUtil.BoundsInFrame(revolveMesh.Vertices(), useF); useF.Origin = useF.FromFrameP(boundsInFrame.Center); // transform mesh into this frame MeshTransforms.ToFrame(revolveMesh, useF); // create new so DMeshSO meshSO = new DMeshSO(); meshSO.Create(revolveMesh, material); meshSO.SetLocalFrame(useF, CoordSpace.ObjectCoords); return(meshSO); }
public PolyTubeSO BuildSO(SOMaterial material, float scale = 1.0f) { Vector3d vCenter = curve.GetBoundingBox().Center; DCurve3 shifted = new DCurve3(curve); for (int i = 0; i < shifted.VertexCount; ++i) { shifted[i] -= vCenter; } Frame3f shiftedFrame = new Frame3f((Vector3f)vCenter, Quaternionf.Identity); PolyTubeSO so = new PolyTubeSO() { Curve = shifted, Polygon = polygon }; so.Create(material); so.SetLocalFrame(shiftedFrame, CoordSpace.WorldCoords); return(so); }
public override PolyCurveSO Create(SOMaterial defaultMaterial) { PlaneIntersectionCurveSO so = (PlaneIntersectionCurveSO)base.Create(defaultMaterial); return(so); }
// Use this for initialization public override void Awake() { // if we need to auto-configure Rift vs Vive vs (?) VR, we need // to do this before any other F3 setup, because MainCamera will change // and we are caching that in a lot of places... if (AutoConfigVR) { VRCameraRig = gs.VRPlatform.AutoConfigureVR(); } // restore any settings SceneGraphConfig.RestorePreferences(); // set up some defaults // this will move the ground plane down, but the bunnies will be floating... //SceneGraphConfig.InitialSceneTranslate = -4.0f * Vector3f.AxisY; SceneGraphConfig.DefaultSceneCurveVisualDegrees = 0.5f; SceneGraphConfig.DefaultPivotVisualDegrees = 1.5f; SceneGraphConfig.DefaultAxisGizmoVisualDegrees = 10.0f; SceneGraphConfig.InitialSceneTranslate = -4 * Vector3f.AxisY; SceneOptions options = new SceneOptions(); options.UseSystemMouseCursor = false; options.Use2DCockpit = false; options.EnableTransforms = true; options.EnableCockpit = true; options.CockpitInitializer = new PhotoToolCockpit(); options.MouseCameraControls = new MayaCameraHotkeys(); options.SpatialCameraRig = VRCameraRig; // very verbose options.LogLevel = 2; context = new FContext(); context.Start(options); // if you had other gizmos, you would register them here //context.TransformManager.RegisterGizmoType("snap_drag", new SnapDragGizmoBuilder()); //controller.TransformManager.SetActiveGizmoType("snap_drag"); // if you had other tools, you would register them here. context.ToolManager.RegisterToolType(DrawPrimitivesTool.Identifier, new DrawPrimitivesToolBuilder()); context.ToolManager.RegisterToolType(DrawSurfaceCurveTool.Identifier, new DrawSurfaceCurveToolBuilder() { AttachCurveToSurface = true, DefaultSamplingRateS = 0.0025f, DefaultSurfaceOffsetS = 0.0025f, CurveMaterialF = () => { var mat = context.Scene.DefaultCurveSOMaterial.Clone(); mat.RGBColor = Colorf.VideoRed; return(mat); } }); context.ToolManager.SetActiveToolType(DrawSurfaceCurveTool.Identifier, ToolSide.Right); // Set up standard scene lighting if requested if (options.EnableDefaultLighting) { GameObject lighting = GameObject.Find("SceneLighting"); if (lighting == null) { lighting = new GameObject("SceneLighting"); } SceneLightingSetup setup = lighting.AddComponent <SceneLightingSetup>(); setup.Context = context; setup.LightDistance = 30.0f; // related to total scene scale... } Context.Scene.DisableSelectionMaterial = true; /* * Import elements of Unity scene that already exist into the FScene */ // set up ground plane geometry (optional) GameObject groundPlane = GameObject.Find("GroundPlane"); if (groundPlane != null && groundPlane.IsVisible()) { context.Scene.AddWorldBoundsObject(groundPlane); } float fSquareSize = 1.0f; Vector3f eyePos = context.ActiveCamera.GetPosition(); System.Random rand = new System.Random(31337); // [RMS] this path only works in Editor, is relative to top-level project directory string sPhotoFolder = "Data\\PhotoSets\\kitchen"; string[] photos = Directory.GetFiles(sPhotoFolder); foreach (string filename in photos) { Texture2D tex = load_texture(filename); if (tex == null) { continue; } float fScale = fSquareSize / (float)tex.width; if (tex.height > tex.width) { fScale = fSquareSize / (float)tex.height; } float w = fScale * (float)tex.width; float h = fScale * (float)tex.height; TrivialRectGenerator rectgen = new TrivialRectGenerator() { Width = w, Height = h }; rectgen.Generate(); DMesh3 mesh = new DMesh3(MeshComponents.VertexUVs); rectgen.MakeMesh(mesh); SOMaterial material = new SOMaterial() { Name = "photomaterial", Type = SOMaterial.MaterialType.TextureMap, RGBColor = Colorf.White }; material.MainTexture = tex; DMeshSO so = new DMeshSO(); so.Create(mesh, material); context.Scene.AddSceneObject(so); float horz = rand.Next(-50, 50); float vert = rand.Next(-20, 25); int mult = 1000; float dist = (float)(rand.Next(2 * mult, 3 * mult)) / (float)mult; Ray3f r = VRUtil.MakeRayFromSphereCenter(horz, vert); r.Origin += eyePos; float fRayT = 0.0f; RayIntersection.Sphere(r.Origin, r.Direction, eyePos, dist, out fRayT); Vector3f v = r.Origin + fRayT * r.Direction; Frame3f f = new Frame3f(v, v.Normalized); Vector3f toEye = context.ActiveCamera.GetPosition() - f.Origin; toEye.Normalize(); f.AlignAxis(1, toEye); f.ConstrainedAlignAxis(2, Vector3f.AxisY, f.Y); so.SetLocalFrame(f, CoordSpace.WorldCoords); } }
public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_so_to_scene; } if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateMesh("tool_generated", Colorf.DimGrey); } if (ErrorMaterial == null) { ErrorMaterial = SOMaterial.CreateMesh("tool_generated_error", Colorf.VideoRed); } // clear selection here so that multi-select GroupSO goes away, otherwise // when we copy frmaes below, they are relative to that GroupSO, and things move inputSelection = new List <SceneObject>(Scene.Selected); set_allow_selection_changes(true); Scene.ClearSelection(); set_allow_selection_changes(false); if (InputSOs.Count == 1 && ForceSceneSpaceComputation == false) { combineMesh = new DMesh3(InputSOs[0].Mesh); sceneToObjUnitScale = SceneTransforms.SceneToObject(InputSOs[0], 1.0f); } else { combineMesh = new DMesh3(); MeshEditor editor = new MeshEditor(combineMesh); foreach (var so in InputSOs) { TransformSequence xform = SceneTransforms.ObjectToSceneXForm(so); DMesh3 inputMesh = so.Mesh; int[] mapV; if (editor.AppendMesh(so.Mesh, out mapV)) { MeshTransforms.PerVertexTransform(combineMesh, inputMesh, mapV, (v, old_id, new_id) => { return(xform.TransformP(v)); }); } } ; sceneToObjUnitScale = 1.0; } MeshSourceOp = new ConstantMeshSourceOp(combineMesh, true, true); EditOp = edit_op_factory(MeshSourceOp); ComputeOp = new ThreadedMeshComputeOp() { MeshSource = EditOp }; PreviewSO = new DMeshSO() { EnableSpatial = EnablePreviewSpatial }; PreviewSO.Create(new DMesh3(), PreviewMaterial); if (InputSOs.Count == 1 && ForceSceneSpaceComputation == false) { PreviewSO.SetLocalFrame(InputSOs[0].GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); PreviewSO.SetLocalScale(InputSOs[0].GetLocalScale()); } Scene.AddSceneObject(PreviewSO); postprocess_target_objects(); base_initialize_parameters(); }
public virtual ToolpathSO Create(ToolpathSet toolpaths, SingleMaterialFFFSettings settings, SOMaterial setMaterial) { AssignSOMaterial(setMaterial); // need to do this to setup BaseSO material stack parentGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("Toolpath")); Toolpaths = toolpaths; Settings = settings; polylines_valid = false; PolylinePool = new fGameObjectPool <fPolylineGameObject>(allocate_polyline_go); PolylinePool.FreeF = (go) => { //go.SetVertices(EmptyToolpathCurve, false, true); }; return(this); }
public virtual void Setup() { // push history stream, so that we can do undo/redo internal to tool, // that will not end up in external history push_history_stream(); if (OnApplyF == null) { OnApplyF = this.add_so_to_scene; } if (PreviewMaterial == null) { PreviewMaterial = SOMaterial.CreateMesh("tool_generated", Colorf.DimGrey); } if (ErrorMaterial == null) { ErrorMaterial = SOMaterial.CreateMesh("tool_generated_error", Colorf.VideoRed); } // clear selection here so that multi-select GroupSO goes away, otherwise // when we copy frmaes below, they are relative to that GroupSO, and things move inputSelection = new List <SceneObject>(Scene.Selected); set_allow_selection_changes(true); Scene.ClearSelection(); set_allow_selection_changes(false); objects = new List <TargetObject>(); foreach (var so in InputSOs) { TargetObject o = new TargetObject(); o.SO = so; o.sceneFrame = so.GetLocalFrame(CoordSpace.SceneCoords); o.sceneToObjUnitScale = SceneTransforms.SceneToObject(o.SO, 1.0f); o.MeshSourceOp = new WrapDMeshSourceOp() { MeshSourceF = () => { return(so.Mesh); }, SpatialSourceF = () => { return(so.Spatial); } }; o.EditOp = edit_op_factory(o); o.Compute = new ThreadedMeshComputeOp() { MeshSource = o.EditOp }; o.Preview = new DMeshSO() { EnableSpatial = EnablePreviewSpatial }; o.Preview.Create(new DMesh3(), PreviewMaterial); o.Preview.SetLocalFrame(so.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords); o.Preview.SetLocalScale(so.GetLocalScale()); Scene.AddSceneObject(o.Preview); objects.Add(o); } postprocess_target_objects(); base_initialize_parameters(); }
public void SetUp() { this.m_Material = new SOMaterial(MATERIAL_NAME); this.m_Quantity = new SOMaterialQuantity(this.m_Material, QUANTITY, UNIT); }
public override PolyCurveSO Create(SOMaterial defaultMaterial) { TrimLoopSO so = (TrimLoopSO)base.Create(defaultMaterial); return(so); }