A Bezier curve. This class can be used to draw smooth curves or move things smoothly on curves. It's also used internally for skeletal animation. The curves are 3-dimensional, but convenience methods are added for 2d curves and there is a caching mechanism for 2d height data to speed up bezier curve usage in animation.A bezier curve consists of control points, each having 3 points: one middle point and two 'handles'. The middle point is the actual position of the control point and the two side points serve as vectors defining how the curve curves towards the next control points.
- The point after which new control points should be added. If NULL, new control points are added to the end of the curve.
- Accuracy value for X-axis curve evaluation. The higher this number, the faster but less accurate X-axis curve evaluation is. Defaults to 0.01
Default constructor.
Returns a control point by index.
Index of the control point to return.
Returns the total number of control points in the curve.
@see addControlPoint3dWithHandles()
Adds a new control point to the curve after the last point.
X position of the first handle point.
Y position of the first handle point.
Z position of the first handle point.
X position of the middle point.
Y position of the middle point.
Z position of the middle point.
X position of the second handle point.
Y position of the second handle point.
Z position of the second handle point.
Adds a new control point to the curve with handles in the same place as the middle points.
X position of the point and both handles.
Y position of the point and both handles.
Z position of the point and both handles.
Adds a new control point to the curve after the last point
X position of the first handle point.
Y position of the first handle point.
X position of the middle point.
Y position of the middle point.
X position of the second handle point.
Y position of the second handle point.
Adds a new control point to the curve with handles in the same place as the middle points
X position of the point and both handles.
Y position of the point and both handles.
Returns the 3d point of the curve at a specified point on the curve.
Normalized (0-1) position along the curve.
Returns the 3d point of the curve at a specified point between two points.
Normalized (0-1) position between two points
Removes all curve control points.
Returns the Y-axis value of the curve at specified X-axis value.
Returns the normalized curve position value at specified X-axis value.
Removes (and deletes!) a given point by pointer.
A curve point defined by 3 positions. @see BezierCurve
- First handle position.
- Middle position.
- Second handle position.
Constructor
X position of the first handle point.
Y position of the first handle point.
Z position of the first handle point.
X position of the middle point.
Y position of the middle point.
Z position of the middle point.
X position of the second handle point.
Y position of the second handle point.
Z position of the second handle point.
Skeleton bone. Bones are bound to vertices of a mesh and when transformed, move the bound vertices of the mesh along with them. Bones are subclassed from Entity, but have their own hierarchy system. @see Skeleton
- Id of the bone.
Constructor.
Name of the bone.
Returns the name of the bone.
Sets the parent bone of this bone.
New parent bone.
Adds another bone as the child of this bone.
New parent bone.
Returns the parent bone of this bone.
Returns the number of child bones of this bone.
Returns the child bone of this bone at the specified index.
Index of the child bone to return.
Returns the bone matrix
Sets the bone matrix.
Returns the rest matrix of this bone.
Returns the full rest matrix of this bone.
Returns the rest matrix of this bone's parent.
@see getBoneMatrix()
Sets the rest matrix for this bone.
New rest matrix.
Sets the base matrix for this bone.
New base matrix.
Returns the base matrix of this bone.
Returns the full base matrix of this bone.
Camera in a 3D scene. Cameras can be added to a scene and changed between dynamically. You can also set a shader to a camera that will run as a screen shader for post-processing effects.
NOTE: Camera instances are not automatically garbage collected.
ProjectionMode: Orthographic projection, with manually set size.
ProjectionMode: Orthographic projection, with height specified used and width scaled proportionally .
ProjectionMode: Orthographic projection, with width specified used and height scaled proportionally.
ProjectionMode: Orthographic projection, scaled to viewport backing resolution.
ProjectionMode: Perspective projection, with field of view specified.
ProjectionMode: Perspective projection, with bounds set by edges of frustum.
ProjectionMode: Manual matrix projection. Use setProjectionMatrix to set the matrix.
- Toggles the frustum culling of the camera. (Defaults to true).
- If set to true, the orthographic projection will be set with the 0,0 coordinate in the top left corner of the viewport. Otherwise, the 0,0 coordinate is in the center.
- Shifts camera frustum by factor of the frustum size. (x=-1 will shift the frustum to the left by a whole screen width).
Constructor.
Scene to add the camera to.
Builds the frustum clipping planes for this camera
Checks if the camera can see a sphere.
Position of the sphere to check.
Radius of the sphere.
Checks if an Axis-aligned bounding box is visible to the camera.
An axis-aligned bounding box
Toggles orthographic projection mode for camera.
If true, sets the camera into orthographic projection mode.
Sets the orthographic size of the camera.
Orthographic width
Orthographic height
Switches into frustum mode and sets up the planes.
Returns true if camera is in orthographic projection mode.
Returns the width of the camera's orthographic frustum.
Returns the height of the camera's orthographic frustum.
Sets the field of view (FOV) for the camera. The larger the field of view, the more the camera can see, the smaller it is, the more zoomed in it is.
The new FOV value.
Returns the current FOV value for the camera.
Sets the clipping planes for the camera.
Near clipping plane.
Far clipping plane.
Returns the near clipping plane of the camera.
Returns the far clipping plane of the camera.
Sets the parent scene of the camera.
New parent scene.
Returns the camera's parent scene.
Check if camera has a post filter material applied
Binds target buffers and renders the scene in multiple passes based on the post filter material.
Sets the post-processing shader for the camera.
Post processing shader material.
Sets the post-processing shader for the camera by name. The material needs have been added as a resource.
The material name of the post-processing filter.
Removes the currently assigned post filter.
Returns the shader material applied to the camera.
Clones the camera.
Applies clone parameters to the camera.
Returns the camera's projection matrix.
Manually sets the camera's projection matrix. Projection mode must be set to MANUAL_MATRIX.
Custom projection matrix. @see setProjectionMode
Return's the camera's pixel viewport based on the last render pass.
@deprecated use setProjectionMode(ProjectionMode mode)
@deprecated use getProjectionMode()
Sets the projection mode of the camera. Possible values are ORTHO_SIZE_MANUAL, ORTHO_SIZE_LOCK_HEIGHT,ORTHO_SIZE_LOCK_WIDTH, ORTHO_SIZE_LOCK_WIDTH, PERSPECTIVE_FOV, PERSPECTIVE_FRUSTUM and MANUAL_MATRIX. See the documentation of each individual mode for details.
New projection mode.
Returns the current projection mode.
Stores and manipulates color information. Color is always RGBA in Polycode.
- Red value.
- Green value.
- Blue value.
- Alpha value.
Create from 0-1 floating point data.
Red value 0-1.
Green value 0-1
Blue value 0-1
Alpha value 0-1
Create from 0-255 integer data.
Red value 0-255.
Green value 0-255.
Blue value 0-255.
Alpha value 0-255.
Create from integer color.
Integer color value.
Sets the color
32-bit integer with color values.
Sets the color
24-bit integer with RGB color values.
Sets the color
String with hex RGBA color values.
Sets the color
String with hex RGB color values.
Sets the color
Hue.
Saturation.
Value.
Sets the color
Red value 0-255.
Green value 0-255.
Blue value 0-255.
Alpha value 0-255.
Sets the color
Red value 0-255.
Green value 0-255.
Blue value 0-255.
Set from 0-1 floating point data.
Red value 0-1.
Green value 0-1
Blue value 0-1
Alpha value 0-1
Returns a new color after blending the second color with specified blending mode.
Color to blend with
Blending mode to use. Currently possible values are Color.BLEND_NORMAL, Color.BLEND_REPLACE_COLOR and Color.BLEND_ADDITIVE
Amount to blend.
Sets the color to a random color. This does not affect alpha.
Retuns the brightness of the color
Returns the hue of the color's HSV component.
Returns the saturation of the color's HSV component.
Returns the value of the color's HSV component
Returns the color as a 32-bit usigned integer.
Saves and loads simple config files. Config stores, loads and saves string and number values associated by string keys. You can use to easily save and load settings and preferences and other data. Configs are separated by namespaces, so you can have multiple configs with the same keys.
Default constructor.
Load config from a specified file into the specified namespace.
Namespace of the config to load data into.
Path to the file to load.
Save config to a specified file from the specified namespace.
Namespace of the config to save data from.
Path to the file to save data to.
Sets a string value into the specified config namespace.
Namespace to set value in.
String key of the value.
The string value to save.
Sets a numeric value into the specified config namespace.
Namespace to set value in.
String key of the value.
The numeric value to save.
Returns a numeric value by a string key.
Namespace to get the value from.
String key of the value.
Returns a string value by a string key.
Namespace to get the value from.
String key of the value.
Sets a string value that represents boolean (true|false) key.
Namespace to set value in.
String key of the value.
The string value to save.
Returns a boolean value by eveluating a string key (true|1 = true).
Namespace to get the value from.
String key of the value.
The main core of the framework. The core deals with system-level functions, such as window initialization and OS interaction. Each platform has its own implementation of this base class. NOTE: SOME OF THE FUNCTIONALITY IN THE CORE IS NOT FULLY IMPLEMENTED!!
- Default width of the desktop screen
- Default height of the desktop screen
Show or hide cursor.
True to show mouse, false to hide it.
Capture the mouse. The mouse will be unable to exit the polycode screen.
True to capture the mouse, false to uncapture it.
Sets the cursor the application is using.
Type of cursor to use. Possible values are CURSOR_ARROW, CURSOR_TEXT, CURSOR_POINTER, CURSOR_CROSSHAIR, CURSOR_RESIZE_LEFT_RIGHT, CURSOR_RESIZE_UP_DOWN
Warps the cursor to a specified point in the window.
New cursor x position
New cursor y position
Launches a Threaded class into its own thread. See the documentation for Threaded for information on how to crated threaded classes.
Target threaded class. @see Threaded
Locks a mutex. Legacy method. Use the "lock" method of CoreMutex!
Mutex to lock.
Unlocks a mutex. Legacy method. Use the "unlock" method of CoreMutex!
Mutex to lock.
Creates a mutex
Copies the specified string to system clipboard.
String to copy to clipboard.
Returns the system clipboard as a string.
Returns the core services. See CoreServices for a detailed explanation of services.
Returns the current average frames per second.
Shuts down the core and quits the application.
Checks if core is in fullscreen mode.
Returns the current anti-aliasing level.
Returns the input class. See CoreInput for details in input.
Returns current horizontal resolution.
Returns current vertical resolution.
Returns actual current horizontal resolution.
Returns actual current vertical resolution.
Provides the current width, height, and refresh rate of the screen.
If non-NULL, current screen width will be written here (or 0 if unknown).
If non-NULL, current screen height will be written here (or 0 if unknown).
If non-NULL, current screen refresh rate will be written here (or 0 if unknown).
Creates a folder on disk with the specified path.
Path to create the folder in.
Copies a disk item from one path to another
Path to the item to copy.
Destination path to copy to.
Moves a disk item from one path to another
Path to the item to move.
Destination path to move to.
Removes a disk item.
Path to the item to remove.
Opens a system folder picker and suspends operation.
Opens a system file picker for the specified extensions.
An STL vector containing the allowed file extensions that can be selected.
If set to true, the picker can select multiple files.
Sets a new video mode.
New horizontal resolution of the renderer.
New vertical resolution of the renderer.
True to launch in fullscreen, false to launch in window.
Level of anti-aliasing. Possible values are 2,4 and 6.
Resizes the renderer.
New horizontal resolution of the renderer.
New vertical resolution of the renderer.
Launches the default browser and directs it to specified URL
URL to launch.
Returns the time elapsed since last frame.
Returns the total ticks elapsed since launch.
Returns the target number of milliseconds between frames
Returns the total ticks elapsed since launch.
Returns the default working path of the application.
Returns the default working path of the application.
Brings the application on top (Cocoa only for now).
User input event dispatcher. The Core input class is where all of the input events originate. You can add event listeners to this class to listen for user input events or poll it manually to check the state of user input.
Left mouse button.
Right mouse button
Middle mouse button
- If set to true, will fire touch events on mouse input. Defaults to false.
- If set to true, simulated touches will have type TYPE_PEN.
- If set to true, will fire mouse events on touch input. Defaults to false.
- If set to true, will not send touch events outside of the screen as define by current core resolution. Defaults to false.
- If set to false, will ignore repeat system keypress events if a key is already pressed-down. Defaults to true.
Returns the current mouse position.
Returns the state of the specified key.
The key to check for
Returns the state of the specified joystick button for the specified joystick index. If the joystick index is invalid, returns false
Joystick index to check the state on
Joystick button to check the stat of.
Returns the value of the specified joystick axis for the specified joystick index. If the joystick index is invalid, returns 0
Joystick index to check the state on
Joystick axis to get the value of.
Returns the current mouse position as delta from last frame.
Returns the state of the specified mouse button
Mouse button to check the state of. Possible values are CoreInput.MOUSE_BUTTON1, CoreInput.MOUSE_BUTTON2 and CoreInput.MOUSE_BUTTON3
Returns the current number of active joysticks.
Returns joystick info for specified joystick index.
Joystick index. Returns NULL if index is invalid.
Returns joystick info for specified joystick device ID. Returns NULL if the joystick device ID is invalid.
Joystick device ID.
Joystick info.
- Internal device ID.
- Joystick index.
Global services singleton. CoreServices instantiates and provides global Singleton access to all of the main manager classes in Polycode as well as the Renderer and Config classes.
Returns the singleton instance. NOTE: The singleton instance is unique to each thread and currently Polycode does not support multithreaded access to the core services. The reason for this is being able to run multiple cores in the same application and still have global singleton access to these services.
Returns the main renderer.
Returns the core.
Returns the core input.
Returns the material manager. The material manager is responsible for loading and managing textures, shaders and materials.
Returns the scene manager. The screen manager is responsible for maintaining and rendering 3D scenes.
Returns the timer manager. The timer manager is responsible for updating timers in the framework.
Returns the tween manager. The tween manager is responsible for updating animated tweens in the framework.
Returns the resource manager. The resource manager is responsible for loading and unloading resources.
Returns the sound manager. The sound manager is responsible for loading and playing sounds.
Returns the logger. It can log messages and broadcast them to listeners.
Returns the config. The config loads and saves data to disk.
Stores, saves and loads data. This class can save and load arbitrary data to and from disk and convert it to strings.
Default constructor
Loads data from a file.
Path to the file to load data from.
Retuns data as a string with the specified encoding.
The encoding to use. Currently only supports String.ENCODING_UTF8
Sets the data from a string with the specified encoding.
The string to create the data from.
The encoding to use. Currently only supports String.ENCODING_UTF8
Saves the data to a file.
Path to the file to save data to.
Returns pointer to the data.
Base class for both 2D and 3D objects in Polycode. It provides position and color transformations as well as hierarchy for all Polycode objects.
NOTE: Entity instances are not automatically garbage collected.
- If set to true, will automatically delete children upon destruction. (defaults to false).
- @name Rendering properties Methods and properties affecting the way the entity is rendered. If this flag is true, the entity will always face the camera. False by default.
- The entity's color.
- If this flag is set to false, this entity will not be rendered or updated.
- If this flag is set to false, this entity will not be rendered.
- If this flag is set to false, this entity will not write to the depth buffer when it's rendered.
- If this flag is set to false, this entity will not check the depth buffer when it's rendering.
- If set to false, the children of this entity will not multiply by this entity's color. Set to true by default.
- If set to false, the children will be rendered even if the entity is invisible.
- If set to true, the entity's transformations will not be affected by its parents. Defaults to false.
- If set to true, will constrain the rendering of this entity into the viewport coordinates defined by scissorBox. @see scissorBox
- Defines the viewport coordinates to clip rendering to if enableScissor is defined. @see enableScissor
- Flags an editor only entity. If set to true, this entity will not be saved to file by entity instances or show up in the IDE entity editor.
- String ID of the entity. Can be used to retrieve specific entities by their ID.
- Entity collision type for physics module. This is set per physics module documentaiton.
- If set to true, will automatically process mouse events and dispatch its own input events if mouse events intersect with the entity's bounding box. Defaults to false. Attention: All of the entity's parents' processInputEvents flags must be set to true for this to function including the parent Scene's rootEntity!
- If set to true, will block input events for entities below itself in the parent's entiy list.
- If set to true, will round the position of this entity to integral values. Use this if you need pixel-perfect positioning in 2D.
- Layer ID. Used by entity instances to separate entities into groups.
Main render method. Override this to do your own drawing.
Main update method. Override this to do your updates before the render cycle.
Clones the entity, return an exact copy. This method must be implemented in an Entity subclass for you to be able to clone it.
If true, perform a deep clone, cloning all the children.
If true, ignore all child entities where editorOnly is set to true (will still clone the entity you call Clone() on even if its editorOnly flag is set to true.
This method must be implemented by all subclasses implementing Clone.
@name Matrix operations. These methods operate directly on the entity's matrix. Sets the state of the dirty matrix flag. The dirty matrix flag gets set automatically when a transformation is applied to the entity and the transfrom matrix needs to be rebuilt. This method is provided to manually override that flag.
New value of the dirty matrix flag.
Forces the transformation matrix to be rebuilt.
Forces the matrix to be rebuilt if the matrix flag is dirty. This is also called on all of the entity's children.
Returns the entity's transform matrix.
Returns the entity's matrix multiplied by its parent's concatenated matrix. This, in effect, returns the entity's actual world transformation.
Returns the concatenated matrix up to the specified parent entity.
Parent entity, relative to which to return the transform matrix.
Returns the concatenated matrix, multiplied by the entity's anchor adjustment. @see setAnchorPoint
Returns Same as getConcatenatedMatrix(), but contains only roll information for rotation. Used internally for billboards.
Sets the transform matrix directly, without setting all of the individual transfrom properties of the entity.
4x4 transform matrix to apply.
Returns the matrix for the entity looking at a location based on a location and an up vector.
Location to look at.
Up vector.
@name Hierarchy operations. These methods add and remove entities to and from each other. Adds another entity as a child. The children inherit the parent's transforms.
The entity to be added.
Removes an entity from the entity's children.
Entity to be removed.
Moves the specified child one position up the render list.
Moves the specified child one position down the render list.
Moves the specified child up to the top of the render list.
Moves the specified child up to the bottom of the render list.
Manually sets the entity's parent. This method does not add the entity to the parent and should not be called manually.
Parent entity.
Returns the parent entity of the entity.
Returns the number of child entities belonging to this entity.
Returns the child entity at specified index.
Index to return entity at.
Sets the ownsChildren flag for this entity and recursively for all its child entities. @see ownsChildren
@name Transform operations. These methods apply various transformations to the entity. Returns the entity's position.
Returns the entity's position as a Vector2
Returns the entity's position added to the combined position of its parent. This method is here only for convenience of calculating certain properties and should not be used to get an entity's actual position in the world. To get the actual world position of the entity, use the entity's concatendated matrix.@see getConcatenatedMatrix()
Sets the entity's position.
X-axis value.
Y-axis value.
Z-axis value.
Returns the entity's position on the X axis.
X-axis value.
Returns the entity's position on the Y axis.
Y-axis value.
Translates the entity relative to its current position.
X-axis value.
Y-axis value.
Z-axis value.
Returns the entity's position on the Z axis.
Z-axis value.
Returns the entity's scale on the X axis.
X-axis scale value.
Returns the entity's scale on the Y axis.
Y-axis scale value.
Returns the entity's scale on the Z axis.
Z-axis scale value.
Scales the entity relative to its current scale.
X-axis value.
Y-axis value.
Z-axis value.
Sets the entity's scale.
X-axis value.
Y-axis value.
Z-axis value.
Returns the entity's scale multiplied by its parent's compound scale.
Returns the entity's scale.
Returns the entity's rotation as euler angles
Returns the entity's pitch combined with the combined pitch of its parent.
Returns the entity's yaw combined with the combined yaw of its parent.
Returns the entity's roll combined with the combined roll of its parent.
Forces the rotation quaternion to be rebuilt.
Sets rotation from euler angles
New rotation values
Sets the pitch rotation of the entity.
New pitch value in degrees.
Sets the yaw rotation of the entity.
New yaw value in degrees.
Sets the roll rotation of the entity.
New roll value in degrees.
Rolls the entity relative to its current roll.
Roll value in degrees.
Yaws the entity relative to its current yaw.
Yaw value in degrees.
Pitches the entity relative to its current pitch.
Pitch value in degrees.
Returns the current pitch of the entity.
Returns the current yaw of the entity.
Returns the current roll of the entity.
Returns the bounding box X value.
Returns the bounding box Y value.
Returns the bounding box Z value.
Sets the bounding box X value.
Sets the bounding box Y value.
Sets the bounding box Z value.
Sets the rotation with quaternion value.
Returns the current rotation as a quaternion.
Orients the entity towards the specified location with the provided up vector. The up vector determines which side of the entity will be pointing in that direction.
Location to look at.
The up vector.
Orients the entity towards another entity with the provided up vector. The up vector determines which side of the entity will be pointing in that direction.
Entity to look at.
The up vector. @see lookAt()
Returns the entity's color multiplied by its parent entity's combined color.
Sets the color of the entity as normalized floating point values.
Red value as a 0-1 floating point number.
Green value as a 0-1 floating point number.
Blue value as a 0-1 floating point number.
Alpha value as a 0-1 floating point number.
Sets the color of the entity as 0-255 integers.
Red value as a 0-255 integer.
Green value as a 0-255 integer.
Blue value as a 0-255 integer.
Alpha value as a 0-255 integer.
Sets the anchor (center) point of the entity as normalized half bounding box coordinates. (i.e. -1.0 or 1.0 will offset the entity by half on a particular axis).
Anchor point as a 3D Vector.
Returns the current anchor (center) point of the entity.
If this flag is set to true, this entity will render only into the depth buffer. This, effectively, means that it will be invisible, but still obscuring other entities.
If this flag is set to true, this entity's transformations will not take into account its parent, making its transforms always relative to 0. Sets user data pointer.
User data pointer
Returns the user data pointer.
Sets the entity's blending mode.
New blending mode to set. Possible values are Renderer.BLEND_MODE_NORMAL, Renderer.BLEND_MODE_LIGHTEN, Renderer.BLEND_MODE_COLOR, Renderer.BLEND_MODE_PREMULTIPLIED, Renderer.BLEND_MODE_MULTIPLY. See the Renderer class for details on individual blending modes. @see Renderer
Returns the first child entity that has the specified string id.
Specified id to search for.
If set to true, will search all child entities recursively.
Returns all child entities which have the specified tag.
Tag to search for.
If set to true, will search all child entities recursively.
Returns all child entities that have the specified layer ID. Layer IDs are used by the entity instances to separate entities into groups.
ID to search for.
If set to true, will search all child entities recursively.
Returns custom string dictionary property of the entity based on the property name.
name to look up.
Sets the entity property for a specified property name in the entity's custom property dictionary.
Property name to set.
Value to set for the specified property name.
If set to true, the y position of the entity matrix will be multiplied by -1.0, inverting its Y-axis coordinate system.
Returns true if the entity is set to use an inverse Y-coordinate system.
Implement this method to do custom ray hit detection beyond a bounding box check. Always returns true by default.
Returns the number of tags this entity has.
Returns the tag at specified index or an empty string if index is invalid.
Returns true if this entity contains the specified tag.
Tag to look up.
Removes all tags from this entity.
Adds a string tag to the entity.
Tag to add.
Returns the screen pixel position of the entity
Projection matrix to use.
Camera matrix to use.
Viewport rectangle.
Return axis-aligned bounding box in world space.
Returns the bounding box of the entity. This is used for hit-testing as well as visibility calculation.
Sets the bounding box of the entity as a 3D Vector. This is used for hit-testing as well as visibility calculation.
Sets the bounding box X-axis value of the entity.
Sets the bounding box Y-axis value of the entity.
Sets the bounding box Z-axis value of the entity.
Event base class. Subclass this class to pass complex data through events.
Default constructor.
Returns the event code for this event.
Returns the event dispatcher which originated the event.
Can dispatch events. The event dispatcher is base class which allows its subclass to dispatch custom events which EventHandler subclasses can then listen to. EventDispatcher and EventHandler are the two main classes in the Polycode event system. If you are familiar with ActionScript3's event system, you will find this to be very similar, except that it uses integers for event codes for speed, rather than strings.
Default constructor
Removes all current event handlers from this dispatcher.
Removes all current event handlers from this dispatcher for a specific event listener.
listener to remove handlers for.
Adds an event listener for a specific event code. Once a listener is registered for a specific event code, that listener will start getting event callbacks into the handleEvent() method.
The event handler to add as a listener
The requested event code to listen to. @see EventHandler
Adds an event listener for specified event code if it hasn't already been added, otherwise does nothing.
The event handler to add as a listener
The requested event code to listen to.
Returns true if this event dispatcher is registered with the specified EventHandler with the specified event code.
EventHandler to check.
The event code to check.
Removes a listener for a specific handler and event code.
The event handler to remove as a listener
The requested event code to remove listener for. @see EventHandler
Dispatches an event to all handlers listening for the event code specified.
Event class to dispatch to listeners. You can subclass the Event class to send data in your events.
The event code to dispatch the event for. @see Event @see EventHandler
Can handle events from EventDispatcher classes.
Default constructor
An image in memory. Basic RGB or RGBA images stored in memory. Can be loaded from PNG files, created into textures and written to file.
NOTE: Image instances are not automatically garbage collected.
Create image from file name.
Path to image file to load.
Create a blank image of specified size and type.
Width of the image to create.
Height of the image to create.
Type of image to create. Can be IMAGE_RGBA or IMAGE_RGB.
Load an image from a file
Path to image file to load.
Saves the image to a file. Currently only PNG files are supported.
Path to image file to load.
Pastes another image into the image
Image to paste
X position of new image within the image
Y position of new image within the image
Blending mode to use. Currently not used.
Recreate the image as an empty image of specified size. The image type stays the same.
Width of the image to create.
Height of the image to create.
Fills the image with the specified color values.
The color to fill it with.
Sets a pixel at specified coordinates to specified color.
X position of pixel.
Y position of pixel.
Red value 0-1.
Green value 0-1
Blue value 0-1
Alpha value 0-1
Returns the pixel color at specified position.
X position of pixel.
Y position of pixel.
Draws a line with specified color.
Starting x position.
Starting y position.
Ending x position.
Ending y position.
Color to use.
Moves brush to specified position
New brush position X
New brush position Y
Translates brush a specified amount relative to its current position.
Amount to translate on X axis
Amount to translate on Y axis
Draws a line to specified position.
Ending x position.
Ending y position.
Color to use.
Draws a rectangle with specified color.
Rectangle x position.
Rectangle y position.
Rectangle width.
Rectangle height.
Color to use.
Draws perlin noise in the image
Seed for the noise
If true, affects alpha, if false only affects the color.
Blurs the image
Size of the blur in pixels.
Returns an area of the image buffer. The area can go outside of image bounds, in which case the pixels not within the image are zeroed out. This method allocates new memory for the returned buffer and you must free it manually.
X position of the area to return.
Y position of the area to return.
Width of the area to return.
Height of the area to return.
Returns a copy of the specified subRect part of the image.
The part of the image to copy. (0, 0) refers to the top left of the image.
Returns the x position of the brush.
Returns the y position of the brush.
Returns the width of the image.
Returns the height of the image.
Returns the raw image data
Multiplies the RGB values by alpha for each pixel.
Event dispatched by CoreInput. This event is dispatched by CoreInput when input happens.
@name Input event types. Possible input event types dispatched by CoreInput.
- If this is a mouse click event, the mouse button that's pressed.
- If this is a mouse event, the mouse position.
- If this is a key event, the key code that's coming down or up.
- If this is a key press event, this will contain the unicode character that's being typed.
An image that can render text into itself. This class is mostly used internally in SceneLabel, but can be used by itself to manually create text-based textures.
Create a text label.
Font to use for this label.
Initial text to render.
Pixel size of the text to render.
Antialiasing mode. Can be ANTIALIAS_FULL, ANTIALIAS_NONE or ANTIALIAS_STRONG.
If set to true, will premultiply alpha in the label image. @see Font
Sets the text of the label.
Text to set.
Returns the current text of the label.
Returns the pixel width for the specified string based on the current label font and size settings.
Text to return width for.
Returns the pixel height for the specified string based on the current label font and size settings.
Text to return height for.
Returns the width of the current text.
Returns the height of the current text.
Sets the color for a range of characters in the label. The colors are only applied upon the next call to setText, not the currently rendered text. This call appends the color range to a list of color ranges, so if you are calling this multiple times for the same ranges, you must call clearColors.
The color to set for the specified range.
Starting index of the specified range.
Ending index of the specified range. @see clearColors
Clears the current label colors. @see setColorForRange
Returns the text color for specified character index.
Returns the premultiply alpha setting.
If set to true, will premultiply alpha when text is set to the label.
Sets the Font used to render text in the label. @see Font
Returns the Font currently used to render text in the label. @see Font
Sets the vertical pixel size of text rendered in the label.
Return the current vertical pixel size of text rendered in the label.
Returns the current antialasing mode.
Sets the antialiasing mode used to render text.
Antialiasing mode. Can be ANTIALIAS_FULL, ANTIALIAS_NONE or ANTIALIAS_STRONG.
Returns the pixel distance from top of image to the baseline of the rendered text.
NOTE: Material instances are not automatically garbage collected.
Manages loading and reloading of materials, textures and shaders. This class should be only accessed from the CoreServices singleton.
4x4 Matrix.
Resets the matrix to identity.
Rotates a vector by the matrix values.
Vector to rotate.
Returns the position from the matrix.
Translates the position in the matrix.
X coordinate.
Y coordinate.
Z coordinate.
Sets the position in the matrix.
X coordinate.
Y coordinate.
Z coordinate.
Sets the scale in the matrix.
X scale.
Returns the matrix rotation as euler angles. (This might be kind of buggy).
Pointer to roll angle to set.
Pointer to pitch angle to set.
Pointer to yaw angle to set.
Returns the transpose of the matrix.
Returns the inverse of the matrix.
Returns the affine inverse of the matrix.
Returns the determinant of the matrix.
Returns the determinant of any general (square) matrix.
A square matrix as an array of pointers to rows (or columns).
The number of dimensions in matrix A.
A mesh comprised of vertices. When data in the mesh changes, arrayDirtyMap must be set to true for the appropriate array types (color, position, normal, etc). Available types are defined in RenderDataArray.
NOTE: Mesh instances are not automatically garbage collected.
Quad based mesh.
Triangle based mesh.
Triangle fan based mesh.
Line based mesh.
Point based mesh.
Line strip based mesh.
Line loop based mesh.
Construct with an empty mesh of specified type.
Type of mesh. Possible values are: Mesh.TRISTRIP_MESH, Mesh.TRI_MESH, Mesh.TRIFAN_MESH, Mesh.TRISTRIP_MESH, Mesh.LINE_MESH, Mesh.POINT_MESH.
Construct from a mesh loaded from a file.
Path to mesh file.
Loads a mesh from a file.
Path to mesh file.
Clears mesh data.
Saves mesh to a file.
Path to file to save to.
Returns the total vertex count in the mesh.
Creates a plane mesh of specified size.
Width of plane.
Depth of plane.
Creates a vertical plane mesh of specified size.
Width of plane.
Depth of plane.
Creates a 2D circle.
Width of circle.
Height of plane.
Number of segments
Creates a 2D circle with normals pointing outwards from vertices.
Width of circle.
Height of plane.
Number of segments
Creates a torus.
Radius of the torus.
Radious of the tube.
Number of radial segments.
Number of tube segments.
Creates a cube mesh of specified size.
Width of cube.
Depth of cube.
Height of cube.
Creates a sphere mesh of specified size.
Radius of sphere.
Number of rings.
Number of segments.
Creates an icosphere of specified radius
Radius of sphere.
0 means you get an icosahedron, don't recommend ever going above about 4 or 5 as they get really big
Creates an octosphere of specified radius
Radius of sphere.
0 means you get an octagon, don't recommend ever going too high as they get really big
Creates a cylinder mesh.
Height of the cylinder.
Radius of the cylinder.
Number of segments.
Create the end caps.
Creates a cone mesh.
Height of the cone.
Radius of the cone.
Number of segments.
Recenters the mesh with all vertices being as equidistant from origin as possible.
Returns the radius of the mesh (furthest vertex away from origin).
Recalculates the mesh normals
Recalculates the tangent space vector for all vertices.
Returns the mesh type.
Sets a new mesh type.
New mesh type. Possible values are: Mesh.TRISTRIP_MESH, Mesh.TRI_MESH, Mesh.TRIFAN_MESH, Mesh.TRISTRIP_MESH, Mesh.LINE_MESH, Mesh.POINT_MESH.
Calculates the mesh bounding box.
Checks if the mesh has a vertex buffer.
Removes a range of vertices starting at beginRemoveVertex. vertexRemovalCount should be a multiple of the num if you want to keep your mesh data clean. If this is an indexedMesh, will also remove any faces that reference
First element of the vertex array to remove
Number of elements to remove from the vertex array
Removes a face from the mesh. Face is defined as a triangle for TRI_MESH, or a line for LI In indexedMesh mode this may result in orphaned vertices.
The 0-indexed face of the mesh (and NOT the index into the indices array!)
For indexedMesh only, removes any unused vertices from the mesh.
Single entry in an Object. Object entries can be accessed as dictionaries or arrays.
- Type of entry. Possible values are (FLOAT_ENTRY, INT_ENTRY, BOOL_ENTRY, ARRAY_ENTRY, STRING_ENTRY, CONTAINER_ENTRY).
- Lookup key for this object entry.
- Number value of this object entry.
- Integer value of this object entry.
- String value of this object entry.
- Boolean value of this object entry.
- Length of this object entry if its type is ARRAY_ENTRY.
Default constructor
Tries to write the Number value of this[key] to out.
A pointer to the value to write the number value to.
Tries to write the String value of this[key] to out.
A pointer to the value to write the String value to.
Tries to write the boolean value of this[key] to out.
A pointer to the value to write the boolean value to.
Adds an empty child entry.
Lookup key for the object entry.
NOTE: SceneParticleEmitter instances are not automatically garbage collected.
- Bezier curve that controls the scale of the particles.
- Bezier curve that controls the red component of particles' color.
- Bezier curve that controls the green component of particles' color.
- Bezier curve that controls the blue component of particles' color.
- Bezier curve that controls the alpha component of particles' color.
2D Perlin noise.
Constructs perlin noise.
Number of noise octaves.
Noise frequency.
Noise amplitude.
Noise seed.
Returns noise value at the specified coordinate.
Horizontal coordinate.
Vertical coordinate.
Rotation quaternion.
Construct from w,x,y,z values.
W value.
X value.
Y value.
Z value.
@name Public members Available public members
Rotate a Vector3 by this Quaternion.
Vector to operate on.
Ray class.
finds the two closest point on the ray to an arbitrary point space.
finds the two closest points between two rays, returns false if they're parallel.
Basic rectangle.
- X position
- Y position
- Width
- Height
Default constructor.
Set rectangle values.
Return a Rectangle formed by clipping this rectangle to the bounds of the passed rectangle.
Return the minimum X coordinate (the left edge).
Return the maximum X coordinate (the right edge).
Return the minimum Y coordinate (the top edge in a Y-down coordinate system).
Return the maximum Y coordinate (the bottom edge in a Y-down coordinate system).
Vertex position array.
Vertex color array.
Vertex normal array.
Vertex texture coordinate array.
Tangent array.
Bone weight array.
Bone weight array.
Index data array.
Secondary texture coordinate array.
Base class for resources. All resources that are managed by the ResourceManager subclass this.
@name Public members Available public members
Manages loading and unloading of resources from directories and archives. Should only be accessed via the CoreServices singleton.
Rendering container. The Scene class is the main container for all rendering in Polycode. Scenes are automatically rendered and need only be instantiated to immediately add themselves to the rendering pipeline. A Scene is created with a camera automatically.
NOTE: Scene instances are not automatically garbage collected.
- Scene clear color
- If set to true, the renderer will clear the screen prior to rendering the scene @default true
- If set to true, the renderer will clear the depth buffer prior to rendering the scene. @default true
- Ambient color, passed to lighting shaders
- Fog color, passed to lighting shaders.
- If this is set to false, the scene is not rendered or updated during the render loop.
- If ownsChildren is set to true, the scene will delete its children upon destruction (defaults to false).
Default constructor with options.
Type of scene to create. Can be Scene.SCENE_2D, Scene.SCENE_3D or Scene.SCENE_2D_TOPLEFT
If this flag is set to true, the scene is not rendered to the screen. Use this if you want to render the scene only to a texture.
Adds a new Entity to the scene
New entity to add.
Adds a new Entity to the scene
New entity to add.
Removes a Entity from the scene
New entity to remove.
Returns the scene's default camera.
Returns the scene's active camera.
Sets the scene's active camera.
New camera to set as the active camera.
Enables and disables fog in the scene.
If false, disables lighting in the scene, if true, enables it.
Sets the fog properties for the scene.
Fog falloff mode. (Renderer.FOG_LINEAR, Renderer.FOG_EXP, Renderer.FOG_EXP2).
Fog color.
Fog density.
Starting depth of the fog.
Ending depth of the fog.
Adds a light to the scene.
Light to add to the scene.
Removes a light from the scene.
Light to remove from the scene.
NOTE: SceneEntityInstance instances are not automatically garbage collected.
2D screen image display. This ScreenEntity can load and display and image.
NOTE: SceneImage instances are not automatically garbage collected.
Create screen image from file.
Create screen image from Image.
Image to create from.
Create screen image from Texture.
Texture to create from.
Changes which part of the image is displayed.
X position of the display rectangle.
Y position of the display rectangle.
Width of the display rectangle.
Height of the display rectangle.
Returns the image width.
Returns the image height.
3D text label. Creates a 3D text label.
NOTE: SceneLabel instances are not automatically garbage collected.
Sets new text for the labe.
New text to display.
3D light source. Lights can be point or spot lights and can be set to different colors.
NOTE: SceneLight instances are not automatically garbage collected.
Constructs a light with parameters.
Type of light to create. Can be SceneLight.POINT_LIGHT or SceneLight.SPOT_LIGHT
Scene to light.
Light color intensity
Constant falloff attenuation value
Linear falloff attenuation value
Quadratic falloff attenuation value
Sets the light's intensity
New intensity value.
Sets the attenuation values for the light.
Constant falloff attenuation value
Linear falloff attenuation value
Quadratic falloff attenuation value
Sets the light color.
Red value 0-1.
Green value 0-1
Blue value 0-1
Alpha value 0-1
Sets the light color.
Red value 0-1.
Green value 0-1
Blue value 0-1
Alpha value 0-1
Sets both the specular and diffust light colors. Use setDiffuseLightColor and setSpecularLightColor to set the individual light colors.
Red value 0-1.
Green value 0-1
Blue value 0-1
Alpha value 0-1
Sets the spotlight properties. These control the shape of the spotlight beam.
Spotlight exponent size
Spotlight furstrum cutoff.
If this is called with 'true', the light will generate a shadow map.
If set to true, enables this light to cast shadows.
Resolution of the shadow map. (defaults to 256x256).
This sets the shadow map field of view. The larger the field of view, the more of the scene it encompasses, but the more quality it loses.
New field of view value.
Returns the light's shadow map field of view.
Returns true if shadows are enabled.
Returns the light type.
BezierCurve scene rendering/placement class. You can use this class to place a bezier curve in scene space for use as animation tracks or rendering.
3D line class. Can connect two SceneEntity classes with a line.
NOTE: SceneLine instances are not automatically garbage collected.
Constructs the line with two taraget entities.
Starting entity.
Ending entity.
Constructs the line with two taraget positions.
Starting position.
Ending position.
This class manages all rendered scenes in Polycode.
Adds a scene to the render loop. Scenes automatically add themselves to the manager on creation, so there's no need to call this manually unless you remove a scene yourself.
Removes scene from the render loop (does not delete the scene).
3D polygonal mesh instance. The SceneMesh is the base for all polygonal 3d geometry. It can have simple textures or complex materials applied to it.
NOTE: SceneMesh instances are not automatically garbage collected.
- Line width for line-based meshes.
- If set to true, will antialias the lines in a line-based mesh. Defaults to false.
- If setto true, will antialias points in a point-based mesh. Defaults to false.
- If true, will delete its Mesh upon destruction or mesh loading. (defaults to true)
- If true, will delete its Skeleton upon destruction. (defaults to true)
- If set to true, will check against actual geometry polygons on ray hit detection. Defaults to false.
- Normally, translucent textures do not affect the depth buffer, but if this flag is set to true, this entity's alpha channel is written to the depth buffer at a preset threshold. This flag is set to false by default.
- If this flag is set to false, backface culling is disabled when rendering this entity, rendering both sides of each face. Set to true by default.
Construct a scene mesh from a mesh file.
Path to mesh file to load.
Construct scene mesh from an existing Mesh instance.
Construct an empty scene mesh with the specified type.
Mesh type to create. See Mesh for possible values.
Returns the Mesh instance of the actual mesh.
Returns the material applied.
Loads a skeleton from a file and applies it to the scene mesh.
Filename to load the skeleton from.
Clears the currently applied material
Set material from existing Material instance.
Material to apply.
Set material by name. You can create materials in material files and name them there, then use this to set a material by name to a scene mesh.
Name of material to apply.
Set the mesh this scene mesh renders.
Set a new mesh to render.
Sets a skeleton from an existing skeleton instance.
Skeleton to set to this mesh.
Returns the skeleton applied to this scene mesh.
Sets the line width for line-based meshes.
If this mesh was loaded form file, returns the filename of the loaded mesh.
Sets the filename path of the mesh.
Loads mesh from file. Deletes current mesh if ownsMesh is set to true.
The Renderer has an ability to set an override material that is set for all rendered entities. If forceMaterial is set to true, this entity will always use its assigned material, even if an override material is set.
3D primitive mesh.
NOTE: ScenePrimitive instances are not automatically garbage collected.
A cube. v1 - X size v2 - Y size v3 - Z size v4 - # of tiles
A horizontal plane. v1 - X size v2 - Z size v3 - # of tiles
A vertical plane. v1 - X size v2 - Y size v3 - # of tiles
A cylinder. v1 - Cylinder length v2 - Cylinder radius v3 - Number of segments. v4 - # of tiles
A cylinder. v1 - Cylinder length v2 - Cylinder radius v3 - Number of segments. v4 - # of tiles
A sphere. v1 - Sphere radius v2 - Lat segments v3 - Long segments v4 - # of tiles
A torus. v1 - Torus radius. v2 - Pipe radius. v3 - Number of ring segments. v4 - Number of pipe segments. v5 - # of tiles
A cone. v1 - Cone length. v2 - Cone raidus. v3 - Number of segments. v4 - # of tiles
A 2D circle. v1 - X size v2 - Y size v3 - Number of segments v4 - # of tiles
An ico sphere. v1 - Sphere radius v2 - number of subdivisions
An ico sphere. v1 - Sphere radius v2 - number of subdivisions
A 2D line circle. v1 - X size v2 - Y size v3 - Number of segments v4 - # of tiles
Create a primitive mesh of specified type and size.
Type of primitive to create. Current types are ScenePrimitive.TYPE_BOX, ScenePrimitive.TYPE_PLANE, ScenePrimitive.TYPE_VPLANE, ScenePrimitive.TYPE_SPHERE, ScenePrimitive.TYPE_CYLINDER, ScenePrimitive.TYPE_CONE and ScenePrimitive.TYPE_TORUS
See the constant primitive types for values for these parameters
See the constant primitive types for values for these parameters
See the constant primitive types for values for these parameters
See the constant primitive types for values for these parameters
See the constant primitive types for values for these parameters
Renders scenes to texture. This class automatically renders a scene to a texture every frame that you can use to texture anything else. You can set a scene to virtual (see Scene for details) to only render a scene to a texture if you need to. This class automatically adds itself to the render cycle, so you do not need to do anything manual every frame.
Construct a new render texture with parameters.
Target scene to render.
to render from.
Horizontal size of the render texture.
Vertical size of the render texture.
Pass true if you want fp16 target renders
Returns the actual render texture.
Returns the target scene.
Returns the target camera.
Creates a positional 3D sound.
NOTE: SceneSound instances are not automatically garbage collected.
Returns the sound object associated with this positional sound.
Creates a positional 3D sound listener. There can be only one listener active at any one time.
NOTE: SceneSprite instances are not automatically garbage collected.
Skeleton animation.
Adds a new bone track
New bone track to add.
Returns the animation name.
Plays the animation.
Stops the animation.
Sets the animation multiplier speed.
Number to multiply the animation speed by.
3D skeleton. Skeletons are applied to scene meshes and can be animated with loaded animations.
Construct skeleton from a skeleton file.
Skeleton file to load.
Construct a blank skeleton.
Loads a new skeleton from file.
Skeleton file to load.
Play back a loaded animation.
Name of animation to play.
If true, will only play the animation once.
Loads in a new animation from a file and adds it to the skeleton.
Name of the new animation.
File to load animation from.
Returns a SkeletonAnimation by its name.
of animation to return.
Get bone instance by its name
Name of the bone.
Toggles bone visibility on and off.
If true, bones will be rendered, if false, they will not.
Returns the number of bones in the skeleton
Returns a bone at the specified index.
Bone index.
Loads and plays a sound. This class can load and play an OGG or WAV sound file.
Constructor.
Path to an OGG or WAV file to load.
Play the sound once or in a loop.
If this is true, play it once, otherwise, loop.
Stop the sound playback.
Sets the volume of this sound.
A Number 0-1, where 0 is no sound and 1 is the loudest.
Sets the pitch of this sound.
A Number 0-1.
Returns true if the sound is playing.
Sets the current sample offset of this sound.
A number 0 <= off < sound sample length
Returns the current sample offset (playback progress) of this sound.
Returns the number of samples in the sound.
Controls global sound settings.
Sets the global sound volume.
Unicode-friendly string. The Polycode String class wraps around STL wstring to support Unicode text in the engine. You can request data from it in different encodings (currently only UTF-8) or plain char data. It is mostly just a wrapper around STL created for easier Unicode support, LUA bindings and convenience methods.
UTF-8 encoding.
- STL string version of the string.
- STL string version of the string.
Default constructor
Return the length of the string.
Return the length of the string.
Returns the substring of the string.
Position of a character in the current string object to be used as starting character for the substring.
Length of the substring.
Find last occurrence of content in string.
String to be searched for in the object.
Position of the last character in the string to be taken into consideration for possible matches. The default value indicates that the entire string is searched.
Find content in string.
String to be searched for in the object.
Position of the first character in the string to be taken into consideration for possible matches. The default value indicates that the entire string is searched.
Find character in string from the end. Searches the string from the end for any of the characters that are part of the passed string.
String containing the characters to search for.
Position of the last character in the string to be taken into consideration for possible matches. The default value indicates that the entire string is searched.
Find character in string from the beginning. Searches the string from the beginnign for any of the characters that are part of the passed string.
String containing the characters to search for.
Position of the first character in the string to be taken into consideration for possible matches. The default value indicates that the entire string is searched.
Returns the lowercase version of the string.
Returns the uppercase version of the string.
Splits the string by the specified delimeter
The delimeter to split by.
Replaces parts of the string with another string.
Ocurrences of which string to replace in this string.
What to replace them with.
Convert a Number to a String.
Number to convert.
Convert an integer to a String.
Integer to convert.
Pointer to char data.
Returns data with the specified encoding. Currently the only supported encoding is String.ENCODING_UTF8
The encoding to use.
Returns wide character data with the specified encoding. Currently the only supported encoding is String.ENCODING_UTF8
The encoding to use.
Returns the size of the data with the specified encoding. Currently the only supported encoding is String.ENCODING_UTF8
The encoding to use.
Sets the data for the string
Data to set the string with.
The encoding to use.
Checks if the string is a number
NOTE: Texture instances are not automatically garbage collected.
A timer that dispatches trigger events.
Creates a new timer.
If true, will dispatch an event at the specified frequency, otherwise it will simply count time. You normally want this to be true.
Timer frequency in milliseconds.
Pauses and resumes the timer.
If true, pauses the timer, otherwise resumes it.
Returns true if the timer is paused.
Resets the timer.
Returns the time elapsed in floating point microseconds.
2D Vector (convenience wrapper around Vector3).
- X coordinate.
- Y coordinate.
Create from x,y,z coordinates.
X coordinate.
Y coordinate.
Sets the vector from x,y,z coordinates.
X coordinate.
Y coordinate.
Returns the distance from this vector to another one.
Second vector.
Returns the vector length.
Returns the dot product with another vector.
Returns the cross product with another vector.
Second vector.
Normalizes the vector.
3D Vector class.
- X coordinate.
- Y coordinate.
- Z coordinate.
Create from x,y,z coordinates.
X coordinate.
Y coordinate.
Z coordinate.
Sets the vector from x,y,z coordinates.
X coordinate.
Y coordinate.
Z coordinate.
Returns the distance from this vector to another one.
Second vector.
Returns the angle between this and the specified vectors.
Returns the vector length.
Returns square of the length of the vector. Cheaper to execute than length(), for use when you're just e.g. comparing vector lengths.
Returns the dot product with another vector.
Returns the cross product with another vector.
Second vector.
Normalizes the vector.
4D Vector class.
- X coordinate.
- Y coordinate.
- Z coordinate.
- W coordinate.
Create from x,y,z coordinates.
X coordinate.
Y coordinate.
Z coordinate.
W coordinate.
Sets the vector from x,y,z coordinates.
X coordinate.
Y coordinate.
Z coordinate.
W coordinate
Returns the dot product with another vector.