How to use the panda3d.core 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 panda3d / panda3d / tests / putil / test_datagram.py View on Github external
def do_file_test(dg, verify, filename):
    dof = core.DatagramOutputFile()
    dof.open(filename)
    dof.put_datagram(dg)
    dof.close()

    dg2 = core.Datagram()
    dif = core.DatagramInputFile()
    dif.open(filename)
    assert dif.get_datagram(dg2)
    dif.close()

    # This is normally saved by the DatagramOutputFile header. We cheat here.
    dg2.set_stdfloat_double(dg.get_stdfloat_double())

    dgi = core.DatagramIterator(dg2)
    verify(dgi)
github panda3d / panda3d / tests / putil / test_datagram.py View on Github external
def do_file_test(dg, verify, filename):
    dof = core.DatagramOutputFile()
    dof.open(filename)
    dof.put_datagram(dg)
    dof.close()

    dg2 = core.Datagram()
    dif = core.DatagramInputFile()
    dif.open(filename)
    assert dif.get_datagram(dg2)
    dif.close()

    # This is normally saved by the DatagramOutputFile header. We cheat here.
    dg2.set_stdfloat_double(dg.get_stdfloat_double())

    dgi = core.DatagramIterator(dg2)
    verify(dgi)
github panda3d / panda3d / tests / display / test_color_buffer.py View on Github external
vertex.set_data3(core.Vec3.rfu(1, 0, 1))
    vertex.set_data3(core.Vec3.rfu(1, 0, -1))

    if vertex_color is not None:
        color = core.GeomVertexWriter(vdata, "color")
        color.set_data4(vertex_color)
        color.set_data4(vertex_color)
        color.set_data4(vertex_color)
        color.set_data4(vertex_color)

    strip = core.GeomTristrips(core.Geom.UH_static)
    strip.set_shade_model(core.Geom.SM_uniform)
    strip.add_next_vertices(4)
    strip.close_primitive()

    geom = core.Geom(vdata)
    geom.add_primitive(strip)

    gnode = core.GeomNode("card")
    gnode.add_geom(geom, state)
    card = scene.attach_new_node(gnode)
    card.set_pos(0, 2, 0)
    card.set_scale(60)

    region.active = True
    region.camera = camera

    color_texture = core.Texture("color")
    region.window.add_render_texture(color_texture,
                                     core.GraphicsOutput.RTM_copy_ram,
                                     core.GraphicsOutput.RTP_color)
github panda3d / panda3d / tests / egg2pg / test_egg_coordsys.py View on Github external
import pytest
from panda3d import core

# Skip these tests if we can't import egg.
egg = pytest.importorskip("panda3d.egg")


COORD_SYSTEMS = [core.CS_zup_right, core.CS_yup_right, core.CS_zup_left, core.CS_yup_left]


@pytest.mark.parametrize("egg_coordsys", COORD_SYSTEMS)
@pytest.mark.parametrize("coordsys", COORD_SYSTEMS)
def test_egg2pg_transform_ident(egg_coordsys, coordsys):
    # Ensures that an identity matrix always remains untouched.
    group = egg.EggGroup("group")
    group.add_matrix4(core.Mat4D.ident_mat())
    assert group.transform_is_identity()

    assert group.get_vertex_frame() == core.Mat4D.ident_mat()
    assert group.get_node_frame() == core.Mat4D.ident_mat()
    assert group.get_vertex_frame_inv() == core.Mat4D.ident_mat()
    assert group.get_node_frame_inv() == core.Mat4D.ident_mat()
    assert group.get_vertex_to_node() == core.Mat4D.ident_mat()
    assert group.get_node_to_vertex() == core.Mat4D.ident_mat()
github Moguri / BlenderPanda / templates / bpbase.py View on Github external
def init(base):
    config = pman.get_config()
    if not pman.is_frozen() and base.appRunner is None and config.getboolean('run', 'auto_build'):
        pman.build(config)

    # Add export directory to model path
    exportdir = pman.get_abs_path(config, config.get('build', 'export_dir'))
    maindir = os.path.dirname(pman.get_abs_path(config, config.get('run', 'main_file')))
    if pman.is_frozen():
        exportdir = os.path.relpath(exportdir, maindir)
    exportdir = p3d.Filename.from_os_specific(exportdir)
    p3d.get_model_path().prepend_directory(exportdir)

    base._bpbase = BPBase(base, config)
github Moguri / BlenderPanda / processor_app.py View on Github external
def make_offscreen(self, sizex, sizey):
        sizex = p3d.Texture.up_to_power_2(sizex)
        sizey = p3d.Texture.up_to_power_2(sizey)

        if self.win and self.win.get_size()[0] == sizex and self.win.get_size()[1] == sizey:
            # The current window is good, don't waste time making a new one
            return

        use_frame_rate_meter = self.frameRateMeter is not None
        self.setFrameRateMeter(False)

        self.graphicsEngine.remove_all_windows()
        self.win = None
        self.view_region = None

        # First try to create a 24bit buffer to minimize copy times
        fbprops = p3d.FrameBufferProperties()
        fbprops.set_rgba_bits(8, 8, 8, 0)
        fbprops.set_depth_bits(24)
github Derfies / panda3d-editor / src / p3d / commonUtils.py View on Github external
int:str,
        str:str,
        unicode:str,
        type:GetName,
        pm.Vec2:FloatTuple2Str,
        pm.LVecBase2f:FloatTuple2Str,
        pm.Vec3:FloatTuple2Str,
        pm.LVecBase3f:FloatTuple2Str,
        pm.Vec4:FloatTuple2Str,
        pm.LVecBase4f:FloatTuple2Str,
        pm.Point2:FloatTuple2Str,
        pm.Point3:FloatTuple2Str,
        pm.Point4:FloatTuple2Str,
        pm.Mat4:Mat42Str,
        pm.LMatrix4f:Mat42Str,
        pc.Filename:str
    }
    
    if type( val ) in fnMap:
        return fnMap[type( val )]( val )
    else:
        return None
github panda3d / panda3d / direct / src / stdpy / threading.py View on Github external
self.__dict__['daemon'] = daemon

    def __setattr__(self, key, value):
        if key == 'name':
            self.setName(value)
        elif key == 'ident':
            raise AttributeError
        elif key == 'daemon':
            self.setDaemon(value)
        else:
            self.__dict__[key] = value

# Copy these static methods from Panda's Thread object.  These are
# useful if you may be running in Panda's SIMPLE_THREADS compilation
# mode.
ThreadBase.forceYield = core.Thread.forceYield
ThreadBase.considerYield = core.Thread.considerYield

class Thread(ThreadBase):
    """ This class provides a wrapper around Panda's PythonThread
    object.  The wrapper is designed to emulate Python's own
    threading.Thread object. """

    def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
        ThreadBase.__init__(self)

        assert group is None
        self.__target = target
        self.__args = args
        self.__kwargs = kwargs

        if not name:
github Moguri / BlenderPanda / processor.py View on Github external
def _make_offscreen(self, sx, sy):
        fbprops = p3d.FrameBufferProperties(p3d.FrameBufferProperties.get_default())
        fbprops.set_srgb_color(True)
        fbprops.set_alpha_bits(0)
        wp = p3d.WindowProperties.size(sx, sy)
        flags = p3d.GraphicsPipe.BF_require_callback_window
        self.win = self.engine.make_output(self.pipe, 'viewport', 0, fbprops, wp, flags)
        self.win.disable_clears()

        def render_cb(cbdata):
            cbdata.upcall()
            cbdata.set_render_flag(True)
        self.win.set_render_callback(p3d.PythonCallbackObject(render_cb))

        dr = self.win.make_mono_display_region()
        dr.set_camera(self.view_camera)
        dr.set_active(True)
        dr.set_clear_color_active(True)
        dr.set_clear_depth(1.0)
        dr.set_clear_depth_active(True)
        self.view_region = dr
github sirikata / scene-generator / renderscene.py View on Github external
instance.setPos(model.x, model.y, model.z)
            instance.setScale(model.scale, model.scale, model.scale)
            q = p3d.Quat()
            q.setI(model.orient_x)
            q.setJ(model.orient_y)
            q.setK(model.orient_z)
            q.setR(model.orient_w)
            instance.setQuat(q)

        base.camLens.setFar(sys.maxint)
        base.camLens.setNear(8.0)

        pcore.attachLights(render)

        render.setShaderAuto()
        render.setTransparency(p3d.TransparencyAttrib.MDual, 1)
        render.setAntialias(p3d.AntialiasAttrib.MAuto)

        controls.KeyboardMovement()
        controls.ButtonUtils(scenepath)
        controls.MouseDrag(scenepath)
        controls.MouseCamera()
        controls.MouseScaleZoom(scenepath)