当前位置: 首页>>代码示例>>C#>>正文


C# Effect.GetParameter方法代码示例

本文整理汇总了C#中Effect.GetParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.GetParameter方法的具体用法?C# Effect.GetParameter怎么用?C# Effect.GetParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Effect的用法示例。


在下文中一共展示了Effect.GetParameter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CieloStellato

 public CieloStellato()
 {
     model = new Model("MEDIA//satellite.x", 0);
     EffectPool pool = new EffectPool();
     effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA//NightSky.fx", null, ShaderFlags.None, pool);
     effectHandles = new EffectHandle[6];
     effectHandles[0] = effect.GetTechnique("t0");
     effectHandles[1] = effect.GetParameter(null, "matViewProjection");
     effectHandles[2] = effect.GetParameter(null, "Time");
     effectHandles[3] = effect.GetParameter(null, "BaseTexture");
     effectHandles[4] = effect.GetParameter(null, "NoiseTexture");
     effectHandles[5] = effect.GetParameter(null, "TexDimension");
     baseTexture = new BaseTexture[2];
     baseTexture[0] = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//StarMap1.jpg");
     baseTexture[1] = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//Noise.jpg");
 }
开发者ID:Chosko,项目名称:high-school-thesis,代码行数:16,代码来源:Planetarium.cs

示例2: CellTexCreator

        public CellTexCreator(int Res)
        {
            texBanks = new System.Collections.Generic.List<TextureBank>();

            //Create basic vertex buffer that can be used for all cells which has positions and texture coordinates
            vBuffer = new VertexBuffer(typeof(CellVertex), 4225, DXMain.device, Usage.WriteOnly, CellVertex.Format, Pool.Managed);
            CellVertex[] CellData = (CellVertex[])vBuffer.Lock(0, LockFlags.None);

            float mult = (float)(Res / 64);
            for(int y=0;y<=64;y++) {
                for(int x=0;x<=64;x++) {
                    //Figure out which index to use
                    int i = y * 65 + x;

                    //Write values
                    CellData[i].x = ((float)x / 64.0f) * 2.0f - 1.0f;
                    CellData[i].y = ((float)y / 64.0f) * 2.0f - 1.0f;
                    CellData[i].z = 0.5f;
                    CellData[i].w = 1.0f;
                    CellData[i].u = (float)x / 16.0f;
                    CellData[i].v = (float)y / 16.0f;
                }
            }
            vBuffer.Unlock();

            //Create triangle strip index buffer
            //Size is 2r + 2rc + 2(r-1) where r is rows and c is colums (squares, not vertices)
            iBuffer = new IndexBuffer(typeof(Int16), 8446, DXMain.device, Usage.WriteOnly, Pool.Managed);
            Int16[] iBuf = (Int16[])iBuffer.Lock(0, LockFlags.None);
            int idx = 0;
            for(int y=0;y<64;y++) {
                //If this is is a continuation strip, we need to add two extra vertices to create degenerat triangles
                //and get us back to the left side
                if ( y > 0 ) {
                    iBuf[idx] = (Int16)(y * 65 + (63+1));
                    iBuf[idx + 1] = (Int16)(y * 65 + 0);
                    idx += 2;
                }

                //Start the row off with a vertex in the lower left corner of the square
                iBuf[idx] = (Int16)(y * 65 + 0);
                ++idx;

                for(int x=0;x<64;x++) {
                    //Add the top left and bottom right vertex of each square
                    iBuf[idx] = (Int16)((y+1) * 65 + x);
                    iBuf[idx + 1] = (Int16)(y * 65 + (x+1));

                    idx += 2;
                }

                //End the row with the top right vertex
                iBuf[idx] = (Int16)((y+1) * 65 + (63+1));
                ++idx;
            }

            iBuffer.Unlock();

            //Create the buffers that will contain different information during each render
            colorBuffer = new VertexBuffer(typeof(NormalColorVertex), 4225, DXMain.device, Usage.WriteOnly, NormalColorVertex.Format, Pool.Managed);

            ResetColorsAndNormals();

            RenderTargetTex=new Texture(DXMain.device, Res, Res, 0, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);
            CompressedTex=new Texture(DXMain.device, Res, Res, 0, Usage.None, Format.Dxt1, Pool.SystemMemory);
            RenderTarget=RenderTargetTex.GetSurfaceLevel(0);
            effect=Effect.FromFile(DXMain.device, EffectPath, null, null, ShaderFlags.NotCloneable, null);

            m1h = effect.GetParameter(null, "transform");
            t1h = effect.GetParameter(null, "t1");
            t2h = effect.GetParameter(null, "t2");
            t3h = effect.GetParameter(null, "t3");
            t4h = effect.GetParameter(null, "t4");
        }
开发者ID:europop,项目名称:morrgraphext,代码行数:74,代码来源:DistantLandTextures.cs

示例3: Load

        /// <summary>
        /// Load the effect file & initialise everything
        /// </summary>
        public static void Load(Device device, ShaderFlags shaderFlags)
        {
            string err = "";										// shader compiler errors
            // Find and load the file
            try
            {
                string path = Utility.FindMediaFile("Simbiosis.fx");
                effect = ResourceCache.GetGlobalInstance().CreateEffectFromFile(device,
                                                                                path, null, null, shaderFlags, null, out err);
                if (effect == null) throw new Exception("effect = null");
            }
            catch (Exception e)
            {
                Debug.WriteLine("=========================================================================================");
                Debug.WriteLine("Unable to compile Effect file." + e.ToString());
                Debug.WriteLine(err);
                Debug.WriteLine("=========================================================================================");
                throw e;
            }

            // Set up handles for the globals
            matDiffuse = effect.GetParameter(null, "matDiffuse");
            matSpecular = effect.GetParameter(null, "matSpecular");
            matEmissive = effect.GetParameter(null, "matEmissive");
            matAmbient = effect.GetParameter(null, "matAmbient");
            baseTexture = effect.GetParameter(null, "baseTexture");
            bumpTexture = effect.GetParameter(null, "bumpTexture");
            world = effect.GetParameter(null, "world");
            worldViewProjection = effect.GetParameter(null, "worldViewProjection");
            eyePosition = effect.GetParameter(null, "eyePosition");
            isTextured = effect.GetParameter(null, "isTextured");
            isBump = effect.GetParameter(null, "isBump");
            isShadowed = effect.GetParameter(null, "isShadowed");
            isSpotlit = effect.GetParameter(null, "isSpotlit");
            spotVP = effect.GetParameter(null, "spotVP");
            spotTexture = effect.GetParameter(null, "spotTexture");
            spotPosition = effect.GetParameter(null, "spotPosition");
            causticTexture = effect.GetParameter(null, "causticTexture");
            envTexture = effect.GetParameter(null, "envTexture");
            shadowTexture = effect.GetParameter(null, "shadowTexture");
            shadowMatrix = effect.GetParameter(null, "shadowMatrix");

            // and the techniques
            mainTechnique = effect.GetTechnique("Main");
            sceneryTechnique = effect.GetTechnique("Scenery");
            waterTechnique = effect.GetTechnique("Water");
            skyboxTechnique = effect.GetTechnique("Skybox");
            shadowTechnique = effect.GetTechnique("Shadow");
            markerTechnique = effect.GetTechnique("Marker");

            // Set once-only shader constants
            effect.SetValue("sunPosition",new Vector4(512,1000,512,0));				// sun's position (.W is ignored - float3 in shader)
            effect.SetValue("ambient", new ColorValue(255, 255, 255));					// amount/colour of ambient skylight
            effect.SetValue("sunlight", new ColorValue(255, 255, 255));				// colour/brightness of sunlight

            // Set up the projection matrix for shadows, based on sun position
            sunProj = Matrix.OrthoLH(100, 100, 0, 1000);							// adjust width, height if necc
            effect.SetValue("sunProj", sunProj);
            SetCameraData();														// also set up the (variable) view matrix

            // Set up the projection matrix for caustics
            Matrix caustic =
                Matrix.Invert(														// "view" matrix
                Matrix.Translation(new Vector3(0, Water.WATERLEVEL, 0))				// caustics start at water level
                * Matrix.RotationYawPitchRoll(0, (float)Math.PI/2, 0)				// looking down
                )																	// Proj matrix (orthogonal)
                * Matrix.OrthoLH(80, 80, 0, 1000);									// adjust width, height
            effect.SetValue("causticMatrix", caustic);
        }
开发者ID:JamesTryand,项目名称:simergy,代码行数:72,代码来源:Fx.cs

示例4: Allocate

    public bool Allocate()
    {
      string[] files = _effectName.Split(';');
      if (files.Length == 0) 
        return false;

      StringBuilder effectShader = new StringBuilder(8196);
      Version vertexShaderVersion = GraphicsDevice.Device.Capabilities.VertexShaderVersion;
      Version pixelShaderVersion = GraphicsDevice.Device.Capabilities.PixelShaderVersion;
      for (int i = files.Length-1; i >= 0; --i)
      {
        string effectFilePath = SkinContext.SkinResources.GetResourceFilePath(string.Format(@"{0}\{1}.fx", SkinResources.SHADERS_DIRECTORY, files[i]));
        if (effectFilePath == null || !File.Exists(effectFilePath))
        {
          if (!_fileMissing)
            ServiceRegistration.Get<ILogger>().Error("Effect file {0} does not exist", effectFilePath);
          _fileMissing = true;
          return false;
        }
        _fileMissing = false;

        using (StreamReader reader = new StreamReader(effectFilePath))
          effectShader.Append(reader.ReadToEnd());

        // Concatenate
        effectShader.Append(Environment.NewLine);
      }

      effectShader.Replace("vs_2_0", String.Format("vs_{0}_{1}", vertexShaderVersion.Major, vertexShaderVersion.Minor));
      effectShader.Replace("ps_2_0", String.Format("ps_{0}_{1}", pixelShaderVersion.Major, pixelShaderVersion.Minor));

      // We place the lock here to comply to the MP2 multithreading guideline - we are not allowed to request the
      // effect resources when holding our lock
      lock (_syncObj)
      {
        if (_effect != null)
          return true;

        string errors = string.Empty;
        try
        {
          const ShaderFlags shaderFlags = ShaderFlags.OptimizationLevel3 | ShaderFlags.EnableBackwardsCompatibility; //| ShaderFlags.NoPreshader;
          _effect = Effect.FromString(GraphicsDevice.Device, effectShader.ToString(), null, null, null, shaderFlags, null, out errors);
          _handleWorldProjection = _effect.GetParameter(null, PARAM_WORLDVIEWPROJ);
          _handleTexture = _effect.GetParameter(null, PARAM_TEXTURE);
          _handleTechnique = _effect.GetTechnique(0);
          return true;
        }
        catch
        {
          ServiceRegistration.Get<ILogger>().Error("EffectAsset: Unable to load '{0}'", _effectName);
          ServiceRegistration.Get<ILogger>().Error("EffectAsset: Errors: {0}", errors);
          return false;
        }
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:56,代码来源:EffectAssetCore.cs

示例5: Sole

 public Sole()
 {
     model = new Model("MEDIA//Sfera5.x", 0);
     EffectPool pool = new EffectPool();
     effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA//Sun.fx", null, ShaderFlags.None, pool);
     effectHandles = new EffectHandle[5];
     effectHandles[0] = effect.GetTechnique("t0");
     effectHandles[1] = effect.GetParameter(null, "matViewProjection");
     effectHandles[2] = effect.GetParameter(null, "Time");
     effectHandles[3] = effect.GetParameter(null, "Texture");
     effectHandles[4] = effect.GetParameter(null, "TexDimension");
     baseTexture = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//N030.jpg");
     Alone = new XMaterial(Color.White, Color.White, Color.Black, 1);
     light = new DirectionalLight(VertexData.Empty, Color.FromArgb(60, 10, 0), Color.FromArgb(255, 170, 100), Color.FromArgb(250, 250, 250));
 }
开发者ID:Chosko,项目名称:high-school-thesis,代码行数:15,代码来源:Planetarium.cs

示例6: CreaAnelli

 public void CreaAnelli(XTexture TextureBase, XTexture TexturePattern)
 {
     anelli = new Model("MEDIA\\ring.x", 0);
     textureAnelli = TextureBase;
     textureAnelliPattern = TexturePattern;
     EffectPool pool = new EffectPool();
     effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA\\anelli.fx", null, ShaderFlags.None, pool);
     effectHandles = new EffectHandle[5];
     effectHandles[0] = effect.GetTechnique("t0");
     effectHandles[1] = effect.GetParameter(null, "matViewProjection");
     effectHandles[2] = effect.GetParameter(null, "matWorld");
     effectHandles[3] = effect.GetParameter(null, "colorTex");
     effectHandles[4] = effect.GetParameter(null, "alphaTex");
 }
开发者ID:Chosko,项目名称:high-school-thesis,代码行数:14,代码来源:Planetarium.cs

示例7: LoadShaderTextures

        private static shader LoadShaderTextures(Effect effect)
        {
            try { effect.SetValue("thisframe", thisFrame); } catch { } //throws an exception if this parameter doesn't exist :(
            try { effect.SetValue("lastpass", lastPass); } catch { }
            try { effect.SetValue("lastshader", lastShader); } catch { }
            try { effect.SetValue("depthframe", depthFrame); } catch { }
            try { effect.SetValue("rcpres", new Vector4(1.0f/1024.0f, 1.0f/1024.0f, 0, 1)); } catch { }
            try { effect.SetValue("HDR", new Vector4(0.5f, 0.5f, 0.5f, 0.5f)); } catch { }
            //**/try { effect.SetValue("lastframe", lastFrame); } catch { }

            int count=1;
            while(true) {
                string texpath;
                try { texpath=effect.GetValueString("texname"+count.ToString()); } catch { break; }
                if(texpath!=null) {
                    try {
                        Texture tex=TextureLoader.FromFile(DXMain.device, Statics.runDir + "\\data files\\textures\\"+texpath);
                        effect.SetValue("tex"+count.ToString(), tex);
                    } catch { }
                } else break;
                count++;
            }

            shader s = new shader();
            try {
                s.ehTime = effect.GetParameter(null, "time");
            } catch {
                s.ehTime = null;
            }
            try {
                s.ehHDR = effect.GetParameter(null, "HDR");
            } catch {
                s.ehHDR = null;
            }
            //**/try {
            //**/    s.ehSinVar=effect.GetParameter(null, "sinvar");
            //**/} catch {
            //**/    s.ehSinVar = null;
            //**/}
            //**/try {
            //**/    s.ehLinVar=effect.GetParameter(null, "linvar");
            //**/} catch {
            //**/    s.ehLinVar = null;
            //**/}
            //**/try {
            //**/    s.ehTicks=effect.GetParameter(null, "tickcount");
            //**/} catch {
            //**/    s.ehTicks = null;
            //**/}
            s.effect=effect;

            return s;
        }
开发者ID:europop,项目名称:morrgraphext,代码行数:53,代码来源:Shaders.cs

示例8: SetEffect

 public static void SetEffect(Effect _effect)
 {
     effect=_effect;
     if(effect!=null) {
         ehWorld=effect.GetParameter(null, "worldMatrix");
         ehIWorld=effect.GetParameter(null, "iWorld");
         ehNormalMatrix=effect.GetParameter(null, "normalMatrix");
         ehWorldView=effect.GetParameter(null, "worldView");
         ehWorldViewProj=effect.GetParameter(null, "worldViewProj");
         ehTexture=effect.GetParameter(null, "colorMap");
         ehGlowMap=effect.GetParameter(null, "glowMap");
         ehNormalMap=effect.GetParameter(null, "normalMap");
         ehMaterialAmb=effect.GetParameter(null, "g_MaterialAmbientColor");
         ehMaterialDif=effect.GetParameter(null, "g_MaterialDiffuseColor");
         ehMaterialSpec=effect.GetParameter(null, "g_MaterialSpecularColor");
         ehMaterialEmm=effect.GetParameter(null, "g_MaterialEmissiveColor");
         ehMaterialGloss=effect.GetParameter(null, "g_MaterialGloss");
         ehMaterialAlpha=effect.GetParameter(null, "g_MaterialAlpha");
         ehUseSpecular=effect.GetParameter(null, "use_specular");
         ehUseGlow=effect.GetParameter(null, "use_glow");
         ehUseDiffuseVColor=effect.GetParameter(null, "use_dvcolor");
         ehUseEmissiveVColor=effect.GetParameter(null, "use_evcolor");
         ehUseExplicitAlpha=effect.GetParameter(null, "use_alpha");
     }
 }
开发者ID:BioBrainX,项目名称:fomm,代码行数:25,代码来源:NifFile.cs

示例9: OnCreateDevice

        /// <summary>
        /// This event will be fired immediately after the Direct3D device has been 
        /// created, which will happen during application initialization and windowed/full screen 
        /// toggles. This is the best location to create Pool.Managed resources since these 
        /// resources need to be reloaded whenever the device is destroyed. Resources created  
        /// here should be released in the Disposing event. 
        /// </summary>
        private void OnCreateDevice(object sender, DeviceEventArgs e) {
            // Setup direction widget
            DirectionWidget.OnCreateDevice(e.Device);

            // Initialize the stats font
            statsFont = ResourceCache.GetGlobalInstance().CreateFont(e.Device, 15, 0, FontWeight.Bold, 1, false, CharacterSet.Default,
                Precision.Default, FontQuality.Default, PitchAndFamily.FamilyDoNotCare | PitchAndFamily.DefaultPitch
                , "Arial");

            // Read the D3DX effect file
            string path = "NifViewer.fx";
            string errors;
            effect = ResourceCache.GetGlobalInstance().CreateEffectFromFile(e.Device, path, null, null, ShaderFlags.NotCloneable, null, out errors);

            if(effect==null) {
                MessageBox.Show("Effects.fx Shader compilation failed.\n"+errors, "Error");
            }

            ehLightDir=effect.GetParameter(null, "g_LightDir");
            ehLightCol=effect.GetParameter(null, "g_LightDiffuse");
            egAmbCol=effect.GetParameter(null, "g_LightAmbient");
            ehViewProj=effect.GetParameter(null, "viewProjection");
            ehEyePos=effect.GetParameter(null, "eyePos");
            ehEyeVec=effect.GetParameter(null, "eyeVec");
            ehHalfVec=effect.GetParameter(null, "g_LightHalfVec");

            NifFile.SetEffect(effect);

            // Setup the camera's view parameters
            camera.SetViewParameters(new Vector3(0.0f, 0.0f, -15.0f), Vector3.Empty);
            camera.IsPositionMovementEnabled=true;

            NifFile.SetCamera(camera);

            lightControl.Radius = 10;
            camera.SetRadius(30.0f, 0, 100.0f);
            
        }
开发者ID:IntegralLee,项目名称:fomm,代码行数:45,代码来源:BasicHLSL.cs

示例10: LoadShaderTextures

        private static shader LoadShaderTextures(Effect effect) {
            try { effect.SetTexture("lastpass", lastPass); } catch { } //throws an exception if this parameter doesn't exist :(
            try { effect.SetTexture("lastshader", lastShader); } catch { }
            try { effect.SetTexture("depthframe", depthFrame); } catch { }
            try { effect.SetValue("rcpres", new Vector4(1f/frameWidth, 1f/frameHeight, 0, 1)); } catch { }
            try { effect.SetValue("fov", 85f); } catch { }
            try { effect.SetValue("fogstart", 819.2f); } catch { }
            try { effect.SetValue("fogrange", 65536.0f); } catch { }
            try { effect.SetValue("waterlevel", 0f); } catch { }
			try { effect.SetValue("HDR", new Vector4(0.25f, 0.25f, 0.25f, 02.5f)); } catch { }
			try { effect.SetValue("eyepos", new Vector3(0f, 0f, 128f)); } catch { }
			try { effect.SetValue("eyevec", new Vector3(1f, 0f, 0f)); } catch { }

            int count=1;
            while(true) {
                string texpath;
                try { texpath=effect.GetString("texname"+count.ToString()); } catch { break; }
                if(texpath!=null) {
                    try {
                        Texture tex=Texture.FromFile(DXMain.device, Statics.runDir + "\\data files\\textures\\"+texpath);
                        effect.SetTexture("tex"+count.ToString(), tex);
                    } catch { }
                } else break;
                count++;
            }

            shader s = new shader();
            try {
                s.ehTime = effect.GetParameter(null, "time");
            } catch {
                s.ehTime = null;
            }
            try {
                s.ehHDR = effect.GetParameter(null, "HDR");
            } catch {
                s.ehHDR = null;
            }
            s.effect=effect;

            return s;
        }
开发者ID:mdmallardi,项目名称:MGE-XE,代码行数:41,代码来源:Shaders.cs

示例11: Update

        public override void Update(DrawArgs drawArgs)
        {
            if (!System.Threading.Thread.CurrentThread.Name.Equals(ThreadNames.WorldWindowBackground))
                throw new System.InvalidOperationException("QTS.Update() must be called from WorkerThread!");

            if (!isInitialized)
                Initialize(drawArgs);

            ServiceDownloadQueue();

            if (m_effectEnabled && (m_effectPath != null) && !File.Exists(m_effectPath))
            {
                Log.Write(Log.Levels.Warning, string.Format("Effect {0} not found - disabled", m_effectPath));
                m_effectEnabled = false;
            }

            if (m_effectEnabled && m_effectPath != null && m_effect == null)
            {
                string errs = string.Empty;

                m_effectHandles.Clear();

                try
                {
                    Log.Write(Log.Levels.Warning, string.Format("Loading effect from {0}", m_effectPath));
                    m_effect = Effect.FromFile(DrawArgs.Device, m_effectPath, null, "", ShaderFlags.None, m_effectPool, out errs);

                    // locate effect handles and store for rendering.
                    m_effectHandles.Add("WorldViewProj", m_effect.GetParameter(null, "WorldViewProj"));
                    m_effectHandles.Add("World", m_effect.GetParameter(null, "World"));
                    m_effectHandles.Add("ViewInverse", m_effect.GetParameter(null, "ViewInverse"));
                    for (int i = 0; i < 8; i++)
                    {
                        string name = string.Format("Tex{0}", i);
                        m_effectHandles.Add(name, m_effect.GetParameter(null, name));
                    }
                    m_effectHandles.Add("Brightness", m_effect.GetParameter(null, "Brightness"));
                    m_effectHandles.Add("Opacity", m_effect.GetParameter(null, "Opacity"));
                    m_effectHandles.Add("TileLevel", m_effect.GetParameter(null, "TileLevel"));
                    m_effectHandles.Add("LightDirection", m_effect.GetParameter(null, "LightDirection"));
                    m_effectHandles.Add("LocalOrigin", m_effect.GetParameter(null, "LocalOrigin"));
                    m_effectHandles.Add("LayerRadius", m_effect.GetParameter(null, "LayerRadius"));
                    m_effectHandles.Add("LocalFrameOrigin", m_effect.GetParameter(null, "LocalFrameOrigin"));
                    m_effectHandles.Add("LocalFrameXAxis", m_effect.GetParameter(null, "LocalFrameXAxis"));
                    m_effectHandles.Add("LocalFrameYAxis", m_effect.GetParameter(null, "LocalFrameYAxis"));
                    m_effectHandles.Add("LocalFrameZAxis", m_effect.GetParameter(null, "LocalFrameZAxis"));
                }
                catch (Exception ex)
                {
                    Log.Write(Log.Levels.Error, "Effect load caused exception:" + ex.ToString());
                    Log.Write(Log.Levels.Warning, "Effect has been disabled.");
                    m_effectEnabled = false;
                }

                if (errs != null && errs != string.Empty)
                {
                    Log.Write(Log.Levels.Warning, "Could not load effect " + m_effectPath + ": " + errs);
                    Log.Write(Log.Levels.Warning, "Effect has been disabled.");
                    m_effectEnabled = false;
                    m_effect = null;
                }
            }

            if (ImageStores[0].LevelZeroTileSizeDegrees < 180)
            {
                // Check for layer outside view
                double vrd = DrawArgs.Camera.ViewRange.Degrees;
                double latitudeMax = DrawArgs.Camera.Latitude.Degrees + vrd;
                double latitudeMin = DrawArgs.Camera.Latitude.Degrees - vrd;
                double longitudeMax = DrawArgs.Camera.Longitude.Degrees + vrd;
                double longitudeMin = DrawArgs.Camera.Longitude.Degrees - vrd;
                if (latitudeMax < m_south || latitudeMin > m_north || longitudeMax < m_west || longitudeMin > m_east)
                    return;
            }

            if (!m_alwaysRenderBaseTiles && DrawArgs.Camera.ViewRange * 0.5f >
                    Angle.FromDegrees(TileDrawDistance * ImageStores[0].LevelZeroTileSizeDegrees))
            {
                lock (((System.Collections.IDictionary)m_topmostTiles).SyncRoot)
                {
                    // Don't dispose of the quadtiles like WorldWind does here (they may be nice to look at)
                    // Do however clear the download requests
                    /*
                    foreach (QuadTile qt in m_topmostTiles.Values)
                        qt.Dispose();
                    m_topmostTiles.Clear();
                     */
                    ClearDownloadRequests();
                }

                return;
            }

            // 'Spiral' from the centre tile outward adding tiles that's in the view
            // Defer the updates to after the loop to prevent tiles from updating twice
            // If the tilespread is huge we are likely looking at a small dataset in the view
            // so just test all the tiles in the dataset.
            int iTileSpread = Math.Max(5, (int)Math.Ceiling(drawArgs.WorldCamera.TrueViewRange.Degrees / (2.0 * ImageStores[0].LevelZeroTileSizeDegrees)));

            int iMiddleRow, iMiddleCol;
//.........这里部分代码省略.........
开发者ID:paladin74,项目名称:Dapple,代码行数:101,代码来源:QuadTileSet.cs

示例12: InitializeGraphics

		private void InitializeGraphics()
		{
			Cursor.Hide();
			PresentParameters presentParams = new PresentParameters();

			presentParams.Windowed = ! FullScreen;
			presentParams.SwapEffect = SwapEffect.Discard;
			presentParams.AutoDepthStencilFormat = DepthFormat.D24X8;
			presentParams.EnableAutoDepthStencil = true;
			// If we want a Fullscreen device we need to set up a backbuffer
			if ( FullScreen)
			{
				presentParams.BackBufferCount = 1;
				presentParams.BackBufferFormat = Format.X8R8G8B8; 
				presentParams.BackBufferWidth = 800;
				presentParams.BackBufferHeight = 600;
			}
			Caps hardware = Manager.GetDeviceCaps(0, DeviceType.Hardware);
			
			
			CreateFlags flags = CreateFlags.SoftwareVertexProcessing;

			if (hardware.DeviceCaps.SupportsHardwareTransformAndLight)
				flags = CreateFlags.HardwareVertexProcessing;

			if (hardware.DeviceCaps.SupportsPureDevice)
				flags |= CreateFlags.PureDevice;

			// Pixelshader 2.0 is required
			// If not available create a Reference device ( must have SDK installed )
			if (hardware.PixelShaderVersion >= new Version(2,0) && hardware.VertexShaderVersion >= new Version(1,1))				
				device = new Device(0, DeviceType.Hardware, this, flags, presentParams);
			else
				device = new Device(0, DeviceType.Reference, this, flags, presentParams);

			String s = null;
			
			effect = Effect.FromFile(device, @"shader.fx", null,null,ShaderFlags.None, null, out s);			
            //if ( s != null) 
            //{
            //    // There are Compilation errors show them and then close app
            //    Cursor.Show();
            //    device.Dispose();
            //    this.Visible = false;
            //    MessageBox.Show(s);
            //    return;
            //}

			effect.Technique = "TransformTexture";

			projMatrix = Matrix.PerspectiveFovLH((float)Math.PI/4f, 
				this.Width / this.Height, 1f, 250f);

			t1 = TextureLoader.FromFile(device,@"..\..\grass.bmp");
			t2 = TextureLoader.FromFile(device,@"..\..\rock.bmp");

			effect.SetValue("Texture1", t1);
			effect.SetValue("Texture2", t2);

			handle1 = effect.GetParameter(null,"ambient");
			handle2 = effect.GetParameter(null,"WorldViewProj");
			handle3 = effect.GetParameter(null,"light");

			t = new Terrain(device,0,28);

			font = new Microsoft.DirectX.Direct3D.Font(device,new System.Drawing.Font("Arial",18));
	}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:67,代码来源:Form1.cs

示例13: GetParameters

        public EffectHandle[] GetParameters(Effect effect)
        {
            EffectHandle[] handles = new EffectHandle[14];
            handles[0] = effect.GetParameter(null, "CameraPosition");
            handles[1] = effect.GetParameter(null, "CameraUp");
            handles[2] = effect.GetParameter(null, "CameraLook");
            handles[3] = effect.GetParameter(null, "CameraVelocity");
            handles[4] = effect.GetParameter(null, "CameraAcceleration");

            handles[5] = effect.GetParameter(null, "World");
            handles[6] = effect.GetParameter(null, "View");
            handles[7] = effect.GetParameter(null, "Projection");
            handles[8] = effect.GetParameter(null, "WorldView");
            handles[9] = effect.GetParameter(null, "WorldViewProjection");
            handles[10] = effect.GetParameter(null, "WorldI");
            handles[11] = effect.GetParameter(null, "WorldIT");

            handles[12] = effect.GetParameter(null, "LightDirection");
            handles[13] = effect.GetParameter(null, "LightColor");

            return handles;
        }
开发者ID:kensniper,项目名称:castle-butcher,代码行数:22,代码来源:ConstantsMap.cs


注:本文中的Effect.GetParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。