コード例 #1
0
ファイル: Scene.cs プロジェクト: MetalYos/OpenGlNet
        public void Render()
        {
            SceneRenderer.Clear(0.2f, 0.4f, 0.6f, 1.0f);
            SceneRenderer.ClearFrameBuffer(0.0f, 0.0f, 0.0f, 1.0f);

            if (m_CurrentViewedCamera == null)
            {
                return;
            }

            // Render objects
            int i       = -1;
            var genObjs = m_Objects.GetGenObjects().Values;
            var lights  = m_Objects.GetLights();

            foreach (var genObj in genObjs)
            {
                i++;

                if (genObj.Name == Settings.NameMainCamera ||
                    genObj.Name == m_CurrentViewedCamera.Name ||
                    genObj.Name == Settings.NameMainLight ||
                    !genObj.IsVisible)
                {
                    continue;
                }

                genObj.Render(SceneRenderer, m_CurrentViewedCamera, lights);
                if (select)
                {
                    genObj.DrawForSelection(SceneRenderer, m_CurrentViewedCamera, MathHelper.GetColorFromIndex(i, genObjs.Count));
                }
            }

            // Render Ground Plane
            m_GroundPlane.DrawWireframe(SceneRenderer, m_CurrentViewedCamera, 0.5f,
                                        new vec4(0.6f, 0.6f, 0.6f, 1.0f));

            // Render view origin
            mat4 axesModelMatrix = new mat4(1.0f);

            m_OriginAxes.Render(SceneRenderer, m_CurrentViewedCamera, ref axesModelMatrix);

            // Select object if needed
            if (select)
            {
                var buffer = SceneRenderer.FrameBuffer.GetPixelData(mousePos[0], mousePos[1], 1, 1);
                int index  = MathHelper.GetIndexFromColor(new vec4(buffer[0]), genObjs.Count);

                var iter = genObjs.GetEnumerator();
                for (int j = 0; j <= index; j++)
                {
                    iter.MoveNext();
                }

                SelectObject(iter.Current, addSelect);
                select = false;
            }
        }
コード例 #2
0
        public void Clear()
        {
            if (_scene != null)
            {
                _scene.Clear();
                SceneRenderer.WorkMode = false;
            }

            if (_text != null)
            {
                _text.Clear();
            }
        }