1
0
Fork 0

auts: commit work

This commit is contained in:
coaljoe 2020-04-30 15:02:14 +03:00
parent 7ff3a55cd1
commit a5769cc640
8 changed files with 131 additions and 4 deletions

22
bit_source.v Normal file
View File

@ -0,0 +1,22 @@
module main
// World bit source (emits bits)
struct BitSource {
mut:
pos WorldPos
elem_type ElemType
rate f32
active bool
}
fn new_bit_source() &BitSource {
bs := &BitSource{
active: true,
}
return bs
}
fn (bs &BitSource) update(dt f32) {
}

33
elems.v
View File

@ -4,16 +4,40 @@ enum ElemType {
none_, // None/Empty
//// Primary form
wood, sand, stone, coal, clay,
wood, sand, stone, coal, clay, iron,
// rock -> stone (?)
// Liquid
water, oil,
water, oil, lava,
// Gas(?)
vapour, methane,
// Extra(?)
biomass,
soil, biomass, silt,
//// Secondary form
glass, concrete, brick
glass, concrete, brick, steel, plastic, cement,
// Liquid
// XXX simplify: no need for special-state concrete,
// use basic type
//liquid_concrete,
//// Compounds(?)
// Ores
iron_ore,
aluminium_ore, // Bauxite
gold_ore,
silver_ore,
platinum_ore, // (?)
copper_ore,
nickel_ore, // Garnierite
zinc_ore,
lead_ore,
uranium_ore,
//alumina, // Aluminium oxide
// Construction
// XXX add only as a subtype of concrete? only useful for recycling information...
// XXX change to subtype
//reinforced_concrete, // Approx 90% concrete, 10% steel (on average)
}
struct Elem {
@ -22,6 +46,7 @@ mut:
elem_type ElemType
density int // XXX per bit?
flameable bool
liquid bool
// when
//when_crushed_fn fn()

33
info.txt Normal file
View File

@ -0,0 +1,33 @@
notes:
- the world is a fixed-grid voxel-space
- mostly it is soil/ground
- the objects are aligned/transformed (local, object) voxel-space (3d)
- the objects have transforms, and not different from 3d objects
- trees are objects
- stones are objects
- most things detachable from land are objects (or what isn't land)
- sand particles are not objects (and they can contribute to the world-space data)
- the world does not interact with the objects by itself (?)
- the objects can interact with the world but not by the world's means (?)
- resource simulation rather than resource-interaction/physics simulation
- resource based economy
- information mostly needed for processing and extraction,
and resource/technology flow
- object representation may look different than underlying voxel model
- TODO: add/test model voxelization based on 3d model material properties?
for instance a 3d pipe with concrete material will create a voxel model with
bits/voxels of concrete element.
- TODO: use models directly created by voxel materials/elements?
things not needed:
- water evaporation
- temperature transfer
- weathering
- non-practical material life times
- non-practical material interaction
- non-practical physics/objects interaction
- flameability (?)
- effects are small
- irrigation (?)
- effects are small, mostly visual
- applying effects outside of [resource] processing

21
main.v
View File

@ -29,6 +29,17 @@ fn main() {
e4.elem_type = .stone
e4.density = 8000
mut e_water := new_elem()
e_water.name = "water"
e_water.elem_type = .water
e_water.density = 10000
e_water.liquid = true
mut e_concrete := new_elem()
e_concrete.name = "concrete"
e_concrete.elem_type = .concrete
e_concrete.density = 20000
//
// Effects
//
@ -109,6 +120,16 @@ fn main() {
println("w b1: ${w.bits[0][0]}")
println("w 1 0: ${w.bits[1][0]}")
//println("w: ${w}")
//println("w: ${w.bits}")
//
// Complex object
//
ob2 := new_object()
ob2.name = "pipe" // Reinforced-concrete pipe, a 3d object
ob2.elem = e_concrete
println("done")
}

View File

@ -1,5 +1,13 @@
module main
// Object bit
// size: 10x10x10 (?)
//
// XXX cannot be compound?
struct ObjectBit {
elem_type ElemType
}
struct Object {
mut:
name string
@ -15,6 +23,9 @@ mut:
// Flixible position in the world
transform &Transform
// Bits of object's voxel model
//bits [10][10]ObjectBit
}
fn new_object() &Object {

BIN
tmp/pix/concrete_pipes.jpg (Stored with Git LFS) Normal file

Binary file not shown.

8
types.v Normal file
View File

@ -0,0 +1,8 @@
module main
struct WorldPos {
mut:
x int
y int
z int
}

View File

@ -7,6 +7,10 @@ mut:
elem_type ElemType
}
//fn (b Bit) str() string {
// return "<Bit>"
//}
struct CompoundBit {
mut:
elem1_type ElemType