def update(self): date = datetime.utcnow() + timedelta(0, self.TimeIn.value * self.TimeScale.value) azimuth = get_azimuth(self.city, date) elevation = get_elevation(self.city, date) r = g = b = 0.0 if (elevation > 0): r = g = b = elevation / 90 r = pow(r, 0.3) * 1.3 g = pow(g, 0.4) * 1.2 b = pow(b, 0.5) * 1.6 self.SunColorOut.value = av.Color(r, g, b) self.MatrixOut.value = av.make_rot_mat( azimuth, 0, 1, 0) * av.make_rot_mat(-elevation, 1, 0, 0) direcion = self.MatrixOut.value * av.Vec3(0, 0, -1) self.DirectionOut.value = av.Vec3(direcion.x, direcion.y, direcion.z) self.BlendFactorOut.value = 0.0 if elevation / 90 < 0: self.BlendFactorOut.value = abs(elevation / 90) * 5 if direcion.y > 0: val = max(0.2 - direcion.y, 0) self.GroundColorOut.value = av.Color(val, val, val) else: self.GroundColorOut.value = av.Color(0.5, 0.5, 0.5)
def create_floor(): floor_geometry = loader.create_geometry_from_file( "floor_geometry", "data/objects/plane.obj", av.LoaderFlags.NORMALIZE_SCALE | av.LoaderFlags.NORMALIZE_POSITION) floor_geometry.Transform.value = av.make_trans_mat( 0, 1.0, 0) * av.make_scale_mat(10, 10.0, 10) floor_geometry.Material.value.set_uniform("Metalness", 0.0) floor_geometry.Material.value.set_uniform( "RoughnessMap", "data/textures/oakfloor2_roughness.png") floor_geometry.Material.value.set_uniform( "ColorMap", "data/textures/oakfloor2_basecolor.png") floor_geometry.Material.value.set_uniform( "NormalMap", "data/textures/oakfloor2_normal.png") av.create_box_shape("box", av.Vec3(10, 1, 10)) floor_collision_shape = av.nodes.CollisionShapeNode( Name="floor_shape", ShapeName="box", Children=[floor_geometry]) floor_body = av.nodes.RigidBodyNode(Name="floor_body", Mass=0, Friction=0.5, Restitution=0.7, Children=[floor_collision_shape]) return floor_body
def SKY_MAP_PASS(self, p): sky_pass = av.nodes.SkyMapPassDescription() sky_pass.OutputTextureName.value = p.skymap_output_texture_name sky_pass.LightDirection.value = av.Vec3(p.skymap_light_direction[0], p.skymap_light_direction[1], p.skymap_light_direction[2]) #sky_pass.GroundColor.value = p.skymap_ground_color return sky_pass