2022-03-01 22:58:58 +01:00
|
|
|
Class {
|
|
|
|
#name : #Diya2DNode,
|
|
|
|
#superclass : #DiyaNode,
|
2022-03-06 18:33:10 +01:00
|
|
|
#instVars : [
|
2022-03-06 19:50:19 +01:00
|
|
|
'color',
|
|
|
|
'vbuffer',
|
|
|
|
'nvertices'
|
2022-03-06 18:33:10 +01:00
|
|
|
],
|
2022-03-01 22:58:58 +01:00
|
|
|
#category : #'Diya-Graphics'
|
|
|
|
}
|
|
|
|
|
2022-03-06 18:33:10 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> color [
|
|
|
|
^ color
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> color: anObject [
|
|
|
|
color := anObject
|
2022-03-03 19:19:40 +01:00
|
|
|
]
|
|
|
|
|
2022-03-01 22:58:58 +01:00
|
|
|
{ #category : #initialization }
|
|
|
|
Diya2DNode >> initialize [
|
|
|
|
super initialize.
|
|
|
|
translation := 0@0.
|
2022-03-02 20:11:01 +01:00
|
|
|
scale := 1.0@1.0.
|
2022-03-01 22:58:58 +01:00
|
|
|
rotation := 0.0.
|
|
|
|
tf := Array2D identity: 3.
|
2022-03-06 18:33:10 +01:00
|
|
|
shader := Diya2DShader uniqueInstance.
|
2022-03-06 19:50:19 +01:00
|
|
|
color := Color white.
|
|
|
|
vbuffer := nil.
|
|
|
|
nvertices := 0.
|
2022-03-06 18:33:10 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
Diya2DNode >> setUpShader [
|
|
|
|
super setUpShader.
|
|
|
|
shader setUniform: #u_color value: self color asGL4FArray.
|
2022-03-01 22:58:58 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> updateTF [
|
|
|
|
tf := Array2D identity:3.
|
|
|
|
"translation"
|
2022-03-02 20:11:01 +01:00
|
|
|
tf := tf +* (Array2D rows: 3 columns: 3 contents: {
|
|
|
|
1.0. 0.0. translation x.
|
|
|
|
0.0. 1.0. translation y.
|
|
|
|
0.0. 0.0. 1.0
|
|
|
|
}).
|
2022-03-01 22:58:58 +01:00
|
|
|
"rotation"
|
2022-03-02 20:11:01 +01:00
|
|
|
tf := tf +* (Array2D rows: 3 columns: 3 contents:{
|
|
|
|
rotation cos. (rotation sin) negated. 0.0.
|
|
|
|
rotation sin. rotation cos. 0.0.
|
|
|
|
0.0. 0.0. 1.0
|
|
|
|
}).
|
|
|
|
"scale"
|
|
|
|
tf := tf +* (Array2D rows: 3 columns: 3 contents:{
|
|
|
|
scale x. 0.0. 0.0.
|
|
|
|
0.0. scale y. 0.0.
|
|
|
|
0.0. 0.0. 1.0
|
|
|
|
}).
|
2022-03-06 18:33:10 +01:00
|
|
|
self parent isRoot ifFalse: [ tf := self parent tf +* tf ].
|
|
|
|
children ifNotNil: [
|
|
|
|
children do:[:c| c updateTF ]].
|
|
|
|
|
2022-03-01 22:58:58 +01:00
|
|
|
]
|