Esempio n. 1
0
        //-----------------------------------------------------------------------------------------------
        private InfluenceFunction GetInfluenceFunctionFromInfluenceSystem()
        {
            InfluenceSystem   influenceSystemRef       = InfluenceSystem.GetInstance();
            InfluenceFunction functionToUseForTemplate = influenceSystemRef.GetInfluenceFunctionByID(m_influenceID);

            if (functionToUseForTemplate == null)
            {
                throw new ArgumentNullException("influenceIDForTemplate");
            }

            return(functionToUseForTemplate);
        }
Esempio n. 2
0
        //-----------------------------------------------------------------------------------------------
        public void MakeAndRegisterInfluenceFunction(string influenceID, float influenceMax, uint distanceMax, uint distanceMin, uint falloffExponent)
        {
            // Make sure a function isn't already registered with the given id
            foreach (InfluenceFunction func in m_registeredInfluenceFunctions)
            {
                if (func.InfluenceID.Equals(influenceID, StringComparison.CurrentCultureIgnoreCase))
                {
                    return;
                }
            }

            InfluenceFunction newFunction = new InfluenceFunction(influenceMax, distanceMax, distanceMin, falloffExponent, influenceID);

            m_registeredInfluenceFunctions.Add(newFunction);
        }
Esempio n. 3
0
        //-----------------------------------------------------------------------------------------------
        public void InitializeData()
        {
            InfluenceFunction functionToInitializeTemplate = GetInfluenceFunctionFromInfluenceSystem();

            // Initialize texture
            // Since the template size is related to the distance from the center of the texture
            // Ex. A template of size 10 has a texture that is 21 by 21
            TemplateData = new float[(TemplateTextureDimension * TemplateTextureDimension) + 1];

            int centerX = (int)m_templateSize + 1;
            int centerY = centerX;

            for (int rowIndex = 0; rowIndex < TemplateTextureDimension; ++rowIndex)
            {
                for (int colIndex = 0; colIndex < TemplateTextureDimension; ++colIndex)
                {
                    float influenceValue = functionToInitializeTemplate.CalculateInfluenceAtPoint(colIndex, rowIndex, centerX, centerY, (int)m_templateSize);

                    int index = (int)(rowIndex * TemplateTextureDimension) + colIndex;
                    TemplateData[index] = influenceValue;
                }
            }
        }