-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
9,330 additions
and
5,123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package bone | ||
|
||
import ( | ||
wrapper "dragonBones/dragonBones" | ||
"log" | ||
) | ||
|
||
type ArmatureDisplayFace interface { | ||
wrapper.IArmatureProxy | ||
deleteIArmatureProxy() | ||
IsIArmatureProxy() | ||
} | ||
|
||
type ArmatureDisplay struct { | ||
Display | ||
wrapper.IArmatureProxy | ||
om *overwrittenMethodsOnArmatureDisplay | ||
} | ||
|
||
func (a *ArmatureDisplay) IsIArmatureProxy() {} | ||
|
||
func (a *ArmatureDisplay) deleteIArmatureProxy() { | ||
wrapper.DeleteDirectorIArmatureProxy(a.IArmatureProxy) | ||
} | ||
|
||
func NewArmatureDisplay() *ArmatureDisplay { | ||
om := &overwrittenMethodsOnArmatureDisplay{} | ||
|
||
face := wrapper.NewDirectorIArmatureProxy(om) | ||
om.base = face | ||
|
||
data := &ArmatureDisplay{IArmatureProxy: face, om: om} | ||
boneObjectAdd(data.Swigcptr(), data) | ||
return data | ||
} | ||
|
||
type overwrittenMethodsOnArmatureDisplay struct { | ||
base wrapper.IArmatureProxy | ||
|
||
armature wrapper.Armature | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) DbInit(armature wrapper.Armature) { | ||
log.Println("DbInit") | ||
om.armature = armature | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) DbClear() { | ||
om.armature = nil | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) DbUpdate() { | ||
log.Println("DbUpdate") | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) Dispose(bool) { | ||
if om.armature != nil { | ||
om.armature.Dispose() | ||
om.armature = nil | ||
} | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) HasDBEventListener(name string) bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,77 @@ | ||
package bone | ||
|
||
import ( | ||
wrapper "dragonBones/dragonBones" | ||
"log" | ||
) | ||
import "github.com/EngoEngine/gl" | ||
|
||
type ArmatureDisplayFace interface { | ||
wrapper.IArmatureProxy | ||
deleteIArmatureProxy() | ||
IsIArmatureProxy() | ||
} | ||
type IDisplay interface { | ||
GetParent() IDisplay | ||
SetParent(IDisplay) | ||
AddChild(IDisplay) | ||
RemoveChild(IDisplay) | ||
GetChildren() []IDisplay | ||
RemoveFromParent() | ||
|
||
type ArmatureDisplay struct { | ||
wrapper.IArmatureProxy | ||
om *overwrittenMethodsOnArmatureDisplay | ||
Texture() *gl.Texture | ||
Width() float32 | ||
Height() float32 | ||
View() (float32, float32, float32, float32) | ||
Close() | ||
} | ||
|
||
func (a *ArmatureDisplay) IsIArmatureProxy() {} | ||
type Display struct { | ||
Parent IDisplay | ||
Children []IDisplay | ||
} | ||
|
||
func (a *ArmatureDisplay) deleteIArmatureProxy() { | ||
wrapper.DeleteDirectorIArmatureProxy(a.IArmatureProxy) | ||
func (d *Display) GetParent() IDisplay { | ||
return d.Parent | ||
} | ||
|
||
func NewArmatureDisplay() *ArmatureDisplay { | ||
om := &overwrittenMethodsOnArmatureDisplay{} | ||
func (d *Display) SetParent(p IDisplay) { | ||
d.Parent = p | ||
} | ||
|
||
face := wrapper.NewDirectorIArmatureProxy(om) | ||
om.base = face | ||
func (d *Display) AddChild(child IDisplay) { | ||
child.SetParent(d) | ||
d.Children = append(d.Children, child) | ||
} | ||
|
||
return &ArmatureDisplay{IArmatureProxy: face, om: om} | ||
func (d *Display) RemoveChild(child IDisplay) { | ||
delete := -1 | ||
for idx, c := range d.Children { | ||
if c == child { | ||
delete = idx | ||
break | ||
} | ||
} | ||
d.Children = append(d.Children[:delete], d.Children[delete+1:]...) | ||
} | ||
|
||
type overwrittenMethodsOnArmatureDisplay struct { | ||
base wrapper.IArmatureProxy | ||
func (d *Display) GetChildren() []IDisplay { | ||
return d.Children | ||
} | ||
|
||
armature wrapper.Armature | ||
func (d *Display) RemoveFromParent() { | ||
if d.Parent != nil { | ||
d.Parent.RemoveChild(d) | ||
d.Parent = nil | ||
} | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) DbInit(armature wrapper.Armature) { | ||
log.Println("DbInit") | ||
om.armature = armature | ||
func (d *Display) Width() float32 { | ||
return 0 | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) DbClear() { | ||
om.armature = nil | ||
func (d *Display) Height() float32 { | ||
return 0 | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) DbUpdate() { | ||
log.Println("DbUpdate") | ||
func (d *Display) Texture() *gl.Texture { | ||
return nil | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) Dispose(bool) { | ||
if om.armature != nil { | ||
om.armature.Dispose() | ||
om.armature = nil | ||
} | ||
func (d *Display) View() (float32, float32, float32, float32) { | ||
return 0, 0, 1, 1 | ||
} | ||
|
||
func (om *overwrittenMethodsOnArmatureDisplay) HasDBEventListener(name string) bool { | ||
return false | ||
func (d *Display) Close() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package bone | ||
|
||
import ( | ||
"github.com/EngoEngine/ecs" | ||
"github.com/EngoEngine/engo/common" | ||
) | ||
|
||
var ( | ||
DragonBoneHUDShader = NewDragonBoneShader(common.HUDShader) | ||
DragonBoneDefaultShader = NewDragonBoneShader(common.DefaultShader) | ||
) | ||
|
||
type DragonBoneShader struct { | ||
wrappedShader common.Shader | ||
culling common.CullingShader | ||
} | ||
|
||
func NewDragonBoneShader(shader common.Shader) *DragonBoneShader { | ||
if culling, ok := shader.(common.CullingShader); ok { | ||
return &DragonBoneShader{wrappedShader: shader, culling: culling} | ||
} | ||
return &DragonBoneShader{wrappedShader: shader} | ||
} | ||
|
||
func (db *DragonBoneShader) PrepareCulling() { | ||
if db.culling != nil { | ||
db.culling.PrepareCulling() | ||
} | ||
} | ||
|
||
func (db *DragonBoneShader) ShouldDraw(rc *common.RenderComponent, sc *common.SpaceComponent) bool { | ||
// todo | ||
return true | ||
} | ||
|
||
func (db *DragonBoneShader) Pre() { | ||
db.wrappedShader.Pre() | ||
} | ||
|
||
func (db *DragonBoneShader) Draw(rc *common.RenderComponent, sc *common.SpaceComponent) { | ||
db.DrawDisplay(rc.Drawable.(IDisplay), sc) | ||
} | ||
|
||
func (db *DragonBoneShader) DrawDisplay(iDisplay IDisplay, sc *common.SpaceComponent) { | ||
children := iDisplay.GetChildren() | ||
for _, subDisplay := range children { | ||
db.DrawDisplay(subDisplay, sc) | ||
} | ||
|
||
switch display := iDisplay.(type) { | ||
case *Sprite: | ||
if display.RenderComponent.Drawable != nil { | ||
db.wrappedShader.Draw(&display.RenderComponent, &display.SpaceComponent) | ||
} | ||
} | ||
} | ||
|
||
func (db *DragonBoneShader) Post() { | ||
db.wrappedShader.Post() | ||
} | ||
|
||
func (db *DragonBoneShader) Setup(*ecs.World) error { | ||
return nil | ||
} | ||
|
||
func (db *DragonBoneShader) SetCamera(cs *common.CameraSystem) { | ||
} |
Oops, something went wrong.