예제 #1
0
 def load(self, patch, callback, cb_args=()):
     if self.texture is None:
         self.texture = Texture()
         self.texture.set_wrap_u(Texture.WMClamp)
         self.texture.set_wrap_v(Texture.WMClamp)
         self.parent.interpolator.configure_texture(self.texture)
         self.do_load(patch, callback, cb_args)
     else:
         if callback is not None:
             callback(self, *cb_args)
예제 #2
0
 def apply(self, instance):
     if self.texture is None:
         if self.image is None:
             self.image = self.generate()
         self.texture = Texture()
         self.texture.load(self.image)
     instance.setTexGen(TextureStage.getDefault(),
                        TexGenAttrib.MPointSprite)
     instance.setTransparency(TransparencyAttrib.MAlpha, 1)
     instance.setTexture(TextureStage('ts'), self.texture, 1)
 def __init__(self, width, height, callback, getCam, callbackParams=(), getCamParams=(), cleanUpCamCall=dispose,toRam=False, texture=None):
     self.cleanUpCamCall=cleanUpCamCall
     self.width=width
     self.height=height
     self.callbackProp=callback
     self.getCamMethod=getCam
     self.getCamParams=getCamParams
     self.toRam=toRam
     self.callbackParams=callbackParams
     self.texture=texture if texture is not None else Texture()
예제 #4
0
def peeker_from_pixel(component_type, format, data):
    """ Creates a 1-pixel texture with the given settings and pixel data,
    then returns a TexturePeeker as result of calling texture.peek(). """

    tex = Texture("")
    tex.setup_1d_texture(1, component_type, format)
    tex.set_ram_image(data)
    peeker = tex.peek()
    assert peeker.has_pixel(0, 0)
    return peeker
예제 #5
0
 def generate(self, callback, cb_args=()):
     if self.texture is None:
         self.texture = Texture()
         self.texture.set_wrap_u(Texture.WMClamp)
         self.texture.set_wrap_v(Texture.WMClamp)
         self.parent.interpolator.configure_texture(self.texture)
         self._make_heightmap(callback, cb_args)
     else:
         if callback is not None:
             callback(self, *cb_args)
예제 #6
0
파일: _model.py 프로젝트: svfgit/solex
 def __apply_Textures(self, recipe, tex_dict):
     for i, ter_dict in enumerate(recipe['terrains']):
         tex_img = PNMImage()
         tex_img.read(Filename("{}/tex/{}".format(recipe['planet_path'], ter_dict['texture'])))
         tex = Texture()
         tex.load(tex_img)
         tex.setMinfilter(Texture.FTLinear)
         ts = TextureStage(str(i))
         ts.setSort(i)
         self.NP.setTexture(ts, tex, i*10)
예제 #7
0
 def load(self, shape, callback, cb_args=()):
     if self.texture is None:
         self.texture = Texture()
         self.texture.set_wrap_u(Texture.WMClamp)
         self.texture.set_wrap_v(Texture.WMClamp)
         self.interpolator.configure_texture(self.texture)
         self.do_load(shape, self.heightmap_ready_cb, (callback, cb_args))
     else:
         if callback is not None:
             callback(self, *cb_args)
예제 #8
0
 def add_color_attachment(self, bits=8, alpha=False):
     """ Adds a new color attachment with the given amount of bits, bits can
     be either a single int or a tuple determining the bits. If bits is a
     single int, alpha determines whether alpha bits are requested """
     self._targets["color"] = Texture(self.debug_name + "_color")
     if isinstance(bits, (list, tuple)):
         self._color_bits = (bits[0], bits[1], bits[2],
                             bits[3] if len(bits) == 4 else 0)
     else:
         self._color_bits = ((bits, bits, bits, (bits if alpha else 0)))
예제 #9
0
 def renderSceneInto(self, depthtex=None, colortex=None, auxtex=None, auxbits=0, textures=None):
     if textures:
         colortex = textures.get('color', None)
         depthtex = textures.get('depth', None)
         auxtex = textures.get('aux', None)
         auxtex0 = textures.get('aux0', auxtex)
         auxtex1 = textures.get('aux1', None)
     else:
         auxtex0 = auxtex
         auxtex1 = None
     if colortex == None:
         colortex = Texture('filter-base-color')
         colortex.setWrapU(Texture.WMClamp)
         colortex.setWrapV(Texture.WMClamp)
     texgroup = (depthtex, colortex, auxtex0, auxtex1)
     winx, winy = self.getScaledSize(1, 1, 1)
     buffer = self.createBuffer('filter-base', winx, winy, texgroup)
     if buffer == None:
         return
     cm = CardMaker('filter-base-quad')
     cm.setFrameFullscreenQuad()
     quad = NodePath(cm.generate())
     quad.setDepthTest(0)
     quad.setDepthWrite(0)
     quad.setTexture(colortex)
     quad.setColor(1, 0.5, 0.5, 1)
     cs = NodePath('dummy')
     cs.setState(self.camstate)
     if auxbits:
         cs.setAttrib(AuxBitplaneAttrib.make(auxbits))
     self.camera.node().setInitialState(cs.getState())
     quadcamnode = Camera('filter-quad-cam')
     lens = OrthographicLens()
     lens.setFilmSize(2, 2)
     lens.setFilmOffset(0, 0)
     lens.setNearFar(-1000, 1000)
     quadcamnode.setLens(lens)
     quadcam = quad.attachNewNode(quadcamnode)
     self.region.setCamera(quadcam)
     self.setStackedClears(buffer, self.rclears, self.wclears)
     if auxtex0:
         buffer.setClearActive(GraphicsOutput.RTPAuxRgba0, 1)
         buffer.setClearValue(GraphicsOutput.RTPAuxRgba0, (0.5, 0.5, 1.0, 0.0))
     if auxtex1:
         buffer.setClearActive(GraphicsOutput.RTPAuxRgba1, 1)
     self.region.disableClears()
     if self.isFullscreen():
         self.win.disableClears()
     dr = buffer.makeDisplayRegion()
     dr.disableClears()
     dr.setCamera(self.camera)
     dr.setActive(1)
     self.buffers.append(buffer)
     self.sizes.append((1, 1, 1))
     return quad
예제 #10
0
 def _initDepthCapture(self):
     
     for camera in self.cameras:
     
         camNode = Camera('Depth camera')
         camNode.setCameraMask(self.cameraMask)
         lens = PerspectiveLens()
         lens.setFov(self.fov)
         lens.setAspectRatio(float(self.size[0]) / float(self.size[1]))
         lens.setNear(self.zNear)
         lens.setFar(self.zFar)
         camNode.setLens(lens)
         camNode.setScene(self.scene.scene)
         cam = camera.attachNewNode(camNode)
         
         winprops = WindowProperties.size(self.size[0], self.size[1])
         fbprops = FrameBufferProperties.getDefault()
         fbprops = FrameBufferProperties(fbprops)
         fbprops.setRgbColor(False)
         fbprops.setRgbaBits(0, 0, 0, 0)
         fbprops.setStencilBits(0)
         fbprops.setMultisamples(0)
         fbprops.setBackBuffers(0)
         fbprops.setDepthBits(16)
         
         flags = GraphicsPipe.BFFbPropsOptional
         if self.mode == 'onscreen':
             flags = flags | GraphicsPipe.BFRequireWindow
         elif self.mode == 'offscreen':
             flags = flags | GraphicsPipe.BFRefuseWindow
         else:
             raise Exception('Unsupported rendering mode: %s' % (self.mode))
         
         buf = self.graphicsEngine.makeOutput(self.pipe, 'Depth buffer', 0, fbprops,
                                              winprops, flags)
         if buf is None:
             raise Exception('Unable to create depth buffer')
         
         # Set to render at the end
         buf.setSort(10000)
         
         dr = buf.makeDisplayRegion()
         dr.setSort(0)
         dr.setCamera(cam)
         dr = camNode.getDisplayRegion(0)
         
         tex = Texture()
         tex.setFormat(Texture.FDepthComponent)
         tex.setComponentType(Texture.TFloat)
         buf.addRenderTexture(tex, GraphicsOutput.RTMCopyRam, GraphicsOutput.RTPDepth)
         #XXX: should use tex.setMatchFramebufferFormat(True)?
         
         agent = camera.getParent()
         self.depthBuffers[agent.getName()] = buf
         self.depthTextures[agent.getName()] = tex
예제 #11
0
    def generate_lookup_table(self):
        tex_generator = self.get_generator(self.lookup_size)
        shader = ONeilLookupTableShader(self)
        shader.create_and_register_shader(None, None)
        self.pbOpticalDepth = Texture()
        self.pbOpticalDepth.setWrapU(Texture.WM_clamp)
        self.pbOpticalDepth.setWrapV(Texture.WM_clamp)
        self.pbOpticalDepth.setMinfilter(Texture.FT_linear)
        self.pbOpticalDepth.setMagfilter(Texture.FT_linear)

        tex_generator.generate(shader, 0, self.pbOpticalDepth)
예제 #12
0
 def setup_post_effect(self):
     self.manager = FilterManager(base.win, base.cam2d)
     tex = Texture()
     #tex = loader.load_texture("assets/noise.png")
     self.quad = self.manager.renderSceneInto(colortex=tex)
     self.quad.setShader(Shader.load(Shader.SL_GLSL, "crt.vert","crt.frag"))
     self.quad.setShaderInput("iResolution", (base.win.getXSize(), base.win.getYSize()))
     self.quad.setShaderInput("pattern", base.loader.load_texture("assets/crt.png"))
     self.quad.get_texture().set_wrap_u(SamplerState.WM_clamp)
     self.quad.get_texture().set_wrap_v(SamplerState.WM_clamp)
     base.accept("window-event", self.on_window_event)
예제 #13
0
    def setSize(self, width, height):
        if self.texture is None:
            self.texture = Texture()

        self.width = width
        self.height = height

        self.texture.setup2dTexture(width, height, Texture.TUnsignedByte, Texture.FRgba)

        if self.browser is not None:
            self.browser.WasResized()
예제 #14
0
파일: shader.py 프로젝트: PlumpMath/yyagl
    def apply(self):
        winprops = WindowProperties.size(2048, 2048)
        props = FrameBufferProperties()
        props.setRgbColor(1)
        props.setAlphaBits(1)
        props.setDepthBits(1)
        lbuffer = base.graphicsEngine.makeOutput(base.pipe, 'offscreen buffer',
                                                 -2, props, winprops,
                                                 GraphicsPipe.BFRefuseWindow,
                                                 base.win.getGsg(), base.win)
        self.buffer = lbuffer
        ldepthmap = Texture()
        lbuffer.addRenderTexture(ldepthmap, GraphicsOutput.RTMBindOrCopy,
                                 GraphicsOutput.RTPDepthStencil)
        ldepthmap.setMinfilter(Texture.FTShadow)
        ldepthmap.setMagfilter(Texture.FTShadow)

        base.camLens.setNearFar(1.0, 10000)
        base.camLens.setFov(75)

        self.lcam = base.makeCamera(lbuffer)
        self.lcam.node().setScene(render)
        self.lcam.node().getLens().setFov(45)
        self.lcam.node().getLens().setNearFar(1, 100)

        render.setShaderInput('light', self.lcam)
        render.setShaderInput('depthmap', ldepthmap)
        render.setShaderInput('ambient', .15, .15, .15, 1.0)

        lci = NodePath(PandaNode('light camera initializer'))
        with open('yyagl/assets/shaders/caster.vert') as f:
            vert = f.read()
        with open('yyagl/assets/shaders/caster.frag') as f:
            frag = f.read()
        lci.setShader(Shader.make(Shader.SLGLSL, vert, frag))
        self.lcam.node().setInitialState(lci.getState())

        mci = NodePath(PandaNode('main camera initializer'))
        with open('yyagl/assets/shaders/main.vert') as f:
            vert = f.read()
        with open('yyagl/assets/shaders/main.frag') as f:
            frag = f.read()
        frag = frag.replace('<LIGHTS>', str(len(self.lights)))
        # use PTALVecBaseX instead
        # setShaderInput('vec3argname', PTALVecBase3(((0, 0, 0), (1, 1, 1))))
        render.setShader(Shader.make(Shader.SLGLSL, vert, frag))
        render.setShaderInput('num_lights', len(self.lights))
        map(lambda lgt: self.set_lgt_args(*lgt), enumerate(self.lights))
        mci.setShader(Shader.make(Shader.SLGLSL, vert, frag))
        base.cam.node().setInitialState(mci.getState())

        self.lcam.setPos(15, 30, 45)
        self.lcam.lookAt(0, 15, 0)
        self.lcam.node().getLens().setNearFar(1, 100)
예제 #15
0
def image_from_stored_pixel(component_type, format, data):
    """ Creates a 1-pixel texture with the given settings and pixel data,
    then returns a PNMImage as result of calling texture.store(). """

    tex = Texture("")
    tex.setup_1d_texture(1, component_type, format)
    tex.set_ram_image(data)

    img = PNMImage()
    assert tex.store(img)
    return img
예제 #16
0
 def create_heightmap(self, patch, callback=None, cb_args=()):
     if self.texture is None:
         self.texture = Texture()
         self.texture.set_wrap_u(Texture.WMClamp)
         self.texture.set_wrap_v(Texture.WMClamp)
         self.texture.setMinfilter(Texture.FT_linear)
         self.texture.setMagfilter(Texture.FT_linear)
         self._make_heightmap(callback, cb_args)
     else:
         if callback is not None:
             callback(self, *cb_args)
예제 #17
0
 def do_load_texture(self, filename, alpha_filename):
     tex = Texture()
     panda_filename = Filename.from_os_specific(filename)
     if alpha_filename is not None:
         panda_alpha_filename = Filename.from_os_specific(alpha_filename)
     else:
         panda_alpha_filename = Filename('')
     tex.read(fullpath=panda_filename,
              alpha_fullpath=panda_alpha_filename,
              primary_file_num_channels=0,
              alpha_file_channel=0)
     return tex
예제 #18
0
    def __chooseHue(self):
        for x in xrange(self.image.getXSize()):
            for y in xrange(self.image.getYSize()):
                self.image.setXel(
                    x, y,
                    colorsys.hsv_to_rgb(self.slider['value'],
                                        (x / 100.0) + self.minSat,
                                        (y / 100.0) + self.minVal))

        texture = Texture()
        texture.load(self.image)
        self.button['image'] = texture
예제 #19
0
def peek_tex_with_clear_color(component_type, format, clear_color):
    """ Creates a 1-pixel texture with the given settings and clear color,
    then peeks the value at this pixel and returns it. """

    tex = Texture("")
    tex.setup_1d_texture(1, component_type, format)
    tex.set_clear_color(clear_color)
    tex.make_ram_image()

    col = LColor()
    tex.peek().fetch_pixel(col, 0, 0)
    return col
예제 #20
0
    def create(self):
        """ Creates the passes """
        self.cloudStartHeight = 900.0
        self.cloudEndHeight = 3300.0
        self.cloudResolution = 768
        self.cloudResolutionH = 128

        self.voxelGrid = Texture("CloudVoxelGrid")
        self.voxelGrid.setup3dTexture(self.cloudResolution,
                                      self.cloudResolution,
                                      self.cloudResolutionH, Texture.TFloat,
                                      Texture.FR16)
        self.voxelGrid.setWrapU(Texture.WMRepeat)
        self.voxelGrid.setWrapV(Texture.WMRepeat)
        self.voxelGrid.setWrapW(Texture.WMClamp)

        self.cloudNoise = Texture("CloudNoise")
        self.cloudNoise.setup3dTexture(64, 64, 64, Texture.TFloat,
                                       Texture.FR16)
        self.cloudNoise.setWrapU(Texture.WMRepeat)
        self.cloudNoise.setWrapV(Texture.WMRepeat)
        self.cloudNoise.setWrapW(Texture.WMRepeat)

        MemoryMonitor.addTexture("CloudVoxelGrid", self.voxelGrid)
        MemoryMonitor.addTexture("CloudNoise", self.cloudNoise)

        self._createInitialGrid()

        self.renderPass = CloudRenderPass()
        self.pipeline.getRenderPassManager().registerPass(self.renderPass)
        self.pipeline.getRenderPassManager().registerStaticVariable(
            "cloudVoxelGrid", self.voxelGrid)
        self.pipeline.getRenderPassManager().registerStaticVariable(
            "cloudStartHeight", self.cloudStartHeight)
        self.pipeline.getRenderPassManager().registerStaticVariable(
            "cloudEndHeight", self.cloudEndHeight)
        self.pipeline.getRenderPassManager().registerStaticVariable(
            "cloudNoise", self.cloudNoise)
        self.pipeline.getRenderPassManager().registerDefine(
            "CLOUDS_ENABLED", 1)
예제 #21
0
    def __init__(self):
        ShowBase.__init__(self)
        manager = FilterManager(base.win, base.cam)
        tex = Texture()
        quad = manager.renderSceneInto(colortex=tex)
        quad.setShader(Shader.load("myfilter.sha"))
        quad.setShaderInput("tex", tex)
 
        # Disable the camera trackball controls.
        self.disableMouse()
 
        # Load the environment model.
        self.environ = self.loader.loadModel("models/environment")
        # Reparent the model to render.
        self.environ.reparentTo(self.render)
        # Apply scale and position transforms on the model.
        self.environ.setScale(0.25, 0.25, 0.25)
        self.environ.setPos(-8, 42, 0)
 
        # Add the spinCameraTask procedure to the task manager.
        self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
 
        # Load and transform the panda actor.
        self.pandaActor = Actor("models/panda-model",
                                {"walk": "models/panda-walk4"})
        self.pandaActor.setScale(0.005, 0.005, 0.005)
        self.pandaActor.reparentTo(self.render)
        # Loop its animation.
        self.pandaActor.loop("walk")
 
        # Create the four lerp intervals needed for the panda to
        # walk back and forth.
        pandaPosInterval1 = self.pandaActor.posInterval(13,
                                                        Point3(0, -10, 0),
                                                        startPos=Point3(0, 10, 0))
        pandaPosInterval2 = self.pandaActor.posInterval(13,
                                                        Point3(0, 10, 0),
                                                        startPos=Point3(0, -10, 0))
        pandaHprInterval1 = self.pandaActor.hprInterval(3,
                                                        Point3(180, 0, 0),
                                                        startHpr=Point3(0, 0, 0))
        pandaHprInterval2 = self.pandaActor.hprInterval(3,
                                                        Point3(0, 0, 0),
                                                        startHpr=Point3(180, 0, 0))
 
        # Create and play the sequence that coordinates the intervals.
        self.pandaPace = Sequence(pandaPosInterval1,
                                  pandaHprInterval1,
                                  pandaPosInterval2,
                                  pandaHprInterval2,
                                  name="pandaPace")
        self.pandaPace.loop()
예제 #22
0
 def heightmap_ready_cb(self, texture, callback, cb_args):
     if texture is not None:
         self.texture = texture
         #print("READY", self.patch.str_id(), texture, self.texture)
         self.texture_peeker = texture.peek()
         #           if self.texture_peeker is None:
         #               print("NOT READY !!!")
         self.heightmap_ready = True
         data = self.texture.getRamImage()
         #TODO: should be completed and refactored
         signed = False
         component_type = texture.getComponentType()
         if component_type == Texture.T_float:
             buffer_type = numpy.float32
             scale = 1.0
         elif component_type == Texture.T_unsigned_byte:
             if signed:
                 buffer_type = numpy.int8
                 scale = 128.0
             else:
                 buffer_type = numpy.uint8
                 scale = 255.0
         elif component_type == Texture.T_unsigned_short:
             if signed:
                 buffer_type = numpy.int16
                 scale = 32768.0
             else:
                 buffer_type = numpy.uint16
                 scale = 65535.0
         if sys.version_info[0] < 3:
             buf = data.getData()
             np_buffer = numpy.fromstring(buf, dtype=buffer_type)
         else:
             np_buffer = numpy.frombuffer(data, buffer_type)
         np_buffer.shape = (self.texture.getYSize(),
                            self.texture.getXSize(),
                            self.texture.getNumComponents())
         self.min_height = np_buffer.min() / scale
         self.max_height = np_buffer.max() / scale
         self.mean_height = np_buffer.mean() / scale
     else:
         if self.parent_heightmap is not None:
             self.calc_sub_patch()
         else:
             print("Make default texture for heightmap")
             texture = Texture()
             texture.setup_2d_texture(1, 1, Texture.T_float, Texture.F_r32)
             texture.set_clear_color(LColor(0, 0, 0, 0))
             texture.make_ram_image()
             self.heightmap_ready_cb(texture, None, None)
     if callback is not None:
         callback(self, *cb_args)
예제 #23
0
def create_color_texture(c):
    """Sets up a simple Panda3D texture from raw numpy values."""
    tex = Texture("image1")
    tex.setMagfilter(Texture.FTNearest)
    tex.setup2dTexture(1, 1, Texture.TUnsignedByte, Texture.FRgb8)

    Pic = np.array(c, np.uint8)
    p1 = PTAUchar()
    p1.setData(Pic.tostring())
    c1 = CPTAUchar(p1)
    tex.setRamImage(c1)

    return tex
예제 #24
0
 def setOwnerTextures(self):
     self.ownerview = True
     root = self.terrain.getRoot()
     root.clearShader()
     root.clearTexture()
     cityTexture = Texture()
     cityTexture.load(self.citymap)
     cityTS = TextureStage('citymap')
     cityTS.setSort(0)
     root.setTexture(self.gridTS, self.gridTexture)
     root.setTexScale(self.gridTS, self.terrain.xchunks,
                      self.terrain.ychunks)
     root.setTexture(cityTS, cityTexture, 1)
예제 #25
0
 def _setup_textures(self):
     """ Prepares all bound textures """
     for i in range(self._aux_count):
         self._targets["aux_{}".format(i)] = Texture(self.debug_name +
                                                     "_aux{}".format(i))
     for tex in itervalues(self._targets):
         tex.set_wrap_u(SamplerState.WM_clamp)
         tex.set_wrap_v(SamplerState.WM_clamp)
         tex.set_anisotropic_degree(0)
         tex.set_x_size(self._size.x)
         tex.set_y_size(self._size.y)
         tex.set_minfilter(SamplerState.FT_linear)
         tex.set_magfilter(SamplerState.FT_linear)
    def _makeLightingComputeBuffer(self):
        self.lightingComputeContainer = RenderTarget("ComputeLighting")
        self.lightingComputeContainer.setSize(
            base.win.getXSize() / self.temporalProjFactor, base.win.getYSize())
        self.lightingComputeContainer.addRenderTexture(RenderTargetType.Color)
        self.lightingComputeContainer.setColorBits(16)
        self.lightingComputeContainer.prepareOffscreenBuffer()

        self.lightingComputeCombinedTex = Texture("Lighting-Compute-Combined")
        self.lightingComputeCombinedTex.setup2dTexture(base.win.getXSize(),
                                                       base.win.getYSize(),
                                                       Texture.TFloat,
                                                       Texture.FRgba16)
        self.lightingComputeCombinedTex.setMinfilter(Texture.FTLinear)
        self.lightingComputeCombinedTex.setMagfilter(Texture.FTLinear)

        self.lastPositionBuffer = Texture("Last-Position-Buffer")
        self.lastPositionBuffer.setup2dTexture(base.win.getXSize(),
                                               base.win.getYSize(),
                                               Texture.TFloat, Texture.FRgba16)
        self.lastPositionBuffer.setMinfilter(Texture.FTNearest)
        self.lastPositionBuffer.setMagfilter(Texture.FTNearest)
예제 #27
0
    def __init__(self, pipeline):
        RenderPass.__init__(self)
        self.pipeline = pipeline

        # Create the storage for the exposure. We cannot simply use the color output
        # as the RenderTargetMatcher would have problems with that (Circular Reference)
        self.lastExposureStorage = Texture("Last Exposure")
        self.lastExposureStorage.setup2dTexture(1, 1, Texture.TFloat,
                                                Texture.FR32)

        # Registers the texture so the lighting pass can use it
        self.pipeline.renderPassManager.registerStaticVariable(
            "dynamicExposureTex", self.lastExposureStorage)
예제 #28
0
 def __get_Texture(self, ref_img):
     # Convert ref_img into texture.
     with TimeIt() as prep_timer:
         ref_tex = Texture()
         # Ensure ref image has an alpha channel.
         if not ref_img.hasAlpha():
             ref_img.addAlpha()
             ref_img.alphaFill(1.0)
         # Load tex and set format
         ref_tex.load(ref_img)
         ref_tex.setFormat(self.img_format)
     self.prepare_time += round(prep_timer.total_time, 3)
     return ref_tex
예제 #29
0
    def __init__(self):
        """ Creates a new IES Loader """
        DebugObject.__init__(self, "IESLoader")
        self.storage = Texture("IESProfiles")
        self.storage.setup2dTextureArray(self.IESTableResolution, 1, 64,
                                         Texture.TFloat, Texture.FRgba16)
        self.storage.setMinfilter(SamplerState.FTLinear)
        self.storage.setMagfilter(SamplerState.FTLinear)
        self.storage.setWrapU(SamplerState.WMClamp)
        self.storage.setWrapV(SamplerState.WMClamp)
        self.storage.setWrapW(SamplerState.WMClamp)

        self.profileNames = []
예제 #30
0
    def __add_block(self, x: int, y: int) -> None:
        idx = y * self.num_blocks_x + x

        mesh = self.square_meshes[idx] = SquareMesh(self.block_size, self.block_size, self.depth)
        np = self.squares[idx] = self.root.attach_new_node(mesh.geom_node)
        np.set_pos((x * self.block_size, y * self.block_size, 0))

        tex = self.textures[idx] = Texture(self.name + "_texture")
        tex.setup_2d_texture(self.texture_w, self.texture_h, Texture.T_unsigned_byte, Texture.F_rgba8)
        tex.modify_ram_image().set_subdata(0, len(self.__init_tex_data), self.__init_tex_data)
        np.set_texture(tex)
        tex.set_wrap_u(Texture.WM_clamp)
        tex.set_wrap_v(Texture.WM_clamp)