Mercurial > games > semicongine
changeset 751:42e692716e38
add: access to non-animated transform
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 14 Jun 2023 23:31:59 +0700 |
parents | 8a1c04f64f3d |
children | bcd246da025d |
files | src/semicongine/scene.nim |
diffstat | 1 files changed, 17 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/semicongine/scene.nim Wed Jun 14 22:56:43 2023 +0700 +++ b/src/semicongine/scene.nim Wed Jun 14 23:31:59 2023 +0700 @@ -54,6 +54,23 @@ func getValue*(animation: var EntityAnimation): Mat4 = return animation.player.currentValue +func transform*(entity: Entity): Mat4 = + result = entity.internal_transform + for component in entity.components.mitems: + if component of EntityAnimation: + result = result * EntityAnimation(component).getValue + +func originalTransform*(entity: Entity): Mat4 = + entity.internal_transform + +func `transform=`*(entity: Entity, value: Mat4) = + entity.internal_transform = value + +func getModelTransform*(entity: Entity): Mat4 = + result = entity.transform + if not entity.parent.isNil: + result = entity.transform * entity.parent.getModelTransform() + func addShaderGlobal*[T](scene: var Scene, name: string, data: T) = scene.shaderGlobals[name] = newDataList(thetype=getDataType[T]()) setValues(scene.shaderGlobals[name], @[data]) @@ -224,20 +241,6 @@ queue.add child yield next -func transform*(entity: Entity): Mat4 = - result = entity.internal_transform - for component in entity.components.mitems: - if component of EntityAnimation: - result = result * EntityAnimation(component).getValue - -func `transform=`*(entity: Entity, value: Mat4) = - entity.internal_transform = value - -func getModelTransform*(entity: Entity): Mat4 = - result = entity.transform - if not entity.parent.isNil: - result = entity.transform * entity.parent.getModelTransform() - proc prettyRecursive*(entity: Entity): seq[string] = var compList: seq[string] for comp in entity.components: