nuclear@2: #include nuclear@5: #include "co_xform.h" nuclear@5: #include "gobj.h" nuclear@2: nuclear@5: static CoXForm reg_co_xform; nuclear@5: static CoPRS reg_co_prs; nuclear@3: nuclear@5: static Component *cons_xform() { return new CoXForm; } nuclear@5: static Component *cons_prs() { return new CoPRS; } nuclear@2: nuclear@5: CoXForm::CoXForm() nuclear@2: { nuclear@2: name = "xform"; nuclear@2: nuclear@2: register_component(name, cons_xform); nuclear@2: } nuclear@2: nuclear@6: // ---- class CoPRS ---- nuclear@6: nuclear@5: CoPRS::CoPRS() nuclear@6: : scale(1, 1, 1) nuclear@2: { nuclear@2: name = "prs"; nuclear@2: nuclear@2: register_component(name, cons_prs); nuclear@2: } nuclear@2: nuclear@6: const char **CoPRS::update_before() const nuclear@6: { nuclear@6: static const char *before[] = { "xform", 0 }; nuclear@6: return before; nuclear@6: } nuclear@6: nuclear@6: void CoPRS::update(float dt) nuclear@2: { nuclear@2: if(!gobj) return; nuclear@2: nuclear@2: if(!co_xform) { nuclear@6: if(!(co_xform = COCAST(CoXForm, gobj->get_component("xform")))) { nuclear@2: assert(co_xform); nuclear@2: return; nuclear@2: } nuclear@2: } nuclear@2: nuclear@2: Matrix4x4 rmat = rot.get_rotation_matrix(); nuclear@2: Matrix4x4 tmat, smat; nuclear@2: nuclear@2: tmat.set_translation(pos); nuclear@2: smat.set_scaling(scale); nuclear@2: nuclear@2: co_xform->xform = rmat * tmat * smat; nuclear@2: }