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 }); }
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; }
/// <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); }
/// <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); }
/// <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; }
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; }
/// <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); }
/// <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); }
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); }
/// <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! }
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); }
protected virtual void OnDestroy() { if (Root.instance && m_sceneObject) { m_sceneObject.Destroy(); } enabled = false; m_sceneObject = null; m_renderObject = null; }
/// <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! }
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); }
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); }
/// <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; }
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); }
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); }
public void SetRenderObject(IRenderObject renderObject) { renderObjectArray.Add(renderObject); }
public void AddObject(IRenderObject a_renderObject) { m_internalGraphics.AddObject(a_renderObject); }
public void RemoveObject(IRenderObject a_renderObject) { m_internalGraphics.RemoveObject(a_renderObject); }
public void AddRenderObject(IRenderObject renderObject) { _objectsToRender.Add(renderObject); }
public void AddRenderObject(IRenderObject renderObject) { renderObjects.Add(renderObject); }
} // 0x007293D0-0x00729460 public void UnregisterRenderObject(IRenderObject obj) { } // 0x00729460-0x007294F0
public RenderObjectHandle(IShader shader) { obj = shader; type = RenderObjectType.SHADER; }
public RenderObjectHandle(Options options) { obj = options; type = RenderObjectType.OPTIONS; }
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
public void RemoveRenderObject(IRenderObject o) { renderables.Remove(o); }
public RenderObjectHandle(Modifier modifier) { obj = modifier; type = RenderObjectType.MODIFIER; }
public RenderTexture GetMainRenderTexture() => default; // 0x007293C0-0x007293D0 public void RegisterRenderObject(IRenderObject obj) { } // 0x007293D0-0x00729460
public RenderObjectHandle(ITesselatable tesselatable) { obj = new Geometry(tesselatable); type = RenderObjectType.GEOMETRY; }
public void AddRenderObject(IRenderObject o) { renderables.Add(o); }
public RenderObjectHandle(PrimitiveList prims) { obj = new Geometry(prims); type = RenderObjectType.GEOMETRY; }
public void RemoveObject(IRenderObject a_object) { m_disposalQueue.Enqueue(a_object); }
public RenderObjectHandle(Instance instance) { obj = instance; type = RenderObjectType.INSTANCE; }
public RenderObjectHandle(LightSource light) { obj = light; type = RenderObjectType.LIGHT; }
public void AddObject(IRenderObject a_object) { m_inputQueue.Enqueue(a_object); }
public RenderObjectHandle(CameraBase camera) { obj = camera; type = RenderObjectType.CAMERA; }
/// <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 void RemoveObject(IRenderObject a_object) { }
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; }