public void DrawWireframeCube_(Game game, float posx, float posy, float posz, float scalex, float scaley, float scalez)
    {
        game.platform.GLLineWidth(2);

        game.platform.BindTexture2d(0);

        if (wireframeCube == null)
        {
            ModelData data = WireframeCube.Get();
            wireframeCube = game.platform.CreateModel(data);
        }
        game.GLPushMatrix();
        game.GLTranslate(posx, posy, posz);
        float half = one / 2;

        game.GLScale(scalex * half, scaley * half, scalez * half);
        game.DrawModel(wireframeCube);
        game.GLPopMatrix();
    }
Пример #2
0
        // Init is called on startup.
        public override void Init()
        {
            VSync = false;

            _mainCam.Viewport        = new float4(0, 0, 100, 100);
            _mainCam.BackgroundColor = new float4(0f, 0f, 0f, 1);
            _mainCam.Layer           = -1;

            _sndCam.Viewport        = new float4(60, 60, 40, 40);
            _sndCam.BackgroundColor = new float4(0.5f, 0.5f, 0.5f, 1);
            _sndCam.Layer           = 10;

            _guiCam.ClearColor       = false;
            _guiCam.ClearDepth       = false;
            _guiCam.FrustumCullingOn = false;


            _mainCamTransform = _guiCamTransform = new Transform()
            {
                Rotation    = float3.Zero,
                Translation = new float3(0, 1, -30),
                Scale       = new float3(1, 1, 1)
            };

            _gui = CreateGui();
            // Create the interaction handler
            _sih = new SceneInteractionHandler(_gui);

            _frustum = new WireframeCube();
            var frustumNode = new SceneNode()
            {
                Name       = "Frustum",
                Components = new List <SceneComponent>()
                {
                    new Transform(),
                    ShaderCodeBuilder.MakeShaderEffect(new float4(1, 1, 0, 1), float4.One, 0),
                    _frustum
                }
            };

            var cam = new SceneNode()
            {
                Name       = "MainCam",
                Components = new List <SceneComponent>()
                {
                    _mainCamTransform,
                    _mainCam,
                    ShaderCodeBuilder.MakeShaderEffect(new float4(1, 0, 0, 1), float4.One, 10),
                    new Cube(),
                },
                Children = new ChildList()
                {
                    new SceneNode()
                    {
                        Components = new List <SceneComponent>()
                        {
                            new Transform()
                            {
                                Scale       = new float3(0.5f, 0.5f, 1f),
                                Translation = new float3(0, 0, 1f)
                            },
                            new Cube()
                        }
                    }
                }
            };

            _sndCamTransform = new Transform()
            {
                Rotation    = new float3(M.PiOver6, 0, 0),//float3.Zero,
                Translation = new float3(10, 40, -60),
                Scale       = float3.One
            };

            var cam1 = new SceneNode()
            {
                Name       = "SecondCam",
                Components = new List <SceneComponent>()
                {
                    _sndCamTransform,
                    _sndCam,
                }
            };

            _anlgeHorznd   = _sndCamTransform.Rotation.y;
            _angleVertSnd  = _sndCamTransform.Rotation.x;
            _anlgeHorzMain = _mainCamTransform.Rotation.y;
            _angleVertMain = _mainCamTransform.Rotation.x;

            // Load the rocket model
            _rocketScene = AssetStorage.Get <SceneContainer>("rnd.fus");
            //_rocketScene = Rocket.Build();


            _cubeOneTransform = _rocketScene.Children[0].GetComponent <Transform>();
            //_cubeOneTransform.Rotate(new float3(0, M.PiOver4, 0));

            _rocketScene.Children.Add(cam);
            _rocketScene.Children.Add(cam1);
            _rocketScene.Children.Add(frustumNode);

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRendererForward(_rocketScene);
            _guiRenderer   = new SceneRendererForward(_gui);

            _rotAxis  = float3.UnitY * float4x4.CreateRotationYZ(new float2(M.PiOver4, M.PiOver4));
            _rotPivot = _rocketScene.Children[1].GetComponent <Transform>().Translation;
        }