genarchitecture

package
v0.0.0-...-ce97658 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

genarchitecture

This will be a package for generating distinct architectural styles.

TODO

  • Add weights for probabilities of variations
  • Vernacular architecture
    • Add climate aspects, insulation of materials, etc.
  • Mesh/building generation
    • Design a "recipe" concept for generating buildings
      • Basic functionality
      • Refine rules
    • Implement some sample recipes
      • Simple cathedral

Building mesh generation

alt text

There are some clumsy attempts to implement a grammar/rule based system for generating buildings. This is a very early stage.

alt text

Documentation

Index

Constants

View Source
const (
	ShapeTypeRect = iota
	ShapeTypePlus
	ShapeTypeCircle
	ShapeTypeTriangle
	ShapeTypeH
)
View Source
const (
	ComplexityNone      = 0
	ComplexitySimple    = 1
	ComplexityIntricate = 2
	ComplexityDetailed  = 3
	ComplexityMasterful = 4
)
View Source
const (
	DecorationTypeNone    = "undecorated"
	DecorationTypePainted = "painted"
	DecorationTypeCarved  = "carved"
	DecorationTypeInlaid  = "inlaid"
	DecorationTypeGilded  = "gilded"
)
View Source
const (
	SizeNone   = 0
	SizeTiny   = 1
	SizeSmall  = 2
	SizeMedium = 3
	SizeLarge  = 4
	SizeHuge   = 5
)
View Source
const (
	MaterialStone   = "stone"
	MaterialWood    = "wood"
	MaterialBrick   = "brick"
	MaterialGlass   = "glass"
	MaterialMetal   = "metal"
	MaterialMarble  = "marble"
	MaterialPlaster = "plaster"
	MaterialPaper   = "paper"
	MaterialClay    = "clay"
	MaterialCeramic = "ceramic"
	MaterialPlastic = "plastic"
	MaterialLeather = "leather"
	MaterialFur     = "fur"
	MaterialBone    = "bone"
	MaterialShell   = "shell"
)
View Source
const (
	FinishNone      = "none"
	FinishPolished  = "polished"
	FinishRough     = "rough"
	FinishBurnished = "burnished"
	FinishPainted   = "painted"
	FinishPlastered = "plastered"
)
View Source
const (
	RoofShapeNone      = "none"
	RoofShapeGable     = "gable"
	RoofShapeHip       = "hip"
	RoofShapeDutch     = "dutch"
	RoofShapeJerkin    = "jerkin"
	RoofShapePyramid   = "pyramid"
	RoofShapeMansard   = "mansard"
	RoofShapeBonnet    = "bonnet"
	RoofShapeGambrel   = "gambrel"
	RoofShapeSilikon   = "silikon"
	RoofShapeCurved    = "curved"
	RoofShapeFlat      = "flat"
	RoofShapeSaltbox   = "saltbox"
	RoofShapeButterfly = "butterfly"
	RoofShapeSawtooth  = "sawtooth"
	RoofShapeDormer    = "dormer"
)
View Source
const (
	RoofMaterialNone         = "none"
	RoofMaterialWoodPlanks   = "wood_planks"
	RoofMaterialWoodShingles = "wood_shingles"
	RoofMaterialHide         = "hide"
	RoofMaterialThatch       = "thatch"
	RoofMaterialStraw        = "straw"
	RoofMaterialSlate        = "slate"
	RoofMaterialTile         = "tile"
	RoofMaterialMetal        = "metal"
	RoofMaterialGlass        = "glass"
)
View Source
const (
	ShapeRectangle = "rectangle"
	ShapeCircle    = "circle"
	ShapeTrapazoid = "trapazoid"
	ShapeOval      = "oval"
	ShapeTriangle  = "triangle"
	ShapeHexagon   = "hexagon"
	ShapeOctagon   = "octagon"
	ShapeArch      = "arch"
)
View Source
const (
	GlassTypeNone      = "none"
	GlassTypeClear     = "clear"
	GlassTypeFrosted   = "frosted"
	GlassTypeEtched    = "etched"
	GlassTypeTinted    = "tinted"
	GlassTypePatterned = "patterned"
	GlassTypeObscured  = "obscured"
	GlassTypeStained   = "stained"
	GlassTypeBottle    = "bottle"
)
View Source
const (
	FabricTypeNone     = "none"
	FabricTypeSilk     = "silk"
	FabricTypeCotton   = "cotton"
	FabricTypeLinen    = "linen"
	FabricTypeWool     = "wool"
	FabricTypeVelvet   = "velvet"
	FabricTypeLeather  = "leather"
	FabricTypeFur      = "fur"
	FabricTypeSuede    = "suede"
	FabricTypeDenim    = "denim"
	FabricTypeCanvas   = "canvas"
	FabricTypeBurlap   = "burlap"
	FabricTypeCorduroy = "corduroy"
	FabricTypeChiffon  = "chiffon"
	FabricTypeSatin    = "satin"
	FabricTypeTaffeta  = "taffeta"
	FabricTypeTweed    = "tweed"
	FabricTypeLace     = "lace"
	FabricTypeOrganza  = "organza"
	FabricTypeJersey   = "jersey"
	FabricTypePique    = "pique"
	FabricTypePoplin   = "poplin"
)

Variables

View Source
var SampleRules = []*Rule{
	{
		Name:         "base",
		Shape:        ShapeTypePlus,
		Width:        2,
		Length:       2,
		Height:       0.2,
		Roof:         true,
		RulesSides:   []string{"wing"},
		RulesCorners: []string{"corner"},
	},
	{
		Name:         "wing",
		Shape:        ShapeTypeRect,
		Width:        0.35,
		Length:       0.35,
		Height:       0.2,
		Roof:         true,
		RulesSides:   []string{"strut"},
		RulesCorners: []string{"strut"},
	},
	{
		Name:         "corner",
		Shape:        ShapeTypeRect,
		Width:        0.1,
		Length:       0.1,
		Height:       0.2,
		Roof:         true,
		RulesSides:   []string{"strut"},
		RulesCorners: []string{"strut"},
	},
	{
		Name:         "strut",
		Shape:        ShapeTypeRect,
		Width:        0.025,
		Length:       0.025,
		Height:       0.2,
		RulesSides:   []string{},
		RulesCorners: []string{},
	},
}
View Source
var SampleRules2 = []*Rule{
	{
		Name:       "base",
		Shape:      ShapeTypeRect,
		Width:      2,
		Length:     2,
		Taper:      1,
		Height:     1,
		RulesSides: []string{"side"},
	},
	{
		Name:         "side",
		Shape:        ShapeTypeH,
		Width:        1.51,
		Length:       0.51,
		Height:       0.35,
		Roof:         true,
		Reorient:     true,
		RulesSides:   []string{"strut"},
		RulesCorners: []string{"strut"},
	},
	{
		Name:         "strut",
		Shape:        ShapeTypeRect,
		Width:        0.025,
		Length:       0.025,
		Height:       0.35,
		Reorient:     true,
		RulesSides:   []string{},
		RulesCorners: []string{},
	},
}

Functions

func ConvertNodeToMesh

func ConvertNodeToMesh(node *Node, mesh *gengeometry.Mesh)

func GenerateSampleCathedral

func GenerateSampleCathedral()

Types

type BaseStyle

type BaseStyle struct {
	Ornate   *Decoration // decoration of the component
	Material string      // main material of the component
	Finish   string      // finish of the component
}

BaseStyle is a struct that contains the basic style information for a building component. It can be embedded in other structs to provide a common set of style information.

func (BaseStyle) Description

func (b BaseStyle) Description() string

Description returns a string describing the style of the component.

type CeilingStyle

type CeilingStyle struct {
	BaseStyle
}

type CurtainsStyle

type CurtainsStyle struct {
	Thickness int
	Size      int
	Shape     string
	BaseStyle
}

type Decoration

type Decoration struct {
	Type       string
	Complexity int
	Motif      string
}

func (Decoration) Description

func (d Decoration) Description() string

type DoorStyle

type DoorStyle struct {
	Shape string
	Size  int
	BaseStyle
}

func (DoorStyle) Description

func (s DoorStyle) Description() string

func (DoorStyle) DrawToSVG

func (s DoorStyle) DrawToSVG(sv *svg.SVG, x, y, width, height int)

type FloorStyle

type FloorStyle struct {
	BaseStyle
}

type GlassStyle

type GlassStyle struct {
	Thickness int
	Color     string
	Type      string
	Shape     string
	BaseStyle
}

type Node

type Node struct {
	ID       string      // The ID of the node.
	Parent   *Node       // The parent node.
	Children []*Node     // The child nodes.
	Data     interface{} // The data associated with the node.
	Replaced bool        // If true, this node will not be drawn, or re-written.
}

func Eval

func Eval() *Node

A graph holds the result of a graph grammar. WARNING: This is not working properly yet!!!! We either run the evaluation until until we reached terminal nodes or we run it for a fixed number of iterations.

type NodeRule

type NodeRule struct {
	ID          string              // The ID of the rule.
	F           func(*Node) []*Node // The function that is applied to the node and produces new nodes.
	ReplaceNode bool                // If true, the node will be replaced by the new nodes.
}

func (*NodeRule) Apply

func (nr *NodeRule) Apply(node *Node) []*Node

type RoofStyle

type RoofStyle struct {
	Shape string
	BaseStyle
}

func (RoofStyle) Description

func (s RoofStyle) Description() string

type Rule

type Rule struct {
	Name         string   // Name of the rule.
	Shape        int      // The shape of the base.
	Roof         bool     // Whether the roof should be generated.
	Reorient     bool     // Whether the shape should be reoriented.
	Width        float64  // Width of the base.
	Length       float64  // Length of the base.
	Height       float64  // Height of the shape.
	Elevation    float64  // How much the roof is elevated from the base.
	Taper        float64  // How much the mesh is tapered.
	RulesSides   []string // Rules to apply to the sides.
	RulesCorners []string // Rules to apply to the corners.
}

func (*Rule) GetShape

func (r *Rule) GetShape() gengeometry.Shape

type RuleCollection

type RuleCollection struct {
	Rules map[string]*Rule
	All   []*Rule
	Root  *Rule
}

func NewRuleCollection

func NewRuleCollection() *RuleCollection

func (*RuleCollection) AddRule

func (rc *RuleCollection) AddRule(r *Rule)

func (*RuleCollection) Run

func (rc *RuleCollection) Run() *gengeometry.Mesh

type ShapeData

type ShapeData struct {
	Shape       gengeometry.Shape
	CurrentPos  vectors.Vec3 // Center of the shape.
	CurrentDir  vectors.Vec2 // Direction of the shape.
	HeightScale float64      // The height scale of the shape.
	Reorient    bool         // If true, the shape will be re-oriented based on the direction of the node.
}

type Style

type Style struct {
	OuterDoorStyle DoorStyle
	InnerDoorStyle DoorStyle
	WindowStyle    WindowStyle
	InnerWallStyle WallStyle
	OuterWallStyle WallStyle
	FloorStyle     FloorStyle
	CeilingStyle   CeilingStyle
	RoofStyle      RoofStyle
}

func GenerateStyle

func GenerateStyle(availableMaterials []string) Style

func (Style) Description

func (s Style) Description() string

func (*Style) ExportSvg

func (s *Style) ExportSvg(path string) error

type WallStyle

type WallStyle struct {
	Shape  string // wall shape
	Height int    // wall height
	BaseStyle
}

func (WallStyle) Description

func (s WallStyle) Description() string

type WindowStyle

type WindowStyle struct {
	Shape string
	Size  int
	BaseStyle
	Glass    GlassStyle
	Curtains CurtainsStyle
}

func (WindowStyle) LightValue

func (s WindowStyle) LightValue() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL