示例#1
0
        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
            });
        }
示例#2
0
        // creates a button with a floating primitive in front of the button shape
        public void CreateMeshIconButton(float fRadius, string sMeshPath, Material bgMaterial,
                                         float fMeshScaleFudge)
        {
            Shape = new HUDShape(HUDShapeType.Disc, fRadius);

            fMesh    iconmesh     = null;
            Material meshMaterial = null;

            try {
                iconmesh     = FResources.LoadMesh(sMeshPath);
                meshMaterial = MaterialUtil.CreateStandardVertexColorMaterial(Color.white);
            } catch { }
            if (iconmesh == null)
            {
                iconmesh     = UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere);
                meshMaterial = MaterialUtil.CreateStandardMaterial(Color.red);
            }

            float fMeshRadius = fRadius * fMeshScaleFudge;

            base.Create(bgMaterial, iconmesh, meshMaterial, fMeshRadius,
                        Frame3f.Identity.Translated(-fMeshRadius * 0.25f, 2).Rotated(-15.0f, 1));
        }
示例#3
0
        public virtual fMesh MakeGeometry(AxisGizmoFlags widget)
        {
            switch (widget)
            {
            case AxisGizmoFlags.AxisTranslateX:
                if (AxisTranslateX == null)
                {
                    AxisTranslateX = FResources.LoadMesh("transform_gizmo/axis_translate_x");
                }
                return(AxisTranslateX);

            case AxisGizmoFlags.AxisTranslateY:
                if (AxisTranslateY == null)
                {
                    AxisTranslateY = FResources.LoadMesh("transform_gizmo/axis_translate_y");
                }
                return(AxisTranslateY);

            case AxisGizmoFlags.AxisTranslateZ:
                if (AxisTranslateZ == null)
                {
                    AxisTranslateZ = FResources.LoadMesh("transform_gizmo/axis_translate_z");
                }
                return(AxisTranslateZ);


            case AxisGizmoFlags.AxisRotateX:
                if (AxisRotateX == null)
                {
                    AxisRotateX = FResources.LoadMesh("transform_gizmo/axisrotate_x");
                }
                return(AxisRotateX);

            case AxisGizmoFlags.AxisRotateY:
                if (AxisRotateY == null)
                {
                    AxisRotateY = FResources.LoadMesh("transform_gizmo/axisrotate_y");
                }
                return(AxisRotateY);

            case AxisGizmoFlags.AxisRotateZ:
                if (AxisRotateZ == null)
                {
                    AxisRotateZ = FResources.LoadMesh("transform_gizmo/axisrotate_z");
                }
                return(AxisRotateZ);


            case AxisGizmoFlags.PlaneTranslateX:
                if (PlaneTranslateX == null)
                {
                    PlaneTranslateX = FResources.LoadMesh("transform_gizmo/plane_translate_yz");
                }
                return(PlaneTranslateX);

            case AxisGizmoFlags.PlaneTranslateY:
                if (PlaneTranslateY == null)
                {
                    PlaneTranslateY = FResources.LoadMesh("transform_gizmo/plane_translate_xz");
                }
                return(PlaneTranslateY);

            case AxisGizmoFlags.PlaneTranslateZ:
                if (PlaneTranslateZ == null)
                {
                    PlaneTranslateZ = FResources.LoadMesh("transform_gizmo/plane_translate_xy");
                }
                return(PlaneTranslateZ);


            case AxisGizmoFlags.UniformScale:
                if (UniformScale == null)
                {
                    UniformScale = FResources.LoadMesh("transform_gizmo/uniform_scale");
                }
                return(UniformScale);


            default:
                throw new Exception("DefaultAxisGizmoWidgetFactory.MakeHoverMaterial: invalid widget type " + widget.ToString());
            }
        }