Esempio n. 1
0
 def getShaderObj(self):
     import shader
     if not shader.Shader.supported():
         return None
     shaderPath = self.getShader()
     if not shaderPath:
         return None
     return shader.getShader(shaderPath, self.shaderDefines)
Esempio n. 2
0
 def addShader(obj):
     if mc.objectType(obj, isType = 'mesh'):
         s = shader.getShader(obj)
         if s:
             asset_shaders[obj] = s
     children = mc.listRelatives(obj, children = True, fullPath = True)
     if children:
         for c in children:
             addShader(c)
Esempio n. 3
0
 def addShader(obj):
     if mc.objectType(obj, isType = 'mesh'):
         s = shader.getShader(obj)
         if s and (not s in asset_shaders):
             asset_shaders.append(s)
     children = mc.listRelatives(obj, children = True, fullPath = True)
     if children:
         for c in children:
             addShader(c)
    def setShader(self, path):
        gui3d.app.selectedHuman.mesh.setShader(path)

        for child in self.paramBox.children[:]:
            self.paramBox.removeWidget(child)

        if not path:
            return

        sh = shader.getShader(path)
        uniforms = sh.getUniforms()
        for index, uniform in enumerate(uniforms):
            if uniform.name.startswith('gl_'):
                continue
            self.paramBox.addWidget(UniformValue(uniform), index)
    def setShader(self, path):
        gui3d.app.selectedHuman.mesh.setShader(path)

        for child in self.paramBox.children[:]:
            self.paramBox.removeWidget(child)

        if not path:
            return

        sh = shader.getShader(path)
        uniforms = sh.getUniforms()
        for index, uniform in enumerate(uniforms):
            if uniform.name.startswith("gl_"):
                continue
            self.paramBox.addWidget(UniformValue(uniform), index)
Esempio n. 6
0
 def shaderObj(self):
     if not shader.Shader.supported():
         return None
     if self._shaderPath != self.parent.shader:
         self._shaderObj = None
     if self._shaderObj is False:
         return None
     if self._shaderObj is None:
         self._shaderPath = self.parent.shader
         if self._shaderPath is None:
             self._shaderObj = None
         else:
             self._shaderObj = shader.getShader(self._shaderPath)
     if self._shaderObj is False:
         return None
     return self._shaderObj
Esempio n. 7
0
 def shaderObj(self):
     if not shader.Shader.supported():
         return None
     if self._shaderPath != self.parent.shader:
         self._shaderObj = None
     if self._shaderObj is False:
         return None
     if self._shaderObj is None:
         self._shaderPath = self.parent.shader
         if self._shaderPath is None:
             self._shaderObj = None
         else:
             self._shaderObj = shader.getShader(self._shaderPath)
     if self._shaderObj is False:
         return None
     return self._shaderObj
Esempio n. 8
0
def init():
    global theWorld
    # Normal OpenGL initializations
    glClearColor(0.5,0.5,0.5,1.0)
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    #glBlendFunc(GL_ONE, GL_ONE)
    glEnable(GL_CULL_FACE)

    #glEnable(GL_ALPHA_TEST)
    #glAlphaFunc(GL_GREATER, 0.001)
    
    # Create the buffer and uniform objects for our sphere surface
    theShader = getShader(shaderfiles[0], shaderfiles[1])
    theSurface = ParametricSurface(point = spherePoint, norm = sphereNorm,
                                   sRange = sRange, tRange = tRange)
    theBuffer = PNTBuffer(theShader,
                          theSurface.vertices,
                          theSurface.indices,
                          5)
    pMatrix = projectionMatrix(1.0, 100.0, 1.0, 1.0)
    pMatrix = orthographicMatrix(1.0, 100.0, 10.0, 10.0)
    pMatrix = confusionMatrix(10.0, 40.0, 100.0, 10.0, 10.0)
    # only used if no joystick:
    tMatrix = translationMatrix(0.0, 0.0, -20.0)
    rMatrix = numpy.eye(4, dtype=numpy.float32)
    theUniforms = Uniforms(theShader,
                           [('focalDistance', 'float',
                             20.0),
                            ('light', 'vec4',
                             numpy.array((10,10,10,1), dtype=numpy.float32)),
                            ('color', 'vec4',
                             numpy.array((0,.5,0), dtype=numpy.float32)),
                            ('modelMatrix', 'mat4',
                             numpy.eye(4, dtype=numpy.float32)),
                            ('translationMatrix', 'mat4',
                             tMatrix),
                            ('preRotationMatrix', 'mat4',
                             rMatrix),
                            ('postRotationMatrix', 'mat4',
                             numpy.eye(4, dtype=numpy.float32)),
                            ('projectionMatrix', 'mat4',
                             pMatrix)
                            ])
    theWorld = Mesh(theUniforms, theBuffer)
def init():
    global theSphere
    # Normal OpenGL initializations
    glClearColor(0.5,0.5,0.5,1.0)
    glEnable(GL_DEPTH_TEST)
    
    # Create the buffer and uniform objects for our sphere surface
    theShader = getShader('shader001.vert', 'shader001.frag')
    theSurface = ParametricSurface(point = spherePoint, norm = sphereNorm,
                                   sRange = sRange, tRange = tRange)
    theBuffer = PNTBuffer(theShader,
                          theSurface.vertices,
                          theSurface.indices,
                          200)
    pMatrix = projectionMatrix(1.0, 100.0, 1.0, 1.0)
    # only used if no joystick:
    tMatrix = translationMatrix(0.0, 0.0, -20.0)
    rMatrix = numpy.eye(4, dtype=numpy.float32)
    theUniforms = Uniforms(theShader,
                           [('light', 'vec4',
                             numpy.array((10,10,10,1), dtype=numpy.float32)),
                            ('color', 'vec4',
                             numpy.array((0,.5,0), dtype=numpy.float32)),
                            ('modelMatrix', 'mat4',
                             numpy.eye(4, dtype=numpy.float32)),
                            ('translationMatrix', 'mat4',
                             tMatrix),
                            ('preRotationMatrix', 'mat4',
                             rMatrix),
                            ('postRotationMatrix', 'mat4',
                             numpy.eye(4, dtype=numpy.float32)),
                            ('projectionMatrix', 'mat4',
                             pMatrix),
                            ('showLines', 'int',
                             0)])
    theSphere = Mesh(theUniforms, theBuffer)