GetModelMatrix() public method

Get model matrix that transform this renderer from model space to world space.
public GetModelMatrix ( ) : MarkableStruct
return MarkableStruct
        private void RenderForPicking(RendererBase sceneElement, PickEventArgs arg)
        {
            if (sceneElement != null)
            {
                mat4 parentCascadeModelMatrix = arg.ModelMatrixStack.Peek();
                sceneElement.cascadeModelMatrix = sceneElement.GetModelMatrix(parentCascadeModelMatrix);

                var      pickable = sceneElement as IPickable;
                TwoFlags flags    = (pickable != null) ? pickable.EnablePicking : TwoFlags.None;
                bool     before   = (pickable != null) && ((flags & TwoFlags.BeforeChildren) == TwoFlags.BeforeChildren);
                bool     children = (pickable == null) || ((flags & TwoFlags.Children) == TwoFlags.Children);

                if (before)
                {
                    pickable.PickingBaseId += arg.RenderedVertexCount;
                    pickable.RenderForPicking(arg);
                    arg.RenderedVertexCount += pickable.GetVertexCount();
                }

                if (children)
                {
                    arg.ModelMatrixStack.Push(sceneElement.cascadeModelMatrix);
                    foreach (var item in sceneElement.Children)
                    {
                        this.RenderForPicking(item, arg);
                    }
                    arg.ModelMatrixStack.Pop();
                }
            }
        }
Esempio n. 2
0
        public static void Render(RendererBase sceneElement, RenderEventArgs arg)
        {
            if (sceneElement != null)
            {
                mat4 parentCascadeModelMatrix = arg.ModelMatrixStack.Peek();
                sceneElement.cascadeModelMatrix = sceneElement.GetModelMatrix(parentCascadeModelMatrix);

                var        renderable = sceneElement as IRenderable;
                ThreeFlags flags      = (renderable != null) ? renderable.EnableRendering : ThreeFlags.None;
                bool       before     = (renderable != null) && ((flags & ThreeFlags.BeforeChildren) == ThreeFlags.BeforeChildren);
                bool       children   = (renderable == null) || ((flags & ThreeFlags.Children) == ThreeFlags.Children);
                bool       after      = (renderable != null) && ((flags & ThreeFlags.AfterChildren) == ThreeFlags.AfterChildren);

                if (before)
                {
                    renderable.RenderBeforeChildren(arg);
                }

                if (children)
                {
                    arg.ModelMatrixStack.Push(sceneElement.cascadeModelMatrix);
                    foreach (var item in sceneElement.Children)
                    {
                        RenderAction.Render(item, arg);
                    }
                    arg.ModelMatrixStack.Pop();
                }

                if (after)
                {
                    renderable.RenderAfterChildren(arg);
                }
            }
        }
Esempio n. 3
0
        private void RenderForPicking(RendererBase sceneElement, LegacyPickEventArgs arg, ref uint currentName)
        {
            var pickable = sceneElement as ILegacyPickable;

            if (pickable != null)
            {
                mat4 parentCascadeModelMatrix = arg.ModelMatrixStack.Peek();
                sceneElement.cascadeModelMatrix = sceneElement.GetModelMatrix(parentCascadeModelMatrix);

                ThreeFlags flags = pickable.EnableLegacyPicking;
                if ((flags & ThreeFlags.BeforeChildren) == ThreeFlags.BeforeChildren)
                {
                    //  Load and map the name.
                    GL.Instance.LoadName(currentName);
                    arg.hitMap[currentName] = sceneElement;

                    pickable.RenderBeforeChildrenForLegacyPicking(arg);

                    //  Increment the name.
                    currentName++;
                }

                if ((flags & ThreeFlags.Children) == ThreeFlags.Children)
                {
                    arg.ModelMatrixStack.Push(sceneElement.cascadeModelMatrix);
                    foreach (var item in sceneElement.Children)
                    {
                        this.RenderForPicking(item, arg, ref currentName);
                    }
                    arg.ModelMatrixStack.Pop();
                }

                //if ((flags & ThreeFlags.AfterChildren) == ThreeFlags.AfterChildren)
                //{
                //    //  Load and map the name.
                //    GL.Instance.LoadName(currentName);
                //    arg.hitMap[currentName] = sceneElement;

                //    pickable.RenderAfterChildrenForLegacyPicking(arg);

                //    //  Increment the name.
                //    currentName++;
                //}
            }
        }