예제 #1
0
        protected virtual void waveGrass(float timeElapsed)
        {
            //Console.WriteLine("waveGrass:  01");
            xpos += xinc * timeElapsed;
            zpos += zinc * timeElapsed;

            // Update vertex program parameters by binding a value to each renderable

            SGRegionMapIterator rit = mStaticGeom.GetRegionIterator();

            while (rit.hasMoreElements())
            {
                //Console.WriteLine("waveGrass:  02");
                OgreDotNet.SGRegion reg = rit.getNext();

                // a little randomness
                xpos      += reg.getCentre().x * 0.001f;
                zpos      += reg.getCentre().z * 0.001f;
                xxoffset.x = (float)Math.Sin((float)xpos) * 0.05f;
                xxoffset.z = (float)Math.Sin((float)zpos) * 0.05f;

                OgreDotNet.SGLODBucketVectorIterator lodit = reg.getLODIterator();
                while (lodit.hasMoreElements())
                {
                    //Console.WriteLine("waveGrass:  03");
                    OgreDotNet.SGLODBucket lod = lodit.getNext();
                    OgreDotNet.SGMaterialBucketMapIterator matit = lod.getMaterialIterator();
                    while (matit.hasMoreElements())
                    {
                        //Console.WriteLine("waveGrass:  04");
                        OgreDotNet.SGMaterialBucket mat = matit.getNext();
                        OgreDotNet.SGGeometryBucketVectorIterator geomit = mat.getGeometryIterator();
                        while (geomit.hasMoreElements())
                        {
                            //Console.WriteLine("waveGrass:  05");
                            OgreDotNet.SGGeometryBucket geom = geomit.getNext();
                            geom.GetMeAsRenderable().setCustomParameter(OFFSET_PARAM, xxoffset);
                        }
                    }
                }
            }
            //Console.WriteLine("waveGrass:  --end--");
        }
예제 #2
0
        void waveGrass(float timeElapsed)
        {
            float   xinc   = Math.PI * 0.3f;
            float   zinc   = Math.PI * 0.44f;
            float   xpos   = Math.RangeRandom(-Math.PI, Math.PI);
            float   zpos   = Math.RangeRandom(-Math.PI, Math.PI);
            Vector4 offset = new Vector4(0, 0, 0, 0);

            xpos += xinc * timeElapsed;
            zpos += zinc * timeElapsed;

            // update vertex program parameters by binding a value to each renderable
            StaticGeometry.RegionIterator regs = StaticGeom.GetRegionIterator();
            while (regs.MoveNext())
            {
                StaticGeometry.Region reg = regs.Current;

                // a little randomness
                xpos    += reg.Centre.x * 0.001f;
                zpos    += reg.Centre.z * 0.001f;
                offset.x = Math.Sin(xpos) * 4;
                offset.z = Math.Sin(zpos) * 4;

                StaticGeometry.Region.LODIterator lods = reg.GetLODIterator();
                while (lods.MoveNext())
                {
                    StaticGeometry.LODBucket.MaterialIterator mats = lods.Current.GetMaterialIterator();
                    while (mats.MoveNext())
                    {
                        IEnumerator <StaticGeometry.MaterialBucket> geoms = mats.GetEnumerator();
                        while (geoms.MoveNext())
                        {
                            geoms.Current.CurrentTechnique.GetPass(0).GetGeometryProgramParameters().SetConstant(999, offset);
                        }
                        //while (geoms.hasMoreElements()) geoms.getNext()->setCustomParameter(999, offset);
                    }
                }
            }
        }