PenguinCollisionShape
A class that will contain some collision information that can be attached to shapes.
There are a few types of collision shapes currently known to the system, and I'll probably be adding more over time. The classes themselves are very basic and only contain data, and no behaviors. If you want collision detection, you can feed the data into a dedicated 3D collision system such as this one.
Some of the properties of collision shapes are complex data types. I'd love to call them "vectors" and "matrices" but since they purely contain data and none of the object-oriented methods that GameMaker users have come to expect from such things, I'm going to refer to them by their more literal nerd names instead.
A structure containing three numerical values: x
, y
, and z
. Sometimes used to represent things such as positions or directions in 3D space.
A structure containing three float3
values, themselves called: x
, y
, and z
. Sometimes used to represent things such as an orientation in 3D space.
Mapping the nine floats onto the 16-value arrays that GameMaker's matrix_build
and similar functions give you looks a bit like this:
float3x3.x.x = mat[ 0]
float3x3.x.y = mat[ 1]
float3x3.x.z = mat[ 2]
float3x3.y.x = mat[ 4]
float3x3.y.y = mat[ 5]
float3x3.y.z = mat[ 6]
float3x3.z.x = mat[ 8]
float3x3.z.y = mat[ 9]
float3x3.z.z = mat[10]
An Oriented Bounding Box. These are useful for a lot of things.
Property | Type | Description |
---|---|---|
position | float3 | The position of the box |
orientation | float3x3 | The orientation of the box |
scale | float3 | The size of the box; in a sense it's only half the size, as the value specifically represents the half-extents of each dimension |
I don't expect the decision to use half extents for the size property to be controversial in the slightest.
A sphere. Arguably the simplest collision shape.
Property | Type | Description |
---|---|---|
position | float3 | The position of the sphere |
radius | real | The radius of the sphere |
There are a few ways to define a capsule, but I'm probably going to go with a line segment with a start and an end, and a radius. Penguin currently contains some code to define them by a length and a radius but it's incomplete and I don't think I like it.
A simpler box. Doesn't feature any orientation information, but the math tends to be simpler to detect collisions against.
A triangle mesh. Can be an array of triangles or sorted into a hierarchy. In either case these are rather slow and I'd like to discourage people from using them when possible. They also generally feature a transform of some sort (position, orientation, and/or scale).