//==== Scale Bounding Box ====// void BndBox::Scale( const vec3d & scale_xyz ) { vec3d center = GetCenter(); for ( int i = 0 ; i < 3 ; i++ ) { m_Min[i] = center[i] + ( m_Min[i] - center[i] ) * scale_xyz[i]; m_Max[i] = center[i] + ( m_Max[i] - center[i] ) * scale_xyz[i]; } }
SuperPill* GOFactory::CreateSuperPill(Tile* p_tile, GameStats* p_gameStats) { fVector3 pos = GetCenter(p_tile, 0.19f); fVector2 size = GetScaledSize(p_tile, 1.5f); SpriteInfo* spriteInfo = CreateSpriteInfo("../Textures/Item_SuperCheesy.png", pos, size, NULL); return new SuperPill(spriteInfo, p_tile, p_gameStats, CreateSoundInfo("../Sounds/use_power-up.wav",100)); }
void EBox::MoveRel(float x, float y) { _x += x; _y += y; _center = GetCenter(); for (int i=0; i<_vChilds.size(); i++) { _vChilds[i]->MoveRel(x,y); } }
void Item::RenderCollisionRegions() { for(unsigned int i = 0; i < m_vpBoundingRegionList.size(); i++) { BoundingRegion* pRegion = m_vpBoundingRegionList[i]; m_pRenderer->PushMatrix(); m_pRenderer->TranslateWorldMatrix(GetCenter().x, GetCenter().y, GetCenter().z); Matrix4x4 justParentRotation; justParentRotation.SetRotation(DegToRad(m_rotation.x), DegToRad(m_rotation.y), DegToRad(m_rotation.z)); m_pRenderer->MultiplyWorldMatrix(justParentRotation); m_pRenderer->ScaleWorldMatrix(m_renderScale, m_renderScale, m_renderScale); pRegion->Render(m_pRenderer); m_pRenderer->PopMatrix(); } }
Trap* GOFactory::CreateTrap(Tile* p_tile, Tilemap* p_map) { fVector3 pos = GetCenter(p_tile, 0.1f); fVector2 size = GetScaledSize(p_tile, 2.0f); SpriteInfo* spriteInfo = CreateSpriteInfo("../Textures/Trap_Spikes.png", pos, size, NULL); return new Trap(spriteInfo, p_tile, p_map); }
void Enemy_01_01::OnWipped() { Enemy::OnWipped(); if (IsInScreen()) { gm.AddObject(new EffectEnemyDead(GetCenter())); dsMgr.playSound(rm.GetSoundBuffer(SOUND_ENEP)); } }
void Heroes::Redraw(Surface & dst, bool with_shadow) const { const Point & mp = GetCenter(); const Interface::GameArea & gamearea = Interface::Basic::Get().GetGameArea(); s16 dx = gamearea.GetMapsPos().x + TILEWIDTH * (mp.x - gamearea.GetRectMaps().x); s16 dy = gamearea.GetMapsPos().y + TILEWIDTH * (mp.y - gamearea.GetRectMaps().y); Redraw(dst, dx, dy, with_shadow); }
void TMesh::Rotate(vector axis, float theta) { vector center = GetCenter(); for (int vi = 0; vi < vertsN; vi++){ //vector d = center - axis; verts[vi].rotatePoint(center, axis, theta); normals[vi].rotateVector(axis, theta); } SetAABB(); }
bool AABB::InsideOf(const Plane& n) const{ vec3 h = (Max - Min)*.5f; vec3 pn(fabs(n.a), fabs(n.b), fabs(n.c)); float e = Dot(h, pn); float s = Dot(GetCenter(), n) + n.d; if(s-e > 0) return true; if(s+e < 0) return false; return true; }
BOOL Bounds::LineIntersection(const Vect &v1, const Vect &v2, float &fT) const { float tMax = M_INFINITE; float tMin = -M_INFINITE; Vect rayVect = (v2-v1); float rayLength = rayVect.Len(); Vect rayDir = rayVect*(1.0f/rayLength); Vect center = GetCenter(); Vect E = Max-center; Vect T = center-v1; for(int i=0; i<3; i++) { float e = T.ptr[i]; float f = rayDir.ptr[i]; float fI = 1.0f/f; if(fabs(f) > 0.0f) { float t1 = (e+E.ptr[i])*fI; float t2 = (e-E.ptr[i])*fI; if(t1 > t2) { if(t2 > tMin) tMin = t2; if(t1 < tMax) tMax = t1; } else { if(t1 > tMin) tMin = t1; if(t2 < tMax) tMax = t2; } if(tMin > tMax) return FALSE; if(tMax < 0.0f) return FALSE; } else if( ((-e - E.ptr[i]) > 0.0f) || ((-e + E.ptr[i]) < 0.0f) ) { return FALSE; } if(tMin > rayLength) return FALSE; } if(tMin > 0.0f) { fT = (tMin/rayLength); return TRUE; } else { fT = (tMax/rayLength); return TRUE; } }
void Heroes::FadeIn(void) const { const Point & mp = GetCenter(); const Interface::GameArea & gamearea = Interface::Basic::Get().GetGameArea(); if(!(gamearea.GetRectMaps() & mp)) return; Display & display = Display::Get(); bool reflect = ReflectSprite(direction); s32 dx = gamearea.GetMapsPos().x + TILEWIDTH * (mp.x - gamearea.GetRectMaps().x); s32 dy = gamearea.GetMapsPos().y + TILEWIDTH * (mp.y - gamearea.GetRectMaps().y); const Sprite & sprite1 = SpriteHero(*this, sprite_index, reflect, false); Point dst_pt1(dx + (reflect ? TILEWIDTH - sprite1.x() - sprite1.w() : sprite1.x()), dy + sprite1.y() + TILEWIDTH); const Rect src_rt = gamearea.RectFixed(dst_pt1, sprite1.w(), sprite1.h()); LocalEvent & le = LocalEvent::Get(); int alpha = 0; while(le.HandleEvents() && alpha < 250) { if(Game::AnimateInfrequentDelay(Game::HEROES_FADE_DELAY)) { Cursor::Get().Hide(); for(s32 y = mp.y - 1; y <= mp.y + 1; ++y) for(s32 x = mp.x - 1; x <= mp.x + 1; ++x) if(Maps::isValidAbsPoint(x, y)) { const Maps::Tiles & tile = world.GetTiles(Maps::GetIndexFromAbsPoint(x, y)); tile.RedrawTile(display); tile.RedrawBottom(display); tile.RedrawObjects(display); } sprite1.Blit(alpha, src_rt, dst_pt1, display); for(s32 y = mp.y - 1; y <= mp.y + 1; ++y) for(s32 x = mp.x - 1; x <= mp.x + 1; ++x) if(Maps::isValidAbsPoint(x, y)) { const Maps::Tiles & tile = world.GetTiles(Maps::GetIndexFromAbsPoint(x, y)); tile.RedrawTop(display); } Cursor::Get().Show(); display.Flip(); alpha += 10; } } }
VOID Bound::Merge( const Bound& Other ) { Sphere OtherSphere; OtherSphere.Center = Other.GetCenter(); OtherSphere.Radius = Other.GetMaxRadius(); if( m_Type == Bound::No_Bound ) { SetSphere( OtherSphere ); return; } Sphere ThisSphere; if( m_Type != Bound::Sphere_Bound ) { // convert this bound into a sphere ThisSphere.Center = GetCenter(); ThisSphere.Radius = GetMaxRadius(); } else { ThisSphere = GetSphere(); } XMVECTOR vThisCenter = XMLoadFloat3( &ThisSphere.Center ); XMVECTOR vOtherCenter = XMLoadFloat3( &OtherSphere.Center ); XMVECTOR vThisToOther = XMVectorSubtract( vOtherCenter, vThisCenter ); XMVECTOR vDistance = XMVector3LengthEst( vThisToOther ); FLOAT fCombinedDiameter = XMVectorGetX( vDistance ) + ThisSphere.Radius + OtherSphere.Radius; if( fCombinedDiameter <= ( ThisSphere.Radius * 2 ) ) { SetSphere( ThisSphere ); return; } if( fCombinedDiameter <= ( OtherSphere.Radius * 2 ) ) { SetSphere( OtherSphere ); return; } XMVECTOR vDirectionNorm = XMVector3Normalize( vThisToOther ); XMVECTOR vRadius = XMVectorSet( ThisSphere.Radius, OtherSphere.Radius, 0, 0 ); XMVECTOR vThisRadius = XMVectorSplatX( vRadius ); XMVECTOR vOtherRadius = XMVectorSplatY( vRadius ); XMVECTOR vCombinedDiameter = vThisRadius + vDistance + vOtherRadius; XMVECTOR vMaxDiameter = XMVectorMax( vCombinedDiameter, vThisRadius * 2 ); vMaxDiameter = XMVectorMax( vMaxDiameter, vOtherRadius * 2 ); XMVECTOR vMaxRadius = vMaxDiameter * 0.5f; ThisSphere.Radius = XMVectorGetX( vMaxRadius ); vMaxRadius -= vThisRadius; XMVECTOR vCombinedCenter = vThisCenter + vMaxRadius * vDirectionNorm; XMStoreFloat3( &ThisSphere.Center, vCombinedCenter ); SetSphere( ThisSphere ); }
void ObjMine::Detection() { uint current_time = GameTime::GetInstance()->ReadSec(); if (escape_time == 0) { escape_time = current_time + static_cast<MineConfig&>(cfg).escape_time; MSG_DEBUG("mine", "Initialize escape_time : %d", current_time); return; } if (current_time < escape_time || animation) return; //MSG_DEBUG("mine", "Escape_time is finished : %d", current_time); Double tmp = PIXEL_PER_METER*static_cast<MineConfig&>(cfg).detection_range; int detection_range = tmp*tmp; FOR_ALL_LIVING_CHARACTERS(team, character) { if (GetCenter().SquareDistance(character->GetCenter()) < detection_range) { Weapon::Message(Format(_("%s is next to a mine!"), character->GetName().c_str())); StartTimeout(); return; } } Double speed_detection = static_cast<MineConfig&>(cfg).speed_detection; Double norm, angle; FOR_EACH_OBJECT(it) { PhysicalObj *obj = *it; if (obj != this && GetName() != obj->GetName() && GetCenter().SquareDistance(obj->GetCenter()) < detection_range) { obj->GetSpeed(norm, angle); if (norm < speed_detection && norm > ZERO) { MSG_DEBUG("mine", "norm: %s, speed_detection: %s", Double2str(norm).c_str(), Double2str(speed_detection).c_str()); StartTimeout(); return; } } } }
bool Ellipsoid::InEllipsoid(const NX::vector<float, 3> &point) const{ const NX::vector<float, 3> v = point - GetCenter(); const float lx = NX::Dot(v, GetAxisX()); const float ly = NX::Dot(v, GetAxisY()); const float lz = NX::Dot(v, GetAxisZ()); const float dx = lx / m_fSemiAxisX; const float dy = ly / m_fSemiAxisY; const float dz = lz / m_fSemiAxisZ; return dx * dx + dy * dy + dz * dz <= kf1; }
int CPlayer::Damage() { g_pResource->sndDamage.Play(0); if(g_pConfig->effect) { g_effect.Add(new CEffect(&g_pResource->imgExplode1,GetCenter(),1,150)); g_effect.Add(new CEffect(&g_pResource->imgSmoke1,GetCenter(),2,140)); } else { g_effect.Add(new CEffect(&g_pResource->imgExplode1,GetCenter(),0,150)); } m_zanki--; m_anmtime = 0; m_state = 2; if(m_zanki<0) return 0; return 1; }
Pill* GOFactory::CreatePill(Tile* p_tile, GameStats* p_gameStats) { fVector3 pos = GetCenter(p_tile, 0.1f); fVector2 size = GetScaledSize(p_tile, 0.7f); SpriteInfo* spriteInfo = CreateSpriteInfo("../Textures/Pill_32.png", pos, size, NULL); return new Pill(spriteInfo, CreateSoundInfo("../Sounds/new_eat_pill_DRIP.wav",100), p_tile, p_gameStats); }
//@cmember Set control window to foreground HRESULT tomEdit::TxSetForegroundWindow() { HWND host = GetCenter()->GetHost() ; if (!SetForegroundWindow(host)) { ::SetFocus(host); } return S_OK ; }
/** *Handles the mouse move event */ void MyGraphicsView::mouseMoveEvent(QMouseEvent* event) { if(!LastPanPoint.isNull()) { //Get how much we panned QPointF delta = mapToScene(LastPanPoint) - mapToScene(event->pos()); LastPanPoint = event->pos(); //Update the center ie. do the pan SetCenter(GetCenter() + delta); } }
void TMesh::ScaleToNewDiagonal(float newDiagonal) { float oldDiagonal = (aabb->corners[1] - aabb->corners[0]).length(); float sf = newDiagonal / oldDiagonal; V3 oldCenter = GetCenter(); Position(V3(0.0f, 0.0f, 0.0f)); Scale(sf); Position(oldCenter); SetAABB(); }
void ISelect::FlipX(Vertex2D * const pvCenter) { GetIEditable()->MarkForUndo(); Vertex2D vCenter; GetCenter(&vCenter); const float delta = vCenter.x - pvCenter->x; vCenter.x -= delta * 2; PutCenter(&vCenter); }
bool OrientedBoxShape::Contains(const sf::Vector2f& Point)const { AlignedBoxShape AlignedB(sf::Vector2f(0.0f, 0.0f), sf::Vector2f(GetHalfExtents().x * 2.0f, GetHalfExtents().y * 2.0f)); sf::Vector2f RotatedPoint = Point - GetCenter(); RotatedPoint = MathUtils::RotateVector(RotatedPoint, - GetRotation()); RotatedPoint = RotatedPoint + GetHalfExtents(); return AlignedB.Contains(RotatedPoint); }
void AABB::GetVertices(FloatDataAccessor & accessor) const { Eigen::Vector3f vertices[8]; vertices[0] = GetCenter(); vertices[0][0] += GetExtent(0); vertices[0][1] += GetExtent(1); vertices[0][2] += GetExtent(2); vertices[1] = GetCenter(); vertices[1][0] -= GetExtent(0); vertices[1][1] += GetExtent(1); vertices[1][2] += GetExtent(2); vertices[2] = GetCenter(); vertices[2][0] -= GetExtent(0); vertices[2][1] -= GetExtent(1); vertices[2][2] += GetExtent(2); vertices[3] = GetCenter(); vertices[3][0] += GetExtent(0); vertices[3][1] -= GetExtent(1); vertices[3][2] += GetExtent(2); vertices[4] = GetCenter(); vertices[4][0] += GetExtent(0); vertices[4][1] += GetExtent(1); vertices[4][2] -= GetExtent(2); vertices[5] = GetCenter(); vertices[5][0] += GetExtent(0); vertices[5][1] -= GetExtent(1); vertices[5][2] -= GetExtent(2); vertices[6] = GetCenter(); vertices[6][0] -= GetExtent(0); vertices[6][1] -= GetExtent(1); vertices[6][2] -= GetExtent(2); vertices[7] = GetCenter(); vertices[7][0] -= GetExtent(0); vertices[7][1] += GetExtent(1); vertices[7][2] -= GetExtent(2); VEC3(accessor[0]) = vertices[0]; VEC3(accessor[1]) = vertices[1]; VEC3(accessor[2]) = vertices[2]; VEC3(accessor[3]) = vertices[3]; VEC3(accessor[4]) = vertices[4]; VEC3(accessor[5]) = vertices[5]; VEC3(accessor[6]) = vertices[6]; VEC3(accessor[7]) = vertices[7]; }
CPlanet::CPlanet() { spriteType_ = PLANET; /* Imageresourcen manager */ CImageResource* imageResource = GetGameClass()->GetImgResource(); /* load pictures */ backgroundStatic_ = new sf::Sprite ( *imageResource->Get ( "images/planet/002.png" ) ); this->SetCenter ( backgroundStatic_->GetSize().x * 0.5, backgroundStatic_->GetSize().y * 0.5 ); backgroundStatic_->SetCenter ( GetCenter() ); shadow_ = new sf::Sprite ( *imageResource->Get ( "images/planet/shadow.png" ) ); shadow_->SetCenter ( GetCenter() ); cloud1_ = new sf::Sprite ( *imageResource->Get ( "images/planet/clouds_001.png" ) ); cloud1_->SetCenter ( GetCenter() ); cloud2_ = new sf::Sprite ( *imageResource->Get ( "images/planet/clouds_002.png" ) ); cloud2_->SetCenter ( GetCenter() ); atmosphere_ = new sf::Sprite ( *imageResource->Get ( "images/planet/atmosphere_001.png" ) ); atmosphere_->SetCenter ( GetCenter() ); /* Set color of planet TODO EXAMPLE DATA! */ planetColor_ = sf::Color ( 160, 220, 255, 255 ); backgroundStatic_->SetColor ( planetColor_ ); atmosphere_->SetColor ( planetColor_ ); /* Add to graphic list */ graphics_.Add ( backgroundStatic_ ); graphics_.Add ( atmosphere_ ); graphics_.Add ( cloud1_ ); graphics_.Add ( cloud2_ ); graphics_.Add ( shadow_ ); /* Set properties */ this->SetZoomFactor( 0.1 ); this->SetZoomLevel ( 0.2 ); }
void Chunk::Render() { if(visible_) { if(GFX->GetCamera()->GetFrustum()->SphereInFrustum(GetCenter(), chunkSize_/1.5f)) { GFX->RenderMesh(meshID_, position_ ); } } }
void Airspaces::SetGroundLevels(const RasterTerrain &terrain) { for (auto v = airspace_tree.begin(); v != airspace_tree.end(); ++v) { FlatGeoPoint c_flat = v->GetCenter(); GeoPoint g = task_projection.unproject(c_flat); short h = terrain.GetTerrainHeight(g); if (!RasterBuffer::IsSpecial(h)) v->set_ground_level((fixed)h); } }
void CBBOX::Scale( float aScale ) { if( m_initialized == false ) return; S3D_VERTEX scaleV = S3D_VERTEX( aScale, aScale, aScale ); S3D_VERTEX centerV = GetCenter(); m_min = (m_min - centerV) * scaleV + centerV; m_max = (m_max - centerV) * scaleV + centerV; }
void ISelect::Translate(Vertex2D *pvOffset) { GetIEditable()->MarkForUndo(); Vertex2D vCenter; GetCenter(&vCenter); vCenter.x += pvOffset->x; vCenter.y += pvOffset->y; PutCenter(&vCenter); }
void CSceneNodeAABB::Render() const{ if(!GetSingleton<CProgram>()->IsInWireFrameMode()) { //glPushAttrib(GL_ALL_ATTRIB_BITS); ////glBegin(); //glEnable(GL_MAP2_VERTEX_3); //vector3 r[4] = { // m_aabb.first , // vector3(m_aabb.first.x,m_aabb.second.y,m_aabb.first.z) , // vector3(m_aabb.second.x,m_aabb.first.y,m_aabb.first.z) , // vector3(m_aabb.second.x,m_aabb.second.y,m_aabb.first.z) //}; //glMap2f( GL_MAP2_VERTEX_3,0.0f,1.0f,6,2,0.0f,1.0f,3,2,(GLfloat*)r); //glMapGrid2f(10,0,1,20,0,1); //glEvalMesh2(GL_FILL,0,10,0,20); ////glEnd(); //glPopAttrib(); vector3 dim(GetDim(m_aabb)); vector3 dx(dim.x,0,0); vector3 dy(0,dim.y,0); vector3 dz(0,0,dim.z); unsigned int nx(dim.x*0.02+1); unsigned int ny(dim.y*0.02+1); unsigned int nz(dim.z*0.02+1); DrawFace(m_aabb.first,dy,dx,ny,nx); DrawFace(m_aabb.first,dx,dz,nx,nz); DrawFace(m_aabb.first,dz,dy,nz,ny); DrawFace(m_aabb.second,-dx,-dy,nx,ny); DrawFace(m_aabb.second,-dy,-dz,ny,nz); DrawFace(m_aabb.second,-dz,-dx,nz,nx); return; } glPushAttrib(GL_TEXTURE_BIT); glPushMatrix(); vector3 center(GetCenter(m_aabb)),dim(GetDim(m_aabb)); glTranslatef(center.x,center.y,center.z); { GLenum coord[2]={GL_S,GL_T}; for(int iCoord(0); iCoord<2; ++iCoord) { float f[4]; glGetTexGenfv(coord[iCoord],GL_OBJECT_PLANE,f); f[0]*=dim.x*0.001f; f[1]*=dim.y*0.001f; f[2]*=dim.z*0.001f; //f[2]*=1000; glTexGenfv(coord[iCoord],GL_OBJECT_PLANE,f); } } glScalef(dim.x,dim.y,dim.z); glutSolidCube(1.0); glPopMatrix(); glPopAttrib(); }
Result PreResult2::GenerateFinalResult(storage::CountryInfoGetter const & infoGetter, CategoriesHolder const * pCat, set<uint32_t> const * pTypes, int8_t locale, ReverseGeocoder const * coder) const { string name = m_str; if (coder && name.empty()) { // Insert exact address (street and house number) instead of empty result name. ReverseGeocoder::Address addr; coder->GetNearbyAddress(GetCenter(), addr); if (addr.GetDistance() == 0) name = FormatStreetAndHouse(addr); } uint32_t const type = GetBestType(pTypes); // Format full address only for suitable results. string address; if (coder) { address = GetRegionName(infoGetter, type); if (ftypes::IsAddressObjectChecker::Instance()(m_types)) { ReverseGeocoder::Address addr; coder->GetNearbyAddress(GetCenter(), addr); address = FormatFullAddress(addr, address); } } switch (m_resultType) { case RESULT_FEATURE: case RESULT_BUILDING: return Result(m_id, GetCenter(), name, address, pCat->GetReadableFeatureType(type, locale), type, m_metadata); default: ASSERT_EQUAL(m_resultType, RESULT_LATLON, ()); return Result(GetCenter(), name, address); } }
void EllipseGeometry::Build () { double rx = GetRadiusX (); double ry = GetRadiusY (); Point *pt = GetCenter (); double x = pt ? pt->x : 0.0; double y = pt ? pt->y : 0.0; path = moon_path_renew (path, MOON_PATH_ELLIPSE_LENGTH); moon_ellipse (path, x - rx, y - ry, rx * 2.0, ry * 2.0); }