Beispiel #1
0
        public View(Viewer viewer, Viewport viewport, RenderTargetView target)
        {
            if (viewer == null)
                throw new ArgumentNullException("viewer");
            if (target == null)
                throw new ArgumentNullException("target");

            Viewer = viewer;
            Viewport = viewport;
            Target = target;
        }
        public void PrepareBatchesForViewer(Viewer viewer)
        {
            Debug.Assert(viewer != null);
            viewerForBatches = viewer;

            Sector startSector = DetermineStartSector(viewer);

            batchesToRender.Clear();
            visibleObjects.Clear();

            if (startSector == null)
                return;

            PrepareBatches(startSector);
        }
Beispiel #3
0
        internal void SetupGlobalParameters(Viewer viewer, Timer timer)
        {
            if (viewer == null)
                throw new ArgumentNullException("viewer");
            if (timer == null)
                throw new ArgumentNullException("timer");

            EffectConstantBuffer perViewParameters = Effect.GetConstantBufferByName("Global");

            perViewParameters.SetVariableBySemantic(StandartSemantics.ViewMatrix,
                viewer.ViewMatrix, false);
            perViewParameters.SetVariableBySemantic(StandartSemantics.ProjectionMatrix,
                viewer.ProjectionMatrix, false);
            perViewParameters.SetVariableBySemantic(StandartSemantics.ViewProjectionMatrix,
                viewer.ViewMatrix * viewer.ProjectionMatrix, false);
            perViewParameters.SetVariableBySemantic(StandartSemantics.TotalTime, (float)timer.Time.Total, false);
            perViewParameters.SetVariableBySemantic(StandartSemantics.ElapsedTime, (float)timer.Time.Elapsed, false);
        }
Beispiel #4
0
        protected internal virtual void SetupPerBatchParameters(Viewer viewer)
        {
            if (viewer == null)
                throw new ArgumentNullException("viewer");

            EffectConstantBuffer perBatchParameters = Effect.GetConstantBufferByName("PerBatch");

            perBatchParameters.SetVariableBySemantic(StandartSemantics.WorldMatrix,
                WorldMatrix, false);
            perBatchParameters.SetVariableBySemantic(StandartSemantics.WorldViewMatrix,
                WorldMatrix * viewer.ViewMatrix, false);
            perBatchParameters.SetVariableBySemantic(StandartSemantics.WorldViewProjectionMatrix,
                WorldMatrix * viewer.ViewMatrix * viewer.ProjectionMatrix, false);
        }
        private Sector DetermineStartSector(Viewer viewer)
        {
            var worldManager = (WorldManager) services.GetService(typeof (WorldManager));
            Sector startSector = null;
            foreach (Sector sector in worldManager.RegisteredSectors)
                if (BoundingFrustum.Intersects(viewer.Frustum, sector.Boundary) &&
                    (startSector == null || BoundingBox.Contains(startSector.Boundary, sector.Boundary) == ContainmentType.Contains))
                    startSector = sector;

            return startSector;
        }
 public abstract BatchReadOnlyCollection GetBatches(Viewer viewer);
 public override BatchReadOnlyCollection GetBatches(Viewer viewer)
 {
     return BatchReadOnlyCollection.Empty;
 }
 public override BatchReadOnlyCollection GetBatches(Viewer viewer)
 {
     batch.Boundary = WorldBoundary;
     batch.WorldMatrix = WorldMatrix;
     return batchesRO;
 }