// コンストラクタ CSceneStageSelect::CSceneStageSelect() : IScene("img_stageSelect", "bgm_stageSelect") { std::string settingFile = gm()->fm().GetFile("#StageSelectFile"); std::ifstream f(settingFile); back_ = charabase::CharPtr(new charabase::CharBase()); back_->resname = BACK_RESNAME; back_->pos.z = 1.f; if (f.fail()) { debug::BToM("CSceneStageSelect::CSceneStageSelect path:%s", settingFile.c_str()); fieldRect_.top = fieldRect_.left = 0; fieldRect_.right = system::WINW; fieldRect_.bottom = system::WINH; } else { LoadInfo(f); } descHeight_ = 0.f; gm()->init(); InsertObject(ObjPtr(new CStageMng())); InsertObject(ObjPtr(new CScoreMng())); }
bool ezDynamicQuadtree::InsertObject(const ezVec3& vCenter, const ezVec3& vHalfExtents, const ezDynamicTree::ezObjectData& Obj, float minx, float maxx, float minz, float maxz, ezUInt32 uiNodeID, ezUInt32 uiAddID, ezUInt32 uiSubAddID, ezDynamicTreeObject* out_Object) { // check if object is COMPLETELY inside the node // if it is not entirely enclosed by the bounding box, insert it at the parent instead if (vCenter.x - vHalfExtents.x < minx) return false; if (vCenter.x + vHalfExtents.x > maxx) return false; if (vCenter.z - vHalfExtents.z < minz) return false; if (vCenter.z + vHalfExtents.z > maxz) return false; // if there are any child-nodes, try inserting there if (uiAddID > 0) { const float lx = ((maxx - minx) * 0.5f) * s_LooseOctreeFactor; const float lz = ((maxz - minz) * 0.5f) * s_LooseOctreeFactor; // to compute the ID of child node 'n', the number of children in child node 'n-1' has to be considered // uiAddID is the number of IDs that need to be skipped to get from the ID of child node 'n' to the ID of child 'n+1' // every time one goes down one step in the tree the number of child-nodes in the sub-tree is divided by 4 // so the number of IDs to skip to get from child 'n' to 'n+1' is reduced to 1/4 const ezUInt32 uiNodeIDBase = uiNodeID + 1; const ezUInt32 uiAddIDChild = uiAddID - uiSubAddID; const ezUInt32 uiSubAddIDChild = uiSubAddID / 4; if (InsertObject(vCenter, vHalfExtents, Obj, minx, minx + lx, minz, minz + lz, uiNodeIDBase + uiAddID * 0, uiAddIDChild, uiSubAddIDChild, out_Object)) return true; if (InsertObject(vCenter, vHalfExtents, Obj, minx, minx + lx, maxz - lz, maxz, uiNodeIDBase + uiAddID * 1, uiAddIDChild, uiSubAddIDChild, out_Object)) return true; if (InsertObject(vCenter, vHalfExtents, Obj, maxx - lx, maxx, minz, minz + lz, uiNodeIDBase + uiAddID * 2, uiAddIDChild, uiSubAddIDChild, out_Object)) return true; if (InsertObject(vCenter, vHalfExtents, Obj, maxx - lx, maxx, maxz - lz, maxz, uiNodeIDBase + uiAddID * 3, uiAddIDChild, uiSubAddIDChild, out_Object)) return true; } // object is inside this node, but not (completely / exclusively) inside any child nodes -> insert here ezDynamicTree::ezMultiMapKey mmk; mmk.m_uiKey = uiNodeID; mmk.m_uiCounter = m_uiMultiMapCounter++; auto key = m_NodeMap.Insert(mmk, Obj); if (out_Object) *out_Object = key; return true; }
void CSpatialTree::Think() { for( std::unordered_map< int, CSpatialTreeObject * >::iterator iter = m_pQTObjects.begin(); iter != m_pQTObjects.end(); ) { CSpatialTreeObject * o = iter->second; if( o->GetShouldKill() ) { for( int i = 0; i < m_NumNodes; i++ ) { m_pChildNodes[i].RemoveObject( o, false ); } delete o; iter = m_pQTObjects.erase( iter ); } else { iter++; if( o->GetShouldUpdate() ) { RemoveIfObjectHasMoved( o ); InsertObject( o ); } } } }
/* Function: EditPaste() PURPOSE: Pastes data from the clipboard RETURN: TRUE - Paste succeeded FALSE - Error pasting */ BOOL WINAPI EditPaste() { HANDLE hData; CPDATA pCopy; CPDATA *buffer = NULL; // Open Clipboard if (!OpenClipboard(ghWndMain)) { return FALSE; } // Get the buffer hData = GetClipboardData(clpFormat); buffer = (CPDATA*)GlobalLock(hData); // Make Local copy pCopy = *buffer; InsertObject(pCopy.line, pCopy.rect, pCopy.fLine, pCopy.colour); GlobalUnlock( hData ); CloseClipboard(); InvalidateRect(ghWndMain, NULL, TRUE); return TRUE; }
void QuadTree::AddMovingObjects( vector<GameObject*> objects ) { rootNode = new MyNode(*rootStatic); for (int i = 0; i<objects.size();i++) { // for each object to be added, find the node that it belongs in InsertObject(objects[i], rootNode,0); } }
/** * Sort the specified object list in Z Y order. * @param pObjList List to sort */ void SortObjectList(OBJECT *pObjList) { OBJECT *pPrev, *pObj; // object list traversal pointers OBJECT head; // temporary head of list - because pObjList is not usually a OBJECT // put at head of list head.pNext = pObjList->pNext; // set head of list dummy OBJ Z Y values to lowest possible head.yPos = intToFrac(MIN_INT16); head.zPos = MIN_INT; for (pPrev = &head, pObj = head.pNext; pObj != NULL; pPrev = pObj, pObj = pObj->pNext) { // check Z order if (pObj->zPos < pPrev->zPos) { // object Z is lower than previous Z // remove object from list pPrev->pNext = pObj->pNext; // re-insert object on list InsertObject(pObjList, pObj); // back to beginning of list pPrev = &head; pObj = head.pNext; } else if (pObj->zPos == pPrev->zPos) { // Z values are the same - sort on Y if (fracToDouble(pObj->yPos) < fracToDouble(pPrev->yPos)) { // object Y is lower than previous Y // remove object from list pPrev->pNext = pObj->pNext; // re-insert object on list InsertObject(pObjList, pObj); // back to beginning of list pPrev = &head; pObj = head.pNext; } } } }
CSpatialTreeObject * CSpatialTree::AddEntity( CWorldEntity * e ) { CSpatialTreeObject * o = new CSpatialTreeObject( e ); e->SetSpatialTreeEntity( o ); e->UpdateSpatialTreeEntityPos(); e->UpdateSpatialTreeEntitySize(); InsertObject( o ); return o; }
/// The object lies at vCenter and has vHalfExtents as its bounding box. /// If bOnlyIfInside is false, the object is ALWAYS inserted, even if it is outside the tree. /// \note In such a case it is inserted at the root-node and thus ALWAYS returned in range/view-frustum queries. /// /// If bOnlyIfInside is true, the object is discarded, if it is not inside the actual bounding box of the tree. /// /// The min and max Y value of the tree's bounding box is updated, if the object lies above/below previously inserted objects. ezResult ezDynamicQuadtree::InsertObject(const ezVec3& vCenter, const ezVec3& vHalfExtents, ezInt32 iObjectType, ezInt32 iObjectInstance, ezDynamicTreeObject* out_Object, bool bOnlyIfInside) { EZ_ASSERT_DEV(m_uiMaxTreeDepth > 0, "ezDynamicQuadtree::InsertObject: You have to first create the tree."); if (out_Object) *out_Object = ezDynamicTreeObject(); if (bOnlyIfInside) { if (vCenter.x + vHalfExtents.x < m_fRealMinX) return EZ_FAILURE; if (vCenter.x - vHalfExtents.x > m_fRealMaxX) return EZ_FAILURE; if (vCenter.z + vHalfExtents.z < m_fRealMinZ) return EZ_FAILURE; if (vCenter.z - vHalfExtents.z > m_fRealMaxZ) return EZ_FAILURE; } // update the bounding boxes min/max Y values m_BBox.m_vMin.y = ezMath::Min(m_BBox.m_vMin.y, vCenter.y - vHalfExtents.y); m_BBox.m_vMax.y = ezMath::Max(m_BBox.m_vMax.y, vCenter.y + vHalfExtents.y); ezDynamicTree::ezObjectData oData; oData.m_iObjectType = iObjectType; oData.m_iObjectInstance = iObjectInstance; // insert the object into the best child if (!InsertObject(vCenter, vHalfExtents, oData, m_BBox.m_vMin.x, m_BBox.m_vMax.x, m_BBox.m_vMin.z, m_BBox.m_vMax.z, 0, m_uiAddIDTopLevel, ezMath::Pow(4, m_uiMaxTreeDepth-1), out_Object)) { if (!bOnlyIfInside) { ezDynamicTree::ezMultiMapKey mmk; mmk.m_uiKey = 0; mmk.m_uiCounter = m_uiMultiMapCounter++; auto key = m_NodeMap.Insert(mmk, oData); if (out_Object) *out_Object = key; return EZ_SUCCESS; } return EZ_FAILURE; } return EZ_SUCCESS; }
void MultiInsertObject(OBJECT *pObjList, OBJECT *pInsObj) { // validate object pointer assert(pInsObj >= objectList && pInsObj <= objectList + NUM_OBJECTS - 1); // for all the objects that make up this multi-part do { // add next part to the specified list InsertObject(pObjList, pInsObj); // next obj in list pInsObj = pInsObj->pSlave; } while (pInsObj != NULL); }
// Insert the given object into this contain property. AAFRESULT STDMETHODCALLTYPE ImplAAFRefContainerValue::InsertElement( ImplAAFPropertyValue* pPropertyValue) { AAFRESULT result = AAFRESULT_SUCCESS; if (NULL == pPropertyValue) return AAFRESULT_NULL_PARAM; ImplAAFStorable * pObject = GetStorableFromPropertyValue(pPropertyValue, result); if (AAFRESULT_FAILED(result)) return result; result = InsertObject(pObject); return result; }
void QuadTree::InsertObject( GameObject* obj, MyNode* n, int steps ) { if (n->tl == NULL) { // after all the objects have been added, split the nodes based off of their depth and number of object inside. n->hasBall = true; n->myObjects.push_back(obj); //SplitNode(n,steps); return; } if (obj->position.x > n->br->position->x || obj->position.x + obj->radius > n->br->position->x) { if (obj->position.y > n->tr->position->y|| obj->position.y + obj->radius > n->tr->position->y) { InsertObject(obj,n->tr, steps+1); } if (obj->position.y < n->tr->position->y|| obj->position.y - obj->radius < n->tr->position->y) { InsertObject(obj,n->br, steps+1); } } if (obj->position.x < n->br->position->x || obj->position.x - obj->radius < n->br->position->x) { if (obj->position.y > n->tr->position->y|| obj->position.y + obj->radius > n->tr->position->y) { InsertObject(obj,n->tl, steps+1); } if (obj->position.y < n->tr->position->y|| obj->position.y - obj->radius < n->tr->position->y) { InsertObject(obj, n->bl, steps+1); } } }
IScene* CSceneStageSelect::NextScene() { const auto& sm = gm()->GetObjects("StageMng"); if (!sm.empty()) { std::dynamic_pointer_cast<CStageMng>(sm[0])->LoadStage(stageName_); } else { ObjPtr stage(new CStageMng()); InsertObject(stage); std::dynamic_pointer_cast<CStageMng>(stage)->LoadStage(stageName_); } return new CSceneMain(); }
Bool CDynamicStringSet::AddString(const String &str) { String* pstr = NewObjClear(String, str); if (!pstr) return false; Bool bExisted = false; if (!InsertObject(pstr, bExisted)) { DeleteObj(pstr); return false; } if (bExisted) DeleteObj(pstr); return true; }
Bool CDynamicFilenameSet::AddFilename(const Filename &fn) { Filename* pfn = NewObjClear(Filename, fn); if (!pfn) return false; Bool bExisted = false; if (!InsertObject(pfn, bExisted)) { DeleteObj(pfn); return false; } if (bExisted) DeleteObj(pfn); return true; }
void TStrings::Move(intptr_t CurIndex, intptr_t NewIndex) { if (CurIndex != NewIndex) { BeginUpdate(); auto cleanup = finally([&]() { EndUpdate(); }); { UnicodeString TempString = GetString(CurIndex); TObject * TempObject = GetObject(CurIndex); Delete(CurIndex); InsertObject(NewIndex, TempString, TempObject); } } }
void wxMainToolBar::InitToolBar() { // set up the toolbar controls int ipos = 0; if(m_first_dpos == 0) { ipos += InsertObject(ipos); ipos += InsertType(ipos); ipos += InsertBin(ipos); // we need to be able to set binning always m_first_dpos = ipos; } if(m_first_dpos > 0) { int ntools = GetToolsCount(); size_t max_pos = ntools-1; // Delete the camera dependent tools for(size_t ipos=max_pos; ipos>m_first_dpos; ipos--) { DeleteToolByPos(ipos); } // clear references to the deleted tools m_zoomSpin = 0; m_temp_text = 0; } wxCamera* camera = wxF()->cam(); if(camera && camera->IsArtcam()) { ipos = m_first_dpos; ipos += InsertZoom(ipos); ipos += InsertSubframe(ipos); ipos += InsertRestartExposure(ipos); ipos += InsertCooling(ipos); } //20080525:BM try to support more webcam else if(camera && camera->IsWebcam()) { ipos = m_first_dpos; ipos += InsertZoom(ipos); ipos += InsertSubframe(ipos); } Realize(); CamEnable(); }
void InsertPolygonVertices (SHORT centerx, SHORT centery, SHORT sides, SHORT radius) { double theta = PIX2 / (double)sides; double tangetial_factor = tan(theta); double radial_factor = cos(theta); double x = radius; double y = 0; for (SHORT n = 0; n < sides; n++) { InsertObject(OBJ_VERTEXES, -1, centerx + (SHORT)round(x), centery + (SHORT)round(y)); double tx = -y; double ty = x; x += tx * tangetial_factor; y += ty * tangetial_factor; x *= radial_factor; y *= radial_factor; } }
void ObjectPool::UpdateObject() { for (int i = 0; i < pool.size(); i++) { if (pool[i]->GetSceneNumber() == SceneManager::GetSceneManager().GetCurrentScene()) { ObjectRun(pool[i]); //物理碰撞↓ if (!pool[i]->IsSkill() && pool[i]->IsReachable() && pool[i]->GetCollisionRange()!=0) for (int j = 0; j < pool.size(); j++) { if (!pool[j]->IsSkill() && pool[j]->IsReachable() && !pool[j]->IsSoild() && pool[j]->GetCollisionRange() != 0 && pool[i]->GetX() != pool[j]->GetX() && pool[i]->GetY() != pool[j]->GetY() && pool[i]->GetDistance(pool[j]) < pool[i]->GetCollisionRange()) { double dis = pool[i]->GetDistance(pool[j]); double angle = pool[i]->GetAngle(pool[j], true); angle -= 3.14; pool[j]->SetPos(pool[j]->GetX() + (cos(angle) - sin(angle))*(pool[i]->GetCollisionRange() - dis), pool[j]->GetY()+(cos(angle) + sin(angle))*(pool[i]->GetCollisionRange() - dis)); } } //物理碰撞↑ /* 碰撞核心: if (dy <= -5) ReverseDy(); else dy = 5; */ } } for (int i = 0; i < instantpool.size(); i++) { InsertObject(instantpool[i]); instantpool.erase(instantpool.begin() + i); } //instantpool.clear(); }
// // WriteTo // AAFRESULT STDMETHODCALLTYPE ImplAAFRefArrayValue::WriteTo( OMProperty* pOmProp) { AAFRESULT result = AAFRESULT_SUCCESS; OMObject* object; ImplAAFStorable* obj; if (NULL == property()) { // First empty the current property. OMContainerProperty * pNewContainerProperty = dynamic_cast<OMContainerProperty *>(pOmProp); if (NULL == pNewContainerProperty) return AAFRESULT_INVALID_OBJ; OMReferenceContainer *pNewReferenceContainer = pNewContainerProperty->referenceContainer(); if (NULL == pNewReferenceContainer) return AAFRESULT_INVALID_OBJ; if (usesReferenceCounting()) { result = ReleaseAllObjects(pNewReferenceContainer); if (AAFRESULT_FAILED(result)) return result; } // Make sure that there are no elements in the new property container. pNewReferenceContainer->removeAllObjects(); // Install the new "empty" container property. SetProperty(pOmProp); OMReferenceContainerIterator* tempIterator = _tempStorableVector->createIterator(); if (NULL == tempIterator) { result = AAFRESULT_NOMEMORY; } else { while (AAFRESULT_SUCCEEDED(result) && (tempIterator->before() || tempIterator->valid())) { if (++(*tempIterator)) { object = tempIterator->currentObject(); obj = dynamic_cast<ImplAAFStorable*>(object); ASSERTU(NULL != obj); if (NULL == obj) { result = AAFRESULT_INVALID_OBJ; } else { // if (usesReferenceCounting()) // { // obj->detach(); // } // Add the element from the temporary property container to the property. result = InsertObject(obj); // reference counts if necessary... if (AAFRESULT_SUCCEEDED(result)) { if (usesReferenceCounting()) { obj->ReleaseReference(); } } } } } delete tempIterator; tempIterator = NULL; } // Cleanup the temporary property now the the the pOmProp has been created and initialized. delete _tempStorableVector; _tempStorableVector = NULL; if (AAFRESULT_FAILED(result)) return result; } return (ImplAAFRefContainerValue::WriteTo(pOmProp)); }
//-------------------------------------------------------------------------- void BackLayer::LoadMapLayer(ASprite** pASprite, char* packName, int packIndex) //-------------------------------------------------------------------------- { BackLayerObject* pBackObject = NULL; int tmpsprid = 0; SUTIL_Data_init(packName); SUTIL_Data_open(packIndex); int AsframeNum = 0; int tmpId = 0; ASprite* tmpASprite; while(1) { SUTIL_Data_readU8(); // 0x08 읽고 버린다. tmpId = (short)SUTIL_Data_readU16(); if(1 == tmpId) // 마지막 데이타 { m_nLayerSizeX += (short)SUTIL_Data_readU16(); break; } else if(2 == tmpId || 3 == tmpId) // 임시값 그냥 흘러간다. { } else if(11 == tmpId) // 랙트를 그려야 한다. { (short)SUTIL_Data_readU16(); // x (short)SUTIL_Data_readU16(); // y (short)SUTIL_Data_readU16(); // 고유 타입 (short)SUTIL_Data_readU16(); // draw type // 0이면 frame, 1이면 animation (short)SUTIL_Data_readU16(); // draw num (short)SUTIL_Data_readU16(); // 임시3 읽고 버린다. (short)SUTIL_Data_readU16(); // 임시3 읽고 버린다. continue; } else { if(100 <= tmpId) //현재 오브젝트의 스프라이트 넘버값을 알려준다. { tmpsprid = (tmpId-100)/100; tmpASprite = pASprite[tmpsprid]; } } pBackObject = GL_NEW BackLayerObject(); pBackObject->x = (short)SUTIL_Data_readU16(); // x pBackObject->y = (short)SUTIL_Data_readU16(); // y (short)SUTIL_Data_readU16(); // 읽고 버린다. pBackObject->type = (short)SUTIL_Data_readU16(); // 고유 타입 pBackObject->drawtype = (short)SUTIL_Data_readU16(); // draw type // 0이면 frame, 1이면 animation AsframeNum = (short)SUTIL_Data_readU16(); // draw num (short)SUTIL_Data_readU16(); // 임시3 읽고 버린다. pBackObject->spridx = tmpsprid; pBackObject->pAsIns = GL_NEW ASpriteInstance(tmpASprite, 0, 0, NULL); pBackObject->pAsIns->SetAniMoveLock(true); if(0 == pBackObject->drawtype) {SUTIL_SetTypeFrameAsprite(pBackObject->pAsIns, AsframeNum);} else if(1 == pBackObject->drawtype) { SUTIL_SetTypeAniAsprite(pBackObject->pAsIns, AsframeNum); SUTIL_SetLoopAsprite(pBackObject->pAsIns, true); } // pBackObject->adjustx = tmpASprite->GetFrameX(AsframeNum); // pBackObject->width = tmpASprite->GetFrameWidth(AsframeNum); pBackObject->x += m_nLayerSizeX; pBackObject->y += m_nBaseYLine; // pBackObject->x += pBackObject->adjustx; pBackObject->z = 0; pBackObject->startx = pBackObject->x + tmpASprite->GetFrameX(AsframeNum); pBackObject->endx = pBackObject->startx + tmpASprite->GetFrameWidth(AsframeNum); InsertObject(pBackObject); } SUTIL_Data_free(); }
bool ObjectManager::PlacementAllObject() { if (m_num_register >0) { for (int i = 0; i < m_num_register; i++) { SAFE_DELETE(m_object_array[i]); } } //オブジェクトの位置決定 Vector3 pos[8] = { //Vector3(0, -5.6, 0), Vector3(10.0f, 0, -5.0f), Vector3(23.74, 0, 24.04), Vector3(-26.74, 0, 29.26), Vector3(-30.88, 0, -29.46), Vector3(29.85, 0, -29.35), Vector3(-1.02, 0, -9.32), Vector3(23.42, 0, 0.51), Vector3(0.66, 0, 25.31), }; //向き決定 Vector3 angle[8] = { Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0), }; for (int i = 0; i < 8; i++) { EntryPoint::Register(pos[i], angle[i]); } m_num_register = 0; iex3DObj* insert = new iex3DObj("DATA\\CHR\\human\\human Find_Me.IEM"); player = new Player( 1, 0.3, Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0.05f, 0.05f, 0.05f), Vector3(1, 1, 1), BaseObjct::TYPE::player, insert); InsertObject(player); iexMesh* insert_mesh = new iexMesh("DATA\\IMO\\new_room.IMO"); Fileobject* insert_obj = new Fileobject(1, 0.3, Vector3(0, -5.6, 0), Vector3(0,0,0), Vector3(1.2, 1.2, 1.2), Vector3(1, 1, 1), BaseObjct::judge, insert_mesh); InsertObject(insert_obj); char* filename[8] = { /*"DATA\\IMO\\new_room.IMO",*/ ("DATA\\IMO\\tana.IMO"), ("DATA\\IMO\\bed.IMO"), ("DATA\\IMO\\sofa.IMO"), ("DATA\\IMO\\table_kai.IMO"), ("DATA\\IMO\\tanataka.IMO"), ("DATA\\IMO\\terebi.IMO"), ("DATA\\IMO\\toire.IMO"), ("DATA\\IMO\\tukuetoisu.IMO"), }; //オブジェクト読み込み for (int i = 0; i < 8; i++) { Vector3 p, a; EntryPoint::GetPoint(&p, &a); iexMesh* insert_mesh = new iexMesh(filename[i]); Vector3 scale = ScaleManager::GetScale(filename[i]); Fileobject* insert_obj = new Fileobject(1, 0.3, p, a, scale, Vector3(1, 1, 1), BaseObjct::judge, insert_mesh); InsertObject(insert_obj); } assert( DecisionAnswerObject()); return true; }
/* FUNCTION: CanvasProc(HWND, UINT, WPARAM, LPARAM) PURPOSE: Windows procedure for the canvas window PARAMETERS: hWnd - window handle message - window message wParam - window message parameter (depends on message) lParam - window message parameter (depends on message) RETURN: If the message was processed, the return value is 0 If the message was not processed and passed to DefWindowProc and the return value depends on the value of that function. */ LRESULT CALLBACK CanvasProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // a rectangle to hold current selection coords and a boolean to know whether we are in a drawing mode or not static RECT rect; static POINT pt[2]; static POINT select; static BOOL fDrawing; HMENU hMenu; // We'll be iterating through the list to find a selected object pPROGRAM_ITEM pListItem; pPROGRAM_ITEM pPrevItem; hMenu = GetMenu(ghWndMain); switch (message) { case WM_CREATE: // case for when the window is created SetRect(&rect, 0, 0, 0, 0); fDrawing = FALSE; break; case WM_MOUSEACTIVATE: // when the mouse moves into this window SetFocus(hWnd); return MA_ACTIVATE; break; case WM_LBUTTONDOWN: if(fDrawing) { // this should not happen, but no harm checking ReleaseCapture(); } // start selecting fDrawing = TRUE; // mouse x and y in lParam rect.left = (short)LOWORD(lParam); rect.top = (short)HIWORD(lParam); rect.right = (short)LOWORD(lParam); rect.bottom = (short)HIWORD(lParam); pt[0].x = (short)LOWORD(lParam); pt[0].y = (short)HIWORD(lParam); pt[1].x = (short)LOWORD(lParam); pt[1].y = (short)HIWORD(lParam); // draw first to keep drawing/erasing in synch. // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } SetCapture(hWnd); return 0; case WM_MOUSEMOVE: if (fDrawing) { RECT rcClient; GetClientRect(hWnd, &rcClient); // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { // erase old selection DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { // erase old selection DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } // mouse x and y in lParam rect.right = (short)LOWORD(lParam); rect.bottom = (short)HIWORD(lParam); pt[1].x = (short)LOWORD(lParam); pt[1].y = (short)HIWORD(lParam); // make sure our selection does not go outside client area if(rect.right < 0) { rect.right = 0; pt[1].x = 0; } if(rect.right > rcClient.right) { rect.right = rcClient.right; pt[1].x = rcClient.right; } if(rect.bottom < 0) { rect.bottom = 0; pt[1].x = 0; } if(rect.bottom > rcClient.bottom) { rect.bottom = rcClient.bottom; pt[1].y = rcClient.bottom; } // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } } break; case WM_LBUTTONUP: if(fDrawing) { // reset selection // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { DrawLine(hWnd, (POINT *)&pt, gRGBCurrent, FALSE); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { DrawRect(hWnd, &rect, gRGBCurrent, FALSE); } fDrawing = FALSE; ReleaseCapture(); // Check to see if we're drawing a line or a rectangle if (GetMenuState(hMenu, ID_TOOLS_LINE, MF_BYCOMMAND) == MF_CHECKED) { // Add line to queue InsertObject(pt, rect, TRUE, gRGBCurrent); } if (GetMenuState(hMenu, ID_TOOLS_RECTANGLE, MF_BYCOMMAND) == MF_CHECKED) { // Add rectangle to queue InsertObject(pt, rect, FALSE, gRGBCurrent); } // draw the newly created object InvalidateRect(hWnd, NULL, TRUE); } // Check to see if we're selecting an object if (GetMenuState(hMenu, ID_TOOLS_SELECT, MF_BYCOMMAND) == MF_CHECKED) { select.x = (short)LOWORD(lParam); select.y = (short)HIWORD(lParam); (PSLIST_HEADER)pListItem = gpListHead; // Reverse the linked list while (pListItem) { if (pListItem->fLine) { if (pListItem->rect.left < select.x && pListItem->rect.right > select.x && pListItem->rect.bottom > select.y && pListItem->rect.top < select.y) { InsertObject(pListItem->line, pListItem->rect, TRUE, SELECTED_OBJECT); selCount++; break; } } else { if (pListItem->rect.left < select.x && pListItem->rect.right > select.x && pListItem->rect.bottom > select.y && pListItem->rect.top < select.y) { InsertObject(pListItem->line, pListItem->rect, FALSE, SELECTED_OBJECT); selCount++; break; } } //switch to next list item pPrevItem = pListItem; pListItem = (pPROGRAM_ITEM)pListItem->ItemEntry.Next; } } return 0; case WM_PAINT: PaintWindow(hWnd); break; case WM_CLOSE: break; default: return (int)DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
///////////////////////////////////////////////////////////////////////////// // FUNCTION....: EditMenuDialogProc // // DESCRIPTION.: // ///////////////////////////////////////////////////////////////////////////// BOOL CALLBACK _export EditMenuDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { BOOL result; OBJECTID objID; switch ( message ) { case WM_INITDIALOG: SetWindowLong(hDlg, DWL_USER, lParam); InitDialog(hDlg, (OBJECTID)lParam); AUtlSetTitleFont(OTYPE_MENU, NULL, GetDlgItem(hDlg, IDD_OBJECT)); AUtlCenterDialog(hDlg, 0); result = FALSE; break; case WM_COMMAND: objID = (OBJECTID)GetWindowLong(hDlg, DWL_USER); switch ( wParam ) { case IDOK: SetFocus(GetDlgItem(hDlg, IDOK)); UpdateObject(hDlg, objID); EndDialog(hDlg, TRUE); result = TRUE; break; case IDCANCEL: SetFocus(GetDlgItem(hDlg, IDCANCEL)); EndDialog(hDlg, FALSE); result = TRUE; break; case IDHELP: // WinHelp (hDlg, "serhelp.hlp", HELP_CONTEXT, HELPID_OBJD_Menu) ; result = TRUE; break; case BTN_DISPLAYNAME: case BTN_DISPLAYTITLE: LbTitleUpdate(hDlg, LB_SOURCE, TRUE); LbTitleUpdate(hDlg, LB_DESTINATION, TRUE); result = TRUE; break; case BTN_SHOWITEMS: case BTN_SHOWMENUS: LbContentUpdate(hDlg,objID); UpdateAddButton(hDlg); result = TRUE; break; case BTN_ADD: InsertObject(hDlg); UpdateAddButton(hDlg); UpdateSeparateButton(hDlg); result = TRUE; break; case BTN_REMOVE: DeleteObjects(hDlg); UpdateEditButton(hDlg); UpdateRemoveButton(hDlg); UpdateSeparateButton(hDlg); result = TRUE; break; case BTN_EDIT: EditObject(hDlg); LbTitleUpdate(hDlg, LB_SOURCE, TRUE); LbTitleUpdate(hDlg, LB_DESTINATION, TRUE); result = TRUE; break; case BTN_SEPARATOR: InsertSeparator(hDlg); result = TRUE; break; case LB_SOURCE: UpdateAddButton(hDlg); if (HIWORD(lParam) == LBN_DBLCLK) { InsertObject(hDlg); UpdateAddButton(hDlg); UpdateSeparateButton(hDlg); } result = TRUE; break; case LB_DESTINATION: UpdateRemoveButton(hDlg); UpdateEditButton(hDlg); if (HIWORD(lParam) == LBN_DBLCLK) { EditObject(hDlg); LbTitleUpdate(hDlg, LB_SOURCE, TRUE); LbTitleUpdate(hDlg, LB_DESTINATION, TRUE); } result = TRUE; break; default: result = FALSE; } break; default: result = FALSE; break; } return result; }
// コンストラクタ CSceneMain::CSceneMain(): IScene("","bgm_main") { InsertObject(ObjPtr(new CCollision())); }
void Execute() { switch(RandomProvider.GetNextAction()) { case ActionType::Allocate: { // Allocate an object of a random size. int size = RandomProvider.GetNextObjectSize(); void* object = Allocator->Allocate(size); if(object == 0) { std::cout<<"Object could not be allocated!"; std::cout<<"Consider building in 64 bit mode."; exit(-1); } TouchData(object, size); InsertObject(object); break; } case ActionType::Deallocate: { if(PassedObjects.size() > 0) { EnterCriticalSection(&PassedObjectsLock); void* object = *(PassedObjects.end() - 1); PassedObjects.pop_back(); LeaveCriticalSection(&PassedObjectsLock); if(!VerifyData(object)) { std::cout<<"Data corruption detected!\n"; } Allocator->Deallocate(object); } if(Objects.size() > 0 && (deallocateObjects != Objects.size())) { // Randomly select an object to be deallocated. int victim = SelectVictim(); if(victim != -1) { // Deallocate the object and insert the location // in the list of unused positions to be used when allocating. void* object = Objects[victim]; if(!VerifyData(object)) { std::cout<<"Data corruption detected!\n"; } Allocator->Deallocate(object); ResetSlot(victim); } } break; } case ActionType::Pass: { if(Threads.size() > 0 && Objects.size() > 0 && (deallocateObjects != Objects.size())) { // Select an object to be passed to one of the other threads. int victim = SelectVictim(); if(victim != -1) { int otherThread = RandomProvider.GetNextInt(Threads.size()); ThreadData* otherThreadData = Threads[otherThread]; void* object = Objects[victim]; ResetSlot(victim); EnterCriticalSection(&otherThreadData->PassedObjectsLock); otherThreadData->PassedObjects.push_back(object); LeaveCriticalSection(&otherThreadData->PassedObjectsLock); } } break; } } }
/** * Main text outputting routine. If a object list is specified a * multi-object is created for the whole text and a pointer to the head * of the list is returned. * @param pList Object list to add text to * @param szStr String to output * @param color Color for monochrome text * @param xPos X position of string * @param yPos Y position of string * @param hFont Which font to use * @param mode Mode flags for the string * @param sleepTime Sleep time between each character (if non-zero) */ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color, int xPos, int yPos, SCNHANDLE hFont, int mode, int sleepTime) { int xJustify; // x position of text after justification int yOffset; // offset to next line of text OBJECT *pFirst; // head of multi-object text list OBJECT *pChar = 0; // object ptr for the character byte c; SCNHANDLE hImg; const IMAGE *pImg; // make sure there is a linked list to add text to assert(pList); // get font pointer const FONT *pFont = (const FONT *)LockMem(hFont); // init head of text list pFirst = NULL; // get image for capital W assert(pFont->fontDef[(int)'W']); pImg = (const IMAGE *)LockMem(FROM_32(pFont->fontDef[(int)'W'])); // get height of capital W for offset to next line yOffset = FROM_16(pImg->imgHeight) & ~C16_FLAG_MASK; while (*szStr) { // x justify the text according to the mode flags xJustify = JustifyText(szStr, xPos, pFont, mode); // repeat until end of string or end of line while ((c = *szStr) != EOS_CHAR && c != LF_CHAR) { if (g_bMultiByte) { if (c & 0x80) c = ((c & ~0x80) << 8) + *++szStr; } hImg = FROM_32(pFont->fontDef[c]); if (hImg == 0) { // no image for this character // add font spacing for a space character xJustify += FROM_32(pFont->spaceSize); } else { // printable character int aniX, aniY; // char image animation offsets OBJ_INIT oi; oi.hObjImg = FROM_32(pFont->fontInit.hObjImg); oi.objFlags = FROM_32(pFont->fontInit.objFlags); oi.objID = FROM_32(pFont->fontInit.objID); oi.objX = FROM_32(pFont->fontInit.objX); oi.objY = FROM_32(pFont->fontInit.objY); oi.objZ = FROM_32(pFont->fontInit.objZ); // allocate and init a character object if (pFirst == NULL) // first time - init head of list pFirst = pChar = InitObject(&oi); // FIXME: endian issue using fontInit!!! else // chain to multi-char list pChar = pChar->pSlave = InitObject(&oi); // FIXME: endian issue using fontInit!!! // convert image handle to pointer pImg = (const IMAGE *)LockMem(hImg); // fill in character object pChar->hImg = hImg; // image def pChar->width = FROM_16(pImg->imgWidth); // width of chars bitmap pChar->height = FROM_16(pImg->imgHeight) & ~C16_FLAG_MASK; // height of chars bitmap pChar->hBits = FROM_32(pImg->hImgBits); // bitmap // check for absolute positioning if (mode & TXT_ABSOLUTE) pChar->flags |= DMA_ABS; // set characters color - only effective for mono fonts pChar->constant = color; // get Y animation offset GetAniOffset(hImg, pChar->flags, &aniX, &aniY); // set x position - ignore animation point pChar->xPos = intToFrac(xJustify); // set y position - adjust for animation point pChar->yPos = intToFrac(yPos - aniY); if (mode & TXT_SHADOW) { // we want to shadow the character OBJECT *pShad; // allocate a object for the shadow and chain to multi-char list pShad = pChar->pSlave = AllocObject(); // copy the character for a shadow CopyObject(pShad, pChar); // add shadow offsets to characters position pShad->xPos += intToFrac(FROM_32(pFont->xShadow)); pShad->yPos += intToFrac(FROM_32(pFont->yShadow)); // shadow is behind the character pShad->zPos--; // shadow is always mono pShad->flags = DMA_CNZ | DMA_CHANGED; // check for absolute positioning if (mode & TXT_ABSOLUTE) pShad->flags |= DMA_ABS; // shadow always uses first palette entry // should really alloc a palette here also ???? pShad->constant = 1; // add shadow to object list InsertObject(pList, pShad); } // add character to object list InsertObject(pList, pChar); // move to end of list if (pChar->pSlave) pChar = pChar->pSlave; // add character spacing xJustify += FROM_16(pImg->imgWidth); } // finally add the inter-character spacing xJustify += FROM_32(pFont->xSpacing); // next character in string ++szStr; } // adjust the text y position and add the inter-line spacing yPos += yOffset + FROM_32(pFont->ySpacing); // check for newline if (c == LF_CHAR) // next character in string ++szStr; } // return head of list return pFirst; }
Bool ExecuteAutoConnect() { ConnectOptions options; Bool addDynamicsTag = false, inheritDynamicsTag = true; GetInt32(CMB_FORCE, options.forcePluginId); GetInt32(CMB_TYPE, options.forceType); GetInt32(CMB_MODE, options.connectMode); GetInt32(EDT_MAXCONN, options.maxConnections); GetFloat(EDT_RADIUS, options.radius); GetBool(CHK_CLOSED, options.closedChain); GetBool(CHK_ADDDYNAMICS, addDynamicsTag); GetBool(CHK_COMPOUND, inheritDynamicsTag); // Create an InExcludeData for the selection object. GeData ge_selection(CUSTOMGUI_INEXCLUDE_LIST, DEFAULTVALUE); auto selectionList = static_cast<InExcludeData*>( ge_selection.GetCustomDataType(CUSTOMGUI_INEXCLUDE_LIST)); if (!selectionList) return false; // Get the active document and object. BaseDocument* doc = GetActiveDocument(); if (!doc) return false; BaseObject* op = doc->GetActiveObject(); if (!op) return false; // Create the root object that will contain the connectors. AutoFree<BaseObject> root(BaseObject::Alloc(Onull)); if (!root) return false; // Function to create a dynamics tag. auto fAddDynamicsTag = [doc] (BaseObject* op, Int32 mode) { // Create a dynamics tag for the root object if it // does not already exist. BaseTag* dyn = op->GetTag(ID_RIGIDBODY); if (!dyn) { dyn = op->MakeTag(ID_RIGIDBODY); if (dyn) doc->AddUndo(UNDOTYPE_NEW, dyn); } // Update the parameters. if (dyn) { dyn->SetParameter(RIGID_BODY_HIERARCHY, mode, DESCFLAGS_SET_0); doc->AddUndo(UNDOTYPE_CHANGE_SMALL, dyn); } }; // This list will contain all objects that should be connected. // While collecting, create the dynamics tags. maxon::BaseArray<BaseObject*> objects; doc->StartUndo(); for (BaseObject* child=op->GetDown(); child; child=child->GetNext()) { objects.Append(child); if (addDynamicsTag && inheritDynamicsTag) fAddDynamicsTag(child, RIGID_BODY_HIERARCHY_COMPOUND); } if (addDynamicsTag && !inheritDynamicsTag) fAddDynamicsTag(op, RIGID_BODY_HIERARCHY_INHERIT); // If no objects where collected, quit already. if (objects.GetCount() <= 0) { doc->EndUndo(); doc->DoUndo(false); return true; } // Create the connection objects. ConnectObjects(op->GetName() + ": ", objects, options); // Fill the selection list and insert the objects. for (auto it=options.output.Begin(); it != options.output.End(); ++it) { (*it)->InsertUnderLast(root); doc->AddUndo(UNDOTYPE_NEW, *it); selectionList->InsertObject(*it, 0); } root->SetName(op->GetName() + ": " + root->GetName() + " (" + options.forceName + ")"); doc->InsertObject(root, nullptr, nullptr); doc->AddUndo(UNDOTYPE_NEW, root); // Create the selection object. if (selectionList->GetObjectCount() > 0) { BaseObject* selection = BaseObject::Alloc(Oselection); if (selection) { selection->SetParameter(SELECTIONOBJECT_LIST, ge_selection, DESCFLAGS_SET_0); selection->SetName(op->GetName() + ": " + options.forceName + " (" + selection->GetName() + ")"); doc->InsertObject(selection, nullptr, nullptr); doc->AddUndo(UNDOTYPE_NEW, selection); } ActiveObjectManager_SetMode(ACTIVEOBJECTMODE_OBJECT, false); doc->SetActiveObject(selection); } else doc->SetActiveObject(root); root.Release(); doc->EndUndo(); EventAdd(); return true; }
void Filters::AddFilterGroup(FilterGroup* filterGroup) { InsertObject(filterGroup); }
void TStrings::SetString(intptr_t Index, const UnicodeString & S) { TObject * TempObject = GetObject(Index); Delete(Index); InsertObject(Index, S, TempObject); }