This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Player { | |
float pos[3]; // array of 3 floats (aka vector3) | |
float rot[4]; // array of 4 floats (aka vector4, aka quaternion) | |
struct Mesh mesh; // if you are in third person u should see your player | |
struct BoxCollider collider; // collision | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Mesh { | |
int meshIndex; // the number of vertices or "size" of the mesh | |
float vertices[meshIndex][3]; // array of 3 dimensional floats | |
float normals[meshIndex][3]; // surface normals | |
float uvs[meshIndex][2]; // 2 dimensional floats, maps a pixel position on the texture to the corresponding vertex | |
int triangles[meshIndex]; // in sets of 3 gets vetices by index to make triangles bewteen the 3 vertices | |
} | |
struct BoxCollider { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <renderer.h> | |
# include <input.h> // other C files except they end in .h | |
// ... our structs | |
int main (void) { | |
// ... initializing a visible os window for rendering | |
struct Player player; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the generic objects struct for static objects in the world (obstactles not moving with physics) | |
struct Object { | |
struct Transform transform; | |
struct Mesh mesh; | |
struct MeshCollider collider; | |
} | |
struct Transform { | |
// float pos[3] or struct with { x, y, z ... } both work | |
struct Vector3 pos; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Object { | |
struct Object *parent; // a pointer | |
struct Transform transform; | |
struct Mesh mesh; | |
struct MeshCollider collider; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Object { | |
struct Object []children; | |
struct Object *parent; | |
struct Transform transform; | |
struct Mesh mesh; | |
struct MeshCollider collider; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Node { | |
public string name; // debug name | |
public Node[] children; | |
public virtual void Update() | |
{ | |
// classes can override this | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Rendering; | |
public class Renderable : Node { | |
public Mesh mesh; | |
public virtual Render() { | |
// this.transform, inherited transform from Node | |
Rendering.enqeue(this.transform, this.mesh); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Spatial : Node { | |
public Transform transform; | |
} | |
public class Renderable : Spatial { | |
public Mesh mesh; | |
public virtual void Render() { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Collider : Spatial { | |
private Enum ColliderType { Box, Sphere, Capsule }; | |
public virtual float GetArea(ColliderType colliderType) { | |
switch(colliderType) { | |
case Box: | |
// return area of box | |
break; | |
case Sphere: | |
// return area of sphere | |
break; |
OlderNewer