def computeMatrix(self):
        scale = Mat4()
        rX = Mat4()
        rY = Mat4()
        rZ = Mat4()
        scale.scale(self.scale.x, self.scale.y, self.scale.z)
        rX.rotateX(self.rotation.x)
        rY.rotateY(self.rotation.y)
        rZ.rotateZ(self.rotation.z)
        self.matrix = scale * rX * rY * rZ
        self.matrix.m[3][0] = self.position.x
        self.matrix.m[3][1] = self.position.y
        self.matrix.m[3][2] = self.position.z
        self.matrix.m[3][3] = 1.0

        self.isComputed = True
Exemplo n.º 2
0
 def getTransform(self):
     returnValue = libpanda._inPOfOPzbsf(self.this)
     import Mat4
     returnObject = Mat4.Mat4(None)
     returnObject.this = returnValue
     if returnObject.this == 0:
         return None
     return returnObject
     return
Exemplo n.º 3
0
    def getInvWrtSpace(self):
        returnValue = libpanda._inPHwca7dHE(self.this)
        import Mat4
        returnObject = Mat4.Mat4(None)
        returnObject.this = returnValue
        if returnObject.this == 0:
            return None

        return returnObject
    def getUserMat(self):
        returnValue = libpanda._inPMAKPM4l8(self.this)
        import Mat4
        returnObject = Mat4.Mat4(None)
        returnObject.this = returnValue
        if returnObject.this == 0:
            return None

        return returnObject
    def getMat(self):
        returnValue = libpanda._inPziw5oJtK(self.this)
        import Mat4
        returnObject = Mat4.Mat4(None)
        returnObject.this = returnValue
        if returnObject.this == 0:
            return None

        return returnObject
Exemplo n.º 6
0
    def getFromSpace(self):
        returnValue = libpanda._inPHwcawz01(self.this)
        import Mat4
        returnObject = Mat4.Mat4(None)
        returnObject.this = returnValue
        if returnObject.this == 0:
            return None

        return returnObject
Exemplo n.º 7
0
 def getSignTransformFromBlockNumber(self, blockNumber):
     returnValue = libtoontown._inPet4y0D3d(self.this, blockNumber)
     import Mat4
     returnObject = Mat4.Mat4(None)
     returnObject.this = returnValue
     if returnObject.this == 0:
         return None
     return returnObject
     return
Exemplo n.º 8
0
 def getSmoothMat(self):
     returnValue = libdirect._inPx5Y6HMYE(self.this)
     import Mat4
     returnObject = Mat4.Mat4(None)
     returnObject.this = returnValue
     if returnObject.this == 0:
         return None
     return returnObject
     return
Exemplo n.º 9
0
 def getProjectionMatInv(self):
     returnValue = libpanda._inPMAKPmcoU(self.this)
     import Mat4
     returnObject = Mat4.Mat4(None)
     returnObject.this = returnValue
     if returnObject.this == 0:
         return None
     return returnObject
     return
Exemplo n.º 10
0
 def getViewMat(self):
     returnValue = libpanda._inPMAKPP_m4(self.this)
     import Mat4
     returnObject = Mat4.Mat4(None)
     returnObject.this = returnValue
     if returnObject.this == 0:
         return None
     return returnObject
     return
Exemplo n.º 11
0
 def getReflectionMat(self):
     returnValue = libpanda._inPSkjPU_l3(self.this)
     import Mat4
     returnObject = Mat4.Mat4(None)
     returnObject.this = returnValue
     if returnObject.this == 0:
         return None
     returnObject.userManagesMemory = 1
     return returnObject
     return
Exemplo n.º 12
0
    def getLcs(self):
        returnValue = libpandaphysics._inP9fJJg4Kt(self.this)
        import Mat4
        returnObject = Mat4.Mat4(None)
        returnObject.this = returnValue
        if returnObject.this == 0:
            return None

        returnObject.userManagesMemory = 1
        return returnObject
Exemplo n.º 13
0
    def getInertialTensor(self):
        returnValue = libpandaphysics._inP9fJJ3KW7(self.this)
        import Mat4
        returnObject = Mat4.Mat4(None)
        returnObject.this = returnValue
        if returnObject.this == 0:
            return None

        returnObject.userManagesMemory = 1
        return returnObject
    def _Quat__overloaded___mul___ptrLQuaternionf_ptrConstLMatrix4f(
            self, parameter1):
        returnValue = libpanda._inPUZN3f9Is(self.this, parameter1.this)
        import Mat4
        returnObject = Mat4.Mat4(None)
        returnObject.this = returnValue
        if returnObject.this == 0:
            return None

        returnObject.userManagesMemory = 1
        return returnObject
Exemplo n.º 15
0
def _blender_to_nodepath(x, y, z, p):
    # TODO: test if it is fine with row-major, column-major, etc.
    mm = (x[0], y[0], z[0], 0, x[1], y[1], z[1], 0, x[2], y[2], z[2], 0, p[0],
          p[1], p[2], 1)
    try:
        import Mat4

        ret = NodePath("")
        ret.setMat(Mat4(*mm))
        return ret
    except ImportError:
        ret = dummynodepath(mm)
        return ret
Exemplo n.º 16
0
def main(filename,
         shadingrate=10,
         pixelvar=0.1,
         fov=48.0,
         width=1024,
         height=720,
         integrator='PxrPathTracer',
         integratorParams={}):
    print('shading rate {} pivel variance {} using {} {}'.format(
        shadingrate, pixelvar, integrator, integratorParams))
    ri = prman.Ri()  # create an instance of the RenderMan interface

    ri.Option("rib", {"string asciistyle": "indented,wide"})
    # this is the begining of the rib archive generation we can only
    # make RI calls after this function else we get a core dump
    ri.Begin(filename)
    ri.Option('searchpath', {'string archive': './assets/:@'})
    ri.Option('searchpath', {'string texture': './textures/:@'})
    # now we add the display element using the usual elements
    # FILENAME DISPLAY Type Output format
    ri.Display('rgb.exr', 'it', 'rgba')
    ri.Format(width, height, 1)

    # setup the raytrace / integrators
    ri.Hider('raytrace', {'int incremental': [1]})
    ri.ShadingRate(shadingrate)
    ri.PixelVariance(pixelvar)
    ri.Integrator(integrator, 'integrator', integratorParams)
    ri.Option('statistics', {'filename': ['stats.txt']})
    ri.Option('statistics', {'endofframe': [1]})

    ri.Projection(ri.PERSPECTIVE, {ri.FOV: fov})

    ri.Rotate(12, 1, 0, 0)
    ri.Translate(0, 0.75, 6.5)

    # now we start our world
    ri.WorldBegin()
    #######################################################################
    #Lighting
    #######################################################################

    ri.AttributeBegin()
    # position x,y,z rot [axis x,y,z]
    xpos = 1.0
    positions = [[-xpos, -0.2, 0, 90, 0, 1, 0], [xpos, -0.2, 0, -90, 0, 1, 0],
                 [-xpos, -0.2, -1, 90, 0, 1,
                  0], [xpos, -0.2, -1, -90, 0, 1, 0],
                 [-xpos, -0.2, -2, 90, 0, 1,
                  0], [xpos, -0.2, -2, -90, 0, 1, 0],
                 [-xpos, -0.2, -3, 90, 0, 1,
                  0], [xpos, -0.2, -3, -90, 0, 1, 0],
                 [-xpos, -0.2, -4, 90, 0, 1,
                  0], [xpos, -0.2, -4, -90, 0, 1, 0],
                 [-xpos, -0.2, -5, 90, 0, 1, 0],
                 [xpos, -0.2, -5, -90, 0, 1, 0], [0, -0.2, 0.8, 180, 0, 1, 0],
                 [0, 2, 0, 0, 0, 1, 0], [0, 0.8, -1, 90, 1, 0, 0],
                 [0, 0.8, -2, 90, 1, 0, 0], [0, 0.8, -3, 90, 1, 0, 0],
                 [0, 0.8, -4, 90, 1, 0, 0]]
    lightNum = 0
    ri.Attribute('visibility', {
        'int indirect': [0],
        'int transmission': [0],
        'int camera': [1]
    })
    # rotation matrix for the master image used in portals
    xrot = Mat4.Mat4()
    xrot.rotateX(90)
    yrot = Mat4.Mat4()
    yrot.rotateY(180)
    tx = yrot * xrot

    for p in positions:
        ri.TransformBegin()
        ri.Declare('portalLight{0}'.format(lightNum), 'string')
        ri.Translate(p[0], p[1], p[2])
        ri.Rotate(p[3], p[4], p[5], p[6])
        ri.Scale(0.5, 0.5, 1)
        lightNum = lightNum + 1
        ri.Light(
            'PxrPortalLight', 'portalLight', {
                'float exposure': 1.0,
                'float intensity': 1.0,
                'string domeColorMap': ['Luxo-Jr_4000x2000.tex'],
                'matrix portalToDome': tx.getMatrix(),
            })
        ri.TransformEnd()
    ri.AttributeEnd()

    #######################################################################
    # end lighting
    #######################################################################

    ri.AttributeBegin()
    ri.TransformBegin()
    ri.Attribute('identifier', {'name': 'cornell'})
    ri.Scale(1.0, 1.0, 1.5)
    ri.ReadArchive('cornell.rib')
    ri.TransformEnd()
    ri.AttributeEnd()

    ri.AttributeBegin()
    ri.Attribute('identifier', {'name': 'buddha'})
    ri.TransformBegin()
    ri.Translate(-0.5, -1, -4)
    ri.Rotate(180, 0, 1, 0)
    ri.Scale(0.1, 0.1, 0.1)
    ri.Attribute('visibility', {'int transmission': [1]})
    ri.Attribute('trace', {
        'int maxdiffusedepth': [1],
        'int maxspeculardepth': [8]
    })
    ri.Bxdf(
        'PxrSurface', 'greenglass', {
            'color refractionColor': [0, 0.9, 0],
            'float diffuseGain': 0,
            'color specularEdgeColor': [0.2, 1, 0.2],
            'float refractionGain': [1.0],
            'float reflectionGain': [1.0],
            'float glassRoughness': [0.01],
            'float glassIor': [1.5],
            'color extinction': [0.0, 0.2, 0.0],
        })

    ri.ReadArchive('buddha.zip!buddha.rib')
    ri.TransformEnd()
    ri.AttributeEnd()

    ri.AttributeBegin()
    ri.Attribute('identifier', {'name': 'sphere'})
    ri.Pattern('PxrVariable', 'du', {
        'string variable': 'du',
        'string type': 'float'
    })
    ri.Pattern('PxrVariable', 'dv', {
        'string variable': 'dv',
        'string type': 'float'
    })
    ri.Pattern('starBall', 'starBall', {
        'reference float du': ['du:resultR'],
        'reference float dv': ['dv:resultR']
    })

    ri.Bxdf('PxrDisney', 'bxdf',
            {'reference color baseColor': ['starBall:Cout']})
    ri.TransformBegin()
    ri.Translate(0.3, -0.7, -4.3)
    ri.Rotate(-30, 0, 1, 0)
    ri.Rotate(20, 1, 0, 0)
    ri.Sphere(0.3, -0.3, 0.3, 360)
    ri.TransformEnd()
    ri.AttributeEnd()

    ri.AttributeBegin()
    ri.Attribute('identifier', {'name': 'teapot'})
    ri.TransformBegin()
    ri.Translate(0, -1, -4.8)
    ri.Rotate(45, 0, 1, 0)
    ri.Rotate(-90, 1, 0, 0)
    ri.Scale(0.1, 0.1, 0.1)
    ri.Bxdf(
        'PxrSurface', 'plastic', {
            'color diffuseColor': [.04, .51, .1],
            'color clearcoatFaceColor': [.5, .5, .5],
            'color clearcoatEdgeColor': [.25, .25, .25]
        })
    ri.Geometry('teapot')
    ri.TransformEnd()
    ri.AttributeEnd()

    ri.AttributeBegin()
    ri.Bxdf(
        'PxrSurface', 'metal', {
            'float diffuseGain': [0],
            'int specularFresnelMode': [1],
            'color specularEdgeColor': [1, 1, 1],
            'color specularIor': [4.3696842, 2.916713, 1.654698],
            'color specularExtinctionCoeff': [5.20643, 4.2313662, 3.7549689],
            'float specularRoughness': [0.1],
            'integer specularModelType': [1]
        })

    ri.Attribute('identifier', {'name': 'ncca'})
    ri.TransformBegin()
    ri.Translate(0, 0.3, 0.8)
    ri.ReadArchive('ncca.rib')
    ri.TransformEnd()
    ri.AttributeEnd()

    # end our world
    ri.WorldEnd()
    # and finally end the rib file
    ri.End()
 def __init__(self):
     self.matrix = Mat4()
     self.position = Vec4(0.0, 0.0, 0.0)
     self.scale = Vec4(1.0, 1.0, 1.0)
     self.rotation = Vec4(0.0, 0.0, 0.0)
     self.isComputed = False
Exemplo n.º 18
0
#!/usr/bin/python

from Mat4 import *

a = Mat4()
print a
a.rotateX(45)
print a
a.identity()
a.rotateY(45)
print a
a.identity()
a.rotateZ(45)
print a
a.identity()
a.scale(2, 2, 2)
a.translate(3, 4, 5)
print a
a.transpose()
print a
print a.getTranspose()
print a * a.getTranspose()
Exemplo n.º 19
0
def axissystem_to_mat4(a):
    return Mat4(a.x.x, a.x.y, a.x.z, 0, a.y.x, a.y.y, a.y.z, 0, a.z.x, a.z.y,
                a.z.z, 0, a.origin.x, a.origin.y, a.origin.z, 1)