void GazeComponent::executeEvent(GameEvent *event) { switch(event->id()) { case GameEvent::AG_GAZE: { // Get event data AgentGazeData* data = static_cast<AgentGazeData*>(event->data()); switch(data->m_type) { case AgentGazeData::GazeToPoint: data->m_returnI = gaze(data->m_targetV.x, data->m_targetV.y, data->m_targetV.z, (data->m_speed >= 0)? data->m_speed : m_speed, data->m_duration); break; case AgentGazeData::GazeToEntity: data->m_returnI = gaze(data->m_targetI, (data->m_speed >= 0)? data->m_speed : m_speed, data->m_duration); break; } break; } case GameEvent::AG_HEADNOD: case GameEvent::AG_HEADSHAKE: { // Get event data AgentGazeData* data = static_cast<AgentGazeData*>(event->data()); headShake(data->m_axis, data->m_extent, data->m_count, data->m_speed, data->m_duration ); break; } case GameEvent::AG_GAZE_GET_STATUS: { // Get event data AgentGazeData* data = static_cast<AgentGazeData*>(event->data()); data->m_returnI = getStatus(data->m_gazeID); break; } case GameEvent::AG_GAZE_GET_SPEED: { // Get event data AgentGazeData* data = static_cast<AgentGazeData*>(event->data()); data->m_returnF = getGazeSpeed(); break; } case GameEvent::AG_GAZE_SET_SPEED: { // Get event data float* data = static_cast<float*>(event->data()); setGazeSpeed(*data); break; } } }
int main(int argc, char **argv) { ros::init(argc, argv, "gaze"); ros::NodeHandle nh_; GazeSimulation gaze(ros::this_node::getName(),nh_); ros::AsyncSpinner spinner(4); spinner.start(); ros::waitForShutdown(); spinner.stop(); return 0; }
// initilize scene // load obj files, set lights, camera void initScene(const std::string& textureName) { // for loading triangle mesh Matrix4x4 matrix; loadObj(objName.c_str(), vertices, normals, texcoord, mesh); matrix.m[2][3] = -9.f; matrix.m[1][3] = 0.f; Transform* tr = new Transform(matrix); trfList.push_back(tr); Mesh* newmesh = new Mesh(tr, &vertices, &normals, &mesh); objList.push_back(newmesh); // object initialize, for sphere /*Matrix4x4 mat; mat.m[2][3] = -16.f; Transform* tr2 = new Transform(mat); trfList.push_back(tr2); Sphere *sphere1 = new Sphere(tr2, 6.f); objList.push_back(sphere1);*/ // initialize image plane intensity = new float[WINX * WINY * 3]; memset(intensity, 0, WINX*WINY * 3 * sizeof(float)); // set up the camera Point camCenter, camLookAt(0.f, 0.f, -1.f); Vector camUp(0.f, 1.f, 0.f); float fovy = 60.f; camera = new PerspectiveCamera(camCenter, camLookAt, camUp, fovy); // set up the projectionLight Point e(-1.5f, 3.f, 15.f), gaze(-1.2f, 1.3f, 0.f); Vector up(0.f, 0.9f, 0.43589f); /* For sphere ray tracing test */ /*Point e(0.f, 0.f, 7.f), gaze(.0f, 0.f, -1.f); Vector up(0.f, 1.f, 0.f);*/ Transform light2world = LookAt(e, gaze, up); //string texname("grid.jpg"); float projFovy = 20.0; ProjectionLight *projector = new ProjectionLight(Inverse(light2world), textureName, projFovy); // set up the sampler sampler = new SimpleSampler(WINX, WINY); scene = new Scene(sampler, camera, &objList, projector, WINX, WINY); }