00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 | //============================================================================= // Spatial Fear // Class: SFProceduralTexture // Description: This class provides helper functionality to manage and render // procederal textures // !! Internal use only !! // // Author: Markus Nuebel //============================================================================= class SFProceduralTexture extends SFObject; var SFArray m_arTextures; // Private: Textues array var int m_nCurrentTex; // Private: Current texture to display var int m_nCount; // Private: Number of Textures in sequence var int m_X, m_Y; // Private: Screen dimensions var int m_XL, m_YL; // Private Screen offset var int m_UL, m_VL; // Private: Offset in texture var float m_U, m_V; // Private: Texture dimensions var float m_fSequenceTime; // Private: Time in msecs for whole sequence of m_nCount frames var float m_fTextureTime; // Private: Time in msecs for a single texture var float m_fCurrentTime; // Private: Single texute countdown timer; var String m_strPrefix; // Private: Texture prefix var SFRenderStyle m_Style; // Private: Render style used during drawing // Initializes the class function init(int nCount, String strPrefix, float fSequenceTime, SFRenderStyle RenderStyle, int XL, int YL, int X, int Y, int UL, int VL, int U, int V) { // Fill in members m_fSequenceTime = fSequenceTime; m_nCount = nCount; m_Style = RenderStyle; m_strPrefix = strPrefix; m_XL = XL; m_YL = YL; m_X = X; m_Y = Y; m_UL = UL; m_VL = VL; m_U = U; m_V = V; // Init custom arrray m_arTextures = Spawn(class'SFArray'); m_arTextures.init(AT_Texture, nCount); // Load the animated texture class'SFUtils'.static.loadAnimatedTexture( m_arTextures, m_nCount, m_strPrefix); // Calc single texture time; m_fTextureTime = m_fSequenceTime/nCount; // Some inits m_fCurrentTime = m_fTextureTime; // Start countdown m_nCurrentTex = 0; //class'SFUtils'.static.sfLogEx(10,"SFProceduralTexture - init: Prefix: " $ m_strPrefix $ " Count: " $ m_nCount $ " SequenceTime: " $ class'SFUtils'.static.FormatFloat(m_fSequenceTime) $ " TextureTime: " $ class'SFUtils'.static.FormatFloat(m_fTextureTime) $ " CurrentTime: " $ class'SFUtils'.static.FormatFloat(m_fCurrentTime)); } // Cleanup stuff function terminate() { m_arTextures = None; } // Increments the texture sequence, thereby rolling over the number limit function incSequence() { m_nCurrentTex++; if(m_nCount <= m_nCurrentTex) m_nCurrentTex = 0; } // Decrements the texture sequence, thereby rolling over zero function decSequence() { m_nCurrentTex--; if(0 > m_nCurrentTex) m_nCurrentTex = m_nCount-1; } // Sets a new sequence time and updates the interal // structures accordingly function setSequenceTime(float fSequenceTime) { local float fOldTime; local float fDiff; // Save old value fOldTime = m_fTextureTime; // Update to new sequence time m_fSequenceTime = fSequenceTime; // Calc single texture time; m_fTextureTime = m_fSequenceTime/m_nCount; // Take current countdown into account fDiff = fOldTime - m_fCurrentTime; // Already counted down m_fCurrentTime = m_fTextureTime-fDiff; // Check if time is already up if(0 >= m_fCurrentTime) { incSequence(); m_fCurrentTime = m_fTextureTime; } } // Should be called every tick to update the texture state. function update(float fDeltaTime) { // Decement countdown m_fCurrentTime -= fDeltaTime*1000; if(0 >= m_fCurrentTime) { incSequence(); m_fCurrentTime = m_fTextureTime; } //class'SFUtils'.static.sfLogEx(5,"SFProceduralTexture - update: CurrentTime: " $ class'SFUtils'.static.FormatFloat(m_fCurrentTime) $ "DeltaTime" $ class'SFUtils'.static.FormatFloat(fDeltaTime) $ " TexIndex: " $ m_nCurrentTex); } // Renders the texture to the passed canvas at the passed position function render(Canvas C, int XL, int YL, float fScale) { C.Style = m_Style; // Set position C.SetPos(XL, YL); // Draw the texture C.DrawTile(m_arTextures.m_arTexture[m_nCurrentTex], m_X*fScale, m_Y*fScale, m_UL, m_VL, m_U, m_V); } defaultproperties { } |