cleaning up script and component implementations
This commit is contained in:
parent
c207493454
commit
a5dea1ede1
6 changed files with 44 additions and 17 deletions
|
@ -30,8 +30,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
node* _node;
|
node* _node;
|
||||||
|
|
||||||
std::string _name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,15 +8,22 @@ namespace pw {
|
||||||
|
|
||||||
class transform : public component {
|
class transform : public component {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using component::component;
|
using component::component;
|
||||||
|
|
||||||
const matrix44d& local() const;
|
const matrix44d& local() const;
|
||||||
void set_local(const matrix44d &local);
|
void set_local(const matrix44d &local);
|
||||||
|
|
||||||
|
void set_global(const matrix44d &global);
|
||||||
|
|
||||||
|
void update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
matrix44d _local;
|
matrix44d _local;
|
||||||
|
|
||||||
matrix44d _global;
|
matrix44d _global;
|
||||||
|
matrix44d _global_inverse;
|
||||||
|
|
||||||
std::vector<ref> _path;
|
std::vector<ref> _path;
|
||||||
|
|
||||||
|
|
|
@ -13,4 +13,14 @@ void transform::set_local(const matrix44d &local)
|
||||||
_local = local;
|
_local = local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void transform::set_global(const matrix44d &global)
|
||||||
|
{
|
||||||
|
_global = global; // need to set global inverse
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void transform::update() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef PW_SCRIPTING_SCRIPT_HPP
|
#ifndef PW_SCRIPTING_SCRIPT_HPP
|
||||||
#define PW_SCRIPTING_SCRIPT_HPP
|
#define PW_SCRIPTING_SCRIPT_HPP
|
||||||
|
|
||||||
|
|
||||||
#include <pw/core/globals.hpp>
|
#include <pw/core/globals.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -18,6 +17,7 @@ public:
|
||||||
|
|
||||||
struct state {
|
struct state {
|
||||||
virtual int run(const std::string& script) = 0;
|
virtual int run(const std::string& script) = 0;
|
||||||
|
virtual ~state() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -62,7 +62,11 @@ void lua_state::load_modules() {
|
||||||
"x", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::x), &quaterniond::set_x),
|
"x", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::x), &quaterniond::set_x),
|
||||||
"y", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::y), &quaterniond::set_y),
|
"y", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::y), &quaterniond::set_y),
|
||||||
"z", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::z), &quaterniond::set_z),
|
"z", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::z), &quaterniond::set_z),
|
||||||
"w", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::w), &quaterniond::set_w)
|
"w", scripting::property(scripting::resolve<const Scalar&() const>(&quaterniond::w), &quaterniond::set_w),
|
||||||
|
"dot",&quaterniond::dot,
|
||||||
|
"inverse",&quaterniond::inverse,
|
||||||
|
"normalized",&quaterniond::normalized,
|
||||||
|
"lerp",&quaterniond::lerp
|
||||||
// "v",&vector3d::values,
|
// "v",&vector3d::values,
|
||||||
// "clone",&vector3d::clone
|
// "clone",&vector3d::clone
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,27 +6,35 @@ print("hello pixwerx!")
|
||||||
local v = pw.vector3.new()
|
local v = pw.vector3.new()
|
||||||
v:set(0,1,2)
|
v:set(0,1,2)
|
||||||
|
|
||||||
-- objects need to be cloned
|
print("v",v.x,v.y,v.z)
|
||||||
local v2 = v:clone()
|
|
||||||
|
|
||||||
-- manipulate stuff
|
|
||||||
v.x = 0.2
|
|
||||||
v.y = pw.pi
|
|
||||||
|
|
||||||
|
|
||||||
print("v : ", v:v())
|
---- objects need to be cloned
|
||||||
print("v2: ", v2:v())
|
----local v2 = v:clone()
|
||||||
|
--local v2 = v
|
||||||
|
|
||||||
|
---- manipulate stuff
|
||||||
|
--v.x = 0.2
|
||||||
|
--v.y = pw.pi
|
||||||
|
|
||||||
|
|
||||||
|
--print("v : ", v:v())
|
||||||
|
--print("v2: ", v2:v())
|
||||||
|
|
||||||
local q = pw.quaternion.new()
|
local q = pw.quaternion.new()
|
||||||
|
|
||||||
print("q",q.x,q.y,q.z,q.w)
|
print("q",q.x,q.y,q.z,q.w)
|
||||||
|
qi = q:inverse()
|
||||||
|
print("q.inverse",qi.x,qi.y,qi.z,qi.w)
|
||||||
|
|
||||||
local aa = pw.axisangle.new()
|
qm = pw.quaternion.lerp(q,qi)
|
||||||
|
print("q.m",qm.x,qm.y,qm.z,qm.w)
|
||||||
|
|
||||||
-- assign vector to axis
|
--local aa = pw.axisangle.new()
|
||||||
aa.axis = v
|
|
||||||
|
|
||||||
print("aa",aa.axis.x)
|
---- assign vector to axis
|
||||||
|
----aa.axis = v
|
||||||
|
|
||||||
|
--print("aa",aa.axis.x)
|
||||||
|
|
||||||
--local scene = pw:scene.new()
|
--local scene = pw:scene.new()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue