當前位置: 首頁>>代碼示例>>Python>>正文


Python GeoMath.vecCrossProduct方法代碼示例

本文整理匯總了Python中lib.GeoMath.vecCrossProduct方法的典型用法代碼示例。如果您正苦於以下問題:Python GeoMath.vecCrossProduct方法的具體用法?Python GeoMath.vecCrossProduct怎麽用?Python GeoMath.vecCrossProduct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lib.GeoMath的用法示例。


在下文中一共展示了GeoMath.vecCrossProduct方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: findBestPatternDynamic

# 需要導入模塊: from lib import GeoMath [as 別名]
# 或者: from lib.GeoMath import vecCrossProduct [as 別名]
    def findBestPatternDynamic(self, curPoint, nextPoint, setClass, prim, patternCrack, tbn, tbnInverse, pointWhichIsRelative, texture, texturePrim):
        '''
        Get the best dynamic pattern
        
        @param curPoint:
        @type curPoint:
        @param nextPoint:
        @type nextPoint:
        @param setClass:
        @type setClass:
        @param prim:
        @type prim:
        @param patternCrack:
        @type patternCrack:
        @param tbn:
        @type tbn:
        @param tbnInverse:
        @type tbnInverse:
        @param pointWhichIsRelative:
        @type pointWhichIsRelative:
        @param texture:
        @type texture:
        @param texturePrim:
        @type texturePrim:
        '''
        logging.debug('Class AutoPattern, method findBestPatternDinamically')
        logging.debug('cur_point: ' + str(curPoint) + "next_point: " + str(nextPoint))

        # Direction of the crack
        vector = GeoMath.vecSub(nextPoint, curPoint)
        vector_rotated = tbnInverse.mulPoint3ToMatrix3(vector)
        logging.debug("vector_rotated: " + str(vector_rotated))
        # Number of attemps to try to find a good pattern
        attempts = 2
        # Get a pattern generated dynamically
        # TODO: wavelength now only 0, but it can be any number
        wavelenght = 0
        first_point = [0, 0, 0]
        # Calculate normal of pattern
        direction = GeoMath.vecNormalize(GeoMath.vecSub(vector_rotated, first_point))
        normal_of_pattern = GeoMath.vecCrossProduct(list(prim.normal()), direction)
        pattern = setClass.getRandomPattern(wavelenght, first_point, vector_rotated, normal_of_pattern)
        validatedPattern = self.validateAndAdjustPatterns(curPoint, nextPoint, setClass, prim, patternCrack, tbn, pointWhichIsRelative, texture, texturePrim, pattern)

        if(not validatedPattern):
            # Try 10 times variing random offset(seed) in the noise function to get a valid pattern
            for _ in range(attempts):
                pattern = setClass.getRandomPattern(wavelenght, first_point, vector_rotated, normal_of_pattern)
                validatedPattern = self.validateAndAdjustPatterns(curPoint, nextPoint, setClass, prim, patternCrack, tbn, pointWhichIsRelative, texture, texturePrim, pattern)
                if(validatedPattern):
                    break

        if(not validatedPattern):
            # Try "attemps" times varying the random offset(seed) of the noise funcion and do the height little to
            # increase posibilities to get a valid pattern
            height = setClass.getSizey() / 2
            reduction_height = 2
            for _ in range(attempts):
                pattern = setClass.getRandomPattern(wavelenght, first_point, vector_rotated, normal_of_pattern, height)

                validatedPattern = self.validateAndAdjustPatterns(curPoint, nextPoint, setClass, prim, patternCrack, tbn, pointWhichIsRelative, texture, texturePrim, pattern)
                # Make the height half, for get more possibilities to do a good pattern
                height = height / reduction_height
                if(validatedPattern):
                    break
        if(not validatedPattern):
            # Apply the joker pattern!
            vecH, vecV = DetermineVectors.DetermineVectors.detVec(prim, GeoMath.vecSub(nextPoint, curPoint), [0, 0, 1])
            validatedPattern = setClass.applyJoker(curPoint, nextPoint, vecH, vecV)
            logging.debug("End method finBestPatternDynamic, class Autopattern. State: Joker applied")
        else:
            logging.debug("End method finBestPatternDynamic, class Autopattern. State: good")

        return validatedPattern
開發者ID:csoriano89,項目名稱:BuildingDestruction,代碼行數:76,代碼來源:AutoPattern.py


注:本文中的lib.GeoMath.vecCrossProduct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。