예제 #1
0
def SetRelativeTransformAtTime(parent, child, time, transform):
	partrans = GetAbsTransformAtTime(parent, time)

	result = vs.matrix3x4_t()
	vs.ConcatTransforms(partrans, transform)

	SetAbsTransformAtTime(child, time, result)
예제 #2
0
def GetRelativeTransformAtTime(parent, child, time):
	partrans = GetAbsTransformAtTime(parent, time)
	childtrans = GetAbsTransformAtTime(child, time)

	inv_partrans = vs.matrix3x4_t()
	vs.MatrixInvert(partrans, inv_partrans)

	result = vs.matrix3x4_t()
	vs.ConcatTransforms(inv_partrans, childtrans, result)

	return result
예제 #3
0
def GetAbsTransformAtTime(dag, time):
	trans = GetTransformAtTime(dag, time)

	if (dag.GetType() == vs.CDmeGameModel_GetStaticTypeSymbol()):
		return trans
	else:
		partrans = GetAbsTransformAtTime(dag.GetParent(), time)

		result = vs.matrix3x4_t()
		vs.ConcatTransforms(partrans, trans, result)
		return result
예제 #4
0
    def writeToGroup(self, group):
        animset = sfm.GetCurrentAnimationSet()
        shot = sfm.GetCurrentShot()
        rootDag = sfmUtils.FindFirstDag([
            "RootTransform", "rootTransform", "roottransform", "Roottransform"
        ])
        suffix = self.createSuffix(self.target)

        groupAddStringAttribute(group, name_targetname, self.target)

        group.SetValue(name_boxsize, self.boxsize)
        group.SetValue(name_boxcenter, self.boxcenter)
        group.SetValue(name_margin, float(self.margin))
        group.SetValue(name_mass, float(self.mass))

        self.handle = sfm.CreateRigHandle(name_handle + suffix,
                                          group=group.GetName())

        #position the handle at the box center
        bonedag = sfm.FindDag(self.target)
        CenterTransform = PosQuatToTransform(self.boxcenter,
                                             vs.Quaternion(0, 0, 0, 1))
        ResultTransform = vs.matrix3x4_t()
        vs.ConcatTransforms(bonedag.GetAbsTransform(), CenterTransform,
                            ResultTransform)
        self.handle.SetAbsTransform(ResultTransform)
        sfmUtils.Parent(self.handle, rootDag)
        sfm.ParentConstraint(name_handle + suffix, self.target, mo=True)

        self.force = sfm.CreateRigHandle(name_force + suffix,
                                         group=group.GetName())
        self.force.SetAbsTransform(self.handle.GetAbsTransform())
        sfmUtils.Parent(self.force, self.handle)

        shapeval = 0
        if self.shape == "sphere":
            shapeval = 1
        groupCreateControlledValue(group, name_shape + suffix, shapeval,
                                   animset, shot)

        kineval = 0
        if self.mass == 0:
            kineval = 1
        groupCreateControlledValue(group, name_kinematic + suffix, kineval,
                                   animset, shot)

        groupCreateControlledValue(group, name_bounce + suffix, self.bounce,
                                   animset, shot)
        groupCreateControlledValue(group, name_friction + suffix,
                                   self.friction, animset, shot)
        groupCreateControlledValue(group, name_lindamp + suffix, self.lindamp,
                                   animset, shot)
        groupCreateControlledValue(group, name_rotdamp + suffix, self.rotdamp,
                                   animset, shot)
예제 #5
0
def SetAbsTransformAtTime(dag, time, transform):
	if (dag.GetType() == vs.CDmeGameModel_GetStaticTypeSymbol()):
		SetTransformAtTime(dag, time, transform)
	else:
		partrans = GetAbsTransformAtTime(dag.GetParent(), time)

		inv_partrans = vs.matrix3x4_t()
		vs.MatrixInvert(partrans, inv_partrans)

		result = vs.matrix3x4_t()
		vs.ConcatTransforms(inv_partrans, transform, result)

		SetTransformAtTime(dag, time, result)
예제 #6
0
    def writeToGroup(self, group):
        animset = sfm.GetCurrentAnimationSet()
        shot = sfm.GetCurrentShot()
        rootDag = sfmUtils.FindFirstDag([
            "RootTransform", "rootTransform", "roottransform", "Roottransform"
        ])
        suffix = self.createSuffix(self.constype, self.bodya, self.bodyb)

        groupAddStringAttribute(group, name_typename, self.constype)
        groupAddStringAttribute(group, name_bodya, self.bodya)
        groupAddStringAttribute(group, name_bodyb, self.bodyb)

        self.handle = sfm.CreateRigHandle(name_handle + suffix,
                                          group=group.GetName())

        #position the handle at bodya plus some offset
        daga = sfm.FindDag(self.bodya)
        dagb = sfm.FindDag(self.bodyb)
        ResultTransform = vs.matrix3x4_t()
        if (self.pos is None):
            #placing pos at the same spot as bodyb is usually a good guess
            ResultTransform = PosQuatToTransform(dagb.GetAbsPosition(),
                                                 daga.GetAbsOrientation())
        else:
            OffsetTransform = PosQuatToTransform(self.pos,
                                                 vs.Quaternion(0, 0, 0, 1))
            vs.ConcatTransforms(daga.GetAbsTransform(), OffsetTransform,
                                ResultTransform)
        #end
        self.handle.SetAbsTransform(ResultTransform)
        sfmUtils.Parent(self.handle, daga)

        if (self.constype == "cone"):
            groupCreateControlledValue(group, name_rotx + suffix,
                                       self.rotx / 180.0, animset, shot)
            groupCreateControlledValue(group, name_roty + suffix,
                                       self.roty / 180.0, animset, shot)
            groupCreateControlledValue(group, name_twist + suffix,
                                       self.twist / 180.0, animset, shot)