コード例 #1
0
ファイル: annotate.py プロジェクト: matthieuCantat/python
    def __init__(self):
        ompy.MUserData.__init__(self, False)
        self.setDeleteAfterUse(False)  # don;t delete after draw
        self.shapes = []  #vector<int>
        self.coords = ompy.MFloatVectorArray()  #MFloatVectorArray
        self.screenSpaceOffsets = ompy.MFloatVectorArray()  #MFloatVectorArray
        self.sizes = []  #vector<float>
        self.thicknesses = []  #vector<float>
        self.colors = ompy.MFloatPointArray()  #MFloatPointArray
        self.pColors = []  #vector<MFloatPointArray>
        self.names = []  #vector<MString>
        self.fills = []  #vector<bool>
        self.spaces = []  #vector<int>
        self.maxMemorys = []  #vector<int>
        self.projPlanes = []  #vector<int>
        self.drawPlaneMode = 0  #int
        self.cameraPath = ompy.MDagPath()  #MDagPath

        self.attrMatrix = ompy.MFloatMatrix()  #MFloatMatrix
        self.attrNames = []  #vector<MString>
        self.attrValueType = []  #vector<MString>
        self.attrValueInt = []  #vector<int>
        self.attrValueFloat = []  #vector<float>
        self.attrValueDouble = []  #vector<double>
        self.attrValueEnum = []  #vector<MString>
コード例 #2
0
ファイル: annotate.py プロジェクト: matthieuCantat/python
def MMatrixToMFloatMatrix(matrixA):

    outMatrix = ompy.MFloatMatrix()

    for row in range(0, 4):
        for col in range(0, 4):
            outMatrix.setElement(row, col, float(matrixA.getElement(row, col)))

    return outMatrix
コード例 #3
0
def J_getGeoSmoothNormalToUv():
    sel = om.MGlobal.getActiveSelectionList()
    newDag = cmds.duplicate(sel.getComponent(0))
    cmds.polySoftEdge(newDag, a=180, ch=1)
    cmds.select(newDag)
    mesh = om.MFnMesh(sel.getComponent(0)[0])

    mesh.createUVSet("map5")
    mesh.clearUVs("map5")
    sel = om.MGlobal.getActiveSelectionList()

    mesh1 = om.MFnMesh(sel.getComponent(0)[0])

    faceCount = mesh.numPolygons
    uvid = 0
    for i in range(0, faceCount, 1):
        vertexCount = 0
        for verticesId in mesh.getPolygonVertices(i):
            vertexNormal = mesh.getFaceVertexNormal(i, verticesId)
            vertexBiNormal = mesh.getFaceVertexBinormal(i, verticesId)
            vertexTangent = mesh.getFaceVertexTangent(i, verticesId)
            vertexBiTangent = mesh.getFaceVertexNormal(i, verticesId).__xor__(
                mesh.getFaceVertexTangent(i, verticesId))

            matrix1 = om.MFloatMatrix(
                ((vertexTangent.x, vertexTangent.y, vertexTangent.z,
                  0), (vertexBiTangent.x, vertexBiTangent.y, vertexBiTangent.z,
                       0), (vertexNormal.x, vertexNormal.y, vertexNormal.z, 0),
                 (0, 0, 0, 0)))
            smoothNormal = vertexNormal = mesh1.getFaceVertexNormal(
                i, verticesId)
            matrix2 = om.MFloatMatrix(
                ((smoothNormal.x, 0, 0, 0), (smoothNormal.y, 0, 0, 0),
                 (smoothNormal.z, 0, 0, 0), (0, 0, 0, 0)))
            print matrix1.__mul__(matrix2)
            mesh.setUV(uvid,
                       matrix1.__mul__(matrix2).getElement(0, 0),
                       matrix1.__mul__(matrix2).getElement(1, 0), "map5")

            mesh.assignUV(i, vertexCount, uvid, "map5")
            uvid += 1
            vertexCount += 1
コード例 #4
0
ファイル: annotate.py プロジェクト: matthieuCantat/python
def dagPath_getAttrMFloatMatrix(objPath, Attr):
    out_value = ompy.MFloatMatrix()

    node = objPath.node()
    plug = ompy.MPlug(node, Attr)
    if (plug.isNull == False):
        dHandle = plug.asMDataHandle()
        out_value = dHandle.asFloatMatrix()
        plug.destructHandle(dHandle)

    return out_value
コード例 #5
0
	def computeShapeOffset( rbT, bboxPos=[0.0,0.0,0.0], comPos=[0.0,0.0,0.0] ):
		# We want the implicit collision shapes (box etc) to 
		# centered around the bounding box center so, we need to make
		# the collider shift offset relative to the center of mass
		rtn = (bboxPos[0]-comPos[0]), (bboxPos[1]-comPos[1]), (bboxPos[2]-comPos[2])

		scl = maya.cmds.xform(rbT, q=True, relative=True, scale=True)

		# if scaling applied then remove
		if scl[0]!=1.0 or scl[1]!=1.0 or scl[2]!=1.0:
			m = [
				scl[0],	0.0,	0.0,	0.0,
				0.0,	scl[1],	0.0,	0.0,
				0.0,	0.0,	scl[2],	0.0,
				0.0,	0.0,	0.0,	1.0 ]

			pt = OpenMaya.MFloatPoint(rtn)
			sclMat = OpenMaya.MFloatMatrix(m)

			# return x,y,z
			rtn = list(pt * sclMat.inverse())[:-1]

		return rtn
コード例 #6
0
ファイル: culling.py プロジェクト: DreamWall-Animation/dwmaya
    def __init__(self, camera_name):
        selection_list = om.MSelectionList()
        selection_list.add(camera_name)
        cam_dag_path = selection_list.getDagPath(0)
        self.camera = om.MFnCamera(cam_dag_path)

        world_to_cam = om.MFloatMatrix(cam_dag_path.inclusiveMatrixInverse())
        projection = self.camera.projectionMatrix()
        post_projection = self.camera.postProjectionMatrix()

        # MFloatMatrix = [x-axis, y-axis, z-axis, translate]
        view_projection = world_to_cam * projection * post_projection

        # Right = translate - x-axis
        self.right = Plane(
            view_projection[3] - view_projection[0],
            view_projection[7] - view_projection[4],
            view_projection[11] - view_projection[8],
            view_projection[15] - view_projection[12],
        )

        # Left = translate + x-axis
        self.left = Plane(
            view_projection[3] + view_projection[0],
            view_projection[7] + view_projection[4],
            view_projection[11] + view_projection[8],
            view_projection[15] + view_projection[12],
        )

        # Bottom = translate + y-axis
        self.bottom = Plane(
            view_projection[3] + view_projection[1],
            view_projection[7] + view_projection[5],
            view_projection[11] + view_projection[9],
            view_projection[15] + view_projection[13],
        )

        # Top = translate - y-axis
        self.top = Plane(
            view_projection[3] - view_projection[1],
            view_projection[7] - view_projection[5],
            view_projection[11] - view_projection[9],
            view_projection[15] - view_projection[13],
        )

        # Far = translate + z-axis
        self.far = Plane(
            view_projection[3] + view_projection[2],
            view_projection[7] + view_projection[6],
            view_projection[11] + view_projection[10],
            view_projection[15] + view_projection[14],
        )

        # Near = translate - z-axis
        self.near = Plane(
            view_projection[3] - view_projection[2],
            view_projection[7] - view_projection[6],
            view_projection[11] - view_projection[10],
            view_projection[15] - view_projection[14],
        )

        self.planes = [
            self.right, self.left, self.bottom, self.top, self.far, self.near
        ]