Пример #1
0
hg.LoadPlugins()

plus = hg.GetPlus()
plus.RenderInit(1024, 768)

scn = plus.NewScene(True)

cam = plus.AddCamera(scn, hg.Matrix4.TranslationMatrix(hg.Vector3(0, 0, -3)))
plus.AddLight(scn, hg.Matrix4.TranslationMatrix(hg.Vector3(0, 7, 0)), hg.LightModelLinear)
plus.AddPlane(scn)

cube, cube_body = plus.AddPhysicCube(scn, hg.Matrix4.Identity, 1, 1, 1, 0)
cube_body.SetType(hg.RigidBodyKinematic)

gfx = hg.SimpleGraphicSceneOverlay(False)
scn.AddComponent(gfx)

cube_angle = 0
while not plus.IsAppEnded():
	dt = plus.UpdateClock()

	cube.GetTransform().SetRotation(hg.Vector3(cube_angle, cube_angle * 2, 0))
	cube_angle += 0.01

	# launch front direction from the camera and see if I hit the cube
	world = cam.GetTransform().GetWorld()
	dir, dir_x, dir_y, pos = world.GetZ(), world.GetX(), world.GetY(), world.GetTranslation()

	def draw_cross(p):
		k = 0.01
Пример #2
0
hg.MountFileDriver(hg.StdFileDriver("assets"), "assets")

# create a windows or resolution 800*600 with antialiasing set to 4
plus.RenderInit(1024, 1024, 4, hg.Windowed)

# add a new scene, which is a container of all objects you want to draw/update
scn = plus.NewScene()

plus.LoadScene(scn, "@assets/geometrics/geometrics.scn")
scn.UpdateAndCommitWaitAll()
cam = scn.GetCurrentCamera()
pos = cam.GetTransform().GetPosition()
pos.y = 1.65
cam.GetTransform().SetPosition(pos)

simple_graphic = hg.SimpleGraphicSceneOverlay(False)
simple_graphic.SetDepthTest(False)
simple_graphic.SetBlendMode(hg.BlendAlpha)
scn.AddComponent(simple_graphic)

teleporter.setup_teleporter(scn, hg.Vector2(200, 200))

# check if there is VR available and Initialise the frame renderer

try:
    openvr_frame_renderer = hg.CreateFrameRenderer("VR")
    # we have the vr frame renderer
    # Initialize it to open steamVR
    if openvr_frame_renderer.Initialize(plus.GetRenderSystem()):
        # add the new frame renderer to the scene.
        # the scene will automatically use it to render the scene.
Пример #3
0
hg.MountFileDriver(hg.StdFileDriver())
hg.MountFileDriver(hg.StdFileDriver(dir_))
hg.MountFileDriver(hg.StdFileDriver(os.path.join(dir_, "assets")), "@assets")

plus.RenderInit(1600, 900, 4, hg.Windowed)

plus.SetBlend2D(hg.BlendAlpha)
plus.SetBlend3D(hg.BlendAlpha)

plus.SetRenderWindow()
plus.GetRendererAsync().SetVSync(False)

scn = plus.NewScene()
scn.AddComponent(hg.Environment())

simple_graphic_scene_overlay = hg.SimpleGraphicSceneOverlay(False)
scn.AddComponent(simple_graphic_scene_overlay)

cam = plus.AddCamera(scn, mat4.TranslationMatrix(vec3(0, 0, -5)))
cam.GetCamera().SetZNear(1)
cam.GetCamera().SetZFar(100000)  # 100km

fps = hg.FPSController(0, 0, -2)
fps.SetSmoothFactor(0.3, 0.3)

font = hg.RasterFont("@assets/fonts/Handel Gothic D Bold.ttf", 16)

navier_stokes.setup()

while not plus.IsAppEnded():
    dt_sec = plus.UpdateClock()
Пример #4
0
hg.LoadPlugins()

plus = hg.GetPlus()
plus.RenderInit(gg.width, gg.height, 4, hg.Windowed)
plus.SetWindowTitle("Gilda Six, Private Investigator")
# plus.GetRenderSystem().SetShadowMapsResolution(2048)

hg.MountFileDriver(hg.StdFileDriver("./"))

gg.scene = plus.NewScene(True, True)
plus.LoadScene(gg.scene, "assets/main_scene.scn")

gg.scene.UpdateAndCommitWaitAll()

gg.osd = hg.SimpleGraphicSceneOverlay(False)
gg.scene.AddComponent(gg.osd)

CreateGameObjects()

GameCreateCamera()

picker = hg.ScenePicking(plus.GetRenderSystem())

while not plus.IsAppEnded():
	dt = plus.UpdateClock()
	GameControlCamera(dt)
	plus.UpdateScene(gg.scene, dt)

	if picker.Prepare(gg.scene, False, True).get():
		mx, my = plus.GetMousePos()