コード例 #1
0
def view_bam(path):
    path = core.Filename.from_os_specific(path)
    loader = core.Loader.get_global_ptr()
    node = loader.load_sync(path)

    lens = core.OrthographicLens()
    lens.film_size = (1, 1)
    lens.set_view_vector((0, 0, -1), (0, 1, 0))
    lens.set_near_far(-100, 100)

    base = ShowBase()
    base.render.attach_new_node(node)

    base.disable_mouse()
    base.cam.node().set_lens(lens)
    base.camLens = lens

    base.run()
コード例 #2
0
#!/usr/bin/env python

import sys

from direct.showbase.ShowBase import ShowBase
from panda3d.core import Vec3, Point3
from panda3d.bullet import BulletWorld, BulletRigidBodyNode, BulletSphereShape

s = ShowBase()
s.disable_mouse()
s.accept('escape', sys.exit)

# The physics simulation itself
physics = BulletWorld()
physics.setGravity(Vec3(0, 0, 0))
def step_physics(task):
  dt = globalClock.getDt()
  physics.doPhysics(dt)
  return task.cont
s.taskMgr.add(step_physics, 'physics simulation')

# A physical object in the simulation
node = BulletRigidBodyNode('Box')
node.setMass(1.0)
node.addShape(BulletSphereShape(1))
# Attaching the physical object in the scene graph and adding
# a visible model to it
np = s.render.attachNewNode(node)
np.set_pos(0, 0, 0)
np.set_hpr(45, 0, 45)
m = loader.loadModel("models/smiley")
コード例 #3
0
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase

load_prc_file_data("", "win-size 512 512")

base = ShowBase(windowType='offscreen')
base.disable_mouse()

assets_dir = Filename(
    ExecutionEnvironment.expand_string("$MAIN_DIR/../assets"))

tuft = base.loader.load_model(Filename(assets_dir, "/models/tuft.egg"))
tuft.set_two_sided(True)
tuft.reparent_to(base.render)

pmin, pmax = tuft.get_tight_bounds()
radius = tuft.get_bounds().get_radius()

dim = max(pmax[2] - pmin[2], radius * 2)

lens = OrthographicLens()
lens.set_near_far(-dim, dim * 3)
lens.set_film_size(dim, dim)
lens.film_offset = (0, dim * 0.5)
base.cam.node().set_lens(lens)

base.cam.set_y(-dim)

tex = Texture()
base.win.add_render_texture(tex, GraphicsOutput.RTM_copy_ram)
コード例 #4
0
from random import random

from direct.showbase.ShowBase import ShowBase

from panda3d.core import VBase3
from panda3d.core import Vec3
from panda3d.core import Quat
from panda3d.core import invert
from panda3d.bullet import BulletWorld
from panda3d.bullet import BulletRigidBodyNode
from panda3d.bullet import BulletSphereShape
from panda3d.bullet import BulletDebugNode

# Basic setup
s = ShowBase()
s.disable_mouse()
s.accept('escape', sys.exit)
s.cam.set_pos(0, -10, 0)

# Physics
bullet_world = BulletWorld()


def run_physics(task):
    bullet_world.do_physics(globalClock.getDt())
    return task.cont


s.task_mgr.add(run_physics, sort=1)

# Debug visualization