void CStalkerAnimationManager::play_legs () { float speed = 0.f; bool first_time = !legs().animation(); bool result = legs().animation(assign_legs_animation()); if (!first_time && !result && legs().blend()) { float amount = legs().blend()->blendAmount; m_previous_speed = (m_current_speed - m_previous_speed)*amount + m_previous_speed; } legs().play (m_skeleton_animated,legs_play_callback,&object(),!fis_zero(m_current_speed),false); if (result && legs().blend()) { float amount = legs().blend()->blendAmount; speed = (m_current_speed - m_previous_speed)*amount + m_previous_speed; } if (fis_zero(speed)) return; if (!legs().blend()) return; object().movement().setup_speed_from_animation (speed); }
void Table::draw() { GLVector<XYZW> bottom_left = GLVector<XYZW>(-.5, -.5, 0, 1); GLVector<XYZW> top_left = GLVector<XYZW>(-.5, .5, 0, 1); GLVector<XYZW> top_right = GLVector<XYZW>(.5, .5, 0, 1); GLVector<XYZW> bottom_right = GLVector<XYZW>(.5, -.5, 0, 1); // glEnable(GL_RESCALE_NORMAL); // TODO Needed? rotate_from(rotation_[0], rotation_[1], rotation_[2], origin_[0], origin_[1], origin_[2]); glScalef(scale_[0], scale_[1], scale_[2]); GLMatrix mv; glGetDoublev(GL_MODELVIEW_MATRIX, mv); /* local_axis_[0] = (mv * GLVector<XYZW>::XVec); local_axis_[1] = (mv * GLVector<XYZW>::YVec); local_axis_[2] = (mv * GLVector<XYZW>::ZVec); */ set_material_color(1, 1); short_border(); long_border(); plank(); set_material_color(1, 2); legs(); glPopMatrix(); }
void display(){ // Clear screen and Z-buffer glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glEnable(GL_COLOR_MATERIAL); // Reset transformations glLoadIdentity(); // Other Transformations glTranslatef( 0.0, -0.8, 0.0 ); glRotatef( -10, 1.0, 0.0, 0.0 ); // Rotate when user changes rotate_x and rotate_y glRotatef( rotate_x, 1.0, 0.0, 0.0 ); glRotatef( rotate_y, 0.0, 1.0, 0.0 ); // Other Transformations // glScalef( 2.0, 2.0, 0.0 ); // Not included helper(); legs(); hips(); torso(); arms(tangan_l); head(); glFlush(); glutSwapBuffers(); }
IC void CStalkerAnimationManager::play_script_impl() { clear_unsafe_callbacks(); global().reset(); torso().reset(); legs().reset(); const CStalkerAnimationScript &selected = assign_script_animation(); script().animation(selected.animation()); if (selected.use_movement_controller()) { script().target_matrix(selected.transform(object())); if (m_start_new_script_animation) { m_start_new_script_animation = false; if (selected.has_transform() && object().animation_movement()) object().destroy_anim_mov_ctrl(); } } script().play( m_skeleton_animated, script_play_callback, selected.use_movement_controller(), selected.local_animation(), false, m_script_bone_part_mask ); head().animation(assign_head_animation()); head().play(m_skeleton_animated, head_play_callback, false, false); }
// 将GPS坐标转化成为Sogou坐标 static Point _gpsToSogou(const double lo, const double la) { int i; Point result; int n = 9; double matA[9][PARAM_NUM]; double matAA[PARAM_NUM][PARAM_NUM]; double los[9], las[9]; double los1[PARAM_NUM], las1[PARAM_NUM]; double coeffs1[PARAM_NUM], coeffs2[PARAM_NUM]; int indx[PARAM_NUM]; // 统一坐标系统 double lng = (lo - 72.0) * 20; double lat = (la - 10.0) * 20; int idxLng = (int)lng; int idxLat = (int)lat; idxLng = min(max(idxLng, 1), 1318); idxLat = min(max(idxLat, 1), 898); int idx = idxLng * 900 + idxLat; for (i = 0; i < 9; i++) { int newidx = offsets[i] + idx; int y = newidx / 900; // y为纵向 表示lng int x = newidx % 900; // x为横向, 表示lat PointInt2D* pt = &gps2Sogo[y][x]; matA[i][0] = y; matA[i][1] = x; matA[i][2] = 1; los[i] = pt->lo; las[i] = pt->la; } matrix_mul_aa(matA, matAA, n); matrix_mul_ab(matA, los, los1, n); matrix_mul_ab(matA, las, las1, n); // matAA * coeffs1 = los1 // matAA * coeffs2 = las1 legs (matAA, PARAM_NUM, los1, coeffs1, las1, coeffs2, indx); result.lo = (coeffs1[0] * lng + coeffs1[1] * lat + coeffs1[2]); result.la = (coeffs2[0] * lng + coeffs2[1] * lat + coeffs2[2]); #ifdef PARAM_TEST printf("Params: (%9.6f, %9.6f, %15.6f) (%9.6f, %9.6f, %15.6f)\n", coeffs1[0], coeffs1[1], coeffs1[2], coeffs2[0], coeffs2[1], coeffs2[2]); #endif // printf("After Interpolation: %.5f %.5f\n", result.lo, result.la); return result; }
IC void CStalkerAnimationManager::play_global_impl (const MotionID &animation, bool const &animation_movement_controller) { head().reset (); torso().reset (); legs().reset (); global().animation (animation); global().play (m_skeleton_animated,global_play_callback,false,false,false); }
IC void CStalkerAnimationManager::play_global_impl (const MotionID &animation) { head().reset (); torso().reset (); legs().reset (); global().animation (animation); global().play (m_skeleton_animated,global_play_callback,&object(),false); }
IC void CStalkerAnimationManager::play_script_impl () { global().reset (); head().reset (); torso().reset (); legs().reset (); script().animation (assign_script_animation()); script().play (m_skeleton_animated,script_play_callback,&object(),false); }
IC void CStalkerAnimationManager::play_global_impl (const MotionID &animation) { torso().reset (); legs().reset (); global().animation (animation); global().play (m_skeleton_animated,global_play_callback,&object(),false,false,m_script_bone_part_mask); head().animation (assign_head_animation()); head().play (m_skeleton_animated,head_play_callback,&object(),false); }
IC void CStalkerAnimationManager::play_script_impl () { global().reset (); torso().reset (); legs().reset (); const CStalkerAnimationScript &selected = assign_script_animation(); script().animation (selected.animation()); script().play (m_skeleton_animated,script_play_callback,&object(),selected.use_movement_controller(),false,m_script_bone_part_mask); head().animation (assign_head_animation()); head().play (m_skeleton_animated,head_play_callback,&object(),false); }
void operatorControl() { while (true) { calibrate(); handleLocks(); handleLcdButtons(); legs(); int shouldshoot = 0; while (joystickGetDigital(1, 7, JOY_LEFT)){ shouldshoot = 1; } //start the shoot loop if (shouldshoot){ shootgo = 1; bot = shoot; shootLoop(); } int shouldlift = 0; while (joystickGetDigital(2, 8, JOY_LEFT)){ shouldlift = 1; } if (shouldlift){ if (bot == lift){ bot = control; } else { bot = lift; } } if (bot == control){ if (joystickGetDigital(1, 8, JOY_LEFT)){ shootLeft(); } if (joystickGetDigital(1, 8, JOY_RIGHT)){ shootRight(); } } delay(25); } }
static Point interpolation(double lo, double la, Node heap[NEIBOR_NUM]) { int i; const Point2 *pt2; Point result; int n; double matA[NEIBOR_NUM][PARAM_NUM]; double matAA[PARAM_NUM][PARAM_NUM]; double los[NEIBOR_NUM], las[NEIBOR_NUM]; double los1[PARAM_NUM], las1[PARAM_NUM]; double coeffs1[PARAM_NUM], coeffs2[PARAM_NUM]; int indx[PARAM_NUM]; for (i = 0; i < NEIBOR_NUM; i++) { pt2 = heap[i].pt; //printf("%d %d %d %d\n", pt2->lo0, pt2->la0, pt2->lo1, pt2->la1); matA[i][0] = pt2->lo0; matA[i][1] = pt2->la0; matA[i][2] = 1; los[i] = pt2->lo1; las[i] = pt2->la1; } n = NEIBOR_NUM; matrix_mul_aa(matA, matAA, n); matrix_mul_ab(matA, los, los1, n); matrix_mul_ab(matA, las, las1, n); // matAA * coeffs1 = los1 // matAA * coeffs2 = las1 legs (matAA, PARAM_NUM, los1, coeffs1, las1, coeffs2, indx); result.lo = (coeffs1[0] * lo + coeffs1[1] * la + coeffs1[2]); // * INVERSE_SCALE; result.la = (coeffs2[0] * lo + coeffs2[1] * la + coeffs2[2]); // * INVERSE_SCALE; #ifdef PARAM_TEST printf("Params: (%9.6f, %9.6f, %15.6f) (%9.6f, %9.6f, %15.6f)\n", coeffs1[0], coeffs1[1], coeffs1[2], coeffs2[0], coeffs2[1], coeffs2[2]); #endif // printf("After Interpolation: %.5f %.5f\n", result.lo, result.la); return result; }
void CStalkerAnimationManager::add_animation_stats () { std::pair<LPCSTR,LPCSTR> blend; if (script().animation()) { add_animation_stats (m_skeleton_animated->LL_MotionDefName_dbg(script().animation()),script().blend_id(m_skeleton_animated,blend),script().m_just_started); return; } if (global().animation()) { add_animation_stats (m_skeleton_animated->LL_MotionDefName_dbg(global().animation()),global().blend_id(m_skeleton_animated,blend),global().m_just_started); return; } // add_animation_stats (m_skeleton_animated->LL_MotionDefName_dbg(head().animation()),head().blend_id(m_skeleton_animated,blend),head().m_just_started); add_animation_stats (m_skeleton_animated->LL_MotionDefName_dbg(torso().animation()),torso().blend_id(m_skeleton_animated,blend),torso().m_just_started); add_animation_stats (m_skeleton_animated->LL_MotionDefName_dbg(legs().animation()),legs().blend_id(m_skeleton_animated,blend),legs().m_just_started); }
IC void CStalkerAnimationManager::play_global_impl(const MotionID &animation, bool const &animation_movement_controller) { torso().reset(); legs().reset(); global().animation(animation); global().play( m_skeleton_animated, global_play_callback, animation_movement_controller, true, false, m_script_bone_part_mask, true ); if (m_global_modifier) m_global_modifier(global().blend()); head().animation(assign_head_animation()); head().play(m_skeleton_animated, head_play_callback, false, false); }
void CStalkerAnimationManager::reload (CAI_Stalker *_object) { m_object = _object; m_visual = object().Visual(); m_crouch_state_config = object().SpecificCharacter().crouch_type(); VERIFY ((m_crouch_state_config == 0) || (m_crouch_state_config == 1) || (m_crouch_state_config == -1)); m_crouch_state = m_crouch_state_config; if (object().already_dead()) return; m_skeleton_animated = smart_cast<CKinematicsAnimated*>(m_visual); VERIFY (m_skeleton_animated); m_data_storage = stalker_animation_data_storage().object(m_skeleton_animated); VERIFY (m_data_storage); if (!object().g_Alive()) return; #ifdef USE_HEAD_BONE_PART_FAKE VERIFY (!m_data_storage->m_head_animations.A.empty()); u16 bone_part = m_skeleton_animated->LL_GetMotionDef(m_data_storage->m_head_animations.A.front())->bone_or_part; VERIFY (bone_part != BI_NONE); m_script_bone_part_mask = CStalkerAnimationPair::all_bone_parts ^ (1 << bone_part); #endif assign_bone_callbacks (); #ifdef DEBUG global().set_dbg_info (*object().cName(),"Global"); head().set_dbg_info (*object().cName(),"Head "); torso().set_dbg_info (*object().cName(),"Torso "); legs().set_dbg_info (*object().cName(),"Legs "); script().set_dbg_info (*object().cName(),"Script"); #endif };
void robot(int t, int T) { #define robot_fall_speed 2048 #define robot_start 40 t *= 402; // ast = |sin(t)| int ast = sin(t); if ( ast < 0 ) ast = -ast; // act = |cos(t)| int act = cos(t); if ( act < 0 ) act = -act; int fall; // head push(); // translate(0, 0.71+0.05*abs(sin(t)), 0.04); fall = (robot_start+88)*robot_fall_speed - T*robot_fall_speed; if ( fall < 0 ) fall = 0; translate(0, 2908+((ast*204)>>12)+fall, 164); // rotateX(-5°+10°*abs(cos(t))); rotateX((-357+715*act)>>12); // scale(0.2, 0.2, 0.2); scale(819, 819, 819); cube(); pop(); // body push(); // translate(0, 0.05*abs(sin(t)), 0); fall = (robot_start+48)*robot_fall_speed - T*robot_fall_speed; if ( fall < 0 ) fall = 0; translate(0, ((ast*204)>>12)+fall, 0); // rotateY(2.5°-5°*cos(t)); rotateY(179-((357*cos(t))>>12)); // scale(0.3, 0.5, 0.17); scale(1229, 2048, 696); cube(); pop(); // left side push(); fall = (robot_start+56)*robot_fall_speed - T*robot_fall_speed; if ( fall < 0 ) fall = 0; translate(0, fall, 0); arms(t, -1); pop(); push(); fall = (robot_start+8)*robot_fall_speed - T*robot_fall_speed; if ( fall < 0 ) fall = 0; translate(0, fall, 0); legs(t, -1); pop(); // right side t += 12868; push(); fall = (robot_start+64)*robot_fall_speed - T*robot_fall_speed; if ( fall < 0 ) fall = 0; translate(0, fall, 0); arms(t, 1); pop(); push(); fall = (robot_start+24)*robot_fall_speed - T*robot_fall_speed; if ( fall < 0 ) fall = 0; translate(0, fall, 0); legs(t, 1); pop(); }
// Clears the window and draws the torus. void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(rotate_x, 1.0, 0.0, 0.0); glRotatef(rotate_y, 0.0, 1.0, 0.0); glScaled(zoom, zoom, zoom); // Draw a red x-axis, a green y-axis, and a blue z-axis. Each of the // axes are ten units long. glBegin(GL_LINES); glColor3f(1, 0, 0); glVertex3f(0, 0, 0); glVertex3f(10, 0, 0); glColor3f(0, 1, 0); glVertex3f(0, 0, 0); glVertex3f(0, 10, 0); glColor3f(0, 0, 1); glVertex3f(0, 0, 0); glVertex3f(0, 0, 10); glEnd(); // Road cube road(point(),2); road.scale(1.0,0.0,10.0); // road.rotate(point(0.0,0.0,0.0), point(1.0,0.0,0.0), 90.0); road.render(); // Home cube home(point(),4); home.translate(point(5.0,2,5.0)); home.setColor (1.0,0.0,0.0); home.render(); /* cube door(point(),2); door.translate(point(5.0,1,7.0)); door.scale(0.25,1,0.25); door.setColor (0.0,0.0,0.0); door.render(); */ // Tree cube trunk(point(0.0,2,0.0),4); trunk.scale(0.25,1,0.25); sphere tree(point(0.0,5.0,0.0),2.0); tree.translate(point(-2.0,0,0)); trunk.translate(point(-2.0,0,0)); tree.setColor (0.0f, 1.0f, 0.0); tree.render(); trunk.render(); // Body sphere tummy(point(),1.0); sphere head(point(0.0,1.0,0.0),0.25); tummy.scale(0.25,1.0,0.25); tummy.translate(point(3.0,0.75,-3.0)); head.translate(point(3.0,0.5,-3.0)); tummy.setColor (0,0,0); // black head.setColor (1,0,0); // red tummy.render(); head.render(); // hands cube hand(point(),0.4); hand.scale(1.0,0.0,1.0); hand.translate(point(3.0,0.75,-3.0)); hand.setColor (0.0,1.0,1.0); hand.render(); // legs cube legs(point(),0.4); // legs.scale(1.0,0.0,0.25); legs.translate(point(3.0,-0.2,-3.0)); legs.setColor (0.0,1.0,1.0); legs.render(); glFlush(); glutSwapBuffers(); }