Example #1
0
        /// <summary>
        /// Cleans up the rendering view of the models.
        /// </summary>
        /// <param name="frustumCuller">The area where models can be viewed from the camera.</param>
        /// <param name="frustumCullMode">The mode of the culling.</param>
        public void FrustumCull(FrustumCulling frustumCuller, EnumFrustumCullMode frustumCullMode)
        {
            indicesGroupsCount = 0;
            int multiplier = (IntPtr.Size == 8) ? 2 : 1;

            RenderedTriangles = 0;
            AllocatedTris     = 0;

            for (int i = 0; i < poolLocations.Count; i++)
            {
                ModelDataPoolLocation location = poolLocations[i];

                int size = location.IndicesEnd - location.IndicesStart;
                if (location.IsVisible(frustumCullMode, frustumCuller))
                {
                    indicesStartsByte[indicesGroupsCount * multiplier] = location.IndicesStart * 4; // Offset in bytes, not ints
                    indicesSizes[indicesGroupsCount] = size;

                    RenderedTriangles += size / 3;

                    indicesGroupsCount++;
                }

                AllocatedTris += size / 3;
            }
        }
 /// <summary>
 /// Creates a new Mesh Data Pool
 /// </summary>
 /// <param name="masterPool">The master mesh data pool manager</param>
 /// <param name="frustumCuller">the Frustum Culler for the Pool</param>
 /// <param name="capi">The Client API</param>
 /// <param name="defaultVertexPoolSize">Size allocated for the Vertices.</param>
 /// <param name="defaultIndexPoolSize">Size allocated for the Indices</param>
 /// <param name="maxPartsPerPool">The maximum number of parts for this pool.</param>
 /// <param name="customFloats">Additional float data</param>
 /// <param name="customBytes">Additional byte data</param>
 /// <param name="customInts">additional int data</param>
 public MeshDataPoolManager(MeshDataPoolMasterManager masterPool, FrustumCulling frustumCuller, ICoreClientAPI capi, int defaultVertexPoolSize, int defaultIndexPoolSize, int maxPartsPerPool, CustomMeshDataPartFloat customFloats = null, CustomMeshDataPartShort customShorts = null, CustomMeshDataPartByte customBytes = null, CustomMeshDataPartInt customInts = null)
 {
     this.masterPool            = masterPool;
     this.frustumCuller         = frustumCuller;
     this.capi                  = capi;
     this.customFloats          = customFloats;
     this.customBytes           = customBytes;
     this.customInts            = customInts;
     this.customShorts          = customShorts;
     this.defaultIndexPoolSize  = defaultIndexPoolSize;
     this.defaultVertexPoolSize = defaultVertexPoolSize;
     this.maxPartsPerPool       = maxPartsPerPool;
 }
Example #3
0
        public bool IsVisible(EnumFrustumCullMode mode, FrustumCulling culler)
        {
            switch (mode)
            {
            case EnumFrustumCullMode.CullInstant:
                return(!Hide && CullVisible[VisibleBufIndex].value && culler.SphereInFrustum(FrustumCullSphere));

            case EnumFrustumCullMode.CullInstantShadowPassNear:
                return(!Hide && CullVisible[VisibleBufIndex].value && culler.SphereInFrustumShadowPass(FrustumCullSphere));

            case EnumFrustumCullMode.CullInstantShadowPassFar:
                return(!Hide && CullVisible[VisibleBufIndex].value && culler.SphereInFrustumShadowPass(FrustumCullSphere) && LodLevel >= 1);

            case EnumFrustumCullMode.CullNormal:
                return(!Hide && CullVisible[VisibleBufIndex].value && UpdateVisibleFlag(culler.SphereInFrustumAndRange(FrustumCullSphere, FrustumVisible, LodLevel)));

            default:
                return(!Hide);
            }
        }
Example #4
0
 /// <summary>
 /// Draw the model.
 /// </summary>
 /// <param name="capi">The core client API</param>
 /// <param name="frustumCuller">The area where models can be viewed from the camera.</param>
 /// <param name="frustumCullMode">The mode of the culling.</param>
 public void Draw(ICoreClientAPI capi, FrustumCulling frustumCuller, EnumFrustumCullMode frustumCullMode)
 {
     FrustumCull(frustumCuller, frustumCullMode);
     capi.Render.RenderMesh(modelRef, indicesStartsByte, indicesSizes, indicesGroupsCount);
 }