convert to module
This commit is contained in:
parent
6f706378ee
commit
3e9249934f
18 changed files with 50 additions and 43 deletions
|
|
@ -1 +0,0 @@
|
||||||
preview.png
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#hidden
|
||||||
class Queue is Sequence{
|
class Queue is Sequence{
|
||||||
data{_data}
|
data{_data}
|
||||||
count{_count}
|
count{_count}
|
||||||
|
|
@ -5,7 +5,7 @@ import "luxe: io" for IO
|
||||||
import "luxe: bytes" for Byter, Bytes
|
import "luxe: bytes" for Byter, Bytes
|
||||||
import "luxe: world" for Block
|
import "luxe: world" for Block
|
||||||
|
|
||||||
//`modifiers/trail/trail > runtime` types
|
//`trail: modifier/trail > runtime` types
|
||||||
|
|
||||||
class ModifierRuntime {
|
class ModifierRuntime {
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ import "luxe: world" for Block
|
||||||
|
|
||||||
} //ModifierRuntime
|
} //ModifierRuntime
|
||||||
|
|
||||||
//`modifiers/trail/trail > runtime` compilers
|
//`trail: modifier/trail > runtime` compilers
|
||||||
|
|
||||||
class ModifierRuntimeCompiler {
|
class ModifierRuntimeCompiler {
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ import "luxe: world" for Block
|
||||||
write_block(compiler, out) {
|
write_block(compiler, out) {
|
||||||
|
|
||||||
//source id
|
//source id
|
||||||
out.write_uint32(compiler.string.hash("modifiers/trail/trail > runtime"))
|
out.write_uint32(compiler.string.hash("trail: modifier/trail > runtime"))
|
||||||
|
|
||||||
//fields count
|
//fields count
|
||||||
out.write_int32(0)
|
out.write_int32(0)
|
||||||
|
|
@ -95,12 +95,12 @@ import "luxe: world" for Block
|
||||||
|
|
||||||
} //ModifierRuntimeCompiler
|
} //ModifierRuntimeCompiler
|
||||||
|
|
||||||
//`modifiers/trail/trail > runtime` block types
|
//`trail: modifier/trail > runtime` block types
|
||||||
|
|
||||||
class BlockModifierRuntime {
|
class BlockModifierRuntime {
|
||||||
|
|
||||||
field { "trail" }
|
field { "trail" }
|
||||||
source { "modifiers/trail/trail > runtime" }
|
source { "trail: modifier/trail > runtime" }
|
||||||
|
|
||||||
construct new(block) {
|
construct new(block) {
|
||||||
_block = block
|
_block = block
|
||||||
|
|
@ -112,7 +112,7 @@ import "luxe: world" for Block
|
||||||
_block = Block.create()
|
_block = Block.create()
|
||||||
_inst_type = instance_type
|
_inst_type = instance_type
|
||||||
_inst = _inst_type.new(_block, 0)
|
_inst = _inst_type.new(_block, 0)
|
||||||
Block.set_type(_block, "modifiers/trail/trail > runtime")
|
Block.set_type(_block, "trail: modifier/trail > runtime")
|
||||||
} //new
|
} //new
|
||||||
|
|
||||||
instance_type {
|
instance_type {
|
||||||
|
|
@ -151,7 +151,7 @@ import "luxe: world" for Block
|
||||||
} //BlockModifierRuntime
|
} //BlockModifierRuntime
|
||||||
|
|
||||||
|
|
||||||
//`modifiers/trail/trail > data` types
|
//`trail: modifier/trail > data` types
|
||||||
|
|
||||||
class ModifierData {
|
class ModifierData {
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ import "luxe: world" for Block
|
||||||
_length = 0.2
|
_length = 0.2
|
||||||
_subdivisions_length = 10
|
_subdivisions_length = 10
|
||||||
_subdivisions_width = 5
|
_subdivisions_width = 5
|
||||||
_material = "asset/flag"
|
_material = "trail: default_material/flag"
|
||||||
} //new
|
} //new
|
||||||
|
|
||||||
edge_length { _edge_length }
|
edge_length { _edge_length }
|
||||||
|
|
@ -188,7 +188,7 @@ import "luxe: world" for Block
|
||||||
|
|
||||||
} //ModifierData
|
} //ModifierData
|
||||||
|
|
||||||
//`modifiers/trail/trail > data` compilers
|
//`trail: modifier/trail > data` compilers
|
||||||
|
|
||||||
class ModifierDataCompiler {
|
class ModifierDataCompiler {
|
||||||
|
|
||||||
|
|
@ -286,7 +286,7 @@ import "luxe: world" for Block
|
||||||
|
|
||||||
|
|
||||||
var material = instance["material"]
|
var material = instance["material"]
|
||||||
if(material == null) material = "asset/flag"
|
if(material == null) material = "trail: default_material/flag"
|
||||||
out.write_uint32((material && material != "") ? compiler.string.hash(material) : 0)
|
out.write_uint32((material && material != "") ? compiler.string.hash(material) : 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ import "luxe: world" for Block
|
||||||
write_block(compiler, out) {
|
write_block(compiler, out) {
|
||||||
|
|
||||||
//source id
|
//source id
|
||||||
out.write_uint32(compiler.string.hash("modifiers/trail/trail > data"))
|
out.write_uint32(compiler.string.hash("trail: modifier/trail > data"))
|
||||||
|
|
||||||
//fields count
|
//fields count
|
||||||
out.write_int32(7)
|
out.write_int32(7)
|
||||||
|
|
@ -353,7 +353,7 @@ import "luxe: world" for Block
|
||||||
// material
|
// material
|
||||||
out.write_uint32(compiler.string.hash("material"))
|
out.write_uint32(compiler.string.hash("material"))
|
||||||
out.write_uint32(2729592961) //type id32
|
out.write_uint32(2729592961) //type id32
|
||||||
var material_default = "asset/flag"
|
var material_default = "trail: default_material/flag"
|
||||||
out.write_uint32((material_default && material_default != "") ? compiler.string.hash(material_default) : 0)
|
out.write_uint32((material_default && material_default != "") ? compiler.string.hash(material_default) : 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -374,12 +374,12 @@ import "luxe: world" for Block
|
||||||
|
|
||||||
} //ModifierDataCompiler
|
} //ModifierDataCompiler
|
||||||
|
|
||||||
//`modifiers/trail/trail > data` block types
|
//`trail: modifier/trail > data` block types
|
||||||
|
|
||||||
class BlockModifierData {
|
class BlockModifierData {
|
||||||
|
|
||||||
field { "trail" }
|
field { "trail" }
|
||||||
source { "modifiers/trail/trail > data" }
|
source { "trail: modifier/trail > data" }
|
||||||
|
|
||||||
construct new(block) {
|
construct new(block) {
|
||||||
_block = block
|
_block = block
|
||||||
|
|
@ -397,8 +397,8 @@ import "luxe: world" for Block
|
||||||
Block.add(_block, "length", "number", 0.2)
|
Block.add(_block, "length", "number", 0.2)
|
||||||
Block.add(_block, "subdivisions_length", "number", 10)
|
Block.add(_block, "subdivisions_length", "number", 10)
|
||||||
Block.add(_block, "subdivisions_width", "number", 5)
|
Block.add(_block, "subdivisions_width", "number", 5)
|
||||||
Block.add(_block, "material", "id32", "asset/flag")
|
Block.add(_block, "material", "id32", "trail: default_material/flag")
|
||||||
Block.set_type(_block, "modifiers/trail/trail > data")
|
Block.set_type(_block, "trail: modifier/trail > data")
|
||||||
} //new
|
} //new
|
||||||
|
|
||||||
instance_type {
|
instance_type {
|
||||||
|
|
@ -451,7 +451,7 @@ import "luxe: world" for Block
|
||||||
} //BlockModifierData
|
} //BlockModifierData
|
||||||
|
|
||||||
|
|
||||||
//`modifiers/trail/trail > world` types
|
//`trail: modifier/trail > world` types
|
||||||
|
|
||||||
class ModifierWorld {
|
class ModifierWorld {
|
||||||
|
|
||||||
|
|
@ -460,7 +460,7 @@ import "luxe: world" for Block
|
||||||
|
|
||||||
} //ModifierWorld
|
} //ModifierWorld
|
||||||
|
|
||||||
//`modifiers/trail/trail > world` compilers
|
//`trail: modifier/trail > world` compilers
|
||||||
|
|
||||||
class ModifierWorldCompiler {
|
class ModifierWorldCompiler {
|
||||||
|
|
||||||
|
|
@ -519,7 +519,7 @@ import "luxe: world" for Block
|
||||||
write_block(compiler, out) {
|
write_block(compiler, out) {
|
||||||
|
|
||||||
//source id
|
//source id
|
||||||
out.write_uint32(compiler.string.hash("modifiers/trail/trail > world"))
|
out.write_uint32(compiler.string.hash("trail: modifier/trail > world"))
|
||||||
|
|
||||||
//fields count
|
//fields count
|
||||||
out.write_int32(0)
|
out.write_int32(0)
|
||||||
|
|
@ -541,12 +541,12 @@ import "luxe: world" for Block
|
||||||
|
|
||||||
} //ModifierWorldCompiler
|
} //ModifierWorldCompiler
|
||||||
|
|
||||||
//`modifiers/trail/trail > world` block types
|
//`trail: modifier/trail > world` block types
|
||||||
|
|
||||||
class BlockModifierWorld {
|
class BlockModifierWorld {
|
||||||
|
|
||||||
field { "trail" }
|
field { "trail" }
|
||||||
source { "modifiers/trail/trail > world" }
|
source { "trail: modifier/trail > world" }
|
||||||
|
|
||||||
construct new(block) {
|
construct new(block) {
|
||||||
_block = block
|
_block = block
|
||||||
|
|
@ -558,7 +558,7 @@ import "luxe: world" for Block
|
||||||
_block = Block.create()
|
_block = Block.create()
|
||||||
_inst_type = instance_type
|
_inst_type = instance_type
|
||||||
_inst = _inst_type.new(_block, 0)
|
_inst = _inst_type.new(_block, 0)
|
||||||
Block.set_type(_block, "modifiers/trail/trail > world")
|
Block.set_type(_block, "trail: modifier/trail > world")
|
||||||
} //new
|
} //new
|
||||||
|
|
||||||
instance_type {
|
instance_type {
|
||||||
|
|
@ -5,12 +5,12 @@ import "luxe: color" for Color
|
||||||
import "luxe: render" for Geometry, Primitive, IndexType, Render
|
import "luxe: render" for Geometry, Primitive, IndexType, Render
|
||||||
import "luxe: assets" for Assets, Strings
|
import "luxe: assets" for Assets, Strings
|
||||||
import "luxe: bytes" for Uint16, Floats
|
import "luxe: bytes" for Uint16, Floats
|
||||||
|
|
||||||
import "queue" for Queue
|
|
||||||
|
|
||||||
import "modifiers/trail/trail.modifier" for ModifierData
|
|
||||||
import "luxe: math" for Math
|
import "luxe: math" for Math
|
||||||
|
|
||||||
|
import "trail: _queue" for Queue
|
||||||
|
|
||||||
|
import "trail: modifier/trail.modifier" for ModifierData
|
||||||
|
|
||||||
//User facing API
|
//User facing API
|
||||||
//This is what the user of your modifier will interact with
|
//This is what the user of your modifier will interact with
|
||||||
class Trail {
|
class Trail {
|
||||||
|
|
@ -153,6 +153,7 @@ class TrailSystem is ModifierSystem {
|
||||||
init(world) {
|
init(world) {
|
||||||
_world = world
|
_world = world
|
||||||
_draw = Draw.create(World.render_set(world))
|
_draw = Draw.create(World.render_set(world))
|
||||||
|
|
||||||
var edge_debug = PathStyle.new()
|
var edge_debug = PathStyle.new()
|
||||||
edge_debug.color = [1,1,1,1]
|
edge_debug.color = [1,1,1,1]
|
||||||
edge_debug.thickness = 2
|
edge_debug.thickness = 2
|
||||||
|
|
@ -203,7 +204,7 @@ class TrailSystem is ModifierSystem {
|
||||||
Render.vertex_buffer_replace(inst_data.color_buffer, color_data, color_data.length)*/
|
Render.vertex_buffer_replace(inst_data.color_buffer, color_data, color_data.length)*/
|
||||||
|
|
||||||
//...but for now...
|
//...but for now...
|
||||||
var data = get(entity)
|
var data = get(entity)
|
||||||
detach(entity, data)
|
detach(entity, data)
|
||||||
attach(entity, data)
|
attach(entity, data)
|
||||||
}
|
}
|
||||||
|
|
@ -213,6 +214,7 @@ class TrailSystem is ModifierSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
attach(entity, data: ModifierData) {
|
attach(entity, data: ModifierData) {
|
||||||
|
|
||||||
var material_id = Strings.get(data.material)
|
var material_id = Strings.get(data.material)
|
||||||
var material = Assets.material(material_id)
|
var material = Assets.material(material_id)
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
material = {
|
|
||||||
basis = "asset/clamped_sprite"
|
|
||||||
inputs = {
|
|
||||||
sprite.image = "asset/flag"
|
|
||||||
sprite.color = [1 1 1 1]
|
|
||||||
sprite.uv = [0 0 1 1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
image = {
|
image = {
|
||||||
source = "asset/flag.png"
|
source = "trail: default_material/flag.png"
|
||||||
generate_mipmaps_at_load = false
|
generate_mipmaps_at_load = false
|
||||||
}
|
}
|
||||||
8
assets/default_material/flag.material.lx
Normal file
8
assets/default_material/flag.material.lx
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
material = {
|
||||||
|
basis = "trail: default_material/clamped_sprite"
|
||||||
|
inputs = {
|
||||||
|
sprite.image = "trail: default_material/flag"
|
||||||
|
sprite.color = [1 1 1 1]
|
||||||
|
sprite.uv = [0 0 1 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 839 B After Width: | Height: | Size: 839 B |
|
|
@ -1,6 +1,6 @@
|
||||||
modifier = {
|
modifier = {
|
||||||
script = "modifiers/trail/trail"
|
script = "trail: trail"
|
||||||
description = "Trail go brrr."
|
description = "Dynamic trails."
|
||||||
field = "trail"
|
field = "trail"
|
||||||
display = "Trail" //the display in the editor
|
display = "Trail" //the display in the editor
|
||||||
class = "Trail" //The code generated name for the modifier API
|
class = "Trail" //The code generated name for the modifier API
|
||||||
|
|
@ -13,7 +13,7 @@ modifier = {
|
||||||
{ name="length" type="number" default=.2 }
|
{ name="length" type="number" default=.2 }
|
||||||
{ name="subdivisions_length" type="number" default=10 }
|
{ name="subdivisions_length" type="number" default=10 }
|
||||||
{ name="subdivisions_width" type="number" default=5 }
|
{ name="subdivisions_width" type="number" default=5 }
|
||||||
{ name="material" type="id32" editor="material" default="asset/flag"}
|
{ name="material" type="id32" editor="material" default="trail: default_material/flag"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
4
module.lx
Normal file
4
module.lx
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
name = "trail"
|
||||||
|
owner = "Ronja"
|
||||||
|
version = "dev"
|
||||||
|
description = "Simple trails. Just add a trail modifier to your moving component."
|
||||||
|
|
@ -7,7 +7,7 @@ import "luxe: draw" for Draw
|
||||||
import "luxe: io" for IO
|
import "luxe: io" for IO
|
||||||
|
|
||||||
import "outline/app" for App
|
import "outline/app" for App
|
||||||
import "modifiers/trail/trail" for Trail
|
import "trail: modifier/trail" for Trail
|
||||||
|
|
||||||
class Game is Ready {
|
class Game is Ready {
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ class Game is Ready {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Input.key_state_released(Key.key_1)) {
|
if(Input.key_state_released(Key.key_1)) {
|
||||||
var subs = Trail.get_subdivisions_length(_blade) + 1
|
var subs = Trail.get_subdivisions_length(_blade) + 5
|
||||||
Trail.set_subdivisions_length(_blade, subs)
|
Trail.set_subdivisions_length(_blade, subs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@ class Project is Entry {
|
||||||
construct entry(target) {
|
construct entry(target) {
|
||||||
|
|
||||||
name = "Trail Test"
|
name = "Trail Test"
|
||||||
version = "0.0.0"
|
version = "1.0.0"
|
||||||
renderer = "outline/renderer"
|
renderer = "outline/renderer"
|
||||||
settings = "outline/settings"
|
settings = "outline/settings"
|
||||||
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
modules = {
|
modules = {
|
||||||
luxe = "dev"
|
luxe = "dev"
|
||||||
|
trail = "dev"
|
||||||
} //modules
|
} //modules
|
||||||
Loading…
Reference in a new issue