void Book::action() { glm::vec4 init_rpos = indexToPos(ipos); glm::vec4 end_rpos = indexToPos(goto_ipos); switch (state) { case BOOK_STATE_NONE: rpos = indexToPos(ipos); break; case BOOK_STATE_MOVING: //바라보는 방향쪽으로? if (ABS(rpos.x, init_rpos.x) < 0.005f && ABS(rpos.y, init_rpos.y) < 0.005f && rpos.z - parent->rpos.z <= 1.8f) { //speed rpos.z = rpos.z + 0.05f; } else if (ABS(rpos.x, end_rpos.x) < 0.005f && ABS(rpos.y, end_rpos.y) < 0.005f && rpos.z - parent->rpos.z >= 0.8f) { //speed rpos.z = rpos.z - 0.05f; } else if (ABS(rpos.x, end_rpos.x) < 0.005f && ABS(rpos.y, end_rpos.y) < 0.005f && rpos.z - parent->rpos.z < 0.8f) { //도착 확인 -> 도착했으면 state 바꾸기 state = BOOK_STATE_NONE; rpos = end_rpos; ipos = goto_ipos; } else { // speed = 0.1f tic = tic + 0.02f; rpos.x = init_rpos.x + (end_rpos.x - init_rpos.x) * tic; rpos.y = init_rpos.y + (end_rpos.y - init_rpos.y) * tic; // 바라보는 방향으로... 튀어나왔다 들어가게 rpos.z = parent->rpos.z + 1.8f + 0.5f * sin(3.14f * tic); if (tic >= 1.0f) { tic = 0.0f; } } break; case BOOK_STATE_CLICKED: break; } //위치보정 scene->T = glm::translate(glm::mat4(1.0f), glm::vec3(rpos)); }
void SetIndexPosition(BookIndex bi) { ipos = bi; //초기 위치 설정 rpos = indexToPos(ipos); scene->T = glm::translate(glm::mat4(1.0f), glm::vec3(rpos)); }
int* CellsRegistry::reserveRandomAvailableGroundPos(int* pos){ if (availableGroundTiles.size() == 0) { return NULL; } int idx = randInt(availableGroundTiles.size()); indexToPos(pos, world.length, availableGroundTiles[idx]); availableGroundTiles.erase(availableGroundTiles.begin()+idx); return pos; }
/** * Returns the position in the som of a code vector * Parameter: _v Reference to the code vector */ SomPos ClassificationMap::codVecPos(SomIn& _v) { return indexToPos(&_v - &(itemAt(0))); }
/** * Returns the position in the som of a code vector * Parameter: _v Reference to the code vector */ SomPos FuzzyMap::codVecPos(SomIn& _v) { return indexToPos(&_v - &(itemAt(0))); }