void ApplyAll() { Hook(0x1129A0, UpdateInputHook).Apply(); Hook(0x105CBA, ProcessUiInputHook, HookFlags::IsCall).Apply(); Hook(0x106417, QuickUpdateUiInputHook, HookFlags::IsCall).Apply(); Hook(0x234238, BlockInputHook, HookFlags::IsCall).Apply(); Hook(0x20BF00, InitBindingsHook).Apply(); Hook(0x10AB40, PreferencesGetKeyBindingsHook).Apply(); Hook(0x10D040, PreferencesSetKeyBindingsHook).Apply(); Hook(0x20C040, GetDefaultBindingsHook).Apply(); Hook(0x20C4F6, GetKeyboardActionTypeHook).Apply(); Hook(0x1128FB, GetControllerStateHook, HookFlags::IsCall).Apply(); Hook(0x11298B, SetControllerVibrationHook, HookFlags::IsCall).Apply(); Patch::NopFill(Pointer::Base(0x6A225B), 2); // Prevent the game from forcing certain binds on load Patch(0x6940E7, { 0x90, 0xE9 }).Apply(); // Disable custom UI input code Hook(0x695012, UpdateUiControllerInputHook, HookFlags::IsCall).Apply(); Patch::NopFill(Pointer::Base(0x112613), 2); // Never clip the cursor to the window boundaries // Fix a bug in the keyboard input routine that screws up UI keys. // If an action has the "handled" flag set and has a secondary key // bound to it, then the tick count gets reset to 0 because the // secondary key won't be down and the action gets spammed. // // To fix it, we have to nop out every place where the flag is // checked, disable the code which updates the flag, and then // update it ourselves only after every key has been checked. uint32_t keyboardFixPointers[] = { 0x20C529, 0x20C558, 0x20C591, 0x20C5C2, 0x20C5FA, 0x20C63F }; for (auto pointer : keyboardFixPointers) Patch::NopFill(Pointer::Base(pointer), 2); Patch(0x20C69F, { 0xEB }).Apply(); Hook(0x20D980, ProcessKeyBindingsHook, HookFlags::IsCall).Apply(); }
//-------------------------------------------------------------------- Patch PdBase::openPatch(const std::string& patch, const std::string& path) { // [; pd open file folder( void* handle = libpd_openfile(patch.c_str(), path.c_str()); if(handle == NULL) { return Patch(); // return empty Patch } int dollarZero = libpd_getdollarzero(handle); return Patch(handle, dollarZero, patch, path); }
void ForceDedicated() { // Put the game into dedicated server mode Patch(0x2E600, { 0xB0, 0x01 }).Apply(); // Force syslink to still work Patch(0x12D62E, { 0xEB }).Apply(); Patch(0x12D67A, { 0xEB }).Apply(); Patch(0x5A8BB, { 0xEB }).Apply(); }
void ApplyAll() { // Enable tag edits Patch(0x101A5B, { 0xEB }).Apply(); Patch::NopFill(Pointer::Base(0x102874), 2); Patch::NopFill(Pointer::Base(0x1030AA), 2); // No --account args patch Patch(0x43731A, { 0xEB, 0x0E }).Apply(); Patch(0x4373AD, { 0xEB, 0x03 }).Apply(); // Remove preferences.dat hash check Patch::NopFill(Pointer::Base(0x10C99A), 0x6); // Patch to allow spawning AI through effects Patch::NopFill(Pointer::Base(0x1033321), 2); // Prevent game variant weapons from being overridden Pointer::Base(0x1A315F).Write<uint8_t>(0xEB); Pointer::Base(0x1A31A4).Write<uint8_t>(0xEB); Hook(0x1A3267, GrenadeLoadoutHook).Apply(); // Hook game ticks Hook(0x105E64, GameTickHook, HookFlags::IsCall).Apply(); // Prevent FOV from being overridden when the game loads Patch::NopFill(Pointer::Base(0x25FA79), 10); Patch::NopFill(Pointer::Base(0x25FA86), 5); Hook(0x10CA02, FovHook).Apply(); // Used to call Patches::ApplyAfterTagsLoaded when tags have loaded Hook(0x1030EA, TagsLoadedHook).Apply(); // Force descoping for all weapons Pointer::Base(0x73F1E6).Write<uint8_t>(0); // Adds the FMOD WASAPI output fix from FMODEx 4.44.56, which stops weird popping sound at startup // TODO: maybe find a way to update HO's FMOD, HO is using 4.26.6 which is ancient Patch(0x100DA75, { 0x2 }).Apply(); // Remove exception handlers /*Patch::NopFill(Pointer::Base(0x2EA2B), 6); Patch::NopFill(Pointer::Base(0x2EC10), 6); //Patch::NopFill(Pointer::Base(0x7FC411), 6); Patch(0x7FC40B, { 0xC3 }).Apply(); Patch(0x7FC42E, { 0xC3 }).Apply(); Patch::NopFill(Pointer::Base(0x106057), 5);*/ }
void SelfPatchCompare::ComputeSourcePatches() { // Find all full patches that are entirely Valid std::cout << "ComputeSourcePatches() with patch size: " << this->TargetRegion.GetSize() << std::endl; this->SourcePatches.clear(); itk::ImageRegionConstIterator<FloatVectorImageType> imageIterator(this->Image, this->Image->GetLargestPossibleRegion()); while(!imageIterator.IsAtEnd()) { itk::Index<2> currentPixel = imageIterator.GetIndex(); itk::ImageRegion<2> region = ITKHelpers::GetRegionInRadiusAroundPixel(currentPixel, this->TargetRegion.GetSize()[0]/2); if(this->MaskImage->GetLargestPossibleRegion().IsInside(region)) { if(this->MaskImage->IsValid(region)) { this->SourcePatches.push_back(Patch(region)); //DebugMessage("Added a source patch."); } } ++imageIterator; } std::cout << "There are " << this->SourcePatches.size() << " source patches." << std::endl; }
void peanoclaw::Vertex::applyFluxCorrection( peanoclaw::Numerics& numerics ) const { //Fill ghost layers of adjacent cells CellDescription* cellDescriptions[TWO_POWER_D]; for(int cellIndex = 0; cellIndex < TWO_POWER_D; cellIndex++) { if(getAdjacentCellDescriptionIndex(cellIndex) != -1) { cellDescriptions[cellIndex] = &CellDescriptionHeap::getInstance().getData(getAdjacentCellDescriptionIndex(cellIndex)).at(0); } } // Prepare ghostlayer Patch patches[TWO_POWER_D]; dfor2(cellIndex) if(getAdjacentCellDescriptionIndex(cellIndexScalar) != -1) { patches[cellIndexScalar] = Patch( *cellDescriptions[cellIndexScalar] ); } enddforx //Apply coarse grid correction interSubgridCommunication::GhostLayerCompositor ghostLayerCompositor(patches, 0, numerics, false); //TODO unterweg debug // ghostLayerCompositor.applyFluxCorrection(); }
void SafeClickInit(bool bIsInit) { if (bIsInit) { if (SettingGet("SafeClick")) { PlantDetourCall((BYTE *)dwGameDll + 0x54D97F, (BYTE *)(DWORD_PTR)SendAction_interception, 5); bIsSafeClickEnable = true; } return; } if (!bIsSafeClickEnable) { PlantDetourCall((BYTE *)dwGameDll + 0x54D97F, (BYTE *)(DWORD_PTR)SendAction_interception, 5); TextPrint("|CFFFCD211Xenon|R: SafeClick turned |CFF00FF00On|R."); bIsSafeClickEnable = true; } else { Patch(dwGameDll + 0x54D97F, "\xE8\x4C\x5B\xF7\xFF", 5); TextPrint("|CFFFCD211Xenon|R: SafeClick turned |CFFFF0000Off|R."); bIsSafeClickEnable = false; } }
Patch FileLoader::loadMvsPatch(ifstream &file) { vector<int> camIdx; int camNum; Vec3d center; Vec2d sphericalNormal; double fitness; double correlation; // read patch center loadMvsVec(file, center); // read patch spherical normal loadMvsVec(file, sphericalNormal); // load visible camera number file.read((char*) &camNum, sizeof(int)); // load visible camera index for (int i = 0; i < camNum; ++i) { int idx; file.read((char*) &idx, sizeof(int)); camIdx.push_back(idx); } // load fitness file.read((char*) &fitness, sizeof(double)); // load correlation file.read((char*) &correlation, sizeof(double)); return Patch(center, sphericalNormal, camIdx, fitness, correlation); }
int wmain(int argc, wchar_t* argv[]) { Params params; if( !ParseCommandLine(argc, argv, params) ) { PrintHelp(); return 0; } if( !CheckCanBePatched(params.inFileName) ) { return 0; } if( params.outFileName ) { if(!CopyFile(params.inFileName, params.outFileName, FALSE)) { std::cout << "Can't create output file." << std::endl; return 1; } } Patch(params.outFileName ? params.outFileName : params.inFileName, params.caption, params.text); return 0; }
Gui::Gui(Gui&& other) noexcept : m_ptr(other.m_ptr), m_type(other.m_type), m_patch(other.m_patch) { other.m_ptr = nullptr; other.m_type = Type::Invalid; other.m_patch = Patch(); }
void ForceDedicated() { //pit Hook(0x2D0EAC, reinterpret_cast<void*>(0x6D0EBC)).Apply(); // Put the game into dedicated server mode Patch(0x2E600, { 0xB0, 0x01 }).Apply(); // Force syslink to still work Patch(0x12D62E, { 0xEB }).Apply(); Patch(0x12D67A, { 0xEB }).Apply(); Patch(0x5A8BB, { 0xEB }).Apply(); // Crash fixes Patch(0xC9C5E0, { 0xC2, 0x08, 0x00 }).Apply(); //Allows for switching of teams Patch(0x378C0, { 0xB0, 0x00, 0x90, 0x90, 0x90 }).Apply(); // Fixes dedicated host crash caused accessing uninitialized player mapping globals by forcing a player datum index of 0 to always be used instead Patch(0x62E636, { 0x33, 0xFF }).Apply(); // Prevents dedicated hosts from crashing due to invalid texture datum lookup Hook(0x66E982, GetTextureDimensionsHook).Apply(); }
void Clout::Game::AssaultCube::unlimitedAmmo() { // decrement ammo when shooting // ac_client.exe+637E9 - FF 0E - dec [esi] DWORD decrementAmmo = moduleHandle + 0x637E9; Patch((VOID*)decrementAmmo, (VOID*)"\x90\x90", 2); log("(Patch) Ammo decrement nooped"); }
void Clout::Game::AssaultCube::unlimitedGrenades() { // decrement grenade // ac_client.exe+63378 - FF 08 - dec [eax] DWORD decrementGrenade = moduleHandle + 0x63378; Patch((VOID*)decrementGrenade, (VOID*)"\x90\x90", 2); log("(Patch) Grenades decrement nooped"); }
void Clout::Game::AssaultCube::unlimitedHealth() { // sub health when get damage (FOR EVERYONE WHEN LOCAL, also bots) // ac_client.exe + 29D1F - 29 7B 04 - sub[ebx + 04], edi DWORD subtractHealth = moduleHandle + 0x29D1F; Patch((VOID*)subtractHealth, (VOID*)"\x90\x90\x90", 3); log("(Patch) Health decrement nooped"); }
void WoodCutter() { if (!bWoodCutter) { Patch(dwGameDll + 0x3A1505, "\x74", 1); TextPrint("|CFFFCD211Xenon|R: WoodCutter turned |CFF00FF00On|R."); bWoodCutter = true; } else { Patch(dwGameDll + 0x3A1505, "\x75", 1); TextPrint("|CFFFCD211Xenon|R: WoodCutter turned |CFFFF0000Off|R."); bWoodCutter = false; } }
PatchModuleArmor::PatchModuleArmor() : ModuleBase("Patches.Armor") { ElDorito::Instance().Modules.NetworkPatches.PlayerPropertiesExtender.Add(std::make_shared<ArmorExtension>()); AddModulePatches( { // Fix rendering the scoreboard player model // (todo: figure out why your biped doesn't show on the postgame screen...there's probably something missing here) Patch("Scoreboard1", 0x835DAB, 0x90, 0x50), Patch("Scoreboard2", 0x8360DE, 0x90, 0x1A9), Patch("Scoreboard3", 0x83628A, { 0x1C }), Patch("Scoreboard4", 0x83628B, 0x90, 0x3) }, { Hook("ScoreboardModel", 0x8360D9, ScoreboardPlayerModelArmorHook, HookType::Call), // Fix the player model on the main menu Hook("MainMenuModel", 0x60086D, UiPlayerModelArmorHook, HookType::Call) }); engine->OnEvent("Core", "Engine.TagsLoaded", UI_RefreshPlayerArmor); }
Patch FileLoader::loadNvmPatch(ifstream &file, const MVS &mvs) { Vec3d center; Vec3b color; int camNum; vector<int> camIdx; vector<Vec2d> imgPoint; char strbuf[STRING_BUFFER_LENGTH]; char *strip; file.getline(strbuf, STRING_BUFFER_LENGTH); // 3D point strip = strtok(strbuf, DELIMITER); // x center[0] = atof(strip); strip = strtok(NULL, DELIMITER); // y center[1] = atof(strip); strip = strtok(NULL, DELIMITER); // z center[2] = atof(strip); // RGB color strip = strtok(NULL, DELIMITER); color[2] = atoi(strip); // r strip = strtok(NULL, DELIMITER); color[1] = atoi(strip); // g strip = strtok(NULL, DELIMITER); color[0] = atoi(strip); // b // number of measurements ( how many cameras see this point) strip = strtok(NULL, DELIMITER); camNum = atoi(strip); for (int i = 0; i < camNum; i++) { // camera index strip = strtok(NULL, DELIMITER); int idx = atoi(strip); camIdx.push_back(idx); const Camera &cam = mvs.getCameras()[idx]; // feature index strip = strtok(NULL, DELIMITER); // 2D image point Vec2d p; strip = strtok(NULL, DELIMITER); p[0] = atof(strip) + cam.getRgbImage().cols / 2; strip = strtok(NULL, DELIMITER); p[1] = atof(strip) + cam.getRgbImage().rows / 2; imgPoint.push_back(p); } return Patch(center, color, camIdx, imgPoint); }
/// <summary> /// Initializes a new instance of the <see cref="Engine"/> class. /// </summary> Engine::Engine() { auto& patches = ElDorito::Instance().Patches; // hook our engine events enginePatchSet = patches.AddPatchSet("Engine", { Patch("WndProc", 0x42EB63, Utils::Misc::ConvertToVector<void*>(EngineWndProc)), Patch("Network_EndGameWriteStats", 0x16183A0, Utils::Misc::ConvertToVector<void*>(Network_state_end_game_write_stats_enterHook)), Patch("Network_Leaving", 0x16183BC, Utils::Misc::ConvertToVector<void*>(Network_state_leaving_enterHook)), Patch("D3DEndScene1", 0xA2179B, { 0x90 }) }, { Hook("GameTick", 0x505E64, GameTickHook, HookType::Call), Hook("TagsLoaded", 0x5030EA, TagsLoadedHook, HookType::Jmp), Hook("ServerSessionInfo", 0x482AAC, Network_managed_session_create_session_internalHook, HookType::Call), Hook("PlayerKick", 0x437E17, Network_leader_request_boot_machineHook, HookType::Call), Hook("D3DEndScene2", 0xA21796, D3D9Device_EndSceneHook, HookType::Call) }); patches.TogglePatchSet(enginePatchSet); }
void ForceHeadless() { // force windowed (temporarily for now) with null d3d reference device Patch(0x620380, { 0x6A, 0x01, 0x6A, 0x00, 0x90, 0x90 }).Apply(); // Fixes the game being stuck in some d3d-related while loop Patch(0x622290, { 0xC3 }).Apply(); *reinterpret_cast<uint8_t*>(0x1917CED) = 0; // fix dedi crash @ 0xA22325 (pairs with patch above) // Fixes an exception that happens with null d3d Patch(0x675E30, { 0xC3 }).Apply(); //Fixes Host crash on pit, may no longer be necessary //Hook(0x2D0EAC, reinterpret_cast<void*>(0x6D0EBC)).Apply(); //// fixed a UI crash that should no longer be necessary //Patch(0xC9C5E0, { 0xC2, 0x08, 0x00 }).Apply(); //// Stops D3DDevice->EndScene from being called // Patch(0x621796, 0x90, 6).Apply(); // TODO: set eax? }
bool XMLFile::BeginLoad(Deserializer& source) { unsigned dataSize = source.GetSize(); if (!dataSize && !source.GetName().Empty()) { URHO3D_LOGERROR("Zero sized XML data in " + source.GetName()); return false; } SharedArrayPtr<char> buffer(new char[dataSize]); if (source.Read(buffer.Get(), dataSize) != dataSize) return false; if (!document_->load_buffer(buffer.Get(), dataSize)) { URHO3D_LOGERROR("Could not parse XML data from " + source.GetName()); document_->reset(); return false; } XMLElement rootElem = GetRoot(); String inherit = rootElem.GetAttribute("inherit"); if (!inherit.Empty()) { // The existence of this attribute indicates this is an RFC 5261 patch file ResourceCache* cache = GetSubsystem<ResourceCache>(); // If being async loaded, GetResource() is not safe, so use GetTempResource() instead XMLFile* inheritedXMLFile = GetAsyncLoadState() == ASYNC_DONE ? cache->GetResource<XMLFile>(inherit) : cache->GetTempResource<XMLFile>(inherit); if (!inheritedXMLFile) { URHO3D_LOGERRORF("Could not find inherited XML file: %s", inherit.CString()); return false; } // Patch this XMLFile and leave the original inherited XMLFile as it is pugi::xml_document* patchDocument = document_; document_ = new pugi::xml_document(); document_->reset(*inheritedXMLFile->document_); Patch(rootElem); delete patchDocument; // Store resource dependencies so we know when to reload/repatch when the inherited resource changes cache->StoreResourceDependency(this, inherit); // Approximate patched data size dataSize += inheritedXMLFile->GetMemoryUse(); } // Note: this probably does not reflect internal data structure size accurately SetMemoryUse(dataSize); return true; }
/* * Draw teapot */ static void Teapot(float x,float y,float z , float th,float ph , float S) { int i; Transform(x,y,z,S,S,S,th,ph); Color(0,1,0); // Draw patches for (i=0;i<10;i++) { // Draw patch reflected to 4 quadrants if (i<6) { Patch(teapot[i],+1,+1,1); Patch(teapot[i],+1,-1,1); Patch(teapot[i],-1,+1,1); Patch(teapot[i],-1,-1,1); } // Draw patch reflected to 2 hemispheres else { Patch(teapot[i],+1,+1,1); Patch(teapot[i],+1,-1,1); } } glPopMatrix(); }
// // Draw teapot // void Teapot::display() { // Set transform glPushMatrix(); glScaled(s,s,s); glRotated(-90,1,0,0); glRotated(th,dx,dy,dz); glTranslatef(x0,y0,z0); glTranslatef(0,0,-1); glColor3f(R,G,B); // Draw parts of teapot for (int i=0;i<10;i++) // Draw patches reflected to 4 quadrants if (i<6) { Patch(teapot[i],+1,+1,n); Patch(teapot[i],+1,-1,n); Patch(teapot[i],-1,+1,n); Patch(teapot[i],-1,-1,n); } // Draw patch reflected to 2 hemispheres else { Patch(teapot[i],+1,+1,n); Patch(teapot[i],+1,-1,n); } // Undo transformations glPopMatrix(); }
void ApplyAll() { // Scoreboard hooks Hook(0x301A47, GLScoreboardPlayerAllocatorHook).Apply(); Hook(0x2F8ED7, GLScoreboardPlayerConstructorHook).Apply(); Hook(0x310163, ScoreboardUpdateHook).Apply(); // Local player UID hook Hook(0x18A1D6, SetLocalPlayerHook).Apply(); // Set scoreboard UIDs to player datum indexes Patch(0x31000F, { 0x3E, 0x8B, 0x4D, 0xC4 }).Apply(); // mov ecx, [ebp - 0x3C] Patch::NopFill(Pointer::Base(0x310013), 2); // nop out leftover data Patch(0x310018, { 0x31, 0xC9 }).Apply(); // xor ecx, ecx Patch::NopFill(Pointer::Base(0x31001A), 4); // nop out leftover data // Set podium UIDs to player datum indexes Patch(0x2E323E, { 0x8B, 0x47, 0x08 }).Apply(); // mov eax, [edi + 8] Patch::NopFill(Pointer::Base(0x2E3241), 4); // nop out leftover data Patch(0x2E3248, { 0x31, 0xC0 }).Apply(); // xor eax, eax Patch::NopFill(Pointer::Base(0x2E324A), 5); // nop out leftover data }
/// <summary> /// Patch some bytes in the target process to create a jump to the target address. /// </summary> /// <param name="jumpTarget">Function to set as patch jump target.</param> /// <param name="addressToPatch">Address in process memory to patch.</param> /// <param name="numBytesToPatch">Number of bytes to overwrite. Must be at least 10 bytes.</param> /// <param name="pBytesOverwritten">Optional: An array of bytes in which to return the /// overwritten bytes. Must have size >= numBytesToPatch if provided.</param> /// <returns>0 if completed successfully, system error code if not.</returns> DWORD MemoryManager::PatchJump(DWORD addressToPatch, int numBytesToPatch, DWORD jumpTarget, BYTE* &pBytesOverwritten) { BYTE* bytesToPatch = new BYTE[numBytesToPatch]; // patch our memory to create our jump in our byte list DWORD bytesAlreadyWritten = PatchBytesWithJump( reinterpret_cast<DWORD>(bytesToPatch), jumpTarget, addressToPatch ); // add any extra nops on the end memset(reinterpret_cast<void*>(bytesToPatch + bytesAlreadyWritten), 0x90, numBytesToPatch - bytesAlreadyWritten); // patch the actual memory address with our list of bytes DWORD result = Patch(addressToPatch, numBytesToPatch, bytesToPatch, pBytesOverwritten); delete[] bytesToPatch; return result; }
//Create a PatchMap which synthesises a new map. PatchMap::PatchMap(const MapLUT& lut, unsigned int x, unsigned int y, float windowWidth, float windowHeight): lut(lut), graph(RoadGraph((float)(xTiles * windowWidth), (float)(yTiles * windowHeight))), patchWidth(windowWidth), patchHeight(windowHeight), xTiles(x), yTiles(y), xPos(0), yPos(0), genGraph(false) { //Set up patch array. patches = std::vector<std::vector<Patch> >(x, std::vector<Patch>(y, Patch(MapFragment()))); };
peanoclaw::Patch peanoclaw::tests::createPatch( int unknownsPerSubcell, int parametersWithoutPerSubcell, int parametersWithPerSubcell, int subdivisionFactor, int ghostlayerWidth, tarch::la::Vector<DIMENSIONS, double> position, tarch::la::Vector<DIMENSIONS, double> size, int level, double time, double timestepSize, double minimalNeighborTime, bool virtualPatch ) { int cellDescriptionIndex = CellDescriptionHeap::getInstance().createData(); std::vector<peanoclaw::records::CellDescription>& cellDescriptions = CellDescriptionHeap::getInstance().getData(cellDescriptionIndex); cellDescriptions.push_back(peanoclaw::records::CellDescription()); peanoclaw::records::CellDescription& cellDescription = CellDescriptionHeap::getInstance().getData(cellDescriptionIndex).at(0); cellDescription.setSubdivisionFactor(subdivisionFactor); cellDescription.setGhostlayerWidth(ghostlayerWidth); cellDescription.setUnknownsPerSubcell(unknownsPerSubcell); cellDescription.setSize(size); cellDescription.setPosition(position); cellDescription.setLevel(level); cellDescription.setTime(time); cellDescription.setTimestepSize(timestepSize); cellDescription.setMinimalNeighborTime(minimalNeighborTime); cellDescription.setCellDescriptionIndex(cellDescriptionIndex); cellDescription.setIsVirtual(false); //uNew array int uNewIndex = DataHeap::getInstance().createData(); std::vector<peanoclaw::records::Data>& uNew = DataHeap::getInstance().getData(uNewIndex); int uNewArraySize = tarch::la::aPowI(DIMENSIONS, subdivisionFactor)*unknownsPerSubcell; int uOldArraySize = tarch::la::aPowI(DIMENSIONS, (subdivisionFactor+2*ghostlayerWidth)) * unknownsPerSubcell; int parametersWithoutGhostlayerArraySize = tarch::la::aPowI(DIMENSIONS, subdivisionFactor) * parametersWithoutPerSubcell; int parametersWithGhostlayerArraySize = tarch::la::aPowI(DIMENSIONS, subdivisionFactor + 2*ghostlayerWidth) * parametersWithPerSubcell; for(int i = 0; i < uNewArraySize + uOldArraySize + parametersWithoutGhostlayerArraySize + parametersWithGhostlayerArraySize; i++) { peanoclaw::records::Data data; data.setU(0.0); uNew.push_back(data); } cellDescription.setUIndex(uNewIndex); return Patch(cellDescription); }
void Terrain::Create(void) { node = new R3Node(); node->transformation = R3identity_matrix; R3Material::Params matParams; matParams.textureName = "mars.jpg"; matParams.kd = R3Rgb(0.6, 0.6, 0.6, 1); matParams.ks = R3Rgb(0.3, 0.3, 0.3, 1); R3Material *mat = new R3Material(matParams); node->AddChild(new R3Node(Patch(R3Point(0,-3, 0), R2Point(TERRAIN_SIZE,TERRAIN_SIZE), R2Point(TERRAIN_DPS,TERRAIN_DPS)), mat, R3identity_matrix)); //node->AddChild(new R3Node(Patch(R3Point(10,-3, 0), R2Point(10,10), R2Point(60,60)), NULL, R3identity_matrix)); globals.scene->root->AddChild(node); }
bool ofxCalibImage::expandByAngle(int nSrc, int nDirn){ ofxCalibGridCorner &gSrc = mvGridCorners[nSrc]; CVD::ImageRef irBest; double dBestDist = 99999; TooN::Vector<2> v2TargetDirn = gSrc.Params.m2Warp().T()[nDirn%2]; if(nDirn >= 2) v2TargetDirn *= -1; for(unsigned int i=0; i<mvCorners.size(); i++){ TooN::Vector<2> v2Diff = vec(mvCorners[i]) - gSrc.Params.v2Pos; if( (v2Diff * v2Diff) < 100 ) continue; if( (v2Diff * v2Diff) > (dBestDist * dBestDist) ) continue; TooN::Vector<2> v2Dirn = v2Diff; normalize(v2Dirn); if( (v2Dirn * v2TargetDirn) < cos(M_PI / 18.0) ) continue; dBestDist = sqrt(v2Diff * v2Diff); irBest = mvCorners[i]; } ofxCalibGridCorner gTarget; gTarget.Params = gSrc.Params; gTarget.Params.v2Pos = vec(irBest); gTarget.Params.dGain *= -1; PTAMM::CalibCornerPatch Patch( data->CornerPatchSize); if(!Patch.IterateOnImageWithDrawing(gTarget.Params, mim)){ gSrc.aNeighborStates[nDirn].val = N_FAILED; return false; } gTarget.irGridPos = gSrc.irGridPos; if(nDirn < 2) gTarget.irGridPos[nDirn]++; else gTarget.irGridPos[nDirn%2]--; // Update connection states: mvGridCorners.push_back(gTarget); // n.b. This invalidates gSrc! mvGridCorners.back().aNeighborStates[(nDirn + 2) % 4].val = nSrc; mvGridCorners[nSrc].aNeighborStates[nDirn].val = static_cast<int>(mvGridCorners.size()) - 1; mvGridCorners.back().draw(); return true; }
// Fill patch map from a city, rather than synthesising a new one. void PatchMap::fill(const City& city){ // Modify patch width/height to fit the user specified number of tiles. patchWidth = (float)city.getWidth() / xTiles; patchHeight = (float)city.getHeight() / yTiles; for(size_t x = 0; x < xTiles; ++x){ for(size_t y = 0; y < yTiles; ++y){ MapFragment frag; city.fillFragment(frag, x * patchWidth, y * patchHeight, patchWidth, patchHeight); patches[x][y] = Patch(frag); } } updatePositions(); updateEdges(); graph.clear(); };
Patch Instance::createPatch(std::string const& name, std::string const& path) { Patch patch; t_canvas* cnv = nullptr; Pd::lock(); pd_setinstance(reinterpret_cast<t_pdinstance *>(m_ptr)); if(!name.empty() && !path.empty()) { cnv = reinterpret_cast<t_canvas*>(glob_evalfile(NULL, gensym(name.c_str()), gensym(path.c_str()))); cnv->gl_edit = 0; } else if(!name.empty()) { cnv = reinterpret_cast<t_canvas*>(glob_evalfile(NULL, gensym(name.c_str()), gensym(""))); cnv->gl_edit = 0; } if(cnv) { patch = Patch(*this, cnv, name, path); } Pd::unlock(); return patch; }