2018-04-02 01:06:50 +02:00
|
|
|
-- loading our libraries
|
|
|
|
pw.script:initialize()
|
|
|
|
|
2018-04-03 09:13:45 +02:00
|
|
|
print("hello pixwerx!")
|
2018-04-02 01:06:50 +02:00
|
|
|
|
2018-12-27 23:45:16 +01:00
|
|
|
local v1 = pw.vector3.new(3,2,1)
|
|
|
|
v1:set(0,1,2)
|
2018-04-02 01:06:50 +02:00
|
|
|
|
2018-12-27 23:45:16 +01:00
|
|
|
print("v1 ",v1.x,v1.y,v1.z)
|
2018-04-02 11:34:53 +02:00
|
|
|
|
2018-04-02 01:06:50 +02:00
|
|
|
|
2018-04-11 17:55:55 +02:00
|
|
|
---- objects need to be cloned
|
|
|
|
----local v2 = v:clone()
|
|
|
|
--local v2 = v
|
2018-04-02 01:06:50 +02:00
|
|
|
|
2018-04-11 17:55:55 +02:00
|
|
|
---- manipulate stuff
|
|
|
|
--v.x = 0.2
|
|
|
|
--v.y = pw.pi
|
2018-04-02 11:34:53 +02:00
|
|
|
|
|
|
|
|
2018-04-11 17:55:55 +02:00
|
|
|
--print("v : ", v:v())
|
|
|
|
--print("v2: ", v2:v())
|
|
|
|
|
|
|
|
local q = pw.quaternion.new()
|
2018-04-02 11:34:53 +02:00
|
|
|
print("q",q.x,q.y,q.z,q.w)
|
2018-12-27 23:45:16 +01:00
|
|
|
|
2018-12-30 23:36:53 +01:00
|
|
|
qi = q.inverse
|
2018-04-11 17:55:55 +02:00
|
|
|
print("q.inverse",qi.x,qi.y,qi.z,qi.w)
|
|
|
|
|
2018-12-27 23:45:16 +01:00
|
|
|
local q2 = pw.quaternion.new(0,0,0,1)
|
|
|
|
|
2018-12-30 23:36:53 +01:00
|
|
|
qm = pw.quaternion.lerp(q,qi,0.5)
|
2018-04-11 17:55:55 +02:00
|
|
|
print("q.m",qm.x,qm.y,qm.z,qm.w)
|
2018-04-02 11:34:53 +02:00
|
|
|
|
2018-12-27 23:45:16 +01:00
|
|
|
-- axis angle test
|
|
|
|
local aa = pw.axisangle.new(v1,0.707)
|
|
|
|
|
|
|
|
print("aa.axis",aa.axis.x,aa.axis.y,aa.axis.z)
|
|
|
|
print("aa.angle",aa.angle)
|
|
|
|
|
2019-01-05 10:13:16 +01:00
|
|
|
local n_1 = pw.node.create()
|
|
|
|
n_1.name = "root"
|
2018-12-27 23:45:16 +01:00
|
|
|
|
|
|
|
print("node 1: ", n_1.name)
|
|
|
|
|
2018-12-28 00:34:39 +01:00
|
|
|
--print(pw.node.create())
|
2018-12-27 23:45:16 +01:00
|
|
|
|
2018-12-28 00:34:39 +01:00
|
|
|
n_1:add_child(pw.node.create()).name = "one"
|
|
|
|
n_1:add_child(pw.node.create()).name = "two"
|
|
|
|
n_1:add_child(pw.node.create()).name = "three"
|
|
|
|
n_1:add_child(pw.node.create()).name = "four"
|
|
|
|
n_1:add_child(pw.node.create()).name = "five"
|
|
|
|
|
|
|
|
--n_1:add_child(n_2:shared())
|
|
|
|
|
|
|
|
print("node 1 - child count ",n_1.child_count)
|
|
|
|
|
2019-01-09 19:58:03 +01:00
|
|
|
-- stuff
|
2018-12-28 00:34:39 +01:00
|
|
|
for i = 1,n_1.child_count do
|
|
|
|
print(i,n_1.children[i],n_1.children[i].name)
|
|
|
|
end
|
2018-12-27 23:45:16 +01:00
|
|
|
|
|
|
|
--print(n_1:shared())
|
|
|
|
--print(pw.my_func())
|
|
|
|
|
|
|
|
--n_1:add_child()
|
|
|
|
|
2018-12-28 00:34:39 +01:00
|
|
|
local w = pw.window.new()
|
2019-01-16 23:45:44 +01:00
|
|
|
w.visible = false
|
2018-12-28 00:34:39 +01:00
|
|
|
|
2019-01-09 17:50:18 +01:00
|
|
|
-- set title
|
|
|
|
w.title = "pixwerx 0.1"
|
|
|
|
|
2019-01-16 18:52:39 +01:00
|
|
|
-- set size
|
|
|
|
w.size = pw.size.new(800,600)
|
|
|
|
-- move window
|
|
|
|
w.position = pw.point.new(100,100)
|
|
|
|
|
2019-01-16 23:45:44 +01:00
|
|
|
print("client size after resize: ",w.client_size.width,w.client_size.height)
|
|
|
|
|
2019-01-16 18:52:39 +01:00
|
|
|
|
2019-01-16 16:55:37 +01:00
|
|
|
local pl = pw.pipeline.new()
|
2019-01-16 18:52:39 +01:00
|
|
|
if pl:create(w.client_size) then
|
2019-01-16 16:55:37 +01:00
|
|
|
print("pipeline ok")
|
|
|
|
else
|
|
|
|
print("pipeline failed")
|
|
|
|
end
|
|
|
|
|
2019-01-16 23:45:44 +01:00
|
|
|
-- setup a lua callback function as callback
|
2019-01-14 22:47:57 +01:00
|
|
|
w.on_update = function(self)
|
2019-01-16 16:55:37 +01:00
|
|
|
pl:draw()
|
|
|
|
-- print("test on update",w.position.x,w.position.y,pw.timer.now)
|
2019-01-16 23:45:44 +01:00
|
|
|
|
2019-01-14 22:47:57 +01:00
|
|
|
end
|
|
|
|
|
2019-01-13 22:14:41 +01:00
|
|
|
local ds = pw.display:all()
|
|
|
|
for i = 1,#ds do
|
|
|
|
print("display ",i,ds[i].name)
|
|
|
|
end
|
|
|
|
|
2019-01-14 21:48:16 +01:00
|
|
|
local t = pw.timer.new()
|
|
|
|
|
2019-01-16 23:45:44 +01:00
|
|
|
w.visible = true
|
|
|
|
|
|
|
|
while w:update() do
|
2019-01-14 09:42:28 +01:00
|
|
|
-- somehow works
|
2019-01-16 16:55:37 +01:00
|
|
|
if (pw.input.get().input_string == 'f') then
|
|
|
|
w.fullscreen = not w.fullscreen
|
|
|
|
end
|
2019-01-09 19:58:03 +01:00
|
|
|
|
2019-01-14 09:42:28 +01:00
|
|
|
-- just to check
|
2019-01-10 10:51:03 +01:00
|
|
|
if (pw.input:get().mouse_button == 1) then
|
2019-01-16 16:55:37 +01:00
|
|
|
print("elapsed",t.elapsed)
|
2019-01-14 21:48:16 +01:00
|
|
|
t:reset()
|
2019-01-16 23:45:44 +01:00
|
|
|
print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y,w.client_size.width,w.client_size.height)
|
2019-01-16 16:55:37 +01:00
|
|
|
end
|
2019-01-09 19:58:03 +01:00
|
|
|
|
2018-12-28 00:34:39 +01:00
|
|
|
-- print("update")
|
|
|
|
end
|
2018-04-02 11:34:53 +02:00
|
|
|
|
|
|
|
--local scene = pw:scene.new()
|
|
|
|
|