public override void BindMesh(Mesh mesh, string passName)
        {
            int index = -1;
            Effect effect = effectList[0];
            foreach (Effect e in effectList)
            {
                index = e.GetPassIndexByName(passName);
                if (index >= 0)
                {
                    effect = e;
                    break;
                }
            }
            if (index < 0)
                throw new Exception("No Effect pass with name '"+passName+"' was found.");

            mesh.BindToPass(D3DDevice, effect, index);
            Geometry.Add(mesh);
        }
Пример #2
0
        void OnInitComplete()
        {
            engine.CameraInput.Camera.FarZ = 12000;

            heightMap = ReadHgtFile(hgtFile, MapSize);

            landscape = new Landscape();
            //landscape.SplitFunction = SplitFromHeight;
            landscape.VisibleFunction = IsTriVisible;
            landscape.FetchFunction = MapFetchFunction;
            landscape.MAP_SIZE = heightMap.GetLength(0)-1;
            landscape.NUM_PATCHES_PER_SIDE = NumPatches;
            landscape.Init();
            landscape.Scale = new Vector3(1, 0.0005f, 1);
            landscape.BindToPass(engine.D3DDevice, engine.Effect, "Terrain");
            engine.Geometry.Add(landscape);

            using (MeshFactory fact = new MeshFactory())
                person = fact.CreateSphere(0.5f, 20, 20);

            float h = GetHeightAtPoint(2.5f,2.5f);

            person.Translation = new Vector3(2.5f, h+1, 2.5f);
            person.BindToPass(engine.D3DDevice, engine.Effect, 2);
            engine.Geometry.Add(person);

            engine.D3DDevice.FillMode = SlimDX.Direct3D10.FillMode.Wireframe;

            engine.CameraInput.LookAt(new Vector3(MapSize/2, 100, 0), new Vector3(MapSize/2, 0, MapSize/2));
        }
Пример #3
0
 public void BindMesh(Mesh mesh, int passIndex)
 {
     if (Effect == null || D3DDevice == null)
         throw new Exception("Cannot bind mesh before initialization successful.");
     mesh.BindToPass(D3DDevice, Effect, passIndex);
     Geometry.Add(mesh);
 }