Valentine::Valentine( iXY initial_loc, unsigned char color, unsigned char flag ) : Vehicle( initial_loc ) { setUnitProperties(); if ( color == false) { body_anim.setData( gValentineBody ); turret_anim.setData( gValentineTurret ); } else { body_anim.setData( gValentineBodyDarkBlue ); turret_anim.setData( gValentineTurretDarkBlue ); } body_anim.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); turret_anim.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); body_anim_shadow.setData( gValentineBodyShadow ); turret_anim_shadow.setData( gValentineTurretShadow ); body_anim_shadow.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); turret_anim_shadow.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); select_info_box.setBoxAttributes( BoundBox( -20, -20, 20, 20), Color::blue ); select_info_box.setBoxState( false ); select_info_box.setFlag( flag ); body_anim_shadow.attachSprite( &body_anim, iXY(0,0) ); body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) ); }
BoundBox BoundBox::Translate( const Vector2& rel ) const { return BoundBox(this->xMin + rel.x, this->yMin + rel.y, this->xMax + rel.x, this->yMax + rel.y); }
Player::Player() : m_CanJump(false), m_ClimbingLadder(false) { m_Bound = BoundBox(-0.5f * m_sCharSize, -0.5f * m_sCharSize, 0.5f * m_sCharSize, 0.5f * m_sCharSize); }
Leopard::Leopard(PlayerState* player, UnitID id, iXY initial_loc, unsigned char color, unsigned char flag ) : Vehicle(player, id, initial_loc) { setUnitProperties(); if ( color == false) { body_anim.setData( gLeopardBody ); turret_anim.setData( gLeopardTurret ); } else { body_anim.setData( gLeopardBodyDarkBlue ); turret_anim.setData( gLeopardTurretDarkBlue ); } body_anim.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); turret_anim.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); body_anim_shadow.setData( gLeopardBodyShadow ); turret_anim_shadow.setData( gLeopardTurretShadow ); body_anim_shadow.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); turret_anim_shadow.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); select_info_box.setBoxAttributes( BoundBox( -25, -25, 25, 25), Color::blue ); select_info_box.setBoxState( false ); select_info_box.setFlag( flag ); body_anim_shadow.attachSprite( &body_anim, iXY(0,0) ); body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) ); }
void Physics::step( real_t dt ) { // step the world forward by dt. Need to detect collisions, apply // forces, and integrate positions and orientations. for(size_t i=0; i<num_spheres(); i++){ //Update Spheres boundbox Vector3 upper = spheres[i]->position + Vector3(spheres[i]->radius, spheres[i]->radius, spheres[i]->radius); Vector3 lower = spheres[i]->position - Vector3(spheres[i]->radius, spheres[i]->radius, spheres[i]->radius); spheres[i]->bound = BoundBox(lower, upper); for(size_t j=0; j<num_spheres(); j++){ if(i!=j){ collides(*spheres[i], *spheres[j], collision_damping); } } for(size_t j=0; j<num_planes(); j++){ collides(*spheres[i], *planes[j], collision_damping); } for(size_t j=0; j<num_triangles(); j++){ collides(*spheres[i], *triangles[j], collision_damping); } for(size_t j=0; j<num_models(); j++){ collides(*spheres[i], *models[j], collision_damping); } //RK4 Position & Orientation rk4_update(*spheres[i], dt); spheres[i]->clear_force(); } }
void ObjectiveInterface::loadObjectiveList(const char *file_path) { if ( ! GameConfig::game_enable_bases ) { return; } ObjectiveID objective_count = 0; try { IFileStream in(file_path); cleanUpObjectiveList(); std::string objectivecount = readToken(in, "ObjectiveCount:"); std::stringstream ss(objectivecount); ss >> objective_count; if ( objective_count > 0 ) { objective_list = new Objective*[objective_count]; num_objectives = 0; } iXY loc; iXY world; std::string name; for (ObjectiveID objective_index = 0; objective_index < objective_count; objective_index++ ) { Objective *objective_obj; name = readToken(in, "Name:"); std::string location = readToken(in, "Location:"); std::stringstream ss(location); ss >> loc.x >> loc.y; MapInterface::mapXYtoPointXY( loc, world ); objective_obj = new Objective(objective_index, world, BoundBox( -48, -32, 48, 32 ) ); strcpy(objective_obj->name, name.c_str()); objective_list[objective_index] = objective_obj; ++num_objectives; } // ** for } catch(std::exception& e) { cleanUpObjectiveList(); LOGGER.warning("OILOL Error loading objectives '%s': %s. Working without them", file_path, e.what()); } }
void ObjectiveInterface::loadObjectiveList(const char *file_path) { ObjectiveID objective_count = 0; try { IFileStream in(file_path); cleanUpObjectiveList(); std::string objectivecount = readToken(in, "ObjectiveCount:"); std::stringstream ss(objectivecount); ss >> objective_count; LOGGER.warning("There are %d objectives", objective_count); size_t loc_x, loc_y; size_t world_x, world_y; std::string name; cleanUpObjectiveList(); for (ObjectiveID objective_index = 0; objective_index < objective_count; objective_index++ ) { Objective *objective_obj; name = readToken(in, "Name:"); std::string location = readToken(in, "Location:"); std::stringstream ss(location); ss >> loc_x >> loc_y; LOGGER.warning("\t%s in %lu,%lu", name.c_str(), (unsigned long)loc_x, (unsigned long)loc_y); MapInterface::mapXYtoPointXY( loc_x, loc_y, &world_x, &world_y ); LOGGER.warning("\t\tin world %lu,%lu", (unsigned long)world_x, (unsigned long)world_y); objective_obj = new Outpost(objective_index, iXY(world_x, world_y), BoundBox( -48, -32, 48, 32 ) ); strcpy(objective_obj->objective_state.name, name.c_str()); objective_list.push_back(objective_obj); } // ** for } catch(std::exception& e) { throw Exception("Error while reading outpost definition '%s': %s", file_path, e.what()); } }
BoundBox CMeshObjects::ComputeBoundBox(const D3DXMATRIX* mat) const { if (m_meshes.size() == 0) return BoundBox(); m_meshes[0]->ComputeBoundBox(mat); BoundBox box = m_meshes[0]->GetBoundBox(); for (size_t i = 1; i < m_meshes.size(); i++) { m_meshes[i]->ComputeBoundBox(mat); BoundBox bbox = m_meshes[i]->GetBoundBox(); //printf("%s -> (%g %g %g) - (%g %g %g)\n", m_meshes[i]->GetName(), bbox.minPoint.x, // bbox.minPoint.y, bbox.minPoint.z, bbox.maxPoint.x, bbox.maxPoint.y, bbox.maxPoint.z); box = BoundBox::unionBoxes(box, m_meshes[i]->GetBoundBox()); } return box; }
TriangleBody::TriangleBody(Vector3 a, Vector3 b, Vector3 c){ vertices[0] = a; vertices[1] = b; vertices[2] = c; orientation = Quaternion::Identity(); velocity = Vector3::Zero(); type = TRIANGLEBODY; real_t max_x = std::max(vertices[0].x, std::max(vertices[1].x, vertices[2].x)); real_t max_y = std::max(vertices[0].y, std::max(vertices[1].y, vertices[2].y)); real_t max_z = std::max(vertices[0].z, std::max(vertices[1].z, vertices[2].z)); Vector3 upper(max_x, max_y, max_z); real_t min_x = std::min(vertices[0].x, std::min(vertices[1].x, vertices[2].x)); real_t min_y = std::min(vertices[0].y, std::min(vertices[1].y, vertices[2].y)); real_t min_z = std::min(vertices[0].z, std::min(vertices[1].z, vertices[2].z)); Vector3 lower(min_x, min_y, min_z); bound = BoundBox(lower, upper); }
Lynx::Lynx( PointXYi initial_loc, unsigned char color, unsigned char flag ) : Vehicle( initial_loc ) { setUnitProperties(); if ( color == false) { body_anim.setData( gLynxBody ); turret_anim.setData( gLynxTurret ); } else { body_anim.setData( gLynxBodyDarkBlue ); turret_anim.setData( gLynxTurretDarkBlue ); } body_anim.setAttrib( PointXYi(0,0), PointXYi(0,0), unitLayer ); turret_anim.setAttrib( PointXYi(0,0), PointXYi(0,0), unitLayer ); body_anim_shadow.setData( gLynxBodyShadow ); turret_anim_shadow.setData( gLynxTurretShadow ); body_anim_shadow.setAttrib( PointXYi(0,0), PointXYi(0,0), unitLayer ); turret_anim_shadow.setAttrib( PointXYi(0,0), PointXYi(0,0), unitLayer ); select_info_box.setBoxAttributes( BoundBox( -30, -30, 30, 30), Color::blue ); select_info_box.setBoxState( false ); select_info_box.setFlag( flag ); body_anim_shadow.attachSprite( &body_anim, PointXYi(0,0) ); body_anim_shadow.attachSprite( &turret_anim_shadow, PointXYi(0,0) ); body_anim_shadow.attachSprite( &turret_anim, PointXYi(0,0) ); body_anim_shadow.attachSprite( &select_info_box, PointXYi(0,0) ); //FLAGS_DBASE.get_sprite_index( flag, select_info_box.unit_flag ); //FLAGS_DBASE.get_sprite_name( "allie", select_info_box.allie_flag ); }
void CCubeBox::ComputeBoundBox() { m_boundBox = BoundBox(Point3(m_Vertices[0].x, m_Vertices[0].y, m_Vertices[0].z), Point3(m_Vertices[5].x, m_Vertices[5].y, m_Vertices[5].z)); }
Patient::Patient() : m_WorldId(1) { m_Bound = BoundBox(-0.45f, -0.45f, 0.45f, 0.45f); }