map_compiler

package module
v0.0.0-...-39016ce Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetTmpDir = c.GetTmpDir

Functions

func AngleBetweenPoints

func AngleBetweenPoints(x1, y1, x2, y2 int) float64

?

func Degrees

func Degrees(radians float64) float64

func DistanceTo

func DistanceTo(x1, y1, x2, y2 int) float64

func DistanceTo(x1, y1, x2, y2 float64) float64 {

func DrawOnTiles

func DrawOnTiles(im *image.NRGBA, x, y int, tiles [][]*image.NRGBA, tileSize int)

Draw/blit on tiled image/tiles Can split in multiple segments

func DrawOnTiles2

func DrawOnTiles2(im *image.NRGBA, x, y int, tiles [][]*image.NRGBA, tileSize int)

Draw/blit on tiled image/tiles Can split in multiple segments x = absolute position (like on map) y = absolute position (like on map)

func DrawSegmentedLine

func DrawSegmentedLine(x1, y1, x2, y2 int,
	tiles [][]*image.NRGBA, tileSize int)

? Draw segmented line ?

func DrawSegmentedLine3

func DrawSegmentedLine3(x1, y1, x2, y2 int,
	tiles [][]*image.NRGBA, tileSize int)

? Draw segmented line ?

func DrawSegmentedLine3Color

func DrawSegmentedLine3Color(x1, y1, x2, y2 int,
	tiles [][]*image.NRGBA, tileSize int, c [3]int)

? Draw segmented line ?

func DrawSegmentedLineTest

func DrawSegmentedLineTest(x1, y1, x2, y2 int, tileSize int) image.Image

? Draw segmented line test ? XXX add version that just accepts segments ?

func DrawSegmentedLineTest2

func DrawSegmentedLineTest2(x1, y1, x2, y2 int, tileSize int) image.Image

? Draw segmented line test ?

func InRect

func InRect(x, y, rx, ry, rw, rh int) bool

True if point is inside the rectange. func InRect(x, y, rx, ry, rw, rh float64) bool {

func Init

func Init(resX, resY int)

func Lerp

func Lerp(a, b, t float64) float64

func LoadPng

func LoadPng(path string) image.Image

func MapLoaderApplyModifiersJson

func MapLoaderApplyModifiersJson(path string) string

XXX Apply modifiers on json level ?

func MdApplyModifiers

func MdApplyModifiers(s *MapDataScene)

Apply modifiers ?

func MdFlatternScene

func MdFlatternScene(s *MapDataScene)

Apply modifiers ?

func MdGetMapBoundingBox

func MdGetMapBoundingBox(m *MapData) rx.AABB

?

func MdGetMeshPathById

func MdGetMeshPathById(s *MapDataScene, meshId uuid) *string

Get mesh record (string) ? Returns mesh path

func MdGetSceneBoundingBox

func MdGetSceneBoundingBox(s *MapDataScene) rx.AABB

func MdHasMeshGenWithId

func MdHasMeshGenWithId(s *MapDataScene, meshId uuid) bool

func MdHasMeshWithId

func MdHasMeshWithId(s *MapDataScene, meshId uuid) bool

SceneHasMeshWithId ?

func MdSceneNodeHasMesh

func MdSceneNodeHasMesh(s *MapDataScene, n *MapDataNode) bool

func MdSceneNodeHasMeshGen

func MdSceneNodeHasMeshGen(s *MapDataScene, n *MapDataNode) bool

func Radians

func Radians(degrees float64) float64

func RenderMapScene

func RenderMapScene(md *MapData)

func RenderNode

func RenderNode(mn *MapDataNode)

XXX test

func SWDepthMergeImages

func SWDepthMergeImages(bgDepth,
	bgColor, objDepth, objColor image.Image, invertDepth bool) (
	image.Image, image.Image)

? Gray 8 ? bgDepth = background depth map texture bgColor = background color texture objDepth = foreground/object depth map texture objColor = foreground/object color / pixels texture invertDepth - invert the depth textures / values

func SWDepthMergeImages16

func SWDepthMergeImages16(bgDepth,
	bgColor, objDepth, objColor image.Image, invertDepth bool) (
	image.Image, image.Image)

? Gray 16 ? bgDepth = background depth map texture bgColor = background color texture objDepth = foreground/object depth map texture objColor = foreground/object color / pixels texture invertDepth - invert the depth textures / values

func SavePng

func SavePng(im image.Image, path string)

func SavePngToBytes

func SavePngToBytes(im image.Image) []byte

Save png to bytes data func SavePngToBytes(im image.Image, buf *bytes.Buffer) {

func SplitImageIntoSegments

func SplitImageIntoSegments(im *image.NRGBA,
	offsetX, offsetY int, tileSize int) (int, int, []*image.NRGBA)

XXX it doesn't pad images ? offsetXY = tile offset Ideologically similar to imagemagick splice (?) Tile offset can't be bigger than tile size returns sx -> sy -> [images / tiles] Split image onto some sort of a grid (with an offsets, if they're presented) TODO: it can also return regions (like drawing rects, an array for each image) position at which tile(s) should be drawn maybe it should be a special function

func SplitImageIntoSegmentsPadded

func SplitImageIntoSegmentsPadded(im *image.NRGBA,
	offsetX, offsetY int, tileSize int) (int, int, []*image.NRGBA)

Just pad the images / tiles

func Test1

func Test1()

func Test2

func Test2()

func Test3

func Test3()

func Test4

func Test4()

func Xdraw3dLine

func Xdraw3dLine(p1, p2 [3]float64, color [3]int)

In world space

func XdrawCrossWS

func XdrawCrossWS(pos [3]float64, size float64, color [3]int)

func XdrawLineWS

func XdrawLineWS(p1, p2 [3]float64, color [3]int)

In world space

func XdrawWorldOrigin

func XdrawWorldOrigin(color [3]int)

In world space top-left corner of map ? map's origin ? world space origin ?

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

type CustomPlotter

type CustomPlotter struct {
	// contains filtered or unexported fields
}

func NewCustomPlotter

func NewCustomPlotter() *CustomPlotter

func NewCustomPlotter(tiles [][]*image.NRGBA) *CustomPlotter {

func (*CustomPlotter) DrawLine

func (p *CustomPlotter) DrawLine(x1, y1, x2, y2 int, col color.Color)

func (*CustomPlotter) DrawLine2

func (p *CustomPlotter) DrawLine2(x1, y1, x2, y2 int,
	col color.Color, tiles [][]*image.NRGBA, tileSize int)

func (*CustomPlotter) Set

func (p *CustomPlotter) Set(x int, y int, c color.Color)

Basically its just a custom bresenham line function that draws at specific tiles/tilesIds and draws at points offsets at that tiles

type Line

type Line struct {
	// contains filtered or unexported fields
}

func JoinLinesTest

func JoinLinesTest(lines []Line) []Line

Test join / proccess path lines Sorts min -> max

func SplitLineIntoTileSegments

func SplitLineIntoTileSegments(x1, y1, x2, y2 int, tileSize int) (int, int, []Line)

? Split line into rectangular tile segments ? Mostly it just returns continuous line segments, that can be drawn (to/as) a straight line -> []Line (line segments)

func SplitLineIntoTileSegments2

func SplitLineIntoTileSegments2(x1, y1, x2, y2 int, tileSize int) (int, int, []Line)

type Map

type Map struct {
	Scenes []*Scene
}

func NewMap

func NewMap() *Map

func (*Map) EvaluateBounds

func (m *Map) EvaluateBounds()

type MapCompiler

type MapCompiler struct {
	// ?
	Map       *Map
	MapLoader *MapLoader
	MapSaver  *MapSaver
}

type MapData

type MapData struct {
	//Info *MapDefInfo
	//Nodes []*MapDefNode
	// XXX these are loaded like def_path
	// to have acceses MapDef.Scenes[0]
	Scenes []*MapDataScene
}

Map def / document (json) Map data XXX rename to MapData ?

func LoadMapJson

func LoadMapJson(path string) *MapData

func NewMapData

func NewMapData() *MapData

type MapDataEditorInfo

type MapDataEditorInfo struct {
	// optional
	Modifiers []*MapDataEditorModifier
}

Map editor info/record (?) (json)

type MapDataEditorModifier

type MapDataEditorModifier struct {

	// _type ?
	Type string

	Amount int

	// node_id ?
	NodeId uuid

	Enabled bool
}

?

type MapDataMesh

type MapDataMesh struct {
	// Object / mesh id ?
	Id uuid
	// XXX path ?
	//Mesh string
	// Optional ?
	Mesh *string

	// XXX Optional ?
	MeshGen *MapDataMeshGen
}

?

func MdGetMeshById

func MdGetMeshById(s *MapDataScene, meshId uuid) *MapDataMesh

Get mesh object ? (MeshDataMesh)

func MdGetMeshForSceneNode

func MdGetMeshForSceneNode(s *MapDataScene, n *MapDataNode) *MapDataMesh

Return nil if there's no mesh ? Returns mesh object

type MapDataMeshGen

type MapDataMeshGen struct {
	Type string
	Size [3]float64

	// Optional ?
	Texture *string
	// Optional ?
	Color *[3]int
	// Optional ?
	Unshaded *bool
}

Map mesh's gen (mesh_gen) info/data/record (json)

func MdGetMeshGenById

func MdGetMeshGenById(s *MapDataScene, meshId uuid) *MapDataMeshGen

Returns mesh gen object / record

func MdGetMeshGenForSceneNode

func MdGetMeshGenForSceneNode(s *MapDataScene, n *MapDataNode) *MapDataMeshGen

Return nil if there's no meshgen ?

type MapDataNode

type MapDataNode struct {
	// _id ?
	Id uuid
	// _type ?
	Type string

	Name        string
	Description string
	NodeType    string

	Pos [3]float64
	Rot [3]float64
	// Default = 1.0,1.0,1.0
	Scale [3]float64

	// Is it optional since
	// MeshGen (mesh_gen) only
	// mesh can exist ?
	// Optional ?
	//Mesh *string
	// XXX
	// Optional ?
	//MeshId *string
	// Is it optional ?
	MeshId *uuid

	Tags []string

	DefPath string
}

Map scene node record (json) an abstraction ?

func MdGetSceneNodes

func MdGetSceneNodes(s *MapDataScene) []*MapDataNode

Get all scene nodes ?

func MdGetSceneNodesWithType

func MdGetSceneNodesWithType(s *MapDataScene, typeString string) []*MapDataNode

func NewMapDataNode

func NewMapDataNode() *MapDataNode

func (*MapDataNode) String

func (n *MapDataNode) String() string

type MapDataScene

type MapDataScene struct {
	Info   *MapDataSceneInfo
	Meshes []*MapDataMesh
	Nodes  []*MapDataNode
	//Scenes
	// XXX extra ?
	// optional
	Editor *MapDataEditorInfo
}

Map scene (json)

func LoadMapSceneJson

func LoadMapSceneJson(path string) *MapDataScene

Load map scene from file ?

func NewMapDataScene

func NewMapDataScene() *MapDataScene

type MapDataSceneInfo

type MapDataSceneInfo struct {
	//Width int
	//Height int
	Dim [2]int
}

Map scene info (json)

type MapLoader

type MapLoader struct {
}

func NewMapLoader

func NewMapLoader() *MapLoader

func (*MapLoader) LoadScene

func (ml *MapLoader) LoadScene(path string) *Scene

Load map scene from file ? func (ml *MapLoader) LoadMapScene(path string) *Scene {

type MapRenderer

type MapRenderer struct {

	// Tiled image
	//Tiles []*MapTile
	Tiles      [][]*image.NRGBA
	TilesDepth [][]*image.NRGBA
	// contains filtered or unexported fields
}

func NewMapRenderer

func NewMapRenderer() *MapRenderer

func (*MapRenderer) BlitImage

func (mr *MapRenderer) BlitImage()

func (*MapRenderer) ClearCache

func (mr *MapRenderer) ClearCache()

func (*MapRenderer) DrawObjectAt

func (mr *MapRenderer) DrawObjectAt(objectId uuid, pos [3]float64)

Blit object at Automatically selects tiles ?

func (*MapRenderer) EvaluateSceneBounds

func (mr *MapRenderer) EvaluateSceneBounds(s *MapDataScene)

Get map / scene extents XXX what if map / scene has sub scenes ?

func (*MapRenderer) EvaluateSceneBounds2

func (mr *MapRenderer) EvaluateSceneBounds2(s *MapDataScene)

func (*MapRenderer) MdMeshGenEqual

func (mr *MapRenderer) MdMeshGenEqual(obj1, obj2 *MapDataMeshGen) bool

XXX util ?

func (*MapRenderer) MdMeshGenNodeEqual

func (mr *MapRenderer) MdMeshGenNodeEqual(s *MapDataScene, n1, n2 *MapDataNode) bool

XXX util ? Test MeshGen/MeshGenNode equal XXX for generated meshes ? func (mr *MapRenderer) MdMeshGenNodeEqual(n1, n2 *MapDataNode) bool {

func (*MapRenderer) MdMeshNodeEqual

func (mr *MapRenderer) MdMeshNodeEqual(s *MapDataScene, n1, n2 *MapDataNode) bool

XXX util ? Test Mesh/MeshNode equal XXX for non-generated meshes ? func (mr *MapRenderer) MdMeshNodeEqual(n1, n2 *MapDataNode) bool {

func (*MapRenderer) RenderAllObjectsToCache

func (mr *MapRenderer) RenderAllObjectsToCache(s *MapDataScene)

Cache ? Render all objects to cache ?

func (*MapRenderer) RenderNode

func (mr *MapRenderer) RenderNode(mn *MapDataNode)

This renders node on the map ?

func (*MapRenderer) RenderNodeObject

func (mr *MapRenderer) RenderNodeObject(mn *MapDataNode)

XXX internal ? This renders node's object ?

func (*MapRenderer) RenderObjectAt

func (mr *MapRenderer) RenderObjectAt(objectId uuid, pos [3]float64)

XXX render object at ?

func (*MapRenderer) RenderScene

func (mr *MapRenderer) RenderScene(s *MapDataScene)
func (mr *MapRenderer)   RenderScene(md *MapDef) {
	fmt.Println("MapRenderer RenderScene md:", md)

func (*MapRenderer) RenderTile

func (mr *MapRenderer) RenderTile()

func (*MapRenderer) Reset

func (mr *MapRenderer) Reset()

func (*MapRenderer) SaveCache

func (mr *MapRenderer) SaveCache(path string)

Save cache to disk in an arbitrary format / dump ?

func (*MapRenderer) SaveTiles

func (mr *MapRenderer) SaveTiles(path string)

func (*MapRenderer) SaveTilesAsImage

func (mr *MapRenderer) SaveTilesAsImage(path string)

func (*MapRenderer) SetMapData

func (mr *MapRenderer) SetMapData(md *MapData)

func (*MapRenderer) SetNumTiles

func (mr *MapRenderer) SetNumTiles(x, y int)

func (*MapRenderer) SetScene

func (mr *MapRenderer) SetScene(s *MapDataScene)

Set scene data ?

func (*MapRenderer) SetTileSize

func (mr *MapRenderer) SetTileSize(tileSize int)

func (*MapRenderer) Test1

func (mr *MapRenderer) Test1(s *MapDataScene)

func (*MapRenderer) Test2

func (mr *MapRenderer) Test2(s *MapDataScene)

func (*MapRenderer) UpdateTile

func (mr *MapRenderer) UpdateTile()

type MapSaver

type MapSaver struct {
}

func NewMapSaver

func NewMapSaver() *MapSaver

func (*MapSaver) SaveScene

func (ms *MapSaver) SaveScene(s *Scene, path string)

Load map scene from file ?

type Mesh

type Mesh struct {
	// Object / mesh id ?
	Id uuid
	// XXX path ?
	//Mesh string
	// Optional ?
	Mesh *string

	// Optional ?
	MeshGen *MeshGen
}

? Mesh component/record ?

func NewMesh

func NewMesh() *Mesh

type MeshGen

type MeshGen struct {
	Type string
	Size [3]float64

	// Optional ?
	Texture *string
	// Optional ?
	Color *[3]int
	// Optional ?
	Unshaded *bool
}

? MeshGen component/record ?

func NewMeshGen

func NewMeshGen() *MeshGen

type ObjectRenderer

type ObjectRenderer struct {
}

func NewObjectRenderer

func NewObjectRenderer() *ObjectRenderer

func (*ObjectRenderer) RenderObject

func (r *ObjectRenderer) RenderObject(path string, modeDepth bool) image.Image

func (*ObjectRenderer) RenderObjectEx

func (r *ObjectRenderer) RenderObjectEx(path string,
	modeDepth bool, rot *[3]float32) image.Image

func (*ObjectRenderer) RenderObjectExGen

func (r *ObjectRenderer) RenderObjectExGen(meshGen *MapDataMeshGen, modeDepth bool,
	rot *[3]float32, scale *[3]float32) image.Image

XXX rename to RenderObjectGenEx ? color = optional ?

func (*ObjectRenderer) RenderObjectGen

func (r *ObjectRenderer) RenderObjectGen(meshGen *MapDataMeshGen, modeDepth bool) image.Image

render with default rot ? render with default scale ?

type RenderCache

type RenderCache struct {
	// XXX a cache ?
	//RenderedObjects *linkedhashset.Set[uuid]
	//RenderedObjectsCache *linkedhashset.Set[uuid]
	//RenderedObjects linkedhashset.Set[v4.UUID]
	//RenderedObjects linkedhashmap.New[uuid, *RenderedObjectData]
	//RenderedObjectsCache *linkedhashmap.Map[uuid, *RenderedObjectData]
	RenderedObjectsCache *linkedhashmap.Map[RenderedObjectsCacheKey,
		*RenderedObjectData]
}

Cache for rendered objects ?

func NewRenderCache

func NewRenderCache() *RenderCache

func (*RenderCache) Clear

func (rc *RenderCache) Clear()

func (*RenderCache) GetKeysWithUuid

func (rc *RenderCache) GetKeysWithUuid(uuid_ uuid) []RenderedObjectsCacheKey

func (*RenderCache) GetObjectByKey

func (*RenderCache) HasObjectWithKey

func (rc *RenderCache) HasObjectWithKey(k RenderedObjectsCacheKey) bool

type RenderedObjectData

type RenderedObjectData struct {
	// contains filtered or unexported fields
}

Cache data ? Can you cache oriented / transformed objects ? Cache for objects ? a cache record

func NewRenderedObjectData

func NewRenderedObjectData() *RenderedObjectData

Creates new rec with default values ?

type RenderedObjectsCacheKey

type RenderedObjectsCacheKey struct {
	// contains filtered or unexported fields
}

a cache key

func NewRenderedObjectsCacheKey

func NewRenderedObjectsCacheKey() RenderedObjectsCacheKey

Creates new empty key with default values ?

func (RenderedObjectsCacheKey) String

func (k RenderedObjectsCacheKey) String() string

func (k *RenderedObjectsCacheKey) String() string {

func (*RenderedObjectsCacheKey) ToString

func (k *RenderedObjectsCacheKey) ToString() string

type Scene

type Scene struct {
	Nodes  []*SceneNode
	Meshes []*Mesh
}

func NewScene

func NewScene() *Scene

func (*Scene) AddMesh

func (s *Scene) AddMesh(mesh *Mesh)

func (*Scene) AddNewMeshWithPath

func (s *Scene) AddNewMeshWithPath(path string) *Mesh

XXX ?

func (*Scene) AddNode

func (s *Scene) AddNode(n *SceneNode)

func (*Scene) EvaluateBounds

func (s *Scene) EvaluateBounds()

func (*Scene) EvaluateBounds2

func (s *Scene) EvaluateBounds2()

func (*Scene) HasMesh

func (s *Scene) HasMesh(mesh *Mesh) bool

func (*Scene) HasNode

func (s *Scene) HasNode(n *SceneNode) bool

func (*Scene) LoadMesh

func (s *Scene) LoadMesh(path string)

XXX ?

func (*Scene) RemoveMesh

func (s *Scene) RemoveMesh(mesh *Mesh)

func (*Scene) RemoveNode

func (s *Scene) RemoveNode(n *SceneNode)

type SceneNode

type SceneNode struct {
	// link ?
	Scene *Scene

	// _id ?
	Id uuid

	Name        string
	Description string
	NodeType    string

	Pos [3]float64
	Rot [3]float64
	// Default = 1.0,1.0,1.0
	Scale [3]float64

	// optional ?
	// link (?)
	// link to scene.Meshes mesh/object/record
	// Note: mesh-sharing
	Mesh *Mesh
}

func NewMeshGenSceneNode

func NewMeshGenSceneNode() *SceneNode

?

func NewMeshSceneNode

func NewMeshSceneNode() *SceneNode

?

func NewSceneNode

func NewSceneNode() *SceneNode

func (*SceneNode) GetBoundingBox

func (s *SceneNode) GetBoundingBox() rx.AABB

func (*SceneNode) HasMesh

func (s *SceneNode) HasMesh() bool

func (*SceneNode) HasMeshGen

func (s *SceneNode) HasMeshGen() bool

func (*SceneNode) SetMesh

func (s *SceneNode) SetMesh(mesh *Mesh)

Directories

Path Synopsis
text module

Jump to

Keyboard shortcuts

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