MotionPlannerInterface* MotionPlannerFactory::Create(const MotionPlanningProblem& problem) { if(problem.startSet) FatalError("MotionPlannerFactory: Cannot do start-set problems yet"); if(problem.qstart.empty() && (!problem.qgoal.empty() || problem.goalSet!=NULL)) FatalError("MotionPlannerFactory: Goal set specified but start not specified"); if(!problem.qstart.empty() && problem.goalSet) { //point-to-goal problem //pick a multi-query planner for the underlying planner string oldtype = type; if(type == "any") type = "sblprt"; MotionPlannerInterface* mp = Create(problem.space); type = oldtype; PointToSetMotionPlanner* psmp = new PointToSetMotionPlanner(mp,problem.qstart,problem.goalSet); return psmp; } else { MotionPlannerInterface* mp = CreateRaw(problem.space); if(!problem.qstart.empty()) { int qstart = mp->AddMilestone(problem.qstart); Assert(qstart == 0); } if(!problem.qgoal.empty()) { int qgoal = mp->AddMilestone(problem.qgoal); Assert(qgoal == 1); } return ApplyModifiers(mp,problem); } }
void CText::Put(CCanvas* canvas, const CRectangle& dstRect, const CRectangle& srcRect) { CRectangle dest(dstRect); CRectangle src(srcRect); ApplyModifiers(src, dest); ApplyAnimators(src, dest); canvas->Blit(dest, *m_pText, src); canvas->AddUpdateRect(dest); } // CText::Put
Import::Import(const char* pathName, Interface* ip, ImpInterface* impip) { // set the path for textures char* ptr = NULL; sprintf (m_path, "%s", pathName); for (int i = 0; m_path[i]; i ++) { if ((m_path[i] == '\\') || (m_path[i] == '/') ) { ptr = &m_path[i]; } } *ptr = 0; m_ip = ip; m_impip = impip; m_succes = TRUE; MaterialCache materialCache (NewDefaultMultiMtl()); SetSceneParameters(); dFloat scale; scale = float (GetMasterScale(UNITS_METERS)); dMatrix scaleMatrix (GetIdentityMatrix()); scaleMatrix[0][0] = 1.0f / scale; scaleMatrix[1][1] = 1.0f / scale; scaleMatrix[2][2] = 1.0f / scale; dMatrix globalRotation (scaleMatrix * dPitchMatrix(3.14159265f * 0.5f) * dRollMatrix(3.14159265f * 0.5f)); NewtonWorld* newton = NewtonCreate(); dScene scene (newton); scene.Deserialize (pathName); // dScene::Iterator iter (scene); // for (iter.Begin(); iter; iter ++) { // dScene::dTreeNode* node = iter.GetNode(); // dNodeInfo* info = scene.GetInfoFromNode(node); // if (info->GetTypeId() == dMeshNodeInfo::GetRttiType()) { // dMeshNodeInfo* mesh = (dMeshNodeInfo*) scene.GetInfoFromNode(node); // mesh->ConvertToTriangles(); // } // } scene.BakeTransform (globalRotation); GeometryCache geometryCache; MaxNodeChache maxNodeCache; LoadMaterials (scene, materialCache); LoadGeometries (scene, geometryCache, materialCache); LoadNodes (scene, geometryCache, materialCache.m_multiMat, maxNodeCache); ApplyModifiers (scene, maxNodeCache); scene.CleanUp(); NewtonDestroy(newton); }
void CText::RenderPut(const CCanvas* canvas, const CRectangle& dstRect, const CRectangle& srcRect) { CRectangle dest(dstRect); CRectangle src(srcRect); dest.SetW(srcRect.GetW()); dest.SetH(srcRect.GetH()); ApplyModifiers(src, dest); ApplyAnimators(src, dest); m_pText->RenderCopy(&dest, &src); }
//---------------------------------------------------------------------------- SceneBuilder::SceneBuilder (const TCHAR *filename, BOOL exportSelected, ExportSettings *settings, ExpInterface *ept, Interface *max, INode *exportNode) { float time = (float)PX2::Time::GetTimeInSeconds(); const size_t size = _tcslen(filename)+1; mFileName = new1<TCHAR>((int)size); _tcscpy_s(mFileName, size, filename); mExportSelected = exportSelected; mSettings = settings; mExport = ept; mMax = max; mExportMaxNode = exportNode; mTicksPerFrame = GetTicksPerFrame(); if (mSettings->IncludeCurrentFrame) { mTimeStart = mMax->GetAnimRange().Start(); mTimeEnd = mTimeStart; } else { mTimeStart = mSettings->StartFrame * GetTicksPerFrame(); mTimeEnd = mSettings->EndFrame * GetTicksPerFrame(); if (mSettings->UseLocalTime) { mTimeOffset = mTimeStart; } else { mTimeOffset = 0; } } // 遍历场景3次。第1次处理materials,第2次遍历节点继承关系,第3次应用 modifiers mScene = new0 PX2::Node(); mScene->SetName("RootNode"); // 1 CollectMaterials(mExportMaxNode); ConvertMaterials(); // 2 if (!mExportSelected) { // entire scene if (mSettings->IncludeLights) { BuildAmbientLight(); } int numChildren = mExportMaxNode->NumberOfChildren(); for (int i=0; i<numChildren; i++) { Traverse(mExportMaxNode->GetChildNode(i), mScene); } } else { // selection only Traverse(mExportMaxNode, mScene); } mScene->Update(0.0f); // 3 if (mSettings->IncludeModifiers) { ApplyModifiers(); } PX2::OutStream stream; if (mExportSelected) { stream.Insert(mScene->GetChild(0)); } else { stream.Insert(mScene); } stream.Save(filename); mScene = 0; }
CObjectImageArray &CCompositeImageDesc::GetImage (const CCompositeImageSelector &Selector, DWORD dwModifiers, int *retiRotation) const // GetImage // // Returns the image { CCompositeImageSelector::ETypes iType = Selector.GetType(DEFAULT_SELECTOR_ID); // If the selector has a wreck image, then we use that if (iType == CCompositeImageSelector::typeShipClass) { if (retiRotation) *retiRotation = Selector.GetVariant(DEFAULT_SELECTOR_ID); return Selector.GetShipwreckImage(DEFAULT_SELECTOR_ID); } // If the selector has an item image, then we use that else if (iType == CCompositeImageSelector::typeItemType) { if (retiRotation) *retiRotation = 0; return Selector.GetFlotsamImage(DEFAULT_SELECTOR_ID); } // Get the image from the root entry else if (m_pRoot) { // retiRotation is used as the vertical index into the image. // Since each variant is expected to be its own image, we set to 0. if (retiRotation) *retiRotation = 0; // Look in the cache SCacheEntry *pEntry = FindCacheEntry(Selector, dwModifiers); if (pEntry) return pEntry->Image; // If not in the cache, add a new entry pEntry = m_Cache.Insert(); pEntry->Selector = Selector; pEntry->dwModifiers = dwModifiers; m_pRoot->GetImage(Selector, &pEntry->Image); // Apply modifiers if (dwModifiers) ApplyModifiers(dwModifiers, &pEntry->Image); // Done return pEntry->Image; } else return EMPTY_IMAGE; }