Documentation ¶
Index ¶
- Variables
- func AngleBetweenPoints(x1, y1, x2, y2 int) float64
- func Degrees(radians float64) float64
- func DistanceTo(x1, y1, x2, y2 int) float64
- func DrawOnTiles(im *image.NRGBA, x, y int, tiles [][]*image.NRGBA, tileSize int)
- func DrawOnTiles2(im *image.NRGBA, x, y int, tiles [][]*image.NRGBA, tileSize int)
- func DrawSegmentedLine(x1, y1, x2, y2 int, tiles [][]*image.NRGBA, tileSize int)
- func DrawSegmentedLine3(x1, y1, x2, y2 int, tiles [][]*image.NRGBA, tileSize int)
- func DrawSegmentedLine3Color(x1, y1, x2, y2 int, tiles [][]*image.NRGBA, tileSize int, c [3]int)
- func DrawSegmentedLineTest(x1, y1, x2, y2 int, tileSize int) image.Image
- func DrawSegmentedLineTest2(x1, y1, x2, y2 int, tileSize int) image.Image
- func InRect(x, y, rx, ry, rw, rh int) bool
- func Init(resX, resY int)
- func Lerp(a, b, t float64) float64
- func LoadPng(path string) image.Image
- func MapLoaderApplyModifiersJson(path string) string
- func MdApplyModifiers(s *MapDataScene)
- func MdFlatternScene(s *MapDataScene)
- func MdGetMapBoundingBox(m *MapData) rx.AABB
- func MdGetMeshPathById(s *MapDataScene, meshId uuid) *string
- func MdGetSceneBoundingBox(s *MapDataScene) rx.AABB
- func MdHasMeshGenWithId(s *MapDataScene, meshId uuid) bool
- func MdHasMeshWithId(s *MapDataScene, meshId uuid) bool
- func MdSceneNodeHasMesh(s *MapDataScene, n *MapDataNode) bool
- func MdSceneNodeHasMeshGen(s *MapDataScene, n *MapDataNode) bool
- func Radians(degrees float64) float64
- func RenderMapScene(md *MapData)
- func RenderNode(mn *MapDataNode)
- func SWDepthMergeImages(bgDepth, bgColor, objDepth, objColor image.Image, invertDepth bool) (image.Image, image.Image)
- func SWDepthMergeImages16(bgDepth, bgColor, objDepth, objColor image.Image, invertDepth bool) (image.Image, image.Image)
- func SavePng(im image.Image, path string)
- func SavePngToBytes(im image.Image) []byte
- func SplitImageIntoSegments(im *image.NRGBA, offsetX, offsetY int, tileSize int) (int, int, []*image.NRGBA)
- func SplitImageIntoSegmentsPadded(im *image.NRGBA, offsetX, offsetY int, tileSize int) (int, int, []*image.NRGBA)
- func Test1()
- func Test2()
- func Test3()
- func Test4()
- func Xdraw3dLine(p1, p2 [3]float64, color [3]int)
- func XdrawCrossWS(pos [3]float64, size float64, color [3]int)
- func XdrawLineWS(p1, p2 [3]float64, color [3]int)
- func XdrawWorldOrigin(color [3]int)
- type Context
- type CustomPlotter
- type Line
- type Map
- type MapCompiler
- type MapData
- type MapDataEditorInfo
- type MapDataEditorModifier
- type MapDataMesh
- type MapDataMeshGen
- type MapDataNode
- type MapDataScene
- type MapDataSceneInfo
- type MapLoader
- type MapRenderer
- func (mr *MapRenderer) BlitImage()
- func (mr *MapRenderer) ClearCache()
- func (mr *MapRenderer) DrawObjectAt(objectId uuid, pos [3]float64)
- func (mr *MapRenderer) EvaluateSceneBounds(s *MapDataScene)
- func (mr *MapRenderer) EvaluateSceneBounds2(s *MapDataScene)
- func (mr *MapRenderer) MdMeshGenEqual(obj1, obj2 *MapDataMeshGen) bool
- func (mr *MapRenderer) MdMeshGenNodeEqual(s *MapDataScene, n1, n2 *MapDataNode) bool
- func (mr *MapRenderer) MdMeshNodeEqual(s *MapDataScene, n1, n2 *MapDataNode) bool
- func (mr *MapRenderer) RenderAllObjectsToCache(s *MapDataScene)
- func (mr *MapRenderer) RenderNode(mn *MapDataNode)
- func (mr *MapRenderer) RenderNodeObject(mn *MapDataNode)
- func (mr *MapRenderer) RenderObjectAt(objectId uuid, pos [3]float64)
- func (mr *MapRenderer) RenderScene(s *MapDataScene)
- func (mr *MapRenderer) RenderTile()
- func (mr *MapRenderer) Reset()
- func (mr *MapRenderer) SaveCache(path string)
- func (mr *MapRenderer) SaveTiles(path string)
- func (mr *MapRenderer) SaveTilesAsImage(path string)
- func (mr *MapRenderer) SetMapData(md *MapData)
- func (mr *MapRenderer) SetNumTiles(x, y int)
- func (mr *MapRenderer) SetScene(s *MapDataScene)
- func (mr *MapRenderer) SetTileSize(tileSize int)
- func (mr *MapRenderer) Test1(s *MapDataScene)
- func (mr *MapRenderer) Test2(s *MapDataScene)
- func (mr *MapRenderer) UpdateTile()
- type MapSaver
- type Mesh
- type MeshGen
- type ObjectRenderer
- func (r *ObjectRenderer) RenderObject(path string, modeDepth bool) image.Image
- func (r *ObjectRenderer) RenderObjectEx(path string, modeDepth bool, rot *[3]float32) image.Image
- func (r *ObjectRenderer) RenderObjectExGen(meshGen *MapDataMeshGen, modeDepth bool, rot *[3]float32, scale *[3]float32) image.Image
- func (r *ObjectRenderer) RenderObjectGen(meshGen *MapDataMeshGen, modeDepth bool) image.Image
- type RenderCache
- type RenderedObjectData
- type RenderedObjectsCacheKey
- type Scene
- func (s *Scene) AddMesh(mesh *Mesh)
- func (s *Scene) AddNewMeshWithPath(path string) *Mesh
- func (s *Scene) AddNode(n *SceneNode)
- func (s *Scene) EvaluateBounds()
- func (s *Scene) EvaluateBounds2()
- func (s *Scene) HasMesh(mesh *Mesh) bool
- func (s *Scene) HasNode(n *SceneNode) bool
- func (s *Scene) LoadMesh(path string)
- func (s *Scene) RemoveMesh(mesh *Mesh)
- func (s *Scene) RemoveNode(n *SceneNode)
- type SceneNode
Constants ¶
This section is empty.
Variables ¶
var GetTmpDir = c.GetTmpDir
Functions ¶
func DistanceTo ¶
func DistanceTo(x1, y1, x2, y2 float64) float64 {
func DrawOnTiles ¶
Draw/blit on tiled image/tiles Can split in multiple segments
func DrawOnTiles2 ¶
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 ¶
? Draw segmented line ?
func DrawSegmentedLine3 ¶
? Draw segmented line ?
func DrawSegmentedLine3Color ¶
? Draw segmented line ?
func DrawSegmentedLineTest ¶
? Draw segmented line test ? XXX add version that just accepts segments ?
func DrawSegmentedLineTest2 ¶
? Draw segmented line test ?
func InRect ¶
True if point is inside the rectange. func InRect(x, y, rx, ry, rw, rh float64) bool {
func MapLoaderApplyModifiersJson ¶
XXX Apply modifiers on json level ?
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 MdSceneNodeHasMesh ¶
func MdSceneNodeHasMesh(s *MapDataScene, n *MapDataNode) bool
func MdSceneNodeHasMeshGen ¶
func MdSceneNodeHasMeshGen(s *MapDataScene, n *MapDataNode) bool
func RenderMapScene ¶
func RenderMapScene(md *MapData)
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 SavePngToBytes ¶
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 XdrawCrossWS ¶
func XdrawWorldOrigin ¶
func XdrawWorldOrigin(color [3]int)
In world space top-left corner of map ? map's origin ? world space origin ?
Types ¶
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)
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
func JoinLinesTest ¶
Test join / proccess path lines Sorts min -> max
func SplitLineIntoTileSegments ¶
? 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)
type Map ¶
type Map struct {
Scenes []*Scene
}
func (*Map) EvaluateBounds ¶
func (m *Map) EvaluateBounds()
type MapCompiler ¶
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 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 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 NewMapDataScene ¶
func NewMapDataScene() *MapDataScene
type MapDataSceneInfo ¶
type MapDataSceneInfo struct { //Width int //Height int Dim [2]int }
Map scene info (json)
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) 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 Mesh ¶
type Mesh struct { // Object / mesh id ? Id uuid // XXX path ? //Mesh string // Optional ? Mesh *string // Optional ? MeshGen *MeshGen }
? Mesh component/record ?
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 (*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 (rc *RenderCache) GetObjectByKey(k RenderedObjectsCacheKey) *RenderedObjectData
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 ¶
func (*Scene) EvaluateBounds ¶
func (s *Scene) EvaluateBounds()
func (*Scene) EvaluateBounds2 ¶
func (s *Scene) EvaluateBounds2()
func (*Scene) RemoveMesh ¶
func (*Scene) RemoveNode ¶
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 NewSceneNode ¶
func NewSceneNode() *SceneNode
func (*SceneNode) GetBoundingBox ¶
func (*SceneNode) HasMeshGen ¶
Source Files ¶
- context.go
- draw.go
- draw2d.go
- draw3d.go
- drawdepthmerge.go
- drawline.go
- drawlinetest.go
- drawlinetest2.go
- drawutil.go
- geom.go
- geomcontrib.go
- geomcontrib2.go
- map.go
- mapcompiler.go
- mapdata.go
- mapdatautil.go
- mapdatautilex.go
- maploader.go
- maploader2.go
- maploaderex.go
- maprenderer.go
- mapsaver.go
- objectrenderer.go
- rendercache.go
- rendercacheex.go
- renderer.go
- scene.go
- scenenode.go
- test1.go
- test2.go
- test3.go
- test4.go
- types.go
- util.go
- utilimage.go