コード例 #1
0
def duplicate_node_object(original_node: hg.Node, name):
    node = hg.Node(name)
    trans = hg.Transform()
    node.AddComponent(trans)
    obj = hg.Object()
    obj.SetGeometry(original_node.GetObject().GetGeometry())
    node.AddComponent(obj)
    return node
コード例 #2
0
def create_instance(scn, path):
    node = hg.Node()
    node.AddComponent(hg.Transform())
    instance = hg.Instance()
    instance.SetPath(path)
    node.AddComponent(instance)
    node.GetTransform().SetPosition(vec3(0, 0, 0))
    scn.AddNode(node)
    return node
コード例 #3
0
ファイル: 4_cornell_box.py プロジェクト: nwy140/Tutorials
def create_box(pos = hg.Vector3(), rot = hg.Vector3(), width = 1.0, height = 1.0):
	node = hg.Node()
	object = hg.Object()
	transform = hg.Transform()
	transform.SetPosition(pos + hg.Vector3(0, height * 0.5, 0))
	transform.SetRotation(rot)
	node.AddComponent(transform)
	object.SetGeometry(render_system.CreateGeometry(hg.CreateCube(width, height, width)))
	node.AddComponent(object)
	return node
コード例 #4
0
ファイル: 4_cornell_box.py プロジェクト: nwy140/Tutorials
def create_wall(pos = hg.Vector3.Zero, rot = hg.Vector3.Zero, width = 1.0, length = 1.0, material_path = "material_diffuse_color.mat", name="dummy"):
	""" generic function to create a wall """
	node = hg.Node()
	transform = hg.Transform()
	transform.SetPosition(pos)
	transform.SetRotation(rot)
	node.AddComponent(transform)
	object = hg.Object()
	object.SetGeometry(render_system.CreateGeometry(hg.CreatePlane(width, length, 1, material_path, name)))
	node.AddComponent(object)
	return node
コード例 #5
0
def load_object(plus, geometry_file_name, name, duplicate_material=False):
    renderSystem = plus.GetRenderSystem()
    node = hg.Node(name)
    trans = hg.Transform()
    node.AddComponent(trans)
    obj = hg.Object()
    geo = hg.Geometry()
    hg.LoadGeometry(geo, geometry_file_name)
    if geo is not None:
        geo = renderSystem.CreateGeometry(geo, False)
        if duplicate_material:
            material = geo.GetMaterial(0)
            material = material.Clone()
            geo.SetMaterial(0, material)
        obj.SetGeometry(geo)
        node.AddComponent(obj)
    return node, geo
コード例 #6
0
def setup_teleporter(scn, ground_size: hg.Vector2):
    global authorise_ground_node
    authorise_ground_node = hg.Node()
    trans = hg.Transform()
    authorise_ground_node.AddComponent(trans)
    rb = hg.RigidBody()
    rb.SetCollisionLayer(2)
    rb.SetType(hg.RigidBodyKinematic)
    authorise_ground_node.AddComponent(rb)

    box_col = hg.BoxCollision()
    box_col.SetDimensions(hg.Vector3(ground_size.x, 0.1, ground_size.y))
    box_col.SetMass(0)
    authorise_ground_node.AddComponent(box_col)
    scn.AddNode(authorise_ground_node)

    while authorise_ground_node.GetRigidBody().GetState() == hg.NotReady:
        scn.UpdateAndCommitWaitAll()
コード例 #7
0
sky.Set("attenuation", 0.75)
sky.Set("shadow_range", 10000.0)  # 10km shadow range
sky.Set("shadow_split", hg.Vector4(0.1, 0.2, 0.3, 0.4))
scn.AddComponent(sky)

# load terrain
terrain = hg.Terrain()
terrain.SetSize(hg.Vector3(68767, 5760, 68767))
terrain.SetHeightmap("@data/terrain/island.r16")
terrain.SetHeightmapResolution(hg.IntVector2(1024, 1024))
terrain.SetMinPrecision(
    50
)  # don't bother with a very fine grid given the low resolution heightmap in use
terrain.SetSurfaceShader("@data/terrain/island.isl")

terrain_node = hg.Node()
terrain_node.AddComponent(hg.Transform())
terrain_node.AddComponent(terrain)
scn.AddNode(terrain_node)

#
fps = hg.FPSController(0, 3000, -30000, 100, 400)

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

    old_pos = fps.GetPos()
    fps.UpdateAndApplyToNode(cam, dt)
    speed = hg.Dist(fps.GetPos(),
                    old_pos) / hg.time_to_sec_f(dt) if dt > 0 else 0
コード例 #8
0
class Main:
	resolution = hg.Vector2(1600, 900)
	antialiasing = 2
	screenMode = hg.FullscreenMonitor1

	main_node = hg.Node()

	controller = None

	scene = None
	camera = None
	satellite_camera = None
	camera_matrix = None
	camera_v_move = hg.Vector3(0, 0, 0)  # Camera velocity for sfx
	fps = None
	sea_render = None
	ligth_sun = None
	ligth_sky = None

	sea_render_script = None
	clouds_render_script = None

	water_reflection = None

	p1_aircraft = None
	p2_aircraft = None

	p1_success = False

	carrier = None
	carrier_radar = None
	island = None

	p1_missiles = [None] * 4
	p2_missiles = [None] * 4
	p1_missiles_smoke_color = hg.Color(1, 1, 1, 1)
	p2_missiles_smoke_color = hg.Color(1, 1, 1, 1)

	p1_targets = []

	bullets = None
	ennemy_bullets = None

	title_font = "assets/fonts/destroy.ttf"
	hud_font = "assets/fonts/Furore.otf"
	texture_hud_plot = None
	texture_noise = None

	fading_cptr = 0
	fading_start_saturation = 0
	fadout_flag = False
	fadout_cptr = 0

	audio = None
	p1_sfx = None
	p2_sfx = None

	title_music = 0
	title_music_settings = None

	clouds = None
	render_volumetric_clouds = True

	show_debug_displays = False
	display_gui = False

	satellite_view = False

	HSL_postProcess=None
	MotionBlur_postProcess=None
	RadialBlur_postProcess=None

	flag_MotionBlur=False

	radial_blur_strength = 0.5
	deceleration_blur_strength=1/6
	acceleration_blur_strength=1/3

	gun_sight_2D=None

	current_view=None
コード例 #9
0
ファイル: 4_cornell_box.py プロジェクト: nwy140/Tutorials
# initialize the render system, which is used to draw through the renderer
render_system = hg.RenderSystem()
render_system.Initialize(renderer)

# create scene
scene = hg.Scene()
hg.SceneSetupCoreSystemsAndComponents(scene, render_system)

env = hg.Environment()
env.SetBackgroundColor(hg.Color.Black)
env.SetAmbientColor(hg.Color.White)
env.SetAmbientIntensity(0.1)
scene.AddComponent(env)

# light Source Definition
node_light = hg.Node()

light_transform = hg.Transform()
light_transform.SetPosition(hg.Vector3(0.0, box_height * 0.825, 0.0))
node_light.AddComponent(light_transform)

light_component = hg.Light()
light_component.SetDiffuseColor(hg.Color(1, 0.9, 0.7))
light_component.SetRange(box_width * 10.0)
light_component.SetShadow(hg.LightShadowMap)
node_light.AddComponent(light_component)

scene.AddNode(node_light)

# wall definitions
def create_wall(pos = hg.Vector3.Zero, rot = hg.Vector3.Zero, width = 1.0, length = 1.0, material_path = "material_diffuse_color.mat", name="dummy"):