• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Texture类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Texture的典型用法代码示例。如果您正苦于以下问题:C# Texture类的具体用法?C# Texture怎么用?C# Texture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Texture类属于命名空间,在下文中一共展示了Texture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Terrain

 public Terrain(Device device, String texture, int pitch, Renderer renderer)
 {
     HeightMap = new System.Drawing.Bitmap(@"Data/Textures/"+texture);
     WaterShader = new WaterShader(device);
     TerrainShader = new TerrainShader(device);
     _width = HeightMap.Width-1;
     _height = HeightMap.Height-1;
     _pitch = pitch;
     _terrainTextures = new ShaderResourceView[4];
     _terrainTextures[0] = new Texture(device, "Sand.png").TextureResource;
     _terrainTextures[1] = new Texture(device, "Grass.png").TextureResource;
     _terrainTextures[2] = new Texture(device, "Ground.png").TextureResource;
     _terrainTextures[3] = new Texture(device, "Rock.png").TextureResource;
     _reflectionClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 0.0f);
     _refractionClippingPlane = new Vector4(0.0f, -1.0f, 0.0f, 0.0f);
     _noClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 10000);
     _reflectionTexture = new RenderTexture(device, renderer.ScreenSize);
     _refractionTexture = new RenderTexture(device, renderer.ScreenSize);
     _renderer = renderer;
     _bitmap = new Bitmap(device,_refractionTexture.ShaderResourceView,renderer.ScreenSize, new Vector2I(100, 100), 0);
     _bitmap.Position = new Vector2I(renderer.ScreenSize.X - 100, 0);
     _bitmap2 = new Bitmap(device, _reflectionTexture.ShaderResourceView, renderer.ScreenSize, new Vector2I(100, 100), 0);
     _bitmap2.Position = new Vector2I(renderer.ScreenSize.X - 100, 120);
     _bumpMap = _renderer.TextureManager.Create("OceanWater.png");
     _skydome = new ObjModel(device, "skydome.obj", renderer.TextureManager.Create("Sky.png"));
     BuildBuffers(device);
     WaveTranslation = new Vector2(0,0);
 }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:28,代码来源:Terrain.cs


示例2: AddEffect

 public ParticleEffect AddEffect(ParticleEffectType type, Func<ParticleEffect, Location> start, Func<ParticleEffect, Location> end,
     Func<ParticleEffect, float> fdata, float ttl, Location color, Location color2, bool fades, Texture texture, float salpha = 1)
 {
     ParticleEffect pe = new ParticleEffect(TheClient) { Type = type, Start = start, End = end, FData = fdata, TTL = ttl, O_TTL = ttl, Color = color, Color2 = color2, Alpha = salpha, Fades = fades, texture = texture };
     ActiveEffects.Add(pe);
     return pe;
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:7,代码来源:ParticleEngine.cs


示例3: DrawItem

 public void DrawItem(OSDTexture item)
 {
   try
   {
     lock (_OSDLock)
     {
       if (item.texture != null && item.width > 0 && item.height > 0)
       {
         // todo: support 2 planes
         if (_OSDTexture == null)
         {
           _OSDTexture = new Texture(item.texture);
         }
       }
       else
       {
         _OSDTexture = null;
       }
     }
   }
   catch (Exception ex)
   {
     Log.Error(ex);
   }
 }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:25,代码来源:BDOSDRenderer.cs


示例4: Video

        public Video(Form _form1_reference)
        {
            form1_reference = _form1_reference;
            critical_failure = false;

            Load_Window_Size();

            if (!initialize_directx())
            {
                MessageBox.Show("problem with directx initialization");
                fatal_error = true;
                return;
            }

            try
            {
                texture = new Texture(device, 256, 256, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default);
                data_copy = new int[256 * 256];
            }
            catch (Direct3D9Exception e)
            {
                MessageBox.Show("Gameboy Revolution failed to create rendering surface. \nPlease report this error. \n\nDirectX Error:\n" + e.ToString(), "Error!", MessageBoxButtons.OK);
                fatal_error = true;
                return;
            }

            setup_screen();
            setup_colors();
        }
开发者ID:hatori,项目名称:GameBoy-Revolution,代码行数:29,代码来源:Video.cs


示例5: Start

	void Start() {

		playerLabel.text = "Player Diconnected";
		defaulttexture = avatar.GetComponent<Renderer>().material.mainTexture;

		//listen for GooglePlayConnection events
		GooglePlayConnection.instance.addEventListener (GooglePlayConnection.PLAYER_CONNECTED, OnPlayerConnected);
		GooglePlayConnection.instance.addEventListener (GooglePlayConnection.PLAYER_DISCONNECTED, OnPlayerDisconnected);
		GooglePlayConnection.instance.addEventListener(GooglePlayConnection.CONNECTION_RESULT_RECEIVED, OnConnectionResult);


		//listen for GooglePlayManager events
		GooglePlayManager.instance.addEventListener (GooglePlayManager.ACHIEVEMENT_UPDATED, OnAchivmentUpdated);
		GooglePlayManager.instance.addEventListener (GooglePlayManager.SCORE_SUBMITED, OnScoreSubmited);

		GooglePlayManager.instance.addEventListener (GooglePlayManager.SEND_GIFT_RESULT_RECEIVED, OnGiftResult);
		GooglePlayManager.instance.addEventListener (GooglePlayManager.PENDING_GAME_REQUESTS_DETECTED, OnPendingGiftsDetected);
		GooglePlayManager.instance.addEventListener (GooglePlayManager.GAME_REQUESTS_ACCEPTED, OnGameRequestAccepted);

		GooglePlayManager.instance.addEventListener (GooglePlayManager.AVALIABLE_DEVICE_ACCOUNT_LOADED, OnAccsLoaded);
		GooglePlayManager.instance.addEventListener (GooglePlayManager.OAUTH_TOCKEN_LOADED, OnToeknLoaded);



		if(GooglePlayConnection.state == GPConnectionState.STATE_CONNECTED) {
			//checking if player already connected
			OnPlayerConnected ();
		} 



	}
开发者ID:minh3d,项目名称:TestCB,代码行数:32,代码来源:PlayServiceExample.cs


示例6: CreateSpriteMetaDataArray

    static SpriteMetaData[] CreateSpriteMetaDataArray(
        Texture texture,
        int horizontalCount,
        int verticalCount)
    {
        float spriteWidth = texture.width / horizontalCount;
        float spriteHeight = texture.height / verticalCount;

        return Enumerable
            .Range(0, horizontalCount * verticalCount)
            .Select(index =>
            {
                int x = index % horizontalCount;
                int y = index / horizontalCount;

                return new SpriteMetaData
                {
                    name = string.Format("{0}_{1}", texture.name, index),
                    rect = new Rect(
                        x: spriteWidth * x,
                        y: texture.height - spriteHeight * (y + 1),
                        width: spriteWidth,
                        height: spriteHeight)
                };
            })
            .ToArray();
    }
开发者ID:RyotaMurohoshi,项目名称:character_animator_creator,代码行数:27,代码来源:SpriteDivider.cs


示例7: SetOverride

	static public void SetOverride(
		Texture front = null,
		Texture back = null,
		Texture left = null,
		Texture right = null,
		Texture top = null,
		Texture bottom = null )
	{
		var compositor = OpenVR.Compositor;
		if (compositor != null)
		{
			var handles = new Texture[] { front, back, left, right, top, bottom };
			var textures = new Texture_t[6];
			for (int i = 0; i < 6; i++)
			{
				textures[i].handle = (handles[i] != null) ? handles[i].GetNativeTexturePtr() : System.IntPtr.Zero;
				textures[i].eType = SteamVR.instance.graphicsAPI;
				textures[i].eColorSpace = EColorSpace.Auto;
			}
			var error = compositor.SetSkyboxOverride(textures);
			if (error != EVRCompositorError.None)
			{
				Debug.LogError("Failed to set skybox override with error: " + error);
				if (error == EVRCompositorError.TextureIsOnWrongDevice)
					Debug.Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity.");
				else if (error == EVRCompositorError.TextureUsesUnsupportedFormat)
					Debug.Log("Ensure skybox textures are not compressed and have no mipmaps.");
			}
		}
	}
开发者ID:RoBorg,项目名称:nyan,代码行数:30,代码来源:SteamVR_Skybox.cs


示例8: CreateTexture

        protected override void CreateTexture()
        {
            if (ControlTexture != null && !ControlTexture.Disposed && Size != TextureSize)
                ControlTexture.Dispose();

            if (ControlTexture == null || ControlTexture.Disposed)
            {
                DXManager.ControlList.Add(this);
                ControlTexture = new Texture(DXManager.Device, Size.Width, Size.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
                ControlTexture.Disposing += ControlTexture_Disposing;
                TextureSize = Size;
            }
            Surface oldSurface = DXManager.CurrentSurface;
            Surface surface = ControlTexture.GetSurfaceLevel(0);
            DXManager.SetSurface(surface);


            DXManager.Device.Clear(ClearFlags.Target, BackColour, 0, 0);

            BeforeDrawControl();
            DrawChildControls();
            AfterDrawControl();

            DXManager.Sprite.Flush();


            DXManager.SetSurface(oldSurface);
            TextureValid = true;
            surface.Dispose();

        }
开发者ID:Pete107,项目名称:Mir2,代码行数:31,代码来源:MirScene.cs


示例9: InitializeGraphics

 public static bool InitializeGraphics(Control handle)
 {
     try
     {
         presentParams.Windowed = true;
         presentParams.SwapEffect = SwapEffect.Discard;
         presentParams.EnableAutoDepthStencil = true;
         presentParams.AutoDepthStencilFormat = DepthFormat.D16;
         device = new Device(0, DeviceType.Hardware, handle, CreateFlags.SoftwareVertexProcessing, presentParams);
         CamDistance = 10;
         Mat = new Material();
         Mat.Diffuse = Color.White;
         Mat.Specular = Color.LightGray;
         Mat.SpecularSharpness = 15.0F;
         device.Material = Mat;
         string loc = Path.GetDirectoryName(Application.ExecutablePath);
         DefaultTex = TextureLoader.FromFile(device, loc + "\\exec\\Default.bmp");
         CreateCoordLines();
         init = true;
         return true;
     }
     catch (DirectXException)
     {
         return false;
     }
 }
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:26,代码来源:Renderer.cs


示例10: ToSerializableVersion

        /// <summary>
        /// Creates a fake <see cref="Texture"/> that will have the given serialized data version.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <returns></returns>
        public static Texture ToSerializableVersion(this Image image)
        {
            var texture = new Texture();
            texture.SetSerializationData(image);

            return texture;
        }
开发者ID:releed,项目名称:paradox,代码行数:12,代码来源:GraphicsSerializerExtensions.cs


示例11: Update

    // Update is called once per frame
    void Update()
    {
        int x = (int) Input.mousePosition.x;
        int y = (int) Input.mousePosition.y;

        bool overCredits = (x > (creditsCoords[0] * Screen.width) && x < (creditsCoords[1] * Screen.width) && y > (creditsCoords[2] * Screen.height) && y < (creditsCoords[3] * Screen.height));

        Debug.Log("Position! " + Input.mousePosition.x + ", " + Input.mousePosition.y);

        if(overCredits){
            buttonTexture = buttonTexture2;
        }
        else
            buttonTexture = backTexture;

        if(Input.GetButtonDown("Fire1")){ //Left click
            //Credits Screen
            if(overCredits){
                Application.LoadLevel("CharacterSelection");
            }
        }
        else{

        }
    }
开发者ID:DanOpdyke,项目名称:SpitfinityDan-v2,代码行数:26,代码来源:CreditScreenScript.cs


示例12: TexturedExtensibleRectangle

        public TexturedExtensibleRectangle(IContext context, Vector2I size, Texture texture, int fixedBorderRadius)
        {
            DeviceContext = context.DirectX.DeviceContext;
            _shader = context.Shaders.Get<TextureShader>();
            _texture = texture;
            _fixedBorderRadius = fixedBorderRadius;

            const int vertexCount = 16;
            _vertices = new VertexDefinition.PositionTexture[vertexCount];
            VertexBuffer = Buffer.Create(context.DirectX.Device, _vertices,
                new BufferDescription
                {
                    Usage = ResourceUsage.Dynamic,
                    SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionTexture>() * vertexCount,
                    BindFlags = BindFlags.VertexBuffer,
                    CpuAccessFlags = CpuAccessFlags.Write,
                    OptionFlags = ResourceOptionFlags.None,
                    StructureByteStride = 0
                });

            IndexCount = 54;
            uint[] indices = new uint[IndexCount];
            for(uint i=0; i< 3; i++)
                for (uint j = 0; j < 3; j++)
                {
                    indices[(i * 3 + j) * 6] = (i + 1) * 4 + j + 1;
                    indices[(i * 3 + j) * 6 + 1] = i * 4 + j + 1;
                    indices[(i * 3 + j) * 6 + 2] = i * 4 + j;
                    indices[(i * 3 + j) * 6 + 3] = (i + 1) * 4 + j;
                    indices[(i * 3 + j) * 6 + 4] = (i + 1) * 4 + j + 1;
                    indices[(i * 3 + j) * 6 + 5] = i * 4 + j;
                }
            IndexBuffer = Buffer.Create(context.DirectX.Device, BindFlags.IndexBuffer, indices);
            Size = size;
        }
开发者ID:ndech,项目名称:Alpha,代码行数:35,代码来源:TexturedExtensibleRectangle.cs


示例13: textureList

    public override IsoDecoration[] textureList(Texture match)
    {
        if (!lists.ContainsKey (match))
            regenerate (match);

        return lists [match].ToArray ();
    }
开发者ID:nvidiosin,项目名称:isoAbbeyTFG,代码行数:7,代码来源:DecorationManager.cs


示例14: Load

    public override void Load(XmlNode xnode)
    {
        type = LocalType.Get(xnode.Name);

        texture = new Texture();
        name = MyXml.GetString(xnode, "name");
        variations = MyXml.GetInt(xnode, "variations", 1);
        maxHP = MyXml.GetInt(xnode, "hp");
        damage = MyXml.GetInt(xnode, "damage");
        attack = MyXml.GetInt(xnode, "attack");
        defence = MyXml.GetInt(xnode, "defence");
        armor = MyXml.GetInt(xnode, "armor");
        movementTime = MyXml.GetFloat(xnode, "movementTime");
        attackTime = MyXml.GetFloat(xnode, "attackTime");
        isWalkable = MyXml.GetBool(xnode, "walkable");
        isFlat = MyXml.GetBool(xnode, "flat");

        if (xnode.Name == "Thing") isWalkable = true;

        string s = MyXml.GetString(xnode, "type");
        if (s != "") creatureType = CreatureType.Get(s);

        s = MyXml.GetString(xnode, "corpse");
        if (creatureType != null && (creatureType.name == "Animal" || creatureType.name == "Sentient")) s = "Blood";
        if (s != "") corpse = Get(s);

        s = MyXml.GetString(xnode, "onDeath");
        if (creatureType != null && creatureType.name == "Animal") s = "Large Chunk of Meat";
        if (s != "") onDeath = ItemShape.Get(s);

        for (xnode = xnode.FirstChild; xnode != null; xnode = xnode.NextSibling)
            abilities.Add(BigBase.Instance.abilities.Get(MyXml.GetString(xnode, "name")));
    }
开发者ID:mxgmn,项目名称:GENW,代码行数:33,代码来源:LocalShape.cs


示例15: Start

	void Start() {
		
		playerLabel.text = "Player Disconnected";
		defaulttexture = avatar.GetComponent<Renderer>().material.mainTexture;
		
		//listen for GooglePlayConnection events
		GooglePlayInvitationManager.ActionInvitationReceived += OnInvite;
		GooglePlayInvitationManager.ActionInvitationAccepted += ActionInvitationAccepted;
		GooglePlayRTM.ActionRoomCreated += OnRoomCreated;

		GooglePlayConnection.ActionPlayerConnected +=  OnPlayerConnected;
		GooglePlayConnection.ActionPlayerDisconnected += OnPlayerDisconnected;

		GooglePlayConnection.ActionConnectionResultReceived += OnConnectionResult;

		
		if(GooglePlayConnection.State == GPConnectionState.STATE_CONNECTED) {
			//checking if player already connected
			OnPlayerConnected ();
		} 

		//networking event
		GooglePlayRTM.ActionDataRecieved += OnGCDataReceived;


	}
开发者ID:sonxoans2,项目名称:Tap-Rotate,代码行数:26,代码来源:RTM_Game_Example.cs


示例16: OnMessage

 public override bool OnMessage(GUIMessage message)
 {
   switch (message.Message)
   {
     case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
       {
         base.OnMessage(message);
         Update();
         return true;
       }
     case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
       {
         if (m_pTexture != null)
         {
           m_pTexture.Dispose();
         }
         m_pTexture = null;
         base.OnMessage(message);
         // Fix for Mantis issue: 0001709: Background not correct after viewing pictures properties twice
         Restore();
         return true;
       }
   }
   return base.OnMessage(message);
 }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:25,代码来源:GUIDialogExif.cs


示例17: Start

 // Use this for initialization
 void Start()
 {
     currTime = 0;
     isBubbleVisible = false;
     defaultTimeToDisplaySpeechBubble = 3;
     speechBubble = (Texture)Resources.Load("speech_bubble");
 }
开发者ID:CG-F15-20-Rutgers,项目名称:UnityProjects,代码行数:8,代码来源:SpeechBubbleController.cs


示例18: Engine_Picture

 public Engine_Picture(string fileName, Color colorKey)
 {
     ImageInformation imageInformation = TextureLoader.ImageInformationFromFile(Engine_Game.PicturesPath + fileName);
     m_Width = imageInformation.Width;
     m_Height = imageInformation.Height;
     m_Texture = TextureLoader.FromFile(Engine_Game.Device, Engine_Game.PicturesPath + fileName, 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, colorKey.ToArgb());
 }
开发者ID:unk1nd,项目名称:US_AirForce,代码行数:7,代码来源:engine_picture.cs


示例19: Start

	// Use this for initialization
	void Start () 
	{
        _animator = GetComponent<Animator>();
		_charCtrl = GetComponent<CharacterController>();
		m_AudioSource = GetComponent<AudioSource>();
		currTexture = myBody.GetComponent<SkinnedMeshRenderer> ().material.mainTexture;
	}
开发者ID:kamilion,项目名称:UNETMovement,代码行数:8,代码来源:LocomotionPlayer.cs


示例20: LoadContent

        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var view = Matrix.LookAtRH(new Vector3(2,2,2), new Vector3(0, 0, 0), Vector3.UnitY);
            var projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.ViewWidth / GraphicsDevice.BackBuffer.ViewHeight, 0.1f, 100.0f);
            worldViewProjection = Matrix.Multiply(view, projection);

            geometry = GeometricPrimitive.Cube.New(GraphicsDevice);
            simpleEffect = new Effect(GraphicsDevice, SpriteEffect.Bytecode);
            parameterCollection = new ParameterCollection();
            parameterCollectionGroup = new EffectParameterCollectionGroup(GraphicsDevice, simpleEffect, new[] { parameterCollection });
            parameterCollection.Set(TexturingKeys.Texture0, UVTexture);
            
            // TODO DisposeBy is not working with device reset
            offlineTarget0 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this);

            offlineTarget1 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this);
            offlineTarget2 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this);

            depthBuffer = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.D16_UNorm, TextureFlags.DepthStencil).DisposeBy(this);

            width = GraphicsDevice.BackBuffer.ViewWidth;
            height = GraphicsDevice.BackBuffer.ViewHeight;
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:25,代码来源:TestRenderToTexture.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Texture2D类代码示例发布时间:2022-05-24
下一篇:
C# TextualExplanation类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap