From a5769cc640b3fa9771230a7a4e1a0191d380a7df Mon Sep 17 00:00:00 2001 From: coaljoe Date: Thu, 30 Apr 2020 15:02:14 +0300 Subject: [PATCH] auts: commit work --- bit_source.v | 22 ++++++++++++++++++++++ elems.v | 33 +++++++++++++++++++++++++++++---- info.txt | 33 +++++++++++++++++++++++++++++++++ main.v | 21 +++++++++++++++++++++ object.v | 11 +++++++++++ tmp/pix/concrete_pipes.jpg | 3 +++ types.v | 8 ++++++++ world.v | 4 ++++ 8 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 bit_source.v create mode 100644 info.txt create mode 100644 tmp/pix/concrete_pipes.jpg create mode 100644 types.v diff --git a/bit_source.v b/bit_source.v new file mode 100644 index 0000000..f5efb37 --- /dev/null +++ b/bit_source.v @@ -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) { + +} diff --git a/elems.v b/elems.v index 9ca6c3b..9773b1f 100644 --- a/elems.v +++ b/elems.v @@ -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() diff --git a/info.txt b/info.txt new file mode 100644 index 0000000..ab00255 --- /dev/null +++ b/info.txt @@ -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 diff --git a/main.v b/main.v index 36cd031..f0d1f28 100644 --- a/main.v +++ b/main.v @@ -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") } diff --git a/object.v b/object.v index 73e7112..36b09c2 100644 --- a/object.v +++ b/object.v @@ -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 { diff --git a/tmp/pix/concrete_pipes.jpg b/tmp/pix/concrete_pipes.jpg new file mode 100644 index 0000000..81b7c26 --- /dev/null +++ b/tmp/pix/concrete_pipes.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd09ef0cdd07ef7f36fefa40a0dbef81e3354a797ade787211a49f1c2d9f6e9f +size 460814 diff --git a/types.v b/types.v new file mode 100644 index 0000000..0786ce0 --- /dev/null +++ b/types.v @@ -0,0 +1,8 @@ +module main + +struct WorldPos { +mut: + x int + y int + z int +} diff --git a/world.v b/world.v index 8ab57ce..bc29c4d 100644 --- a/world.v +++ b/world.v @@ -7,6 +7,10 @@ mut: elem_type ElemType } +//fn (b Bit) str() string { +// return "" +//} + struct CompoundBit { mut: elem1_type ElemType