func NewChunk(parentObject *engine.Object, size int, ts *Tileset) *Chunk { chk := &Chunk{ Size: size, Tileset: ts, Data: make([]*Voxel, size*size*size), vao: render.CreateVertexArray(), vbo: render.CreateVertexBuffer(), } chk.ComponentBase = engine.NewComponent(parentObject, chk) return chk }
func NewPlacementGrid(parentObject *engine.Object) *PlacementGrid { pg := &PlacementGrid{ mesh: geometry.CreateLines(), Chunk: nil, } pg.ComponentBase = engine.NewComponent(parentObject, pg) // find chunk obj, exists := parentObject.GetComponent(pg.Chunk) if !exists { panic("no chunk component") } chunk := obj.(*ColorChunk) // compute grid mesh pg.Chunk = chunk pg.Y = chunk.Size - 1 pg.Compute() return pg }