Beispiel #1
0
    def real_world_length(self):
        """
		nCloth simulates in meters; so, convert and return the space scale
		in the scene's working units.
		"""
        self._real_world_length = convertUnit(float( \
         self.nucleus.attr('spaceScale').get()), fromUnit='m')
        return self._real_world_length
Beispiel #2
0
	def real_world_length(self):
		"""
		nCloth simulates in meters; so, convert and return the space scale
		in the scene's working units.
		"""
		self._real_world_length = convertUnit(float( \
			self.nucleus.attr('spaceScale').get()), fromUnit='m')
		return self._real_world_length
Beispiel #3
0
	def real_world_length(self, value=None):
		"""
		Sets the real world length according to the scene's working units and
		also sets the nCloth nucleus space scale to compensate.
		"""
		if value:
			# Run a conversion formula to adjust for any variance between the
			# size of the object in the real world vs. the size of the object in Maya.
			max_length, bbs = 0, self.shared_transforms \
				and [st.getBoundingBox() for st in self.shared_transforms] \
				or [self.transform.getBoundingBox()]
			for bb in bbs:
				max_length = max(max_length, bb.width(), bb.height(), bb.depth())
			self._real_world_length = float(convertUnit(value))
			ss = self._real_world_length / max_length
			ss = float(convertUnit(ss, toUnit='m')[:-1])
		else:
			# No value was passed. Assume the units are accurate to the scene's
			# working units.
			self._real_world_length = float(convertUnit(1, toUnit='m')[:-1])
			ss = self._real_world_length
		self.nucleus.attr('spaceScale').set(ss)
Beispiel #4
0
    def real_world_length(self, value=None):
        """
		Sets the real world length according to the scene's working units and
		also sets the nCloth nucleus space scale to compensate.
		"""
        if value:
            # Run a conversion formula to adjust for any variance between the
            # size of the object in the real world vs. the size of the object in Maya.
            max_length, bbs = 0, self.shared_transforms \
             and [st.getBoundingBox() for st in self.shared_transforms] \
             or [self.transform.getBoundingBox()]
            for bb in bbs:
                max_length = max(max_length, bb.width(), bb.height(),
                                 bb.depth())
            self._real_world_length = float(convertUnit(value))
            ss = self._real_world_length / max_length
            ss = float(convertUnit(ss, toUnit='m')[:-1])
        else:
            # No value was passed. Assume the units are accurate to the scene's
            # working units.
            self._real_world_length = float(convertUnit(1, toUnit='m')[:-1])
            ss = self._real_world_length
        self.nucleus.attr('spaceScale').set(ss)
Beispiel #5
0
def create_scaled_ncloth_prompt(msg=None):
	lines = []
	if msg:
		lines.append(msg)
	rwl = promptBox('Create Scaled nCloth',
		os.linesep.join(lines +[ \
		'What is the real-world length of the longest object in',
		'your selection (e.g. 7ft, 2in, etc. or scene)?']),
		'Create Scaled nCloth', 'Cancel')
	if rwl:
		if rwl.lower() == 'scene':
			return create_scaled_ncloth_auto()
		try:
			rwl = float(convertUnit(rwl))
		except RuntimeError:
			return create_scaled_ncloth_prompt( \
				msg='Conversion error: invalid units. Please try again.')
		return create_scaled_ncloth_auto(rwl=rwl)
Beispiel #6
0
def create_scaled_ncloth_prompt(msg=None):
    lines = []
    if msg:
        lines.append(msg)
    rwl = promptBox('Create Scaled nCloth',
     os.linesep.join(lines +[ \
     'What is the real-world length of the longest object in',
     'your selection (e.g. 7ft, 2in, etc. or scene)?']),
     'Create Scaled nCloth', 'Cancel')
    if rwl:
        if rwl.lower() == 'scene':
            return create_scaled_ncloth_auto()
        try:
            rwl = float(convertUnit(rwl))
        except RuntimeError:
            return create_scaled_ncloth_prompt( \
             msg='Conversion error: invalid units. Please try again.')
        return create_scaled_ncloth_auto(rwl=rwl)
Beispiel #7
0
def convert_points(points):
	for i, p in enumerate(points):
		for j, p2 in enumerate(p):
			points[i][j] = float(convertUnit(p2, fromUnit='cm'))
	return points
Beispiel #8
0
def convert_points(points):
    for i, p in enumerate(points):
        for j, p2 in enumerate(p):
            points[i][j] = float(convertUnit(p2, fromUnit='cm'))
    return points