public MaterialBucket(LODBucket parent, string materialName)
 {
     this.parent = parent;
     this.materialName = materialName;
     geometryBucketList = new List<GeometryBucket>();
     currentGeometryMap = new Dictionary<string, GeometryBucket>();
 }
Esempio n. 2
0
 public MaterialBucket(LODBucket parent, string materialName)
 {
     this.parent        = parent;
     this.materialName  = materialName;
     geometryBucketList = new List <GeometryBucket>();
     currentGeometryMap = new Dictionary <string, GeometryBucket>();
 }
Esempio n. 3
0
            public void Build(bool stencilShadows, int logLevel)
            {
                // Create a node
                this.node = this.sceneMgr.RootSceneNode.CreateChildSceneNode(name, this.center);
                this.node.AttachObject(this);
                // We need to create enough LOD buckets to deal with the highest LOD
                // we encountered in all the meshes queued
                for (ushort lod = 0; lod < this.lodValues.Count; ++lod)
                {
                    var lodBucket = new LODBucket(this, lod, (float)this.lodValues[lod]);
                    this.lodBucketList.Add(lodBucket);
                    // Now iterate over the meshes and assign to LODs
                    // LOD bucket will pick the right LOD to use
                    IEnumerator iter = this.queuedSubMeshes.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        var qsm = (QueuedSubMesh)iter.Current;
                        lodBucket.Assign(qsm, lod);
                    }
                    // now build
                    lodBucket.Build(stencilShadows, logLevel);
                }

                // Do we need to build an edge list?
                if (stencilShadows)
                {
                    var eb = new EdgeListBuilder();
                    //int vertexSet = 0;
                    foreach (var lod in this.lodBucketList)
                    {
                        foreach (var mat in lod.MaterialBucketMap.Values)
                        {
                            // Check if we have vertex programs here
                            var t = mat.Material.GetBestTechnique();
                            if (null != t)
                            {
                                var p = t.GetPass(0);
                                if (null != p)
                                {
                                    if (p.HasVertexProgram)
                                    {
                                        this.vertexProgramInUse = true;
                                    }
                                }
                            }

                            foreach (var geom in mat.GeometryBucketList)
                            {
                                // Check we're dealing with 16-bit indexes here
                                // Since stencil shadows can only deal with 16-bit
                                // More than that and stencil is probably too CPU-heavy
                                // in any case
                                if (geom.IndexData.indexBuffer.Type != IndexType.Size16)
                                {
                                    throw new AxiomException("Only 16-bit indexes allowed when using stencil shadows");
                                }
                                eb.AddVertexData(geom.VertexData);
                                eb.AddIndexData(geom.IndexData);
                            }
                        }
                    }
                    this.edgeList = eb.Build();
                }
            }
Esempio n. 4
0
			public void Build( bool stencilShadows, int logLevel )
			{
				// Create a node
				this.node = this.sceneMgr.RootSceneNode.CreateChildSceneNode( name, this.center );
				this.node.AttachObject( this );
				// We need to create enough LOD buckets to deal with the highest LOD
				// we encountered in all the meshes queued
				for ( ushort lod = 0; lod < this.lodValues.Count; ++lod )
				{
					var lodBucket = new LODBucket( this, lod, (float)this.lodValues[ lod ] );
					this.lodBucketList.Add( lodBucket );
					// Now iterate over the meshes and assign to LODs
					// LOD bucket will pick the right LOD to use
					IEnumerator iter = this.queuedSubMeshes.GetEnumerator();
					while ( iter.MoveNext() )
					{
						var qsm = (QueuedSubMesh)iter.Current;
						lodBucket.Assign( qsm, lod );
					}
					// now build
					lodBucket.Build( stencilShadows, logLevel );
				}

				// Do we need to build an edge list?
				if ( stencilShadows )
				{
					var eb = new EdgeListBuilder();
					//int vertexSet = 0;
					foreach ( var lod in this.lodBucketList )
					{
						foreach ( var mat in lod.MaterialBucketMap.Values )
						{
							// Check if we have vertex programs here
							var t = mat.Material.GetBestTechnique();
							if ( null != t )
							{
								var p = t.GetPass( 0 );
								if ( null != p )
								{
									if ( p.HasVertexProgram )
									{
										this.vertexProgramInUse = true;
									}
								}
							}

							foreach ( var geom in mat.GeometryBucketList )
							{
								// Check we're dealing with 16-bit indexes here
								// Since stencil shadows can only deal with 16-bit
								// More than that and stencil is probably too CPU-heavy
								// in any case
								if ( geom.IndexData.indexBuffer.Type != IndexType.Size16 )
								{
									throw new AxiomException( "Only 16-bit indexes allowed when using stencil shadows" );
								}
								eb.AddVertexData( geom.VertexData );
								eb.AddIndexData( geom.IndexData );
							}
						}
					}
					this.edgeList = eb.Build();
				}
			}
Esempio n. 5
0
        public override void UpdateRenderQueue(RenderQueue queue)
        {
            LODBucket lodBucket = lodBucketList[currentLod];

            lodBucket.AddRenderables(queue, renderQueueID, camDistanceSquared);
        }
Esempio n. 6
0
        // Returns the number of geometry buckets
        public int Build(bool stencilShadows, bool logDetails)
        {
            int bucketCount = 0;

            // Create a node
            node = sceneMgr.RootSceneNode.CreateChildSceneNode(name, center);
            node.AttachObject(this);
            // We need to create enough LOD buckets to deal with the highest LOD
            // we encountered in all the meshes queued
            for (ushort lod = 0; lod < lodSquaredDistances.Count; ++lod)
            {
                LODBucket lodBucket = new LODBucket(this, lod, (float)lodSquaredDistances[lod]);
                lodBucketList.Add(lodBucket);
                // Now iterate over the meshes and assign to LODs
                // LOD bucket will pick the right LOD to use
                foreach (QueuedSubMesh qsm in queuedSubMeshes)
                {
                    lodBucket.Assign(qsm, lod);
                }
                // now build
                bucketCount += lodBucket.Build(stencilShadows, logDetails);
            }

            // Do we need to build an edge list?
            if (stencilShadows)
            {
                EdgeListBuilder eb = new EdgeListBuilder();
                foreach (LODBucket lod in lodBucketList)
                {
                    foreach (MaterialBucket mat in lod.MaterialBucketMap.Values)
                    {
                        // Check if we have vertex programs here
                        Technique t = mat.Material.GetBestTechnique();
                        if (null != t)
                        {
                            Pass p = t.GetPass(0);
                            if (null != p)
                            {
                                if (p.HasVertexProgram)
                                {
                                    vertexProgramInUse = true;
                                }
                            }
                        }

                        foreach (GeometryBucket geom in mat.GeometryBucketList)
                        {
                            bucketCount++;
                            // Check we're dealing with 16-bit indexes here
                            // Since stencil shadows can only deal with 16-bit
                            // More than that and stencil is probably too CPU-heavy
                            // in any case
                            if (geom.IndexData.indexBuffer.Type != IndexType.Size16)
                            {
                                throw new AxiomException("Only 16-bit indexes allowed when using stencil shadows");
                            }
                            eb.AddVertexData(geom.VertexData);
                            eb.AddIndexData(geom.IndexData);
                        }
                    }
                }
                edgeList = eb.Build();
            }
            return(bucketCount);
        }
Esempio n. 7
0
        // Returns the number of geometry buckets
        public int Build(bool stencilShadows, bool logDetails)
        {
            int bucketCount = 0;
            // Create a node
            node = sceneMgr.RootSceneNode.CreateChildSceneNode(name, center);
            node.AttachObject(this);
            // We need to create enough LOD buckets to deal with the highest LOD
            // we encountered in all the meshes queued
            for(ushort lod = 0; lod < lodSquaredDistances.Count; ++lod)
            {
                LODBucket lodBucket = new LODBucket(this, lod, (float)lodSquaredDistances[lod]);
                lodBucketList.Add(lodBucket);
                // Now iterate over the meshes and assign to LODs
                // LOD bucket will pick the right LOD to use
                foreach (QueuedSubMesh qsm in queuedSubMeshes)
                    lodBucket.Assign(qsm, lod);
                // now build
                bucketCount += lodBucket.Build(stencilShadows, logDetails);
            }

            // Do we need to build an edge list?
            if(stencilShadows)
            {
                EdgeListBuilder eb = new EdgeListBuilder();
                foreach (LODBucket lod in lodBucketList) {
                    foreach(MaterialBucket mat in lod.MaterialBucketMap.Values) {
                        // Check if we have vertex programs here
                        Technique t = mat.Material.GetBestTechnique();
                        if(null != t)
                        {
                            Pass p = t.GetPass(0);
                            if(null != p)
                            {
                                if(p.HasVertexProgram)
                                {
                                    vertexProgramInUse = true;
                                }
                            }
                        }

                        foreach (GeometryBucket geom in mat.GeometryBucketList) {
                            bucketCount++;
                            // Check we're dealing with 16-bit indexes here
                            // Since stencil shadows can only deal with 16-bit
                            // More than that and stencil is probably too CPU-heavy
                            // in any case
                            if(geom.IndexData.indexBuffer.Type != IndexType.Size16) throw new AxiomException("Only 16-bit indexes allowed when using stencil shadows");
                            eb.AddVertexData(geom.VertexData);
                            eb.AddIndexData(geom.IndexData);
                        }
                    }
                }
                edgeList = eb.Build();
            }
            return bucketCount;
        }