nuclear@2: #include nuclear@2: #include "comp_xform.h" nuclear@2: #include "gameobj.h" nuclear@2: nuclear@3: static CompXForm reg_co_xform; nuclear@3: static CompPRS reg_co_prs; nuclear@3: nuclear@2: static Component *cons_xform() { return new CompXForm; } nuclear@2: static Component *cons_prs() { return new CompPRS; } nuclear@2: nuclear@2: CompXForm::CompXForm() nuclear@2: { nuclear@2: name = "xform"; nuclear@2: nuclear@2: register_component(name, cons_xform); nuclear@2: } nuclear@2: nuclear@2: CompPRS::CompPRS() nuclear@2: { nuclear@2: name = "prs"; nuclear@2: nuclear@2: register_component(name, cons_prs); nuclear@2: } nuclear@2: nuclear@2: void CompPRS::update() nuclear@2: { nuclear@2: if(!gobj) return; nuclear@2: nuclear@2: if(!co_xform) { nuclear@2: Component *co = gobj->get_component("xform"); nuclear@2: if(!co || !(co_xform = dynamic_cast(co))) { 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: }