// Ready function, called once at the beginning of the scene when all children are ready
    public override void _Ready()
    {
        // Assign required nodes
        objectBody      = GetNode <StaticBody>("ViewportContainer/Viewport/ObjectRoot/Object1");
        ray             = GetNode <RayCast>("ViewportContainer/Viewport/ObjectRoot/HiddenLineRay");
        freeCameraRoot  = GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/CameraRoot");
        orthoCameraRoot = GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/OrthoCameraRoot");

        // Populate the list of planes with the nodes of each BoxPlaneControl object
        planes = new Spatial[PLANE_COUNT] {
            GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/FrontPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/RightPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/BackPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/LeftPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/TopPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/BottomPlaneControl")
        };

        // All faces are hidden at first
        isFaceShown = new bool[PLANE_COUNT] {
            false, false, false, false, false, false
        };

        // Initialize the required static variables in the PlaneControl class
        PlaneControl.Initialize(objectBody.GetChild <MeshInstance>(0), ray, PlaneControl.ORTHOGRAPHIC);

        // Set the display size
        PlaneControl.SetScreenSize(PLANE_X_SCALE, PLANE_Y_SCALE, MAX_FOCUS);

        // Set the zoom of the PlaneControl class
        // A zoom value of 1 is set because this scene requires orthographic projection (without scaling to screen size)
        PlaneControl.SetZoom(MAX_FOCUS);

        // Set the projection colours
        ProjectionRoot.SetColours(true, false);
    }
Пример #2
0
    // Ready function, called once at the beginning of the scene when all children are ready
    public override void _Ready()
    {
        // Assignment of required nodes
        // ObjectRoot (root of all 3D nodes)
        objectRoot = GetNode <Spatial>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/ObjectRoot");

        // PlaneControl Objects
        topViewPlane       = GetNode <Spatial>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/ObjectRoot/TopViewPlane");
        frontViewPlane     = GetNode <Spatial>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/ObjectRoot/FrontViewPlane");
        sideViewPlane      = GetNode <Spatial>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/ObjectRoot/RightViewPlane");
        auxiliaryViewPlane = GetNode <Spatial>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/ObjectRoot/AuxiliaryViewPlane");

        // ProjectionRoot Objects
        mainDisplayRoot   = GetNode <Node2D>("HorizontalViewContainer/MainProjectionDisplayContainer/MainProjectionViewport/ProjectionRoot");
        topViewRoot       = GetNode <Node2D>("HorizontalViewContainer/MainProjectionDisplayContainer/ViewGridContainer/TopViewportContainer/TopViewport/TopViewRoot");
        frontViewRoot     = GetNode <Node2D>("HorizontalViewContainer/MainProjectionDisplayContainer/ViewGridContainer/FrontViewportContainer/FrontViewport/FrontViewRoot");
        sideViewRoot      = GetNode <Node2D>("HorizontalViewContainer/MainProjectionDisplayContainer/ViewGridContainer/SideViewportContainer/SideViewport/SideViewRoot");
        auxiliaryViewRoot = GetNode <Node2D>("HorizontalViewContainer/MainProjectionDisplayContainer/ViewGridContainer/AuxiliaryViewportContainer/AuxiliaryViewport/AuxiliaryViewRoot");

        // UI Control Nodes
        ControlsNode     = GetNode <Control>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/Controls");
        FocusZoomSlider  = GetNode <HSlider>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/Controls/ControlsPanel/ViewControl/FocusZoomSlider");
        ObjectXDegSlider = GetNode <HSlider>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/Controls/ControlsPanel/ObjectControl/HBoxContainer/SlidersVBoxContainer/ObjectXDegSlider");
        ObjectYDegSlider = GetNode <HSlider>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/Controls/ControlsPanel/ObjectControl/HBoxContainer/SlidersVBoxContainer/ObjectYDegSlider");
        ObjectZDegSlider = GetNode <HSlider>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/Controls/ControlsPanel/ObjectControl/HBoxContainer/SlidersVBoxContainer/ObjectZDegSlider");
        viewList         = GetNode <OptionButton>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/Controls/ControlsPanel/ViewControl/ViewSelectList");
        viewGrid         = GetNode <GridContainer>("HorizontalViewContainer/MainProjectionDisplayContainer/ViewGridContainer");

        // RayCast Node
        ray = GetNode <RayCast>("HorizontalViewContainer/ObjectViewContainter/ObjectViewport/ObjectRoot/HiddenLineRayCast");

        // Populate the objects array with the required NodePaths
        for (int index = 0; index < OBJECT_COUNT; index++)
        {
            objects[index] = objectRoot.GetChild <StaticBody>(index + FIRST_OBJECT_INDEX).GetPath();
        }

        // The second object is initially selected
        currentObjectIndex = 1;

        // Get the object's static body from the selected NodePath in the objects array
        objectBody = GetNode <StaticBody>(objects[currentObjectIndex]);

        // Initialize the required static variables in the PlaneControl class
        PlaneControl.Initialize(objectBody.GetChild <MeshInstance>(0), ray, PlaneControl.ORTHOGRAPHIC);

        // Set the screen size so that the projection is properly scaled
        PlaneControl.SetScreenSize(LARGE_PLANE_X_SCALE, LARGE_PLANE_Y_SCALE, MAX_FOCUS);

        // Set the zoom value of the PlaneControl class according to the focus/zoom slider's value
        PlaneControl.SetZoom((float)FocusZoomSlider.Value);

        // Set the colours that the projection is to be displayed in, by specifying whether the projection is on the cube, and whether the colours have been switched
        ProjectionRoot.SetColours(false, false);

        // Auxiliary view is disabled at first
        isAuxEnabled = false;

        // Set the display nodes and display onto the screen
        SetDisplay();
        Display();
    }
Пример #3
0
    // This function sets which viewport/display to display to, as well as which view(s) is (are) visible
    public static void SetDisplay()
    {
        // Set grid view as invisible and main view as visible
        viewGrid.Visible        = false;
        mainDisplayRoot.Visible = true;

        // Set planeControl objects (in 3D view) as invisible
        topViewPlane.Visible       = false;
        frontViewPlane.Visible     = false;
        sideViewPlane.Visible      = false;
        auxiliaryViewPlane.Visible = false;

        // Set the display size to the main viewport size
        PlaneControl.SetScreenSize(LARGE_PLANE_X_SCALE, LARGE_PLANE_Y_SCALE, MAX_FOCUS);

        if (selectedView == (int)Views.ALL_VIEWS)
        {
            // If all views are visible, set the grid view to visible and main view to invisible
            viewGrid.Visible        = true;
            mainDisplayRoot.Visible = false;

            // Set the individual view display ndoes
            topViewPlane.Call("SetDisplayNode", topViewRoot.GetPath());
            frontViewPlane.Call("SetDisplayNode", frontViewRoot.GetPath());
            sideViewPlane.Call("SetDisplayNode", sideViewRoot.GetPath());
            auxiliaryViewPlane.Call("SetDisplayNode", auxiliaryViewRoot.GetPath());

            // Set all planeControl objects (in 3D view) as visible
            topViewPlane.Visible   = true;
            frontViewPlane.Visible = true;
            sideViewPlane.Visible  = true;

            // If auxiliary view is enabled for this object, make the auxiliary planeControl object visible
            if (isAuxEnabled)
            {
                auxiliaryViewPlane.Visible = true;
            }

            // If all views are selected, change the display size to the small viewport size
            PlaneControl.SetScreenSize(SMALL_PLANE_X_SCALE, SMALL_PLANE_Y_SCALE, MAX_FOCUS);
        }
        else if (selectedView == (int)Views.TOP_VIEW)
        {
            // If top view is selected, set top view display node and set 3D planeControl object as visible
            topViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            topViewPlane.Visible = true;
        }
        else if (selectedView == (int)Views.FRONT_VIEW)
        {
            // If front view is selected, set front view display node and set 3D planeControl object as visible
            frontViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            frontViewPlane.Visible = true;
        }
        else if (selectedView == (int)Views.SIDE_VIEW)
        {
            // If side view is selected, set side view display node and set 3D planeControl object as visible
            sideViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            sideViewPlane.Visible = true;
        }
        else if (selectedView == (int)Views.AUX_VIEW && isAuxEnabled)
        {
            // If auxiliary view is selected, set auxiliary view display node and set 3D planeControl object as visible
            auxiliaryViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            auxiliaryViewPlane.Visible = true;
        }
    }