コード例 #1
0
ファイル: MeshDataPool.cs プロジェクト: anegostudios/vsapi
        /// <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;
            }
        }
コード例 #2
0
        /// <summary>
        /// Renders the model.
        /// </summary>
        /// <param name="playerpos">The position of the Player</param>
        /// <param name="originUniformName"></param>
        /// <param name="frustumCullMode">The culling mode.  Default is CulHideDelay.</param>
        public void Render(Vec3d playerpos, string originUniformName, EnumFrustumCullMode frustumCullMode = EnumFrustumCullMode.CullNormal)
        {
            for (int i = 0; i < pools.Count; i++)
            {
                MeshDataPool pool = pools[i];
                pool.FrustumCull(frustumCuller, frustumCullMode);

                capi.Render.CurrentActiveShader.Uniform(originUniformName, tmp.Set(
                                                            (float)(pool.poolOrigin.X - playerpos.X),
                                                            (float)(pool.poolOrigin.Y - playerpos.Y),
                                                            (float)(pool.poolOrigin.Z - playerpos.Z)
                                                            ));

                capi.Render.RenderMesh(pool.modelRef, pool.indicesStartsByte, pool.indicesSizes, pool.indicesGroupsCount);
            }
        }
コード例 #3
0
ファイル: MeshDataPool.cs プロジェクト: anegostudios/vsapi
        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);
            }
        }
コード例 #4
0
ファイル: MeshDataPool.cs プロジェクト: anegostudios/vsapi
 /// <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);
 }