Loxoc.core¶
Attributes¶
The types able to be sent to shaders via Uniforms. |
Classes¶
The shader type of a |
|
This class is the 3d perspective for a |
|
This class is used to create/load meshes. |
|
|
|
This decides how to render an Object ( |
|
Holds all model data for an imported 3D asset file. |
|
This class is your 3D game object. |
|
Used to import shader files (glsl) that can be used in |
|
A 4 float datastructure used to represent positional data, colors, or whatever you may need it for. |
|
A 3 float datastructure used to represent positional data, colors, or whatever you may need it for. |
|
A 2 float datastructure used to represent positional data, 2D rotation, or whatever you may need it for. |
|
An application window for a game. This class also keeps track of the state of the game engine runtime (ie. what to and not to render along with events and time). |
|
An IO or engine event flag. |
|
The state of an IO or engine event flag. |
|
The type of a mouse event. |
|
The button of a mouse event. |
|
The wheel direction of a mouse wheel event. |
|
The mousewheel data for a mouse wheel event. |
|
The data for a mouse device populated durring a mouse event. |
|
This non-constructable class contains all information pertaining to |
|
A "4 dimensional" rotation arround a developer defined |
|
The texture filtering setting for a |
|
The texture wrapping setting for a |
|
The image asset which is used when rendering an |
|
An 2 Dimensional Object which is rendered infront of all |
|
A Object that emits light from a |
|
The Collider base class. |
|
An Oriented Box Collider. |
|
A convex hull collider. |
|
A raycast collider that takes in an |
|
Returned by |
|
A 4 by 4 matrix. |
|
A 3 by 4 matrix. |
|
A 2 by 4 matrix. |
|
A 3 by 3 matrix. |
|
A 4 by 3 matrix. |
|
A 2 by 3 matrix. |
|
A 2 by 2 matrix. |
|
A 3 by 2 matrix. |
|
A 4 by 2 matrix. |
|
Renders the specified Font to the screen. Usable with |
|
Renders the specified Text to the screen with the specified |
|
A cubemap. Can be used to create a |
|
A |
|
Emits particles. |
|
A sound asset. This can also be used to play sounds directly. |
Module Contents¶
- Loxoc.core.UniformValueType¶
The types able to be sent to shaders via Uniforms.
Includes:
int , float ,
Matrix2x2,Matrix2x3,Matrix2x4,Matrix3x2,Matrix3x3,Matrix3x4,Matrix4x2,Matrix4x3,Matrix4x4,Vec2,Vec3,Vec4
- class Loxoc.core.ShaderType(*args, **kwds)¶
Bases:
enum.EnumThe shader type of a
Shaderobject.- FRAGMENT: ShaderType¶
- VERTEX: ShaderType¶
- GEOMETRY: ShaderType¶
- COMPUTE: ShaderType¶
- class Loxoc.core.Camera(position: Vec3, rotation: Vec3, view_width: int, view_height: int, focal_length: float, fov: float)¶
This class is the 3d perspective for a
Window.- property view_width: int¶
The view width of the camera.
- property view_height: int¶
The view height of the camera.
- property focal_length: float¶
The focal length of the camera.
- property fov: float¶
The field of view of the camera.
- property time_ns: int¶
The time in nanoseconds since the creation of the
Windowthe camera is attached to.
- property rotation: Quaternion¶
The current rotation of the
Cameraas aQuaternion.
- class Loxoc.core.Mesh¶
This class is used to create/load meshes.
- static from_file(file_path: str, animated: bool = False) Model¶
Returns the
Modelinstance created from the provided file. If the 3D asset contains animations, set animated to True .
- property name: str¶
Name of the mesh.
- Return type:
str
- class Loxoc.core.MeshDict(name: str, meshes: list[Mesh | MeshDict])¶
Loxoc.MeshDictis a datastructure that acts like a statically typed dictionary storing eachMeshby name. This is nessicary because 3D asset files can have more than oneMeshin them. If you have a 3D asset file with more than oneMeshinside of it, you can extract them from theirMeshDictto new individualMeshDicts and then toModels to be used inObject3Ds like so:my_assets: MeshDict = Model.from_file("./assets/models/model_name/model_name.gltf").mesh_dict # Import the 3D asset file. player_md = MeshDict("player_model_mesh", [my_assets["player_model"]]) # Extract the Mesh into its own group/MeshDict player_object = Object3D(Model(player_md), Vec3(0.0, 0.0, 20.0), vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0)) # Now our model is ready to be used.
We can extract the
Meshs we need from themy_assetsMeshDictby name. Hence we usemy_assets["player_model"]. This is assuming your desiredMeshis at the top level of your imported 3D file/asset’s heirarchy. if it is in a group inside the 3D file/asset you imported you could do something like:my_assets["group_name"]["player_model"]- property name¶
- The name associated with the :class:`MeshDict` .
- remove(name: str) None¶
Remove a Mesh from the dict by name.
- class Loxoc.core.Material(vertex: Shader | None = None, fragment: Shader | None = None, geometry: Shader | None = None, compute: Shader | None = None, animated: bool = False)¶
This decides how to render an Object (
Object3DorObject2D).You may supply your own
Shaders to customize how Objects are rendered.- set_uniform(name: str, value: UniformValueType) None¶
Sets the value of a uniform for the shaders in the material.
- class Loxoc.core.Model(mesh_dict: MeshDict, animated: bool = False)¶
Holds all model data for an imported 3D asset file.
- static from_file(file_path: str, animated: bool = False) Model¶
Returns the
Modelinstance created from the provided file. If the 3D asset contains animations, set animated to True .
- property use_default_material_properties: bool¶
Uses the
Materialproperties defined by eachMesh‘sMaterial. This only has an effect if theObject3Dof interest has an object-levelMaterialset (having an object-levelMaterialmeans theObject3D‘s Object3D.material attribute is set.). When there is an object-levelMaterialset, the default value for use_default_material_properties is False.
- play_animation(animation: str) None¶
Plays the specified animation.
- property animated: bool¶
Whether or not the model has animations. If it does set this to true.
- class Loxoc.core.Object3D(model_data: Model, position: Vec3 = Vec3(0.0, 0.0, 0.0), rotation: Vec3 = Vec3(0.0, 0.0, 0.0), scale: Vec3 = Vec3(1.0, 1.0, 1.0), collider: Collider | None = None, material: Material | None = None)¶
This class is your 3D game object.
- property use_default_material_properties: bool¶
Uses the
Materialproperties defined by eachMesh‘sMaterial. This only has an effect if theObject3Dof interest has an object-levelMaterialset (having an object-levelMaterialmeans theObject3D‘s Object3D.material attribute is set.). When there is an object-levelMaterialset, the default value for use_default_material_properties is False.
- check_collision(intersection: Vec3 | Object3D) bool¶
Checks for a collision between this
Object3Dand anotherObject3DorVec3.
- play_animation(animation_name: str) None¶
Plays the specified animation by name of the model.
- property rotation: Quaternion¶
The rotation of the object as a Quaternion.
- class Loxoc.core.Shader(source: str, shader_type: ShaderType)¶
Used to import shader files (glsl) that can be used in
Materials.- classmethod from_file(filepath: str, type: ShaderType) Shader¶
- class Loxoc.core.Vec4(x: float, y: float, z: float, w: float)¶
A 4 float datastructure used to represent positional data, colors, or whatever you may need it for. Contains useful linear algebra operators and functions.
- __copy__() Quaternion¶
Copies the
Vec4.
- __mul__(other: Vec4 | float | Quaternion) Vec4¶
Multiplies the
Vec4.
- class Loxoc.core.Vec3(x: float, y: float, z: float)¶
A 3 float datastructure used to represent positional data, colors, or whatever you may need it for. Contains useful linear algebra operators and functions.
- __repr__() str¶
Vec3 str representation.
- property quaternion: Quaternion¶
Get the
Quaternionform of the vector. Can also be assigned to, but not mutated.
- property x: float¶
- property y: float¶
- property z: float¶
- __mul__(other: Vec3 | float | Quaternion) Vec3¶
Multiply 2 vectors.
- cross(other: Quaternion | Vec3) Vec3¶
Performs a cross product operation between two
Vec3s.
- get_magnitude() float¶
Returns the magnitude of the vector.
- to_quaternion() Quaternion¶
Constructs a
Quaternionfrom the given Euler AngleVec3(in radians).
- class Loxoc.core.Vec2(x: float, y: float)¶
A 2 float datastructure used to represent positional data, 2D rotation, or whatever you may need it for. Contains useful linear algebra operators and functions.
- property angle: float¶
The vector converted to an angle in radians.
- to_angle() float¶
Convert the vector to an angle in radians
- property x: float¶
- property y: float¶
- class Loxoc.core.Window(title: str, cam: Camera, width: int, height: int, fullscreen: bool = False, ambient_light: Vec3 = Vec3(1.0, 1.0, 1.0))¶
An application window for a game. This class also keeps track of the state of the game engine runtime (ie. what to and not to render along with events and time).
- property fullscreen: bool¶
Wether to render the window in fullscreen mode (True) or not (False).
- property resizeable: bool¶
This flag determines wether or not the window is resizeable. The default value is True.
- property event: Event¶
This is the most recent event that the window recieved durring
Window.update().
- property deltatime: float¶
The current deltatime for the window.
- property dt: float¶
The current deltatime for the window.
- property time_ns: int¶
Time since the launch of the window in nanoseconds.
- property time: int¶
Time since the launch of the window in seconds.
- update() None¶
Re-renders and refreshes the
Window.eventon the applicationWindow. Should be used in a render/gameloop like so:window = Window(...) while ...: # render/gameloop code... window.update()
Whenever
Window.update()is called, a new frame is drawn to theWindow. If the program ends, the window will be closed.
- lock_mouse(lock: bool) None¶
Locks the mouse in the center of the window.
- add_object(obj: Object3D) None¶
Adds the
Object3Dto the scene. This ensures that theObject3Dis rendered by the camera.
- remove_object(obj: Object3D) None¶
Removes the
Object3Dfrom the scene. OnlyObject3Ds which are in the scene will be rendered by the camera.
- add_object_list(objs: list[Object3D]) None¶
Adds multiple
Object3Ds to the scene. This ensures that they are rendered by the camera.
- remove_object_list(objs: list[Object3D]) None¶
Removes multiple
Object3Ds from the scene. OnlyObject3Ds which are in the scene will be rendered by the camera.
- add_object2d(obj: Object2D) None¶
Adds the
Object2Dto the scene. This ensures that theObject2Dis rendered by the camera.
- remove_object2d(obj: Object2D) None¶
Removes the
Object2Dfrom the scene. OnlyObject2Ds which are in the scene will be rendered by the camera.
- add_object2d_list(objs: list[Object2D]) None¶
Adds multiple
Object2Ds to the scene. This ensures that they are rendered by the camera.
- remove_object2d_list(objs: list[Object2D]) None¶
Removes multiple
Object2Ds from the scene. OnlyObject2Ds which are in the scene will be rendered by the camera.
- add_point_light(obj: PointLight) None¶
Adds the
PointLightto the scene. This ensures that thePointLightis rendered by the camera.
- remove_point_light(obj: PointLight) None¶
Removes the
PointLightfrom the scene. OnlyPointLights which are in the scene will be rendered by the camera.
- add_point_light_list(objs: list[PointLight]) None¶
Adds multiple
PointLights to the scene. This ensures that they are rendered by the camera.
- remove_point_light_list(objs: list[PointLight]) None¶
Removes multiple
PointLights from the scene. OnlyPointLights which are in the scene will be rendered by the camera.
- add_directional_light(obj: DirectionalLight) None¶
Adds the
DirectionalLightto the scene. This ensures that theDirectionalLightis rendered by the camera.
- remove_directional_light(obj: DirectionalLight) None¶
Removes the
DirectionalLightfrom the scene. OnlyDirectionalLights which are in the scene will be rendered by the camera.
- add_directional_light_list(objs: list[DirectionalLight]) None¶
Adds multiple
DirectionalLights to the scene. This ensures that they are rendered by the camera.
- remove_directional_light_list(objs: list[DirectionalLight]) None¶
Removes multiple
DirectionalLights from the scene. OnlyDirectionalLights which are in the scene will be rendered by the camera.
- add_spot_light(obj: SpotLight) None¶
Adds the
SpotLightto the scene. This ensures that theSpotLightis rendered by the camera.
- remove_spot_light(obj: SpotLight) None¶
Removes the
SpotLightfrom the scene. OnlySpotLights which are in the scene will be rendered by the camera.
- add_spot_light_list(objs: list[SpotLight]) None¶
Adds multiple
SpotLights to the scene. This ensures that they are rendered by the camera.
- remove_spot_light_list(objs: list[SpotLight]) None¶
Removes multiple
SpotLights from the scene. OnlySpotLights which are in the scene will be rendered by the camera.
- add_text(obj: Text) None¶
Adds the
Textto the scene. This ensures that theTextis rendered by the camera.
- remove_text(obj: Text) None¶
Removes the
Textfrom the scene. OnlyTexts which are in the scene will be rendered by the camera.
- add_text_list(objs: list[Text]) None¶
Adds multiple
Texts to the scene. This ensures that they are rendered by the camera.
- remove_text_list(objs: list[Text]) None¶
Removes multiple
Texts from the scene. OnlyTexts which are in the scene will be rendered by the camera.
- add_emitter(obj: Emitter) None¶
Adds the
Emitterto the scene. This ensures that theEmitteris rendered by the camera.
- remove_emitter(obj: Emitter) None¶
Removes the
Emitterfrom the scene. OnlyEmitters which are in the scene will be rendered by the camera.
- class Loxoc.core.EVENT_FLAG(*args, **kwds)¶
Bases:
enum.EnumAn IO or engine event flag.
- WINDOW_MINIMIZE: EVENT_FLAG¶
Flagged when the window minimize button is clicked.
- WINDOW_CLOSE: EVENT_FLAG¶
Flagged when the window close button is clicked.
- QUIT: EVENT_FLAG¶
Flagged when the window close button is clicked.
- KEY_UP: EVENT_FLAG¶
- KEY_DOWN: EVENT_FLAG¶
- KEY_RIGHT: EVENT_FLAG¶
- KEY_LEFT: EVENT_FLAG¶
- KEY_SPACE: EVENT_FLAG¶
- KEY_a: EVENT_FLAG¶
- KEY_b: EVENT_FLAG¶
- KEY_c: EVENT_FLAG¶
- KEY_d: EVENT_FLAG¶
- KEY_e: EVENT_FLAG¶
- KEY_f: EVENT_FLAG¶
- KEY_g: EVENT_FLAG¶
- KEY_h: EVENT_FLAG¶
- KEY_i: EVENT_FLAG¶
- KEY_j: EVENT_FLAG¶
- KEY_k: EVENT_FLAG¶
- KEY_l: EVENT_FLAG¶
- KEY_m: EVENT_FLAG¶
- KEY_n: EVENT_FLAG¶
- KEY_o: EVENT_FLAG¶
- KEY_p: EVENT_FLAG¶
- KEY_q: EVENT_FLAG¶
- KEY_r: EVENT_FLAG¶
- KEY_s: EVENT_FLAG¶
- KEY_t: EVENT_FLAG¶
- KEY_u: EVENT_FLAG¶
- KEY_v: EVENT_FLAG¶
- KEY_w: EVENT_FLAG¶
- KEY_x: EVENT_FLAG¶
- KEY_y: EVENT_FLAG¶
- KEY_z: EVENT_FLAG¶
- KEY_LSHIFT: EVENT_FLAG¶
- KEY_RSHIFT: EVENT_FLAG¶
- KEY_LCTRL: EVENT_FLAG¶
- KEY_LALT: EVENT_FLAG¶
- KEY_ESCAPE: EVENT_FLAG¶
- KEY_COMMA: EVENT_FLAG¶
- KEY_PERIOD: EVENT_FLAG¶
- KEY_FORWARDSLASH: EVENT_FLAG¶
- KEY_BACKSLASH: EVENT_FLAG¶
- KEY_OPEN_BRACKET: EVENT_FLAG¶
- KEY_CLOSE_BRACKET: EVENT_FLAG¶
- KEY_SEMICOLON: EVENT_FLAG¶
- KEY_QUOTE: EVENT_FLAG¶
- KEY_ENTER: EVENT_FLAG¶
- KEY_BACKSPACE: EVENT_FLAG¶
- KEY_TAB: EVENT_FLAG¶
- KEY_BACKTICK: EVENT_FLAG¶
- KEY_DASH: EVENT_FLAG¶
- KEY_EQUALS: EVENT_FLAG¶
- KEY_1: EVENT_FLAG¶
- KEY_2: EVENT_FLAG¶
- KEY_3: EVENT_FLAG¶
- KEY_4: EVENT_FLAG¶
- KEY_5: EVENT_FLAG¶
- KEY_6: EVENT_FLAG¶
- KEY_7: EVENT_FLAG¶
- KEY_8: EVENT_FLAG¶
- KEY_9: EVENT_FLAG¶
- KEY_0: EVENT_FLAG¶
- KEY_RCTRL: EVENT_FLAG¶
- KEY_RALT: EVENT_FLAG¶
- MOUSE_BUTTON_DOWN: EVENT_FLAG¶
- MOUSE_BUTTON_UP: EVENT_FLAG¶
- MOUSE_WHEEL: EVENT_FLAG¶
- MOUSE_MOTION: EVENT_FLAG¶
- WINDOW_RESIZE: EVENT_FLAG¶
- class Loxoc.core.EVENT_STATE(*args, **kwds)¶
Bases:
enum.EnumThe state of an IO or engine event flag.
- NONE: EVENT_STATE¶
- PRESSED: EVENT_STATE¶
- RELEASED: EVENT_STATE¶
- class Loxoc.core.MOUSE_EVENT_TYPE(*args, **kwds)¶
Bases:
enum.EnumThe type of a mouse event.
- BUTTON_DOWN: MOUSE_EVENT_TYPE¶
- BUTTON_UP: MOUSE_EVENT_TYPE¶
- NONE: MOUSE_EVENT_TYPE¶
- class Loxoc.core.MOUSE_BUTTON(*args, **kwds)¶
Bases:
enum.EnumThe button of a mouse event.
- LEFT: MOUSE_BUTTON¶
- RIGHT: MOUSE_BUTTON¶
- MIDDLE: MOUSE_BUTTON¶
- class Loxoc.core.MOUSE_WHEEL_DIRECTION(*args, **kwds)¶
Bases:
enum.EnumThe wheel direction of a mouse wheel event.
- FLIPPED: MOUSE_WHEEL_DIRECTION¶
- NORMAL: MOUSE_WHEEL_DIRECTION¶
- class Loxoc.core.MouseWheel¶
The mousewheel data for a mouse wheel event.
- int_x: int¶
The x value of the mouse wheel with integer precision.
- int_y: int¶
The y value of the mouse wheel with integer precision.
- x: float¶
The x value of the mouse wheel with full floating point precision.
- y: float¶
The y value of the mouse wheel with full floating point precision.
- direction: MOUSE_WHEEL_DIRECTION¶
The direction of the mouse wheel.
- class Loxoc.core.MouseDevice¶
The data for a mouse device populated durring a mouse event.
- id: int¶
The id of the mouse device.
- timestamp: int¶
The timestamp of the mouse event.
- x: int¶
The x position of the mouse in relation to the window.
- y: int¶
The y position of the mouse in relation to the window.
- rel_x: int¶
The x position of the mouse relative to its last position. Also can be thought of as the mouse x delta.
- rel_y: int¶
The y position of the mouse relative to its last position. Also can be thought of as the mouse y delta.
- clicks: int¶
The ammount of clicks recorded.
- type: MOUSE_EVENT_TYPE¶
The type of mouse event.
- state: EVENT_STATE¶
The state of the mouse event.
- button: MOUSE_BUTTON¶
The button pressed durring the mouse event.
- wheel: MouseWheel¶
The mouse wheel data for mouse wheel events.
- class Loxoc.core.Event¶
This non-constructable class contains all information pertaining to
Windowevents. This class can be accessed/read viaWindow.event.To check if an
EVENT_FLAGhas been triggered you can useWindow.event.check_flag(...):window = Window(...) while not window.event.check_flag(EVENT_FLAG.QUIT): # some game loop code... window.update()
This can be useful for events where you only need to chjeck if they have been triggered. Such as quitting the game when you close the window.
To check the
EVENT_STATEof anEVENT_FLAGyou can useWindow.event.get_flag(...):window = Window(...) while not window.event.check_flag(EVENT_FLAG.QUIT): if window.event.get_flag(EVENT_FLAG.KEY_UP) == EVENT_STATE.PRESSED: # do some stuff when up is pressed... window.update()
This can be useful for getting the
EVENT_STATEof specificEVENT_FLAGs. It is recommended to do this before attempting to access data from theEventthat is related to theEVENT_FLAGand itsEVENT_STATE.- get_flag(_event: EVENT_FLAG) EVENT_STATE¶
Checks if the provided event flag is occuring.
- check_flag(_event: EVENT_FLAG) bool¶
Checks if the provided event flag is occuring.
- property mouse: MouseDevice¶
Gets the current mouse device. Contains current mouse events.
- get_mouse(id: int) MouseDevice¶
Gets the mouse device with the provided id. Contains current mouse events.
- class Loxoc.core.Quaternion(w: float, x: float, y: float, z: float)¶
A “4 dimensional” rotation arround a developer defined
Vec3axis.In simple terms, a Quaternion is just an angle (in radians) rotation arround some 3D vector. For example if we wanted to rotate arround the Euler y axis of an
Object3Dor along “yaw” we would just rotate arroud theObject3D.rotation.upvector:obj = Object3D(...) yaw_rotation = math.radians(90) quat = Quaternion.from_axis_angle(obj.rotation.up, yaw_rotation)
It is recommended to construct Quaternions with
Quaternion.from_axis_angle().Read more about Quaternions here.
- __repr__() str¶
The string representation of the Quaternion.
- __neg__() Quaternion¶
- property w: float¶
- property x: float¶
- property y: float¶
- property z: float¶
- property euler_angles: Vec3¶
The Euler Angle Vec3 form of the Quaternion. Can also be assigned to, but not mutated.
Use
Quaternion.rotate_pitch(),Quaternion.rotate_yaw(), andQuaternion.rotate_roll()for mutating Euler angle rotation.
- property euler_pitch: float¶
Rotation about the x axis.
- rotate_pitch(value: float) Quaternion¶
Rotates the Euler pitch (x) axis by the provided value.
- property euler_yaw: float¶
Rotation about the y axis.
- rotate_yaw(value: float) Quaternion¶
Rotates the Euler yaw (y) axis by the provided value.
- property euler_roll: float¶
Rotation about the z axis.
- rotate_roll(value: float) Quaternion¶
Rotates the Euler roll (z) axis by the provided value.
- __add__(other: Quaternion | float) Quaternion¶
- __sub__(other: Quaternion | float) Quaternion¶
- __mul__(other: Quaternion | float | Vec3) Quaternion | Vec3¶
- __truediv__(other: Quaternion | float) Quaternion¶
- dot(other: Quaternion) float¶
The dot product of 2
Quaternions.
- cross(other: Quaternion | Vec3) float¶
The cross product of the
Quaternionand another compatible structure.
- get_magnitude() float¶
Returns the magnitude of the
Quaternion.
- get_normalized() Quaternion¶
Returns the normalized
Quaternion.
- to_euler() Vec3¶
Converts the
Quaternionto a Euler AngleVec3(in radians).
- get_conjugate() Quaternion¶
The conjugate of the
Quaternion.
- get_inverse() Quaternion¶
The inverse of the
Quaternion.
- get_reverse() Quaternion¶
The 180 degree reverse of the
Quaternion.
- static from_euler(euler_vec: Vec3) Quaternion¶
Converts the provided Euler Angle
Vec3(in radians) to aQuaternion.
- static from_axis_angle(axis: Vec3, angle: float) Quaternion¶
Constructs a
Quaternionwith a rotation ofanglearroundaxis.
- rotate(axis: Vec3, angle: float) None¶
Mutably rotates the
Quaternionby angle arround axis.
- static from_quat(quat: Quaternion) Quaternion¶
Used to construct a copy of a
Quaternion.
- static from_unit(axis: Vec3, up: Vec3 | None = Vec3(0.0, 1.0, 0.0)) Quaternion¶
Takes in a unit
Vec3direction and returns aQuaternionrotated in that direction from the global forward Vec3(0.0, 0.0, 1.0) .
- lerp(other: Quaternion, ratio: float) Quaternion¶
Returns a lerped
Quaternionbetween twoQuaternionby the provided ratio.
- slerp(other: Quaternion, ratio: float) Quaternion¶
Returns a slerped
Quaternionbetween twoQuaternionby the provided ratio.
- class Loxoc.core.TextureFiltering(*args, **kwds)¶
Bases:
enum.EnumThe texture filtering setting for a
Texture.- NEAREST: TextureFiltering¶
- LINEAR: TextureFiltering¶
- class Loxoc.core.TextureWraping(*args, **kwds)¶
Bases:
enum.EnumThe texture wrapping setting for a
Texture.- REPEAT: TextureWraping¶
- MIRRORED_REPEAT: TextureWraping¶
- CLAMP_TO_EDGE: TextureWraping¶
- CLAMP_TO_BORDER: TextureWraping¶
- class Loxoc.core.Texture¶
A texture for a
MeshorSprite.- classmethod from_file(file_path: str, wrap: TextureWraping = TextureWraping.REPEAT, filtering: TextureFiltering = TextureFiltering.LINEAR) Texture¶
Create a
Texturefrom the specified file.
- class Loxoc.core.Sprite(file_path: str)¶
The image asset which is used when rendering an
Object2D. Serves a purpose similar to howMeshis used withObject3Dbut forObject2D.
- class Loxoc.core.Object2D(sprite: Sprite, camera: Camera, position: Vec2 = Vec2(0.0, 0.0), depth: float = 0.0, rotation: float = 0.0, scale: Vec2 = Vec2(1.0, 1.0), material: Material = None)¶
An 2 Dimensional Object which is rendered infront of all
Object3Ds on the screen. Good for GUI, HUD interfaces, or anything else 2D.- property depth: float¶
The depth layer of the
Spritewhen rendered, or “z” position.Object2Ds with a higher depth are rendered underneathObject2Ds with a lower depth.
- class Loxoc.core.PointLight(position: Vec3, radius: float, color: Vec3, intensity: float)¶
A Object that emits light from a
Vec3point in 3D space.- property intensity: float¶
The intensity of the light.
- property radius: float¶
The radius of the light
- class Loxoc.core.DirectionalLight(rotation: Vec3 = None, color: Vec3 = None, ambient: Vec3 = None, diffuse: Vec3 = None, specular: Vec3 = None, intensity: float = 1.0)¶
- property rotation: Quaternion¶
The
Quaternionrotation of theDirectionalLight
- property ambient: Vec3¶
The
Vec3ambient property of theDirectionalLight
- property diffuse: Vec3¶
The
Vec3diffuse property of theDirectionalLight
- property specular: Vec3¶
The
Vec3specular property of theDirectionalLight
- property intensity: float¶
The intensity property of the
DirectionalLight
- property color: Vec3¶
The
Vec3color property of theDirectionalLight
- class Loxoc.core.SpotLight(position: Vec3, rotation: Vec3 = None, color: Vec3 = None, cutoff: float = 12.5, outer_cutoff: float = 17.5, intensity: float = 1.0, reach: float = 100.0, cookie: Texture = None)¶
-
- property rotation: Quaternion¶
The direction of the spotlight as a
Quaternion.
- property intensity: float¶
The intensity of the light.
- property cutoff: float¶
the cutoff of the light cookie as an angle from the center.
- property outer_cutoff: float¶
the cutoff of the light cookie smoothing as an angle from the center.
- property reach: float¶
The distance the light is able to travel.
- class Loxoc.core.Collider¶
The Collider base class.
- check_collision(intersection: Vec3 | Collider | Object3D) bool¶
Checks for a collision between this
Colliderand anotherCollider,Object3DorVec3.
- property rotation: Quaternion¶
The
Quaternionrotation of the collider.
- property show¶
- Makes the collider visible. Good for debugging purposes.
- class Loxoc.core.BoxCollider(object: Object3D, offset: Vec3 = Vec3(0, 0, 0), rotation: Vec3 | Quaternion = Vec3(0, 0, 0), scale: Vec3 = Vec3(1.0, 1.0, 1.0))¶
Bases:
ColliderAn Oriented Box Collider.
- classmethod from_bounds(upper_bound: Vec3 = Vec3(10, 10, 10), lower_bound: Vec3 = Vec3(-10, -10, -10), offset: Vec3 = Vec3(0, 0, 0), rotation: Vec3 | Quaternion = Vec3(0, 0, 0), scale: Vec3 = Vec3(1.0, 1.0, 1.0)) BoxCollider¶
Constructs an
BoxColliderfrom the provided bounds.
- class Loxoc.core.ConvexCollider(object: Object3D, offset: Vec3 = Vec3(0, 0, 0), rotation: Vec3 | Quaternion = Vec3(0, 0, 0), scale: Vec3 = Vec3(1.0, 1.0, 1.0))¶
Bases:
ColliderA convex hull collider.
- classmethod from_mesh(msh: Mesh, offset: Vec3 = Vec3(0, 0, 0), rotation: Vec3 | Quaternion = Vec3(0, 0, 0), scale: Vec3 = Vec3(1.0, 1.0, 1.0)) BoxCollider¶
Creates a
ConvexColliderfrom the providedMesh.
- classmethod from_mesh_dict(msh_dict: MeshDict, offset: Vec3 = Vec3(0, 0, 0), rotation: Vec3 | Quaternion = Vec3(0, 0, 0), scale: Vec3 = Vec3(1.0, 1.0, 1.0)) BoxCollider¶
Creates a
ConvexColliderfrom the providedMeshDict.
- class Loxoc.core.RayCollider(origin: Vec3, direction: Quaternion)¶
Bases:
ColliderA raycast collider that takes in an
Vec3origin andQuaterniondirection.- get_collision(intersection: Collider | Object3D) RayHit¶
Checks for a collision on the RayCollider . Upon colliding this function returns an instance of
RayHit.
- property rotation: Quaternion¶
The
Quaterniondirection of the RayCollider .
- property direction: Quaternion¶
The
Quaterniondirection of the RayCollider .
- class Loxoc.core.RayHit¶
Returned by
RayCollider.get_collision. This class contains information about theRayCollidercollision.- property hit: bool¶
True if the
RayColliderhas hit its target, False if not.
- property has_normal: bool¶
Wether the RayHit ‘s collided surface has a normal.
- property has_distance: bool¶
Wether the RayHit has recorded the distance between the collision point and its origin.
- property normal: Vec3¶
The
Vec3normal of the surface theRayColliderhas collided with.
- class Loxoc.core.Matrix4x4(x0: float, y0: float, z0: float, w0: float, x1: float, y1: float, z1: float, w1: float, x2: float, y2: float, z2: float, w2: float, x3: float, y3: float, z3: float, w3: float)¶
A 4 by 4 matrix.
- static from_ortho(left: float, right: float, bottom: float, top: float, zNear: float | None = None, zFar: float | None = None) Matrix4x4¶
Creates an orthographic projection
Matrix4x4with the specified bounds.
- static look_at(eye: Vec3, center: Vec3, up: Vec3) Matrix4x4¶
Creates a look at
Matrix4x4from the specified parameters.
- static from_perspective(fovy: float, aspect: float, near: float, far: float) Matrix4x4¶
Creates a perspective projection
Matrix4x4with the specified bounds.
- static from_quaternion(quat: Quaternion) Matrix4x4¶
Converts a
Quaternioninto aMatrix4x4.
- to_quaternion() Quaternion¶
Converts the
Matrix4x4into aQuaternion.
- get_up() Vec3¶
Returns the up
Vec3of theMatrix4x4, assuming that it is being used as a transform.
- get_right() Vec3¶
Returns the right
Vec3of theMatrix4x4, assuming that it is being used as a transform.
- class Loxoc.core.Matrix3x4(x0: float, y0, z0: float, w0: float, x1: float, y1: float, z1: float, w1: float, x2: float, y2: float, z2: float, w2: float)¶
A 3 by 4 matrix.
- class Loxoc.core.Matrix2x4(x0: float, y0: float, z0: float, w0: float, x1: float, y1: float, z1: float, w1: float)¶
A 2 by 4 matrix.
- class Loxoc.core.Matrix3x3(x0: float, y0: float, z0: float, x1: float, y1: float, z1: float, x2: float, y2: float, z2: float)¶
A 3 by 3 matrix.
- to_quaternion() Quaternion¶
Converts the
Matrix3x3to a Quaternion.
- class Loxoc.core.Matrix4x3(x0: float, y0: float, z0: float, x1: float, y1: float, z1: float, x2: float, y2: float, z2: float, x3: float, y3: float, z3: float)¶
A 4 by 3 matrix.
- class Loxoc.core.Matrix2x3(x0: float, y0: float, z0: float, x1: float, y1: float, z1: float)¶
A 2 by 3 matrix.
- class Loxoc.core.Matrix2x2(x0: float, y0: float, x1: float, y1: float)¶
A 2 by 2 matrix.
- class Loxoc.core.Matrix3x2(x0: float, y0: float, x1: float, y1: float, x2: float, y2: float)¶
A 3 by 2 matrix.
- class Loxoc.core.Matrix4x2(x0: float, y0: float, x1: float, y1: float, x2: float, y2: float, x3: float, y3: float)¶
A 4 by 2 matrix.
- class Loxoc.core.Font(font_path: str, font_size: int = 48)¶
Renders the specified Font to the screen. Usable with
Text.
- class Loxoc.core.Text(text_string: str, color: Vec4, position: Vec2, scale: Vec2 = Vec2(1.0, 1.0), rotation: float = 0, font: Font | None = None, material: Material | None = None)¶
Renders the specified Text to the screen with the specified
Font.- property rotation: float¶
The rotation of the text.
- property text: str¶
The content of the text object.
- class Loxoc.core.CubeMap(right_path: str, left_path: str, top_path: str, bottom_path: str, back_path: str, front_path: str)¶
A cubemap. Can be used to create a
SkyBox.
- class Loxoc.core.SkyBox(cube_map: CubeMap, mat: Material | None = None)¶
A
CubeMapskybox. Can be applied toWindow.sky_box.
- class Loxoc.core.Emitter(position: Vec3, direction: Quaternion, scale_min: Vec2 = Vec2(1.0, 1.0), scale_max: Vec2 = Vec2(1.0, 1.0), rate: int = 50, decay_rate: float = 1.0, spread: float = math.radians(30), velocity_decay: float = 1.0, start_velocity_min: float = 1.0, start_velocity_max: float = 1.0, start_lifetime_min: float = 10.0, start_lifetime_max: float = 10.0, color_min: Vec4 = Vec4(1.0, 1.0, 1.0, 1.0), color_max: Vec4 = Vec4(1.0, 1.0, 1.0, 1.0), material: Material | None = None)¶
Emits particles.
- start() None¶
Starts emitting particles.
- stop() None¶
Stops emitting particles.
- property direction: Quaternion¶
The
Quaterniondirection of the emitter.
- property color_min: Vec4¶
The
Vec4minimum color of the particles. The color of the particle will be randomly selected between Emitter.color_min and Emitter.color_max .
- property color_max: Vec4¶
The
Vec4maximum color of the particles. The color of the particle will be randomly selected between Emitter.color_min and Emitter.color_max .
- property scale_min: Vec2¶
The
Vec2minimum scale of the particles. The scale of the particle will be randomly selected between Emitter.scale_min and Emitter.scale_max .
- property scale_max: Vec2¶
The
Vec2maximum scale of the particles. The scale of the particle will be randomly selected between Emitter.scale_min and Emitter.scale_max .
- property rate: int¶
The ammount of particles present at any one time.
- property decay_rate: float¶
The speed of decay, or how much a particle’s life decreases each second. When a particle’s life reaches 0, it disappears.
- property spread: float¶
The radius of the cone of particle spread.
- property velocity_decay: float¶
The ammount a particle’s velocity decreases over time.
- property start_velocity_min: float¶
The minimum starting velocity of a particle. The start velocity of a particle will be randomly selected between Emitter.start_velocity_min and Emitter.start_velocity_max .
- property start_velocity_max: float¶
The maximum starting velocity of a particle. The start velocity of a particle will be randomly selected between Emitter.start_velocity_min and Emitter.start_velocity_max .
- property start_lifetime_min: float¶
The minimum starting life value of a particle. The start life value of a particle will be randomly selected between Emitter.start_lifetime_min and Emitter.start_lifetime_max .
- property start_lifetime_max: float¶
The maximum starting life value of a particle. The start life value of a particle will be randomly selected between Emitter.start_lifetime_min and Emitter.start_lifetime_max .
- class Loxoc.core.Sound(win: Window, source: str, loop: bool)¶
A sound asset. This can also be used to play sounds directly.
- play(volume: float = 1.0, panning: float = 0.0, pitch: float = 1.0, position: Vec3 | None = None) None¶
Plays the sound globally. If a
Vec3position is specified, the panning and volume will be balanced to play from that position relative to the camera. It will play with the same panning and volume until the sound is finished. For dynamic positional audio seeSound3D.
- stop() None¶
Stops the sound if it is playing.