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 System.Collections; | |
using System.Collections.Generic; | |
using Unity.Mathematics; | |
using UnityEngine; | |
public static class VoxelTables | |
{ | |
// all 8 possible vertices for a voxel | |
public static readonly Vector3[] Vertices = new Vector3[8] | |
{ |
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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public static class VoxelTables | |
{ | |
// all 8 possible vertices for a voxel | |
public static readonly Vector3[] Vertices = new Vector3[8] | |
{ | |
new Vector3(0.0f, 0.0f, 0.0f), |
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; |
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
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 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
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
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
// 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
# 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; |
NewerOlder