coeng

view src/co_xform.cc @ 5:0e5da17d589c

decided to really work on this, so first a slight rename
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Feb 2015 01:35:42 +0200
parents src/comp_xform.cc@66d1762eb203
children 2f872a179914
line source
1 #include <assert.h>
2 #include "co_xform.h"
3 #include "gobj.h"
5 static CoXForm reg_co_xform;
6 static CoPRS reg_co_prs;
8 static Component *cons_xform() { return new CoXForm; }
9 static Component *cons_prs() { return new CoPRS; }
11 CoXForm::CoXForm()
12 {
13 name = "xform";
15 register_component(name, cons_xform);
16 }
18 CoPRS::CoPRS()
19 {
20 name = "prs";
22 register_component(name, cons_prs);
23 }
25 void CoPRS::update()
26 {
27 if(!gobj) return;
29 if(!co_xform) {
30 Component *co = gobj->get_component("xform");
31 if(!co || !(co_xform = dynamic_cast<CoXForm*>(co))) {
32 assert(co_xform);
33 return;
34 }
35 }
37 Matrix4x4 rmat = rot.get_rotation_matrix();
38 Matrix4x4 tmat, smat;
40 tmat.set_translation(pos);
41 smat.set_scaling(scale);
43 co_xform->xform = rmat * tmat * smat;
44 }