예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="geom"></param>
        public override void Init(PagedGeometry geom)
        {
            mSceneMgr = geom.SceneManager;
            mBatch = new BatchedGeometry(mSceneMgr, geom.SceneNode);

            mFadeEnabled = false;
            RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities;
            if (caps.HasCapability(Capabilities.VertexPrograms))
                mShadersSupported = true;
            else
                mShadersSupported = false;

            ++mRefCount;
        }
예제 #2
0
            /// <summary>
            /// 
            /// </summary>
            /// <param name="parent"></param>
            /// <param name="ent"></param>
            public SubBatch(BatchedGeometry parent, SubEntity ent) {
                mMeshType = ent.SubMesh;
                mParent = parent;
                mBuild = false;
                mRequireVertexColors = false;
                // Material must always exist
                Material origMat = (Material)MaterialManager.Instance.GetByName(ent.MaterialName);
                if (origMat != null) {
                    material = (Material)MaterialManager.Instance.GetByName(GetMaterialClone(origMat).Name);
                }
                else {
                    Tuple<Resource, bool> result = MaterialManager.Instance.CreateOrRetrieve("PagedGeometry_Batched_Material", "General");
                    if (result.First == null)
                        throw new Exception("BatchedGeometry failed to create a material for entity with invalid material.");

                    material = (Material)result.First;
                }

                //Setup vertex/index data structure
                vertexData = mMeshType.vertexData.Clone(false);
                indexData = mMeshType.indexData.Clone(false);

                //Remove blend weights from vertex format
                VertexElement blendIndices = vertexData.vertexDeclaration.FindElementBySemantic(VertexElementSemantic.BlendIndices);
                VertexElement blendWeights = vertexData.vertexDeclaration.FindElementBySemantic(VertexElementSemantic.BlendWeights);

                if (blendIndices != null && blendWeights != null) {
                    Debug.Assert(blendIndices.Source == blendWeights.Source, "Blend indices and weights should be in the same buffer");
                    Debug.Assert(blendIndices.Size + blendWeights.Size == vertexData.vertexBufferBinding.GetBuffer(blendIndices.Source).VertexSize,
                        "Blend indices and blend buffers should have buffer to themselves!");

                    //Remove the blend weights
                    vertexData.vertexBufferBinding.UnsetBinding(blendIndices.Source);
                    vertexData.vertexDeclaration.RemoveElement(VertexElementSemantic.BlendIndices);
                    vertexData.vertexDeclaration.RemoveElement(VertexElementSemantic.BlendWeights);
                }

                //Reset vertex/index count
                vertexData.vertexStart = 0;
                vertexData.vertexCount = 0;
                indexData.indexStart = 0;
                indexData.indexCount = 0;
            }