public virtual void InvalidateViewMeshes() { if (viewMeshGO != null) { SourceSO.RemoveGO((fGameObject)viewMeshGO); viewMeshGO.Destroy(); viewMeshGO = null; } decomp_valid = false; }
public void AddComponent(MeshDecomposition.Component C) { fMesh submesh = new fMesh(C.triangles, mesh, C.source_vertices, true, true); fMeshGameObject submesh_go = GameObjectFactory.CreateMeshGO("component", submesh, false); submesh_go.SetMaterial(new fMaterial(CurrentMaterial)); displayComponents.Add(new DisplayMeshComponent() { go = submesh_go, source_vertices = C.source_vertices }); AppendNewGO(submesh_go, parentGO, false); }
public virtual fMeshGameObject AppendMeshGO(string name, fMesh mesh, fMaterial setMaterial, fGameObject parent, bool bCollider = true) { fMeshGameObject go = new fMeshGameObject(mesh, true, bCollider); go.EnableCollisions = false; go.SetMaterial(setMaterial); go.SetName(name); vObjects.Add(go); parent.AddChild(go); go.SetLayer(parent.GetLayer()); return(go); }
public void AddComponent(MeshDecomposition.Component C) { fMesh submesh = new fMesh(C.triangles, mesh, C.source_vertices, true, true, true); fMeshGameObject submesh_go = GameObjectFactory.CreateMeshGO("component", submesh, true); submesh_go.SetMaterial(SourceSO.CurrentMaterial, true); submesh_go.SetLayer(SourceSO.RootGameObject.GetLayer()); displayComponents.Add(new DisplayMeshComponent() { go = submesh_go, source_vertices = C.source_vertices }); if (SourceSO.ShadowsEnabled == false) { MaterialUtil.DisableShadows(submesh_go, true, true); } SourceSO.AppendNewGO(submesh_go, SourceSO.RootGameObject, false); }
static public fGameObject EmitDebugMesh(string name, DMesh3 meshIn, Colorf color, GameObject parent = null, bool bIsInWorldPos = true) { DMesh3 mesh = new DMesh3(meshIn); if (FPlatform.InMainThread() == false) { ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugMesh(name, mesh, color, parent, bIsInWorldPos); }); return(null); } fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO(name, new fMesh(mesh), false, true); fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterialF(color)); if (parent != null) { parent.AddChild(fMeshGO, bIsInWorldPos); } return(fMeshGO); }
public List <fGameObject> Generate() { fMesh mesh = FResources.LoadMesh(Path); fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO("iconMesh", mesh, false, true); fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterial(this.Color), true); // apply orientation fMeshGO.SetLocalScale(new Vector3f(Scale, Scale, Scale)); fMeshGO.SetLocalPosition(fMeshGO.GetLocalPosition() + Translate); fMeshGO.SetLocalRotation(Rotate); // ignore material changes when we add to GameObjectSet fMeshGO.AddComponent <IgnoreMaterialChanges>(); return(new List <fGameObject>() { fMeshGO }); }
public virtual void ValidateViewMeshes() { if (decomp_valid) { return; } fMesh unityMesh = UnityUtil.DMeshToUnityMesh(mesh, false, true); viewMeshGO = GameObjectFactory.CreateMeshGO("component", unityMesh, false, true); viewMeshGO.SetMaterial(SourceSO.CurrentMaterial, true); viewMeshGO.SetLayer(SourceSO.RootGameObject.GetLayer()); if (SourceSO.ShadowsEnabled == false) { MaterialUtil.DisableShadows(viewMeshGO, true, true); } SourceSO.AppendNewGO(viewMeshGO, SourceSO.RootGameObject, false); decomp_valid = true; }
static public fGameObject EmitDebugBox(string name, Box3d box, Colorf color, GameObject parent = null, bool bIsInWorldPos = true) { if (FPlatform.InMainThread() == false) { ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugBox(name, box, color, parent, bIsInWorldPos); }); return(null); } TrivialBox3Generator boxgen = new TrivialBox3Generator() { Box = box, NoSharedVertices = true, Clockwise = true }; boxgen.Generate(); DMesh3 mesh = boxgen.MakeDMesh(); fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO(name, new fMesh(mesh), false, true); fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterialF(color)); if (parent != null) { parent.AddChild(fMeshGO, bIsInWorldPos); } return(fMeshGO); }
// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDTextEntry")); fMesh mesh = MeshGenerators.CreateTrivialRect(Width, Height, MeshGenerators.UVRegionType.FullUVSquare); backgroundMaterial = MaterialUtil.CreateFlatMaterialF(BackgroundColor); activeBackgroundMaterial = MaterialUtil.CreateFlatMaterialF(ActiveBackgroundColor); bgMesh = AppendMeshGO("background", mesh, backgroundMaterial, entry); bgMesh.RotateD(Vector3f.AxisX, -90.0f); // ?? BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); cursor = GameObjectFactory.CreateRectangleGO("cursor", Height * 0.1f, Height * 0.8f, Colorf.VideoBlack, false); BoxModel.Translate(cursor, Vector2f.Zero, this.Bounds2D.CenterLeft, -Height * 0.1f); cursor.RotateD(Vector3f.AxisX, -90.0f); AppendNewGO(cursor, entry, false); cursor.SetVisible(false); }
override protected void BuildGizmo() { gizmo.SetName("SurfaceConstrainedGizmo"); make_materials(); centerGO = AppendMeshGO("object_origin", UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere), srcMaterial, gizmo); centerGO.SetLocalScale(WidgetScale); Widgets[centerGO] = new SurfaceConstrainedPointWidget(this, this.parentScene) { RootGameObject = centerGO, StandardMaterial = srcMaterial, HoverMaterial = srcHoverMaterial }; PuncturedDiscGenerator discgen = new PuncturedDiscGenerator() { StartAngleDeg = 180, EndAngleDeg = 270, OuterRadius = 1.5f, InnerRadius = 0.75f }; discgen.Generate(); SimpleMesh discmesh = discgen.MakeSimpleMesh(); MeshTransforms.Rotate(discmesh, Vector3d.Zero, Quaternionf.AxisAngleD(Vector3f.AxisX, 90)); rotateGO = AppendMeshGO("object_rotate", new fMesh(discmesh), srcMaterial, gizmo); rotateGO.SetLocalScale(WidgetScale); Widgets[rotateGO] = new AxisRotationWidget(2) { RootGameObject = rotateGO, StandardMaterial = srcMaterial, HoverMaterial = srcHoverMaterial }; gizmo.Hide(); }