How to use the panda3d.core.Vec4 function in Panda3D

To help you get started, we’ve selected a few Panda3D examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tobspr / RenderPipeline / code / gui / onscreen_debugger.py View on Github external
self._hint_reloading = Sprite(
            image="data/gui/shader_reload_hint.png",
            x=float((Globals.base.win.get_x_size()) // 2) / self._gui_scale - 465 // 2, y=220,
            parent=self._fullscreen_node)
        self.set_reload_hint_visible(False)

        if not NATIVE_CXX_LOADED:
            # Warning when using the python version
            python_warning = Sprite(
                image="data/gui/python_warning.png",
                x=((Globals.base.win.get_x_size()/self._gui_scale) - 1054) // 2,
                y=(Globals.base.win.get_y_size()/self._gui_scale) - 118 - 40, parent=self._fullscreen_node)

            Sequence(
                python_warning.color_scale_interval(0.7, Vec4(0.3, 1, 1, 0.7), blendType="easeOut"),
                python_warning.color_scale_interval(0.7, Vec4(1, 1, 1, 1.0), blendType="easeOut"),
            ).loop()

        # Keybinding hints
        self._keybinding_instructions = Sprite(
            image="data/gui/keybindings.png", x=30,
            y=Globals.base.win.get_y_size()//self._gui_scale - 510.0,
            parent=self._fullscreen_node, any_filter=False)
github tobspr / RenderPipeline / code / gui / onscreen_debugger.py View on Github external
""" Creates the hints like keybindings and when reloading shaders """
        self._hint_reloading = Sprite(
            image="data/gui/shader_reload_hint.png",
            x=float((Globals.base.win.get_x_size()) // 2) / self._gui_scale - 465 // 2, y=220,
            parent=self._fullscreen_node)
        self.set_reload_hint_visible(False)

        if not NATIVE_CXX_LOADED:
            # Warning when using the python version
            python_warning = Sprite(
                image="data/gui/python_warning.png",
                x=((Globals.base.win.get_x_size()/self._gui_scale) - 1054) // 2,
                y=(Globals.base.win.get_y_size()/self._gui_scale) - 118 - 40, parent=self._fullscreen_node)

            Sequence(
                python_warning.color_scale_interval(0.7, Vec4(0.3, 1, 1, 0.7), blendType="easeOut"),
                python_warning.color_scale_interval(0.7, Vec4(1, 1, 1, 1.0), blendType="easeOut"),
            ).loop()

        # Keybinding hints
        self._keybinding_instructions = Sprite(
            image="data/gui/keybindings.png", x=30,
            y=Globals.base.win.get_y_size()//self._gui_scale - 510.0,
            parent=self._fullscreen_node, any_filter=False)
github PiratesOnlineRewritten / Pirates-Online-Rewritten / pirates / seapatch / SeaPatchRoot.py View on Github external
def resetProperties(self):
        self.seaLevel = 0
        self.center = 0
        self.anchor = None
        self.overallSpeed = 0
        self.uvSpeed = Vec2(0, 0)
        self.threshold = 0
        self.radius = 0
        self.uvScale = VBase2(0, 0)
        self.waveEnabled = 0
        self.high = Vec4(0, 0, 0, 0)
        self.mid = VBase4(0, 0, 0, 0)
        self.low = Vec4(0, 0, 0, 0)
github tobspr / RenderPipeline / Code / GUI / FastText.py View on Github external
def __init__(self, font="Data/Font/Roboto-Medium.ttf", pixel_size=16, align="left",
                 pos=Vec2(0), color=Vec3(1), outline=Vec4(0, 0, 0, 1), parent=None):
        """ Creates a new text instance with the given font and pixel size """
        DebugObject.__init__(self)
        self._font = font
        self._size = pixel_size
        self._align = align
        self._position = Vec2(pos)
        self._cache_key = self._font + "##" + str(self._size)
        self._parent = Globals.base.aspect2d if parent is None else parent
        self._pta_position = PTALVecBase4.empty_array(self._MAX_CHARS)
        self._pta_offset = PTAFloat.empty_array(1)
        self._pta_uv = PTALVecBase4.empty_array(self._MAX_CHARS)
        self._pta_color = PTALVecBase4.empty_array(2)
        self._pta_color[0] = Vec4(color.x, color.y, color.z, 1.0)
        self._pta_color[1] = Vec4(outline)
        self._text = ""
github tobspr / RenderPipeline / Code / GUI / FastText.py View on Github external
def set_color(self, r, g, b):
        """ Sets the text color """
        self._pta_color[0] = Vec4(r, g, b, 1)
github tobspr / RenderPipeline / rpcore / gui / debugger.py View on Github external
def create_stats(self):
        """ Creates the stats overlay """
        self.overlay_node = Globals.base.aspect2d.attach_new_node("Overlay")
        self.debug_lines = []

        num_lines = 6 if self.advanced_info else 1
        for i in range(num_lines):
            self.debug_lines.append(TextNode(
                pos=Vec2(0, -i * 0.046), parent=self.overlay_node, align="right", color=Vec3(0.7, 1, 1)))
        self.debug_lines[0].color = Vec4(1, 1, 0, 1)
github tobspr / RenderPipeline / Code / GlobalIllumination.py View on Github external
# Create the voxelize pass which is used to voxelize the scene from
        # several directions
        self.voxelizePass = VoxelizePass(self.pipeline)
        self.voxelizePass.setVoxelGridResolution(self.voxelGridResolution)
        self.voxelizePass.setVoxelGridSize(self.voxelGridSize)
        self.voxelizePass.setGridResolutionMultiplier(1)
        self.pipeline.getRenderPassManager().registerPass(self.voxelizePass)

        self.generationTextures = []

        # Create the buffers used to create the voxel grid
        for color in "rgb":
            tex = Texture("VoxelGeneration-" + color)
            tex.setup3dTexture(self.voxelGridResolution, self.voxelGridResolution, self.voxelGridResolution, Texture.TInt, Texture.FR32)
            tex.setClearColor(Vec4(0))
            self.generationTextures.append(tex)
            Globals.render.setShaderInput("voxelGenDest" + color.upper(), tex)
            
            MemoryMonitor.addTexture("VoxelGenerationTex-" + color.upper(), tex)

        self.bindTo(Globals.render, "giData")

        self.convertGridTarget = RenderTarget("ConvertGIGrid")
        self.convertGridTarget.setSize(self.voxelGridResolution * self.slideCount, self.voxelGridResolution * self.slideCount)

        if self.pipeline.settings.useDebugAttachments:
            self.convertGridTarget.addColorTexture()
        self.convertGridTarget.prepareOffscreenBuffer()

        # Set a near-filter to the texture
        if self.pipeline.settings.useDebugAttachments:
github tobspr / RenderPipeline / Code / GUI / FastText.py View on Github external
def update(self):
        """ Updates the text """
        advance_x = 0.0
        text_scale_x = self._size * 2.0 / float(Globals.base.win.get_y_size())
        # text_scale_y = self._size * 2.0 * 2.0 / float(Globals.base.win.get_y_size())
        text_scale_y = text_scale_x

        for char_pos, char in enumerate(self._text):
            idx = self._SUPPORTED_GLYPHS.index(char)
            uv, pos, advance = self._font_data[2][idx]
            self._pta_uv[char_pos] = uv
            self._pta_position[char_pos] = Vec4(
                self._position.x + (advance_x + pos[0]) * text_scale_x,
                self._position.y + pos[1] * text_scale_y,
                self._position.x + (advance_x + pos[2]) * text_scale_x,
                self._position.y + pos[3] * text_scale_y)
            advance_x += advance

        if self._align == "left":
            self._pta_offset[0] = 0
        elif self._align == "center":
            self._pta_offset[0] = -advance_x * text_scale_x * 0.5
        elif self._align == "right":
            self._pta_offset[0] = -advance_x * text_scale_x

        self._card.set_instance_count(len(self._text))
github cosmonium / cosmonium / third-party / pandamenu / menu.py View on Github external
tnp=NodePath(tn.getInternalGeom())
                underlineXend=tnp.getTightBounds()[1][0]
                tnp.removeNode()
                tn.setText(t[underlinePos])
                tnp=NodePath(tn.getInternalGeom())
                b3=tnp.getTightBounds()
                underlineXstart=underlineXend-(b3[1]-b3[0])[0]
                tnp.removeNode()
                underlineZpos=-.7*baselineToBot-self.font.getLineHeight()*t[:underlinePos].count('\n')
                LSunder=LineSegs()
                LSunder.setThickness(underscoreThickness)
                LSunder.moveTo(underlineXstart+texMargin,0,underlineZpos)
                LSunder.drawTo(underlineXend-texMargin,0,underlineZpos)
                if disabled:
                   underline=b.attachNewNode(LSunder.create())
                   underline.setColor(Vec4(*textColorDisabled),1)
                else:
                   underline=b.stateNodePath[0].attachNewNode(LSunder.create())
                   underline.setColor(Vec4(*textColorReady),1)
                   underline.copyTo(b.stateNodePath[1],10).setColor(Vec4(*textColorHover if haveSubmenu else textColorPress),1)
                   underline.copyTo(b.stateNodePath[2],10).setColor(Vec4(*textColorHover),1)
                   hotkey=t[underlinePos].lower()
                   if hotkey in self.hotkeys:
                      self.hotkeys[hotkey].append(self.numItems)
                   else:
                      self.hotkeys[hotkey]=[self.numItems]
                      self.accept(self.BTprefix+hotkey,self.__processHotkey,[hotkey])
                      self.accept(self.BTprefix+'alt-'+hotkey,self.__processHotkey,[hotkey])
             if haveSubmenu:
                if disabled:
                   arrow=realArrow.instanceUnderNode(b,'')
                   arrow.setColor(Vec4(*textColorDisabled),1)
github cosmonium / cosmonium / cosmonium / procedural / water.py View on Github external
def create_instance(self):
        self.create_buffer()
        # Water surface
        maker = CardMaker('water')
        maker.setFrame(self.x1, self.x2, self.y1, self.y2)

        self.waterNP = self.parent.instance.attachNewNode(maker.generate())
        self.waterNP.setHpr(0, -90, 0)
        self.waterNP.setPos(0, 0, self.z)
        self.waterNP.setTransparency(TransparencyAttrib.MAlpha)
        self.waterNP.setShader(Shader.load(Shader.SL_GLSL,
                                           vertex=defaultDirContext.find_shader('water-vertex.glsl'),
                                           fragment=defaultDirContext.find_shader('water-fragment.glsl')))
        self.waterNP.setShaderInput('wateranim', Vec4(0.03, -0.015, self.scale, 0)) # vx, vy, scale, skip
        # offset, strength, refraction factor (0=perfect mirror, 1=total refraction), refractivity
        self.waterNP.setShaderInput('waterdistort', Vec4(0.4, 4.0, 0.25, 0.45))
        self.waterNP.setShaderInput('time', 0)

        # Reflection plane
        self.waterPlane = Plane(Vec3(0, 0, self.z + 1), Point3(0, 0, self.z))
        planeNode = PlaneNode('waterPlane')
        planeNode.setPlane(self.waterPlane)

        # reflection texture, created in realtime by the 'water camera'
        tex0 = self.buffer.getTexture()
        tex0.setWrapU(Texture.WMClamp)
        tex0.setWrapV(Texture.WMClamp)
        ts0 = TextureStage('reflection')
        self.waterNP.setTexture(ts0, tex0)

        # distortion texture
        tex1 = loader.loadTexture('textures/water.png')