def _side_color( self, side: Side, normal: Vec, min_pos: Vec, used_tex_func: Callable[[str], None], ) -> None: """Output the side texture for fields. used_tex_func is called with each material we use. """ if not self.side_color: # Just apply nodraw. side.mat = const.Tools.NODRAW return # Produce a hex colour string, and use that as the material name. side.mat = 'BEE2/fizz_sides/side_color_{:02X}{:02X}{:02X}'.format( round(self.side_color.x * 255), round(self.side_color.y * 255), round(self.side_color.z * 255), ) used_tex_func(side.mat) # FLip orientation if needed. if not side.uaxis.vec().dot(normal): side.vaxis, side.uaxis = side.uaxis, side.vaxis # The texture width is 32 pixels. side.scale = self.thickness / 32 side.uaxis.offset = 16 + 2 * self.thickness * side.uaxis.vec().dot( min_pos) % 32
def _side_color(self, side: Side, normal: Vec, min_pos: Vec, used_tex_func): """Output the side texture for fields.""" if not self.side_color: # Just apply nodraw. side.mat = const.Tools.NODRAW return import vbsp # Produce a hex colour string, and use that as the material name. side.mat = 'BEE2/fizz_sides/side_color_{:02X}{:02X}{:02X}'.format( round(self.side_color.x * 255), round(self.side_color.y * 255), round(self.side_color.z * 255), ) used_tex_func(side.mat) # Pack the file. vbsp.PACK_FILES.add('materials/{}.vmt'.format(side.mat)) # Pack the auxiliary texture needed. vbsp.PACK_FILES.add('materials/BEE2/fizz/fizz_side.vtf') # FLip orientation if needed. if not side.uaxis.vec().dot(normal): side.vaxis, side.uaxis = side.uaxis, side.vaxis # The texture width is 32 pixels. side.scale = self.thickness / 32 side.uaxis.offset = 16 + 2 * self.thickness * side.uaxis.vec().dot( min_pos) % 32
def _texture_fit( self, side: Side, tex_size: float, field_length: float, fizz: Fizzler, neg: Vec, pos: Vec, is_laserfield=False, ) -> None: """Calculate the texture offsets required for fitting a texture.""" if side.vaxis.vec() != -fizz.up_axis: # Rotate it rot_angle = side.normal().rotation_around() for _ in range(4): side.uaxis = side.uaxis.rotate(rot_angle) side.vaxis = side.vaxis.rotate(rot_angle) if side.vaxis.vec() == -fizz.up_axis: break else: LOGGER.warning("Can't fix rotation for {} -> {}", side.vaxis, fizz.up_axis) side.uaxis.offset = -(tex_size / field_length) * neg.dot(side.uaxis.vec()) side.vaxis.offset = -(tex_size / 128) * neg.dot(side.vaxis.vec()) # The above fits it correctly, except it's vertically half-offset. # For laserfields that's what we want, for fizzlers we want it normal. if not is_laserfield: side.vaxis.offset += tex_size / 2 side.uaxis.scale = field_length / tex_size side.vaxis.scale = 128 / tex_size side.uaxis.offset %= tex_size side.vaxis.offset %= tex_size
def _side_color( self, side: Side, normal: Vec, min_pos: Vec, used_tex_func: Callable[[str], None], ) -> None: """Output the side texture for fields. used_tex_func is called with each material we use. """ if not self.side_color: # Just apply nodraw. side.mat = const.Tools.NODRAW return # Produce a hex colour string, and use that as the material name. side.mat = 'bee2/fizz_sides/side_color_{:02X}{:02X}{:02X}'.format( round(self.side_color.x * 255), round(self.side_color.y * 255), round(self.side_color.z * 255), ) used_tex_func(side.mat) # FLip orientation if needed. if not side.uaxis.vec().dot(normal): side.vaxis, side.uaxis = side.uaxis, side.vaxis # The texture width is 32 pixels. side.scale = self.thickness / 32 side.uaxis.offset = 16 + 2 * self.thickness * side.uaxis.vec().dot(min_pos) % 32