| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using System;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- namespace BansheeEngine
- {
- /** @addtogroup Rendering
- * @{
- */
- /// <summary>
- /// Texture that references a part of a larger texture by specifying an UV subset. When the sprite texture is rendererd
- /// only the portion of the texture specified by the UV subset will be rendered. This allows you to use the same texture
- /// for multiple sprites (texture atlasing). Sprite textures also allow you to specify sprite sheet animation by varying
- /// which portion of the UV is selected over time.
- /// </summary>
- public partial class SpriteTexture : Resource
- {
- private SpriteTexture(bool __dummy0) { }
- protected SpriteTexture() { }
- /// <summary>Creates a new sprite texture that references the entire area of the provided texture.</summary>
- public SpriteTexture(Texture texture)
- {
- Internal_create(this, texture);
- }
- /// <summary>Creates a new sprite texture that references a sub-area of the provided texture.</summary>
- public SpriteTexture(Vector2 uvOffset, Vector2 uvScale, Texture texture)
- {
- Internal_create0(this, ref uvOffset, ref uvScale, texture);
- }
- /// <summary>Determines the internal texture that the sprite texture references.</summary>
- public Texture Texture
- {
- get { return Internal_getTexture(mCachedPtr); }
- set { Internal_setTexture(mCachedPtr, value); }
- }
- /// <summary>Returns width of the sprite texture in pixels.</summary>
- public uint Width
- {
- get { return Internal_getWidth(mCachedPtr); }
- }
- /// <summary>Returns height of the sprite texture in pixels.</summary>
- public uint Height
- {
- get { return Internal_getHeight(mCachedPtr); }
- }
- /// <summary>
- /// Determines the offset into the referenced texture where the sprite starts. The offset is in UV coordinates, in range
- /// [0, 1].
- /// </summary>
- public Vector2 Offset
- {
- get
- {
- Vector2 temp;
- Internal_getOffset(mCachedPtr, out temp);
- return temp;
- }
- set { Internal_setOffset(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Determines the size of the sprite in the referenced texture. Size is in UV coordinates, range [0, 1].
- /// </summary>
- public Vector2 Scale
- {
- get
- {
- Vector2 temp;
- Internal_getScale(mCachedPtr, out temp);
- return temp;
- }
- set { Internal_setScale(mCachedPtr, ref value); }
- }
- /// <summary>
- /// Sets properties describing sprite animation. The animation splits the sprite area into a grid of sub-images which can
- /// be evaluated over time. In order to view the animation you must also enable playback through setAnimationPlayback().
- /// </summary>
- public SpriteSheetGridAnimation Animation
- {
- get
- {
- SpriteSheetGridAnimation temp;
- Internal_getAnimation(mCachedPtr, out temp);
- return temp;
- }
- set { Internal_setAnimation(mCachedPtr, ref value); }
- }
- /// <summary>Determines if and how should the sprite animation play.</summary>
- public SpriteAnimationPlayback AnimationPlayback
- {
- get { return Internal_getAnimationPlayback(mCachedPtr); }
- set { Internal_setAnimationPlayback(mCachedPtr, value); }
- }
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_setTexture(IntPtr thisPtr, Texture texture);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern Texture Internal_getTexture(IntPtr thisPtr);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern uint Internal_getWidth(IntPtr thisPtr);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern uint Internal_getHeight(IntPtr thisPtr);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_setOffset(IntPtr thisPtr, ref Vector2 offset);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_getOffset(IntPtr thisPtr, out Vector2 __output);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_setScale(IntPtr thisPtr, ref Vector2 scale);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_getScale(IntPtr thisPtr, out Vector2 __output);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_setAnimation(IntPtr thisPtr, ref SpriteSheetGridAnimation anim);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_getAnimation(IntPtr thisPtr, out SpriteSheetGridAnimation __output);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_setAnimationPlayback(IntPtr thisPtr, SpriteAnimationPlayback playback);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern SpriteAnimationPlayback Internal_getAnimationPlayback(IntPtr thisPtr);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_create(SpriteTexture managedInstance, Texture texture);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern void Internal_create0(SpriteTexture managedInstance, ref Vector2 uvOffset, ref Vector2 uvScale, Texture texture);
- }
- /** @} */
- }
|