示例#1
0
        public static void SetAsSelected(Node node, Gizmo gizmo, PulsarScene scene)
        {
            StaticModel nodeModel = node.GetComponent <StaticModel>();

            if (nodeModel != null && scene != null)
            {
                PulsarApplication pulsarApplication = scene.GetApplication();
                if (pulsarApplication != null)
                {
                    MaterialTemp tempMaterial = new MaterialTemp(nodeModel, pulsarApplication);
                    if (tempMaterial != null)
                    {
                        tempMaterial.Name = "materialTemp";

                        try
                        {
                            tempMaterial.SetTransparentMaterial();
                        }
                        catch (PulsarGizmoException gizmoException)
                        {
                            gizmoException.Source = "[GizmoHelper:SetAsSelected]";
                            throw gizmoException;
                        }

                        node.AddComponent(tempMaterial);
                        if (gizmo != null)
                        {
                            gizmo.Node.Position = node.Position;
                            gizmo.SetGizmoVisible(true);
                            gizmo.Node.Enabled = true;
                        }
                    }
                }
            }
        }
示例#2
0
        public static void SetAsSelected(Node node, Gizmo gizmo, PulsarScene scene)
        {
            StaticModel nodeModel = node.GetComponent <StaticModel>();

            if (nodeModel != null)
            {
                MaterialTemp tempMaterial = new MaterialTemp(nodeModel, scene.GetApplication());
                if (tempMaterial != null)
                {
                    tempMaterial.Name = "materialTemp";
                    tempMaterial.SetTransparentMaterial();

                    node.AddComponent(tempMaterial);
                    if (gizmo != null)
                    {
                        gizmo.Node.Position = node.Position;
                        Debug.Print("GizmoHelper.SetAsSelected - Calling gizmo.SetGizmoVisible with value true for gizmo '" + gizmo.Name);
                        gizmo.SetGizmoVisible(true);
                        Debug.Print("GizmoHelper.SetAsSelected - Setting gizmo.Node.Enabled to true for gizmo '" + gizmo.Name);
                        gizmo.Node.Enabled = true;
                    }
                }
            }
        }
示例#3
0
        public void Initialise()
        {
            PulsarComponentClass = ComponentClass.Node;
            PulsarComponentType  = ComponentType.Gizmo;

            if (Scene != null)
            {
                if (Node != null)
                {
                    _gizmoGeometryNode = Node.CreateChild("gizmoGeometry_" + Node.Name);

                    CustomGeometry customGeometry = _gizmoGeometryNode.CreateComponent <CustomGeometry>();
                    customGeometry.BeginGeometry(0, PrimitiveType.LineList);
                    var material = new Material();
                    material.SetTechnique(0, CoreAssets.Techniques.NoTextureUnlitVCol, 1, 100);
                    material.RenderOrder = 255;
                    customGeometry.SetMaterial(material);

                    //x
                    customGeometry.DefineVertex(Vector3.Zero);
                    customGeometry.DefineColor(Color.Red);
                    customGeometry.DefineVertex(Vector3.UnitX * (_size.X /* * 5f */));
                    customGeometry.DefineColor(Color.Red);
                    //y
                    customGeometry.DefineVertex(Vector3.Zero);
                    customGeometry.DefineColor(Color.Green);
                    customGeometry.DefineVertex(Vector3.UnitY * (_size.Y /* * 5f */));
                    customGeometry.DefineColor(Color.Green);
                    //z
                    customGeometry.DefineVertex(Vector3.Zero);
                    customGeometry.DefineColor(Color.Blue);
                    customGeometry.DefineVertex(Vector3.UnitZ * (_size.Z /* * 5f */));
                    customGeometry.DefineColor(Color.Blue);

                    customGeometry.Commit();

                    var yNode = _gizmoGeometryNode.CreateChild("yTranslateGizmoNode_" + Node.Name);
                    var xNode = _gizmoGeometryNode.CreateChild("zTranslateGizmoNode_" + Node.Name);
                    var zNode = _gizmoGeometryNode.CreateChild("xTranslateGizmoNode_" + Node.Name);

                    var model = yNode.CreateComponent <StaticModel>();
                    model.Model = _scene.GetApplication().ResourceCache.GetModel("Models/Axis.mdl");
                    model.SetMaterial(_scene.GetApplication().ResourceCache.GetMaterial("Materials/GizmoGreen.xml"));
                    model.GetMaterial().RenderOrder = 255;
                    var gizmoGeometryNodePosition   = yNode.Position;
                    gizmoGeometryNodePosition.Y += (_size.Y / 2);
                    yNode.Position = gizmoGeometryNodePosition;
                    yNode.Scale    = Node.Scale / 2;

                    model       = zNode.CreateComponent <StaticModel>();
                    model.Model = _scene.GetApplication().ResourceCache.GetModel("Models/Axis.mdl");
                    model.SetMaterial(_scene.GetApplication().ResourceCache.GetMaterial("Materials/GizmoRed.xml"));
                    model.GetMaterial().RenderOrder = 255;
                    zNode.Rotate(new Quaternion(0, 0, -90));
                    gizmoGeometryNodePosition    = zNode.Position;
                    gizmoGeometryNodePosition.X += (_size.X / 2);
                    zNode.Position = gizmoGeometryNodePosition;
                    zNode.Scale    = Node.Scale / 2;

                    model       = xNode.CreateComponent <StaticModel>();
                    model.Model = _scene.GetApplication().ResourceCache.GetModel("Models/Axis.mdl");
                    model.SetMaterial(_scene.GetApplication().ResourceCache.GetMaterial("Materials/GizmoBlue.xml"));
                    model.GetMaterial().RenderOrder = 255;
                    xNode.Rotate(new Quaternion(90, 0, 0));
                    gizmoGeometryNodePosition    = xNode.Position;
                    gizmoGeometryNodePosition.Z += (_size.Z / 2);
                    xNode.Position = gizmoGeometryNodePosition;
                    xNode.Scale    = Node.Scale / 2;

                    _gizmoGeometryNode.Enabled = false;
                }
            }
        }