本文整理汇总了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