Mercurial > hg > Members > kono > Cerium
changeset 770:aed3d2501c38
property_chain is under construction
author | hiroki@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Sun, 14 Feb 2010 04:18:38 +0900 |
parents | 2a00c1f470b7 |
children | 720720e4e8df |
files | Renderer/Test/property_chain.cc |
diffstat | 1 files changed, 53 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Test/property_chain.cc Sun Feb 14 01:23:38 2010 +0900 +++ b/Renderer/Test/property_chain.cc Sun Feb 14 04:18:38 2010 +0900 @@ -11,6 +11,12 @@ #define FALSE 0 #define TRUE !FALSE static const int PROPERTY_LENGTH = 51; +static double m = 100.0; +static double k = 7000.0; +static double g = 9.8; +static double dt = 0.003; +static double chain_width = 10; +static double safe = 0.995; typedef struct { double x, y, next_x, next_y; @@ -47,6 +53,25 @@ static void set_relation(SceneGraphPtr parent, SceneGraphPtr child); static void +init_chain(Property *p, int index) { + for (int i = 0; i < 3; i++) { + p->xyz[i] = 0; + p->angle[i] = 0; + p->stack_xyz[i] = 0; + p->next_xyz[i] = 0; + p->v_xyz[i] = 0; + } + + p->property_index = index; + p->parent_index = 0; + p->have_parent = 0; + p->can_move = TRUE; + p->parent = NULL; + p->children = NULL; + p->node = NULL; +} + +static void move(SceneGraphPtr node, void *sgroot_, int screen_w, int screen_h) { SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; @@ -177,20 +202,47 @@ property = (Property *)sgroot->manager->allocate(sizeof(Property)*PROPERTY_LENGTH); update_property = (Property *)sgroot->manager->allocate(sizeof(Property)*PROPERTY_LENGTH); + // property の初期化 application ごとに固有 + for(int i = 0; i < PROPERTY_LENGTH; i++) { + init_chain(property[i], i); + } + SceneGraphPtr root_chain, chain; sgroot->createFromXMLfile("xml_file/chain.xml"); root_chain = sgroot->createSceneGraph("CHAIN"); root_chain->xyz[0] = screen_w / 2; - root_chain->xyz[1] = screen_h / 2; + root_chain->xyz[1] = 0.0f; + root_chain->set_move_collision(move, colliison); + + + for (int i = 1; i < PROPERTY_LENGTH; i++) { + chain = sgroot->createSceneGraph("CHAIN"); + chain->xyz[0] = 0; + chain->xyz[1] = chain_width * i; + chain->angle[1] = -90 * (i % 2); + + root_chain->addChild(chain); + // この段階じゃ set_relation はダメか + set_relation(root_chain, chain); + } + + SceneGraphPtr moon; moon = sgroot->createSceneGraph("Moon"); earth->addChild(moon); + // root の set_property は一通り SceneGraph を作成してから実行 + // addChild したら set_relation しないとだめ、あんまりにもだめ set_property(&property[root_obj_index], earth, 0); set_property(&property[1], moon, 1); set_relation(earth, moon); + + /* + apply_property は post_func の createSceneGraphFromProperty 中で使う + apply_property は sgroot に持たせてもいいと思います○ + */ sgroot->setSceneData(earth);