void CBoomRockManBullet::Update(CTimer* gameTime) { if (_deltaTimeExplode == 0) { bool hasCollideHorizontal = false; if (_collideLeft._object != NULL) { _position.x += _v.x*_collideLeft._timeCollide; _v.x = 0.0f; _a.x = 0.0f; hasCollideHorizontal = true; } if (_collideRight._object != NULL) { _position.x += _v.x*_collideRight._timeCollide; _v.x = 0.0f; _a.x = 0.0f; hasCollideHorizontal = true; } if (_collideUp._object != NULL) { _position.y += _v.y*_collideUp._timeCollide-1; _v.y = 0.0f; }if (_collideDown._object != NULL) { _position.y += _v.y*_collideDown._timeCollide; _velocityYDefault /= 2.0f; if (_velocityYDefault > ROCK_BOOM_BULLET_VERLOCITY_Y/100) _v.y = _velocityYDefault; else{ _typeID = ID_BULLET_ROCKMAN_BOOM; _deltaTimeExplode = 1; // Tăng lên một để đảm bảo là đếm thời gian bắt đầu phát nổ CExplodingEffectManager::Add(new CExplodingEffectX(_position, ResourceManager::GetSprite(ID_SPRITE_BOOMMAN_BOOM_BURST),false)); UpdateBox(); } } _position += _v*gameTime->GetTime(); _v += _a*gameTime->GetTime(); UpdateBox(); _collideLeft = CollisionInfo(NULL, CDirection::ON_LEFT, 100); _collideRight = CollisionInfo(NULL, CDirection::ON_RIGHT, 100); _collideUp = CollisionInfo(NULL, CDirection::ON_UP, 100); _collideDown = CollisionInfo(NULL, CDirection::ON_DOWN, 100); } else { _deltaTimeExplode += gameTime->GetTime(); if (_deltaTimeExplode >= 1000) Destroy(); } _sprite.Update(gameTime); }
int CEnemyWallShooter::Initlize() { _origin = D3DXVECTOR2(_size.x / 2, _size.y / 2); _sprite.SetIndex(0); UpdateBox(); return 1; }
CBoomRockManBullet::CBoomRockManBullet(Megaman* master) : CBullet(0, ID_BULLET_ROCKMAN_BOOM_NONE, ResourceManager::GetSprite(ID_SPRITE_BULLET_BOSS_BOOM), 10, D3DXVECTOR2(0,0), master->_position) { _master = master; // Tính lại vị trí xuất hiện của đạn _position.y = _master->GetBox()._y; if (_master->_isRight) { _position.x += _master->GetBox()._width ; _v.x = ROCK_BOOM_BULLET_VERLOCITY_X; _a.x = -ROCKMAN_ACCELERATE_X; _velocityYDefault=_v.y = ROCK_BOOM_BULLET_VERLOCITY_Y; _a.y = -ROCK_BOOM_BULLET_ACCELERATE_Y; } else { _position.x -= _master->GetBox()._width; _v.x = -ROCK_BOOM_BULLET_VERLOCITY_X; _a.x = ROCKMAN_ACCELERATE_X; _velocityYDefault = _v.y = ROCK_BOOM_BULLET_VERLOCITY_Y; _a.y = -ROCK_BOOM_BULLET_ACCELERATE_Y; } UpdateBox(); _isChangeSprite = false; _collideLeft = CollisionInfo(NULL, CDirection::ON_LEFT, 100); _collideRight = CollisionInfo(NULL, CDirection::ON_RIGHT, 100); _collideUp = CollisionInfo(NULL, CDirection::ON_UP, 100); _collideDown = CollisionInfo(NULL, CDirection::ON_DOWN, 100); }
void TEXTEDITBOX::GetInput(char Stringx[100]){ MSG Msg; //save the original programflow variable to change it back later. int ProgramFlowTemp=Pass.ProgramFlow; Pass.ProgramFlow=PF_TEXTEDITBOX; Info=TEBI_NOTHING; //display the text box on the screen. //message loop while(Info!=TEBI_DONE){ UpdateBox(); if(!GetMessage(&Msg, NULL, 0, 0)){ //if they're trying to quit... Pass.SettingsInfo=SETTINGS_EXIT; Pass.ProgramFlow=PF_EXIT; Info=TEBI_DONE; } TranslateMessage(&Msg); DispatchMessage(&Msg); } if(Pass.ProgramFlow!=PF_EXIT) Pass.ProgramFlow=ProgramFlowTemp; //now put the screen back together again. Blit(Pass.DDFront, StorageSurface, 0, 0, TEXTENTRYBOX_WIDTH, TEXTENTRYBOX_HEIGHT, TEXTENTRYBOX_LEFT, TEXTENTRYBOX_TOP); Blit(Pass.DDBack, StorageSurface, 0, 0, TEXTENTRYBOX_WIDTH, TEXTENTRYBOX_HEIGHT, TEXTENTRYBOX_LEFT, TEXTENTRYBOX_TOP); lstrcpy(Stringx, String); }
//------------------------------------------------------------------------------ CRenderAudio::CRenderAudio(const CRegionAI& AudioInfo,const SString& AudioName,ILogicHandler* pHandler) : CRenderNode(pHandler),m_uUnitSetIndex(0) { m_pAEmitter = GetAudioModule()->CreateAudioEmitter(); m_pAEmitter->SetAutoStop(true); m_uUnitSetIndex = AudioInfo.SetIndex; SetPosition(AudioInfo.cX,AudioInfo.cY,AudioInfo.cZ); m_bPlayNotRepeat = AudioInfo.bPlayNotRepeat; m_uPlayTimeLenMin = AudioInfo.uPlayTimeLenMin; m_uPlayTimeLenMax = AudioInfo.uPlayTimeLenMax; m_uPlayIntervalMin = AudioInfo.uPlayIntervalMin; m_uPlayIntervalMax = AudioInfo.uPlayIntervalMax; m_uCurRandomPlayTime = GetRandomValue(m_uPlayTimeLenMin, m_uPlayTimeLenMax); m_uCurRandomInterval = GetRandomValue(m_uPlayIntervalMin, m_uPlayIntervalMax); m_strAudioName = AudioName; CVector3f mMin = CVector3f(-30.0f, 0.0f, -30.0f); CVector3f mMax = CVector3f( 30.0f, 60.0f, 30.0f); float fRange = eGridSpan * AudioRange; mMin = mMin - CVector3f(fRange, fRange, fRange); mMax = mMax + CVector3f(fRange, fRange, fRange); m_OrgAABB.setExtents(mMin, mMax); UpdateBox(); m_pAEmitter->SetPosition(GetPosition()); m_bNeedPlayBegin = true; m_bNeedIntervalBegin = true; m_bPlayError = false; }
CBulletNinja::CBulletNinja(int id, int typeID, CSprite spriteBullet, int dame, float v0, D3DXVECTOR2 beginPosition, float angleFly, int x, int y) :CBullet(id, typeID, spriteBullet, dame, D3DXVECTOR2(v0*cosf(angleFly), v0*sinf(angleFly)), beginPosition) { _position.x = x; _position.y = y; _state = BULLET_BASE_STATE::FLYING; Initlize(); UpdateBox(); }
void CEditableObject::TranslateToWorld(const Fmatrix& parent) { EditMeshIt m = m_Meshes.begin(); for(;m!=m_Meshes.end();m++) (*m)->Transform( parent ); #ifdef _EDITOR OnDeviceDestroy(); #endif UpdateBox(); }
const AniResult CEditModel::RenderFrame( const CMatrix& matWorld, float uCurFrame, RenderObjStyle* pRORS) { UpdateBox(); if (m_matCached!=matWorld) { m_matCached = matWorld; m_bNeedUpdate = false; } float DeltaFrame = uCurFrame - m_RenderMatrix.m_CurFrame; int32 DeltaTime = int32(DeltaFrame * GetCurFrameRatio()); CalculateMatrix( DeltaTime ); m_RenderMatrix.m_MatWorld = m_matCached; m_RenderMatrix.m_CurrentTime += DeltaTime; if (!m_isVisible) return m_RenderMatrix.m_Result; RenderObjStyle* pRenderRS = (pRORS && pRORS->m_eType == ROS_UNKNOWN) ? NULL : pRORS; if ( pRORS && m_eRenderStyle!=pRORS->m_eType) ClearModelRender(); if (NULL != pRenderRS) { if (m_bNeedPushRender) { m_eRenderStyle = pRORS->m_eType; sMaterial* material = (sMaterial*)(pRORS->m_nParam2); if (NULL != material) m_Material = *(sMaterial*)(pRORS->m_nParam2); CGraphic::GetInst()->BeginModel(this); if ( pRORS->m_bRenderMesh ) RenderMesh( pRenderRS ); CGraphic::GetInst()->EndModel(); m_bNeedPushRender= false; } else { UpdateRenderStyle(pRenderRS); } } m_RenderMatrix.m_CurrentTime = max(1,m_RenderMatrix.m_CurrentTime); /*if ( !pRORS || pRORS->m_bRenderLink ) RenderLink( m_RenderMatrix.m_CurrentTime, pRenderRS );*/ if(m_OrgAABB.isNull()) UpdateDynamicBox(); //RenderDebugLine(); return m_RenderMatrix.m_Result; }
void CDrescher::ReceiveData(PNETWORKDATA data) { if (data->p1==1) { pos=*(D3DVECTOR*)data->userdata; parent=game->chain->Find(data->p2); ang.y=LongToFloat(data->p3); UpdateBox(); } DebugOut("CDrescher::ReceiveData();"); }
void PCF8814_GFX::drawPixel (int16_t x, int16_t y, uint16_t color) { if ((x < 0) || (x >= LCD_X) || (y < 0) || (y >= LCD_Y)) return; if (color) LCDCache[x+ (y/8)*LCD_X] |= _BV(y%8); else LCDCache[x+ (y/8)*LCD_X] &= ~_BV(y%8); UpdateBox(x,y,x,y); }
bool Geometry::Cross(Geometry& g) { if(!box_updated) UpdateBox(); if(!g.box_updated) g.UpdateBox(); if(!CrossBoxes(box1,box2,g.box1,g.box2))return false; return CrossTrianglesSet(tr,g.tr); }
void Geometry::RebuildTrBB2() { UpdateBox(); //float lim = max(box2.x-box1.x,max(box2.y-box1.y,box2.z-box1.z))/6; float lim = 1; boxes.clear(); for(int i=0;i<tr_bb.size();i++) { AddToBoxes(tr_bb[i],i,boxes,lim); } //printf("T %d ",boxes.size()); }
int TEXTEDITBOX::ProcFunction(PASSPROCVARS Params){ TCHAR Char; // switch(Params.uMsg){ case WM_PAINT: RestoreFonts(); Pass.DDFront->Restore(); Pass.DDBack->Restore(); this->EditBoxSurface->Restore(); DDReLoadBitmap(this->EditBoxSurface, BMP_TEXTEDITBOX); this->StorageSurface->Restore(); break; case WM_CHAR: switch(Params.wParam){ case 0x08: /* backspace */ DeleteChar(); break; case 0x0A: /* linefeed */ case 0x0D: /* carriage return */ Info=TEBI_DONE; break; case 0x1B: /* escape */ case 0x09: /* tab */ break; default: //normal character: Char=(TCHAR) Params.wParam; AddChar(Char); break; } break; case WM_KEYDOWN: ///put it in the box. switch(Params.wParam){ case VK_RETURN: break; case VK_ESCAPE: break; case VK_LEFT: break; case VK_RIGHT: break; } break; } UpdateBox(); return 0; }
void CDrescher::Notify(PNETWORKDATA data) { switch(data->p1) { case 1: { // Position empfangen struct _r { D3DVECTOR pos,ang,speed; }*r=(_r*)data->userdata; pos=r->pos; ang=r->ang; speed=r->speed; UpdateBox(); } break; } }
void CGutsRockmanBullet::Update(CTimer* gameTime) { if (!_isAtFirst) { if (_master->_isThrowRock||_master->_currentSkill!=Skill::GUTS) { if (_master->_currentSkill == Skill::GUTS) { _master->_canFire = true; _spriteStatus = ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL; _sprite = ResourceManager::GetSprite(_spriteStatus); } D3DXVECTOR2 v = D3DXVECTOR2(135.0f / 1000.0f, 5.0f / 1000.0f); if (!_master->_isRight) v.x *= -1.0f; CBulletRockman *bullet1 = new CBulletRockman(v + D3DXVECTOR2(48.0f / 1000.0f, 5.0f / 1000.0f), _position + D3DXVECTOR2(-8, 8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); CBulletRockman *bullet2 = new CBulletRockman(v + D3DXVECTOR2(32.0f / 1000.0f, 10.0f / 1000.0f), _position + D3DXVECTOR2(8, 8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); CBulletRockman *bullet3 = new CBulletRockman(v + D3DXVECTOR2(16.0f / 1000.0f, 0.0f / 1000.0f), _position + D3DXVECTOR2(-8, -8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); CBulletRockman *bullet4 = new CBulletRockman(v + D3DXVECTOR2(8.0f / 1000.0f, 5.0f), _position + D3DXVECTOR2(8, -8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); _master->_bullets.push_back(bullet1); _master->_bullets.push_back(bullet2); _master->_bullets.push_back(bullet3); _master->_bullets.push_back(bullet4); Die(); } _position = _master->_position + D3DXVECTOR2(0, _master->GetBox()._height / 2 + GetBox()._height / 2); } else { _deltaTime += gameTime->GetTime(); if (_deltaTime >= 50) { _isAtFirst = false; _deltaTime = 0; _position = _master->_position + D3DXVECTOR2(0, _master->GetBox()._height / 2 + GetBox()._height / 2); } } UpdateBox(); }
CGutsRockmanBullet::CGutsRockmanBullet(Megaman* master, int rockTypeID) :CBullet(0, ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_BIG), 5, D3DXVECTOR2(0, 0), master->_position) { _master = master; _isAtFirst = true; _deltaTime = 0; _dame = DAME_BULLET_GUTS_ROCKMAN; if (_master->_isRight) { _position = _master->_position + D3DXVECTOR2(_sprite.GetFrameWidth()/2,_sprite.GetFrameHeight()/2); } else { _position = _master->_position + D3DXVECTOR2(-_sprite.GetFrameWidth() / 2, _sprite.GetFrameHeight() / 2); } switch (rockTypeID) { case ID_ROCK_IN_GUT_STAGE: _sprite = ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_STAGE_BIG); } UpdateBox(); }
int CEnemyInk::Initlize() { _heightInk = 100; _timeStand = 30; _timeStandDefault = 1000; _anpha = 0.7f; _timeaddspeed = 2.0f; _vFall = 0.0f; _testpositiony = 1000; _testbug = 0; _timeHistoryCollide = std::numeric_limits<float>::infinity(); _timeJump = 1500; _sprite = ResourceManager::GetSprite(_kindInk); _v = D3DXVECTOR2(50.0f / 1000.0f, 50.0f / 1000.0f); _g = 0.2f / 1000.0f;//0.098f / 1000.0f; _V0 = 172.0f / 1000.0f; _static = StaticEnemyInk::STAND; _spriteStatus = ID_ENEMY_INK_STAND; UpdateBox(); return 1; }
MinBox2<Real>::MinBox2 ( int numPoints, const Vector2<Real>* points, Real epsilon, Query::Type queryType, bool isConvexPolygon ) { // Get the convex hull of the points. Vector2<Real>* hullPoints = 0; if ( isConvexPolygon ) { hullPoints = ( Vector2<Real>* )points; } else { ConvexHull2<Real> hull( numPoints, ( Vector2<Real>* )points, epsilon, false, queryType ); int hullDim = hull.GetDimension(); int hullNumSimplices = hull.GetNumSimplices(); const int* hullIndices = hull.GetIndices(); if ( hullDim == 0 ) { mMinBox.Center = points[0]; mMinBox.Axis[0] = Vector2<Real>::UNIT_X; mMinBox.Axis[1] = Vector2<Real>::UNIT_Y; mMinBox.Extent[0] = ( Real )0; mMinBox.Extent[1] = ( Real )0; return; } if ( hullDim == 1 ) { ConvexHull1<Real>* hull1 = hull.GetConvexHull1(); hullIndices = hull1->GetIndices(); mMinBox.Center = ( ( Real )0.5 ) * ( points[hullIndices[0]] + points[hullIndices[1]] ); Vector2<Real> diff = points[hullIndices[1]] - points[hullIndices[0]]; mMinBox.Extent[0] = ( ( Real )0.5 ) * diff.Normalize(); mMinBox.Extent[1] = ( Real )0.0; mMinBox.Axis[0] = diff; mMinBox.Axis[1] = -mMinBox.Axis[0].Perp(); delete0( hull1 ); return; } numPoints = hullNumSimplices; hullPoints = new1<Vector2<Real> >( numPoints ); for ( int i = 0; i < numPoints; ++i ) { hullPoints[i] = points[hullIndices[i]]; } } // The input points are V[0] through V[N-1] and are assumed to be the // vertices of a convex polygon that are counterclockwise ordered. The // input points must not contain three consecutive collinear points. // Unit-length edge directions of convex polygon. These could be // precomputed and passed to this routine if the application requires it. int numPointsM1 = numPoints - 1; Vector2<Real>* edges = new1<Vector2<Real> >( numPoints ); bool* visited = new1<bool>( numPoints ); int i; for ( i = 0; i < numPointsM1; ++i ) { edges[i] = hullPoints[i + 1] - hullPoints[i]; edges[i].Normalize(); visited[i] = false; } edges[numPointsM1] = hullPoints[0] - hullPoints[numPointsM1]; edges[numPointsM1].Normalize(); visited[numPointsM1] = false; // Find the smallest axis-aligned box containing the points. Keep track // of the extremum indices, L (left), R (right), B (bottom), and T (top) // so that the following constraints are met: // V[L].X() <= V[i].X() for all i and V[(L+1)%N].X() > V[L].X() // V[R].X() >= V[i].X() for all i and V[(R+1)%N].X() < V[R].X() // V[B].Y() <= V[i].Y() for all i and V[(B+1)%N].Y() > V[B].Y() // V[T].Y() >= V[i].Y() for all i and V[(T+1)%N].Y() < V[T].Y() Real xmin = hullPoints[0].X(), xmax = xmin; Real ymin = hullPoints[0].Y(), ymax = ymin; int LIndex = 0, RIndex = 0, BIndex = 0, TIndex = 0; for ( i = 1; i < numPoints; ++i ) { if ( hullPoints[i].X() <= xmin ) { xmin = hullPoints[i].X(); LIndex = i; } if ( hullPoints[i].X() >= xmax ) { xmax = hullPoints[i].X(); RIndex = i; } if ( hullPoints[i].Y() <= ymin ) { ymin = hullPoints[i].Y(); BIndex = i; } if ( hullPoints[i].Y() >= ymax ) { ymax = hullPoints[i].Y(); TIndex = i; } } // Apply wrap-around tests to ensure the constraints mentioned above are // satisfied. if ( LIndex == numPointsM1 ) { if ( hullPoints[0].X() <= xmin ) { xmin = hullPoints[0].X(); LIndex = 0; } } if ( RIndex == numPointsM1 ) { if ( hullPoints[0].X() >= xmax ) { xmax = hullPoints[0].X(); RIndex = 0; } } if ( BIndex == numPointsM1 ) { if ( hullPoints[0].Y() <= ymin ) { ymin = hullPoints[0].Y(); BIndex = 0; } } if ( TIndex == numPointsM1 ) { if ( hullPoints[0].Y() >= ymax ) { ymax = hullPoints[0].Y(); TIndex = 0; } } // The dimensions of the axis-aligned box. The extents store width and // height for now. mMinBox.Center.X() = ( ( Real )0.5 ) * ( xmin + xmax ); mMinBox.Center.Y() = ( ( Real )0.5 ) * ( ymin + ymax ); mMinBox.Axis[0] = Vector2<Real>::UNIT_X; mMinBox.Axis[1] = Vector2<Real>::UNIT_Y; mMinBox.Extent[0] = ( ( Real )0.5 ) * ( xmax - xmin ); mMinBox.Extent[1] = ( ( Real )0.5 ) * ( ymax - ymin ); Real minAreaDiv4 = mMinBox.Extent[0] * mMinBox.Extent[1]; // The rotating calipers algorithm. Vector2<Real> U = Vector2<Real>::UNIT_X; Vector2<Real> V = Vector2<Real>::UNIT_Y; bool done = false; while ( !done ) { // Determine the edge that forms the smallest angle with the current // box edges. int flag = F_NONE; Real maxDot = ( Real )0; Real dot = U.Dot( edges[BIndex] ); if ( dot > maxDot ) { maxDot = dot; flag = F_BOTTOM; } dot = V.Dot( edges[RIndex] ); if ( dot > maxDot ) { maxDot = dot; flag = F_RIGHT; } dot = -U.Dot( edges[TIndex] ); if ( dot > maxDot ) { maxDot = dot; flag = F_TOP; } dot = -V.Dot( edges[LIndex] ); if ( dot > maxDot ) { maxDot = dot; flag = F_LEFT; } switch ( flag ) { case F_BOTTOM: if ( visited[BIndex] ) { done = true; } else { // Compute box axes with E[B] as an edge. U = edges[BIndex]; V = -U.Perp(); UpdateBox( hullPoints[LIndex], hullPoints[RIndex], hullPoints[BIndex], hullPoints[TIndex], U, V, minAreaDiv4 ); // Mark edge visited and rotate the calipers. visited[BIndex] = true; if ( ++BIndex == numPoints ) { BIndex = 0; } } break; case F_RIGHT: if ( visited[RIndex] ) { done = true; } else { // Compute box axes with E[R] as an edge. V = edges[RIndex]; U = V.Perp(); UpdateBox( hullPoints[LIndex], hullPoints[RIndex], hullPoints[BIndex], hullPoints[TIndex], U, V, minAreaDiv4 ); // Mark edge visited and rotate the calipers. visited[RIndex] = true; if ( ++RIndex == numPoints ) { RIndex = 0; } } break; case F_TOP: if ( visited[TIndex] ) { done = true; } else { // Compute box axes with E[T] as an edge. U = -edges[TIndex]; V = -U.Perp(); UpdateBox( hullPoints[LIndex], hullPoints[RIndex], hullPoints[BIndex], hullPoints[TIndex], U, V, minAreaDiv4 ); // Mark edge visited and rotate the calipers. visited[TIndex] = true; if ( ++TIndex == numPoints ) { TIndex = 0; } } break; case F_LEFT: if ( visited[LIndex] ) { done = true; } else { // Compute box axes with E[L] as an edge. V = -edges[LIndex]; U = V.Perp(); UpdateBox( hullPoints[LIndex], hullPoints[RIndex], hullPoints[BIndex], hullPoints[TIndex], U, V, minAreaDiv4 ); // Mark edge visited and rotate the calipers. visited[LIndex] = true; if ( ++LIndex == numPoints ) { LIndex = 0; } } break; case F_NONE: // The polygon is a rectangle. done = true; break; } } delete1( visited ); delete1( edges ); if ( !isConvexPolygon ) { delete1( hullPoints ); } }
int CBlock::Initlize() { UpdateBox(); return 0; }
bool CEditableObject::Load(IReader& F) { bool bRes = true; do{ u32 version = 0; shared_str buf; shared_str sh_name; R_ASSERT(F.r_chunk(EOBJ_CHUNK_VERSION,&version)); if (version!=EOBJ_CURRENT_VERSION){ ELog.DlgMsg( mtError, "CEditableObject: unsupported file version. Object can't load."); bRes = false; break; } R_ASSERT(F.r_chunk(EOBJ_CHUNK_FLAGS, &m_Flags.flags)); if (F.find_chunk (EOBJ_CHUNK_CLASSSCRIPT)){ F.r_stringZ (m_ClassScript); } if (F.find_chunk (EOBJ_CHUNK_LODS)){ F.r_stringZ (m_LODs); } // surfaces if (F.find_chunk(EOBJ_CHUNK_SURFACES3)){ u32 cnt = F.r_u32(); m_Surfaces.resize(cnt); for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ *s_it = xr_new<CSurface>(); F.r_stringZ (buf); (*s_it)->SetName (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShader (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShaderXRLC (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetGameMtl (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetTexture (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetVMap (buf.c_str()); (*s_it)->m_Flags.assign(F.r_u32()); (*s_it)->SetFVF (F.r_u32()); cnt = F.r_u32(); if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str()); R_ASSERT(1<=cnt); } }else if (F.find_chunk(EOBJ_CHUNK_SURFACES2)){ u32 cnt = F.r_u32(); m_Surfaces.resize(cnt); for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ *s_it = xr_new<CSurface>(); F.r_stringZ (buf); (*s_it)->SetName (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShader (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetShaderXRLC (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetTexture (buf.c_str()); F.r_stringZ (buf); (*s_it)->SetVMap (buf.c_str()); (*s_it)->m_Flags.assign(F.r_u32()); (*s_it)->SetFVF (F.r_u32()); cnt = F.r_u32(); if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str()); R_ASSERT(1<=cnt); } }else{ R_ASSERT(F.find_chunk(EOBJ_CHUNK_SURFACES)); u32 cnt = F.r_u32(); m_Surfaces.resize(cnt); for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ *s_it = xr_new<CSurface>(); F.r_stringZ(buf); (*s_it)->SetName(buf.c_str()); F.r_stringZ(sh_name); (*s_it)->m_Flags.set(CSurface::sf2Sided,!!F.r_u8()); (*s_it)->SetFVF (F.r_u32()); cnt = F.r_u32(); if (cnt>1) ELog.DlgMsg(mtError,"Object surface '%s' has more than one TC's.",buf.c_str()); R_ASSERT(1<=cnt); F.r_stringZ (buf); (*s_it)->SetTexture(buf.c_str()); F.r_stringZ (buf); (*s_it)->SetVMap(buf.c_str()); (*s_it)->SetShader (sh_name.c_str()); (*s_it)->SetShaderXRLC ("default"); } // surfaces xrlc part if(F.find_chunk(EOBJ_CHUNK_SURFACES_XRLC)) for (s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ F.r_stringZ(buf); (*s_it)->SetShaderXRLC(buf.c_str()); } } // Load meshes IReader* OBJ = F.open_chunk(EOBJ_CHUNK_EDITMESHES); if(OBJ){ IReader* M = OBJ->open_chunk(0); for (int count=1; M; count++) { CEditableMesh* mesh=xr_new<CEditableMesh>(this); if (mesh->LoadMesh(*M)) m_Meshes.push_back(mesh); else{ ELog.DlgMsg( mtError, "CEditableObject: Can't load mesh '%s'!", *mesh->m_Name ); xr_delete(mesh); bRes = false; } M->close(); if (!bRes) break; M = OBJ->open_chunk(count); } OBJ->close(); } // bones if (bRes){ IReader* B_CHUNK = F.open_chunk(EOBJ_CHUNK_BONES2); if (B_CHUNK){ int chunk = 0; IReader* O; while (0!=(O=B_CHUNK->open_chunk(chunk++))){ m_Bones.push_back(xr_new<CBone>()); m_Bones.back()->Load_1(*O); O->close(); } B_CHUNK->close(); PrepareBones(); }else if (F.find_chunk(EOBJ_CHUNK_BONES)){ m_Bones.resize(F.r_u32()); for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){ *b_it = xr_new<CBone>(); (*b_it)->Load_0(F); } PrepareBones(); } // skeleton motions if (F.find_chunk(EOBJ_CHUNK_SMOTIONS)){ m_SMotions.resize(F.r_u32()); for (SMotionIt s_it=m_SMotions.begin(); s_it!=m_SMotions.end(); s_it++){ *s_it = xr_new<CSMotion>(); if (!(*s_it)->Load(F)){ Log ("!Motions has different version. Load failed."); xr_delete(*s_it); m_SMotions.clear(); break; } // resort bone_mots (*s_it)->SortBonesBySkeleton(m_Bones); } } if (F.find_chunk(EOBJ_CHUNK_SMOTIONS2)){ F.r_stringZ (m_SMotionRefs); } } // bone parts if (bRes){ if (F.find_chunk(EOBJ_CHUNK_BONEPARTS)){ m_BoneParts.resize(F.r_u32()); bool bBPok = true; for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){ F.r_stringZ (buf); bp_it->alias=buf; bp_it->bones.resize(F.r_u32()); for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++){ int idx = F.r_u32(); if ((idx>=0)&&(idx<(int)m_Bones.size())){ *s_it = m_Bones[idx]->Name(); }else{ Log ("!Invalid bone parts.",GetName()); bBPok = false; break; } } if (!bBPok) break; } if (!bBPok) m_BoneParts.clear(); if (!m_BoneParts.empty()&&!VerifyBoneParts()) Log ("!Invalid bone parts. Found duplicate bones in object '%s'.",GetName()); }else if (F.find_chunk(EOBJ_CHUNK_BONEPARTS2)){ m_BoneParts.resize(F.r_u32()); for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){ F.r_stringZ (buf); bp_it->alias=buf; bp_it->bones.resize(F.r_u32()); for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++) F.r_stringZ(*s_it); } if (!m_BoneParts.empty()&&!VerifyBoneParts()) Log ("!Invalid bone parts. Found duplicate bones in object '%s'.",GetName()); } } if (bRes){ if (F.find_chunk (EOBJ_CHUNK_ACTORTRANSFORM)){ F.r_fvector3 (a_vPosition); F.r_fvector3 (a_vRotate); } if (F.find_chunk (EOBJ_CHUNK_DESC)){ F.r_stringZ (m_CreateName); F.r (&m_CreateTime,sizeof(m_CreateTime)); F.r_stringZ (m_ModifName); F.r (&m_ModifTime,sizeof(m_ModifTime)); } ResetSAnimation(); } if (!bRes) break; UpdateBox (); VerifyMeshNames (); }while(0); return bRes; }
void CEnemyInk::Update(CTimer* gameTime, Megaman* rockman) { if (_historyCollide != CDirection::NONE_DIRECT) { switch (_historyCollide) { case CDirection::ON_UP: _position.y += _timeHistoryCollide*_v.y-2; _v.y = _vFall; _v.x = 0; _static = StaticEnemyInk::FALL; break; case CDirection::ON_RIGHT: _position.x += _timeHistoryCollide*_v.x-2; _v.y = _vFall; _v.x = 0; _static = StaticEnemyInk::FALL; break; case CDirection::ON_LEFT: _position.x += _timeHistoryCollide*_v.x+2; _v.x = 0; _v.y = _vFall; _static = StaticEnemyInk::FALL; break; case CDirection::ON_DOWN: _spriteStatus = ID_ENEMY_INK_SIT; _sprite.SetIndex(0); _timeStand = _timeStandDefault;//1000 _position.y += _timeHistoryCollide*_v.y+1; _v.y = 0.0f; _v.x = 0.0f; _anpha = 0; _static = StaticEnemyInk::STAND; break; default: break; } } // xử lý cho va chạm trước đó switch (_static) { case CEnemyInk::JUMP: _position.x += _v.x*(gameTime->GetTime() * 1000); _position.y += _v.y*(gameTime->GetTime() * 1000); _v.y -= _g*(gameTime->GetTime() * 1000); break; case CEnemyInk::STAND: _timeStand -= gameTime->GetTime() * 1000; if (_timeStand <= 0) Jump(rockman->GetPos()); break; case CEnemyInk::FALL: _position.y += _v.y*(gameTime->GetTime() * 1000); _v.y -= _g*(gameTime->GetTime() * 1000); break; default: break; } _historyCollide = CDirection::NONE_DIRECT; _timeHistoryCollide = std::numeric_limits<float>::infinity(); _sprite.Update(gameTime); UpdateBox(); CGameObject::Update(gameTime); }
void CDrescher::NewWorld() { pos.y=world->HeightAtPoint(pos.x,pos.z); UpdateBox(); }
void CDrescher::Execute(float elapsed) { if (schaukelphase>0.0f) { schaukelphase-=(elapsed*12.0f); if (schaukelphase<0.0f)schaukelphase=0.0f; } if (IstNormale!=Normale) { // Den Mähdrescher "weich" an Untergrundsteigung anpassen GlattAnpassen(IstNormale.x,Normale.x,elapsed); GlattAnpassen(IstNormale.z,Normale.z,elapsed); // Y-Koordinate anpassen IstNormale.y=sqrtf(1-sqr(IstNormale.x)-sqr(IstNormale.z)); alpha=acosf(DotProduct(IstNormale,D3DVECTOR(0,1,0))); beta=atan2f(IstNormale.x,IstNormale.z); } if (parent!=NULL) { rolle+=elapsed*5.75f; D3DMATRIX m; D3DVECTOR v; D3DUtil_SetRotateYMatrix(m,ang.y); D3DMath_VectorMatrixMultiply(v,speed,m); pos+=(v*elapsed); pos.y=world->HeightAtPoint(pos.x,pos.z); float r=box1->GetRadius()*1.2f; D3DVECTOR c=GetCenter1(); c=korrigieren(c,D3DVECTOR(r,0,0)); c=korrigieren(c,D3DVECTOR(-r,0,0)); c=korrigieren(c,D3DVECTOR(0,0,r)); c=korrigieren(c,D3DVECTOR(0,0,-r)); pos=pos-GetCenter1()+c; UpdateBox(); speed+=(acc*elapsed); speed*=powf(0.45f,elapsed); const float s=sqrtf(sqr(speed.x)+sqr(speed.z)); if (rot!=0.0f) { float s2=sqrtf(s/5.0f); ang.y+=rot*s2*elapsed; } CPlayer* driver=(CPlayer*)parent; driver->pos=GetCenter1(); driver->ang=ang; driver->ang.y=-driver->ang.y; sound->SetFrequency(ULONG(20000.0f+s*3200.0f)); sound->Set3DParameters(pos); if (driver->IsLocal) { // An Objekten abprallen und Position senden CObject* o; o=chain->GetFirst(); while (o) { if (GetType(o->id)==IDTree) { CTree* t=(CTree*)o; if (t->box->Collidate(box2)) { pos=PrivotFromCenter2(box2->MoveOut(t->box)); UpdateBox(); goto weiter; } } if (GetType(o->id)==IDStall) { CStall* s=(CStall*)o; if (s->box->Collidate(box2)) { pos=PrivotFromCenter2(box2->MoveOut(s->box)); UpdateBox(); goto weiter; } } if ((o->IsType(IDDrescher))&&(o!=this)) { CDrescher* d=(CDrescher*)o; if (d->box2->Collidate(box2)) { pos=PrivotFromCenter2(box2->MoveOut(d->box2)); UpdateBox(); goto weiter; } } weiter: o=o->next; } struct _r { D3DVECTOR pos,ang,speed; }r; r.pos=pos; r.ang=ang; r.speed=speed; statusmessage->Send(DPID_ALLPLAYERS,NM_NOTIFY,id,1,0,0,&r,sizeof(r),FALSE); } }else rolle+=elapsed*0.7f; statusmessage->Execute(elapsed); // Kollisionen nur bei Server checken if (!game->IsServer)return; // Kollisionen mit Hühnern testen CObject* o=chain->GetFirst(); while (o) { if (GetType(o->id)==IDChicken) { CChicken* c=(CChicken*)o; if (c->dead!=0.0f)goto weiter2; // if (c->bound!=NULL)goto weiter2; if (parent!=NULL)if (HitRolle(c->box)) { // Getroffen schaukelphase=2*g_PI; c->Splat(SPLAT_NORMAL); ((CPlayer*)parent)->HasHit(c->id); ((CPlayer*)parent)->SendNotify(3,c->id); if (Config.blut)game->AddGimmick(new CDrescherBlood(id,1.5f)); if (Config.federn)game->AddGimmick(new CDrescherFedern(id,1.5f)); goto weiter2; } CBoundingTube* box=(parent?box1:box2); if (c->box->Collidate(box)) // Huhn nach ausserhalb bewegen { c->pos=c->box->MoveOut(box); goto weiter2; } } weiter2: o=o->next; } }