Пример #1
0
            public override fMesh MakeGeometry(AxisGizmoFlags widget)
            {
                switch (widget)
                {
                case AxisGizmoFlags.AxisTranslateY:
                    if (MyAxisTranslateY == null)
                    {
                        Radial3DArrowGenerator arrowGen = new Radial3DArrowGenerator()
                        {
                            HeadLength = 2.0f, TipRadius = 0.1f, StickLength = 1.5f, Clockwise = true
                        };
                        DMesh3 mesh = arrowGen.Generate().MakeDMesh();
                        MeshNormals.QuickCompute(mesh);
                        MeshTransforms.Translate(mesh, 0.5 * Vector3d.AxisY);
                        DMesh3 flip = new DMesh3(mesh);
                        MeshTransforms.Rotate(flip, Vector3d.Zero, Quaterniond.AxisAngleD(Vector3d.AxisX, 180));
                        MeshEditor.Append(mesh, flip);
                        MyAxisTranslateY = new fMesh(mesh);
                    }
                    return(MyAxisTranslateY);

                default:
                    return(null);
                }
            }
Пример #2
0
        virtual protected fGameObject append_widget(AxisGizmoFlags widgetType, int nAxis, string name,
                                                    fMaterial material, fMaterial hoverMaterial)
        {
            var useMaterial = (Factory.UniqueColorPerWidget || material == null)
                ? Factory.MakeMaterial(widgetType) : material;
            var useHoverMaterial = (Factory.UniqueColorPerWidget || hoverMaterial == null)
                ? Factory.MakeHoverMaterial(widgetType) : hoverMaterial;
            var go = AppendMeshGO(name, Factory.MakeGeometry(widgetType), useMaterial, RootGameObject, true);

            Standard3DTransformWidget widget = null;

            switch (widgetType)
            {
            case AxisGizmoFlags.AxisTranslateX:
            case AxisGizmoFlags.AxisTranslateY:
            case AxisGizmoFlags.AxisTranslateZ:
                widget = new AxisTranslationWidget(nAxis)
                {
                    RootGameObject    = go, StandardMaterial = useMaterial, HoverMaterial = useHoverMaterial,
                    TranslationScaleF = () => { return(TranslateSpeed / parentScene.GetSceneScale()); }
                };
                break;

            case AxisGizmoFlags.AxisRotateX:
            case AxisGizmoFlags.AxisRotateY:
            case AxisGizmoFlags.AxisRotateZ:
                widget = new AxisRotationWidget(nAxis)
                {
                    RootGameObject   = go, StandardMaterial = useMaterial, HoverMaterial = useHoverMaterial,
                    EnableSnapping   = EnableRotationSnapping,
                    SnapIncrementDeg = RotationSnapStepSizeDeg
                };
                break;

            case AxisGizmoFlags.PlaneTranslateX:
            case AxisGizmoFlags.PlaneTranslateY:
            case AxisGizmoFlags.PlaneTranslateZ:
                widget = new PlaneTranslationWidget(nAxis)
                {
                    RootGameObject    = go, StandardMaterial = useMaterial, HoverMaterial = useHoverMaterial,
                    TranslationScaleF = () => { return(TranslateSpeed / parentScene.GetSceneScale()); }
                };
                break;

            case AxisGizmoFlags.UniformScale:
                widget = new UniformScaleWidget(parentScene.ActiveCamera)
                {
                    RootGameObject   = go, StandardMaterial = useMaterial, HoverMaterial = useHoverMaterial,
                    ScaleMultiplierF = () => { return(ScaleSpeed / parentScene.GetSceneScale()); }
                };
                break;

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

            Widgets[go] = widget;
            return(go);
        }
Пример #3
0
        public virtual fMaterial MakeHoverMaterial(AxisGizmoFlags widget)
        {
            switch (widget)
            {
            case AxisGizmoFlags.AxisRotateX:
            case AxisGizmoFlags.AxisTranslateX:
            case AxisGizmoFlags.PlaneTranslateX:
                if (XHover == null)
                {
                    XHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoRed);
                    if (OverrideRenderQueue != -1)
                    {
                        XHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(XHover);

            case AxisGizmoFlags.AxisRotateY:
            case AxisGizmoFlags.AxisTranslateY:
            case AxisGizmoFlags.PlaneTranslateY:
                if (YHover == null)
                {
                    YHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoGreen);
                    if (OverrideRenderQueue != -1)
                    {
                        YHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(YHover);

            case AxisGizmoFlags.AxisRotateZ:
            case AxisGizmoFlags.AxisTranslateZ:
            case AxisGizmoFlags.PlaneTranslateZ:
                if (ZHover == null)
                {
                    ZHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoBlue);
                    if (OverrideRenderQueue != -1)
                    {
                        ZHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(ZHover);

            case AxisGizmoFlags.UniformScale:
                if (AllHover == null)
                {
                    AllHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoWhite);
                    if (OverrideRenderQueue != -1)
                    {
                        AllHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(AllHover);

            default:
                throw new Exception("DefaultAxisGizmoWidgetFactory.MakeHoverMaterial: invalid widget type " + widget.ToString());
            }
        }
Пример #4
0
            public override fMaterial MakeMaterial(AxisGizmoFlags widget)
            {
                switch (widget)
                {
                case AxisGizmoFlags.AxisTranslateY:
                    if (MyYMaterial == null)
                    {
                        MyYMaterial = MaterialUtil.CreateStandardMaterial(Colorf.VideoGreen);
                    }
                    return(MyYMaterial);

                default:
                    return(null);
                }
            }
Пример #5
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());
            }
        }
Пример #6
0
 public virtual bool Supports(AxisGizmoFlags widget)
 {
     return(true);
 }
Пример #7
0
 public override fMaterial MakeHoverMaterial(AxisGizmoFlags widget)
 {
     return(MakeMaterial(widget));
 }
Пример #8
0
 public override bool Supports(AxisGizmoFlags widget)
 {
     return((widget == AxisGizmoFlags.AxisTranslateY) ? true : false);
 }