Exemple #1
0
        public Intersection Intersect(Ray ray)
        {
            var           t             = float.MaxValue;
            IRenderObject closestObject = null;

            foreach (var renderObject in RenderObjects)
            {
                var intersectT = renderObject.Intersect(ray);

                if (intersectT == 0 || !(intersectT < t))
                {
                    continue;
                }

                t             = intersectT;
                closestObject = renderObject;
            }

            return(new Intersection
            {
                Distance = t,
                Ray = ray,
                RenderObject = closestObject
            });
        }
Exemple #2
0
        public void AddObject(
            int renderOrder,
            IRenderObject renderObject,
            ShaderProgram vertProg,
            ShaderProgram fragProg,
            ShaderProgram shadowFragProg,
            string debugName = null)
        {
            IInternalRenderObject internalRenderObj = renderObject as IInternalRenderObject;

            if (internalRenderObj == null)
            {
                throw new Exception(
                          $"[{nameof(RenderScene)}] Render objects have to be implemented at engine level");
            }

            //Keep track of all objects
            objects.Add(internalRenderObj);

            //Add them to techniques for rendering
            gbufferTechnique.AddObject(internalRenderObj, vertProg, fragProg, renderOrder, debugName);
            if (shadowFragProg != null)
            {
                shadowTechnique.AddObject(
                    internalRenderObj, vertProg, shadowFragProg, renderOrder, debugName);
            }

            dirty = true;
        }
Exemple #3
0
        /// <summary>
        /// Gets the IIntersectable implementor to be used for picking and snapping. If null,
        /// picking and snapping (if supported at all) are done using OpenGL render-picking.</summary>
        /// <returns>The correct IIntersectable or null, if there is none</returns>
        /// <remarks>There are situations where multiple classes can implement IIntersectable
        /// for a particular adaptable object (like DomNode). This method allows the IRenderObject
        /// to choose the correct one.</remarks>
        public virtual IIntersectable GetIntersectable()
        {
            // See if we've done this expensive search already.
            if (m_intersectableCached)
            {
                return(m_intersectable);
            }

            m_intersectableCached = true;
            m_intersectable       = Adapters.As <IIntersectable>(this);
            if (m_intersectable != null && !m_intersectable.CanIntersect)
            {
                m_intersectable = null;
            }

            // If we were to return an IIntersectable on a different RenderObject, the
            //  intersection test probably won't be valid. For example, if RenderObject A
            //  is the TranslateManipulator and it does not implement IIntersectable,
            //  but RenderObject B is a RenderSubMesh which does, and both A & B
            //  are attached to the same object, we can't return the IIntersectable
            //  of the RenderSubMesh when requested on a TranslateManipulator.
            if (m_intersectable != null)
            {
                IRenderObject other = m_intersectable as IRenderObject;
                if (other != null && other != this as IRenderObject)
                {
                    m_intersectable = null;
                }
            }

            return(m_intersectable);
        }
Exemple #4
0
        /// <summary>
        /// Adds a render object of the given generic type to the render object list</summary>
        /// <typeparam name="T">The type of render object to add</typeparam>
        /// <param name="addOnSubTree">Whether to add recusively on sub tree</param>
        /// <returns>True if the render object was successfully added</returns>
        public bool AddRenderObject <T>(bool addOnSubTree)
            where T : class, IRenderObject
        {
            bool appended = false;

            if (m_sourceObject != null)
            {
                //IRenderObject renderObject = m_sourceObject.CreateInterface<T>();
                IRenderObject renderObject = m_sourceObject.As <T>();
                if (renderObject != null)
                {
                    m_renderObjects.Add(renderObject);
                    appended = true;
                }
            }

            if (addOnSubTree)
            {
                foreach (SceneNode child in m_children)
                {
                    child.AddRenderObject <T>(addOnSubTree);
                }
            }

            return(appended);
        }
Exemple #5
0
 /// <summary>
 /// Constructs a hit record representing either a windowed selection or single-click selection.
 /// For single clicks, set the WorldIntersection property and possibly Normal and NearestVert properties.</summary>
 /// <param name="graphPath">The graph path to the RenderObject</param>
 /// <param name="renderObject">The RenderObject that was hit</param>
 /// <param name="transform">The world transform of the RenderObject</param>
 /// <param name="renderObjectData">Application specific hit data</param>
 public HitRecord(SceneNode[] graphPath, IRenderObject renderObject, Matrix4F transform, uint[] renderObjectData)
 {
     m_graphPath         = graphPath;
     m_renderObject      = renderObject;
     m_transform         = transform;
     m_renderObjectData  = renderObjectData;
     m_useIntersectionPt = false;
 }
Exemple #6
0
 public Luz(IRenderObject luzMesh, Color color, Vector3 posicion)
 {
     this.luzMesh     = luzMesh;
     this.luzColor    = color;
     this.luzPosicion = posicion;
     //TODO ver de mover toda la luz 5 veces.
     this.luzPosicion.Y *= 5;
 }
Exemple #7
0
 public Luz(IRenderObject luzMesh, Color color, Vector3 posicion)
 {
     this.luzMesh = luzMesh;
     this.luzColor = color;
     this.luzPosicion = posicion;
     //TODO ver de mover toda la luz 5 veces.
     this.luzPosicion.Y *= 5;
 }
Exemple #8
0
 /// <summary>
 /// Constructor</summary>
 /// <param name="renderObject">RenderObject. A reference is held to this, so that IRenderObject.Dispatch
 /// can be called.</param>
 /// <param name="transform">Transform to use when dispatching the RenderObject; a reference is held</param>
 /// <param name="graphPath">Graph path leading to RenderObject; a reference is held</param>
 /// <param name="renderState">RenderState to use for RenderObject; is copied</param>
 public TraverseNode(
     IRenderObject renderObject,
     Matrix4F transform,
     Stack<SceneNode> graphPath,
     RenderState renderState)
 {
     Init(renderObject, transform, graphPath, renderState);
 }
Exemple #9
0
 /// <summary>
 /// Constructor</summary>
 /// <param name="renderObject">RenderObject. A reference is held to this, so that IRenderObject.Dispatch
 /// can be called.</param>
 /// <param name="transform">Transform to use when dispatching the RenderObject; a reference is held</param>
 /// <param name="graphPath">Graph path leading to RenderObject; a reference is held</param>
 /// <param name="renderState">RenderState to use for RenderObject; is copied</param>
 public TraverseNode(
     IRenderObject renderObject,
     Matrix4F transform,
     Stack <SceneNode> graphPath,
     RenderState renderState)
 {
     Init(renderObject, transform, graphPath, renderState);
 }
Exemple #10
0
 public bool AddRenderObject(int id, IRenderObject render)
 {
     if (m_toRender.ContainsKey(id))
     {
         return(false);
     }
     m_toRender.Add(id, render);
     return(true);
 }
        /// <summary>
        /// Builds just this SceneNode without traversing any children of the source object</summary>
        /// <param name="source">The source object to be represented by the new SceneNode</param>
        /// <param name="parent">The parent that the new SceneNode will be attached to</param>
        /// <param name="forceBuild">If true, even if there are no constraints and no renderable objects,
        /// the SceneNode is still created</param>
        /// <returns>Either:
        /// 1. A new SceneNode, attached to 'parent'. The child objects should be traversed.
        /// 2. 'parent', which means that this source object had no useful info and 'forceBuild' was false.
        /// The child objects should be traversed.
        /// 3. null if this source object is an object reference and that reference should not be
        /// rendered, so the caller must not traverse the children of this source object.</returns>
        private SceneNode BuildNodeInternal(object source, SceneNode parent, bool forceBuild)
        {
            // Check if source object is an object reference and if it's renderable.
            if (parent.Source != null)
            {
                IRenderableParent renderableParent = parent.Source.As <IRenderableParent>();
                if (renderableParent != null)
                {
                    if (renderableParent.IsRenderableChild(source) == false)
                    {
                        return(null);
                    }
                }
            }

            SceneNode node = new SceneNode(source);

            // Next build RenderObjects
            foreach (IBuildSceneNode buildNode in source.AsAll <IBuildSceneNode>())
            {
                if (buildNode.CreateByGraphBuilder)
                {
                    // Build render objects
                    IRenderObject renderObject = buildNode as IRenderObject;
                    if (renderObject != null)
                    {
                        if (renderObject.Init(node))
                        {
                            // Add to node which will sort by type dependency.
                            node.RenderObjects.Add(renderObject);
                        }
                    }

                    // Call the OnBuildNode method
                    buildNode.OnBuildNode(node);
                }
            }

            if (node.RenderObjects.Count > 0 ||
                node.Source.Is <IBoundable>() ||
                forceBuild)
            {
                if (parent != null)
                {
                    parent.Children.Add(node);
                }
            }
            else
            {
                node = parent;
            }

            return(node);
        }
Exemple #12
0
 /// <summary>
 /// Initializes instance</summary>
 /// <param name="renderObject">RenderObject. A reference is held to this, so that IRenderObject.Dispatch
 /// can be called.</param>
 /// <param name="transform">Transform to use when dispatching the RenderObject; a reference is held</param>
 /// <param name="graphPath">Graph path leading to RenderObject; a reference is held</param>
 /// <param name="renderState">RenderState to use for RenderObject; is copied</param>
 public void Init(
     IRenderObject renderObject,
     Matrix4F transform,
     Stack <SceneNode> graphPath,
     RenderState renderState)
 {
     m_renderObject = renderObject;
     m_transform    = transform;
     m_renderState.Init(renderState);
     m_graphPath = graphPath.ToArray();//faster to create every time than to cache!
 }
Exemple #13
0
        private void RegisterAnimationSet(AnimationSet animationSet, int id, IRenderObject renderObject)
        {
            AnimationController animationController = renderObject.AnimationController;

            animationController.RegisterAnimationSet(animationSet);
            animationController.SetTrackAnimationSet(id, animationSet);
            animationController.SetTrackWeight(id, 1);
            animationController.SetTrackSpeed(id, 0);
            animationController.SetTrackPosition(id, 0);
            animationController.SetTrackPriority(id, TrackPriority.High);
        }
Exemple #14
0
    protected virtual void OnDestroy()
    {
        if (Root.instance && m_sceneObject)
        {
            m_sceneObject.Destroy();
        }

        enabled        = false;
        m_sceneObject  = null;
        m_renderObject = null;
    }
Exemple #15
0
 /// <summary>
 /// Initializes instance</summary>
 /// <param name="renderObject">RenderObject. A reference is held to this, so that IRenderObject.Dispatch
 /// can be called.</param>
 /// <param name="transform">Transform to use when dispatching the RenderObject; a reference is held</param>
 /// <param name="graphPath">Graph path leading to RenderObject; a reference is held</param>
 /// <param name="renderState">RenderState to use for RenderObject; is copied</param>
 public void Init(
     IRenderObject renderObject,
     Matrix4F transform,
     Stack<SceneNode> graphPath,
     RenderState renderState)
 {
     m_renderObject = renderObject;
     m_transform = transform;
     m_renderState.Init(renderState);
     m_graphPath = graphPath.ToArray();//faster to create every time than to cache!
 }
Exemple #16
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // základní prvky samotné okno hry
            font = new QFont(new Font(DefaultFontFamily, 16f));
            cursor = LoadCursor("cursor_normal.cur");

            // přídavky
            gameMenu = new GameMenu(this);

            // získá poslední velikost a pozici okna
            prevWindowRect = new Rectangle(Location.X, Location.Y, Width, Height);
        }
Exemple #17
0
        public static void PushDebugGroup(string verb, IRenderObject obj)
        {
            if (!Enabled)
            {
                return;
            }

            var objName = obj.Name;

            if (string.IsNullOrEmpty(objName))
            {
                objName = obj.GetType().Name;
            }
            var name = $"{verb} GameObject {obj.Id} [{objName}]";

            GL.PushDebugGroup(DebugSourceExternal.DebugSourceApplication, obj.Id, name.Length, name);
        }
Exemple #18
0
        /// <summary>
        /// Checks the given RenderObject against the filter and returns true if it is pickable</summary>
        /// <param name="renderObject">RenderObject checked</param>
        /// <returns>True iff the RenderObject is pickable according to the filter</returns>
        private bool FilterByType(IRenderObject renderObject)
        {
            if (m_typesFilter == null)
            {
                return(true);
            }

            foreach (Type t in m_typesFilter)
            {
                if (t.IsAssignableFrom(renderObject.GetType()))
                {
                    return(true);
                }
            }

            return(false);
        }
        public override int AddRenderObject(IRenderObject renderObject)
        {
            int id = base.AddRenderObject(renderObject);
            foreach (var pair in animationSets)
            {
                RegisterAnimationSet(pair.Value, pair.Key, renderObject);
            }

            var handler = RenderObjectAdded;
            if (handler != null)
            {
                handler(this, new EventArgs());
            }

            Render();
            return id;
        }
Exemple #20
0
        public virtual int AddRenderObject(IRenderObject renderObject)
        {
            int id;

            if (renderObjectFreeIds.Count > 0)
            {
                id = renderObjectFreeIds[0];
                renderObjectFreeIds.RemoveAt(0);
            }
            else
            {
                id = renderObjects.Count;
            }

            renderObjects.Add(id, renderObject);

            Render();
            return(id);
        }
Exemple #21
0
        public override int AddRenderObject(IRenderObject renderObject)
        {
            int id = base.AddRenderObject(renderObject);

            foreach (var pair in animationSets)
            {
                RegisterAnimationSet(pair.Value, pair.Key, renderObject);
            }

            var handler = RenderObjectAdded;

            if (handler != null)
            {
                handler(this, new EventArgs());
            }

            Render();
            return(id);
        }
Exemple #22
0
 public void SetRenderObject(IRenderObject renderObject)
 {
     renderObjectArray.Add(renderObject);
 }
Exemple #23
0
 public void AddObject(IRenderObject a_renderObject)
 {
     m_internalGraphics.AddObject(a_renderObject);
 }
Exemple #24
0
 public void RemoveObject(IRenderObject a_renderObject)
 {
     m_internalGraphics.RemoveObject(a_renderObject);
 }
 public void AddRenderObject(IRenderObject renderObject)
 {
     _objectsToRender.Add(renderObject);
 }
Exemple #26
0
 public void AddRenderObject(IRenderObject renderObject)
 {
     renderObjects.Add(renderObject);
 }
Exemple #27
0
    }                                                          // 0x007293D0-0x00729460

    public void UnregisterRenderObject(IRenderObject obj)
    {
    }                                                            // 0x00729460-0x007294F0
Exemple #28
0
 public RenderObjectHandle(IShader shader)
 {
     obj = shader;
     type = RenderObjectType.SHADER;
 }
Exemple #29
0
 public RenderObjectHandle(Options options)
 {
     obj  = options;
     type = RenderObjectType.OPTIONS;
 }
Exemple #30
0
 public void AddObject(IRenderObject a_object)
 {
 }
    public CommandBuffer GetCommandBuffer() => default; // 0x008C47A0-0x008C47B0

    public void RegisterRenderObject(IRenderObject obj)
    {
    }                                                          // 0x008C47B0-0x008C4840
    }                                                          // 0x008C47B0-0x008C4840

    public void UnregisterRenderObject(IRenderObject obj)
    {
    }                                                            // 0x008C4840-0x008C48D0
Exemple #33
0
 public void RemoveRenderObject(IRenderObject o)
 {
     renderables.Remove(o);
 }
Exemple #34
0
 public RenderObjectHandle(Modifier modifier)
 {
     obj = modifier;
     type = RenderObjectType.MODIFIER;
 }
Exemple #35
0
    public RenderTexture GetMainRenderTexture() => default; // 0x007293C0-0x007293D0

    public void RegisterRenderObject(IRenderObject obj)
    {
    }                                                          // 0x007293D0-0x00729460
Exemple #36
0
 public RenderObjectHandle(ITesselatable tesselatable)
 {
     obj = new Geometry(tesselatable);
     type = RenderObjectType.GEOMETRY;
 }
Exemple #37
0
 public void AddRenderObject(IRenderObject o)
 {
     renderables.Add(o);
 }
Exemple #38
0
 public RenderObjectHandle(PrimitiveList prims)
 {
     obj = new Geometry(prims);
     type = RenderObjectType.GEOMETRY;
 }
Exemple #39
0
 public void RemoveObject(IRenderObject a_object)
 {
     m_disposalQueue.Enqueue(a_object);
 }
Exemple #40
0
 public RenderObjectHandle(Instance instance)
 {
     obj = instance;
     type = RenderObjectType.INSTANCE;
 }
 private void RegisterAnimationSet(AnimationSet animationSet, int id, IRenderObject renderObject)
 {
     AnimationController animationController = renderObject.AnimationController;
     animationController.RegisterAnimationSet(animationSet);
     animationController.SetTrackAnimationSet(id, animationSet);
     animationController.SetTrackWeight(id, 1);
     animationController.SetTrackSpeed(id, 0);
     animationController.SetTrackPosition(id, 0);
     animationController.SetTrackPriority(id, TrackPriority.High);
 }
Exemple #42
0
 public RenderObjectHandle(LightSource light)
 {
     obj = light;
     type = RenderObjectType.LIGHT;
 }
Exemple #43
0
 public void AddObject(IRenderObject a_object)
 {
     m_inputQueue.Enqueue(a_object);
 }
Exemple #44
0
 public RenderObjectHandle(CameraBase camera)
 {
     obj = camera;
     type = RenderObjectType.CAMERA;
 }
Exemple #45
0
        /// <summary>
        /// Checks the given RenderObject against the filter and returns true if it is pickable</summary>
        /// <param name="renderObject">RenderObject checked</param>
        /// <returns>True iff the RenderObject is pickable according to the filter</returns>
        private bool FilterByType(IRenderObject renderObject)
        {
            if (m_typesFilter == null)
                return true;

            foreach (Type t in m_typesFilter)
            {
                if (t.IsAssignableFrom(renderObject.GetType()))
                    return true;
            }
            
            return false;
        }
Exemple #46
0
 public RenderObjectHandle(Options options)
 {
     obj = options;
     type = RenderObjectType.OPTIONS;
 }
Exemple #47
0
 public void RemoveObject(IRenderObject a_object)
 {
 }
Exemple #48
0
        public virtual int AddRenderObject(IRenderObject renderObject)
        {
            int id;
            if (renderObjectFreeIds.Count > 0)
            {
                id = renderObjectFreeIds[0];
                renderObjectFreeIds.RemoveAt(0);
            }
            else
            {
                id = renderObjects.Count;
            }

            renderObjects.Add(id, renderObject);

            Render();
            return id;
        }