void HelloWorld::myupdate(float dt){ camera->setPosition3D(car_cabine->getPosition3D() + Vec3(100.0f * sinf(_angle), 30.0f, 100.0f * cosf(_angle))); camera->lookAt(car_cabine->getPosition3D(), Vec3(0.0f, 1.0f, 0.0f)); if (_hud->movingleft == true){ constraint5->setLimit(CC_DEGREES_TO_RADIANS(-20), CC_DEGREES_TO_RADIANS(0)); physics_rbd_wheel_bar->setAngularVelocity(Vec3(0.0, 1.0, 0.0)); //physics_rbd_wheel_bar->setAngularFactor(Vec3(0.0, 0.0, 0.0)); } if (_hud->movingright == true){ constraint5->setLimit(CC_DEGREES_TO_RADIANS(0), CC_DEGREES_TO_RADIANS(20)); physics_rbd_wheel_bar->setAngularVelocity(Vec3(0.0, -1.0, 0.0)); //physics_rbd_wheel_bar->setAngularFactor(Vec3(0.0, 0.0, 0.0)); } if (_hud->movingup == true){ constraint5->setLimit(CC_DEGREES_TO_RADIANS(-0.5), CC_DEGREES_TO_RADIANS(0.5)); Vec3 mynearP((int)wheel1->getPosition3D().x, 0.0, (int)wheel1->getPosition3D().z), myfarP((int)wheel3->getPosition3D().x, 0.0, (int)wheel3->getPosition3D().z); Vec3 mynearP2((int)wheel2->getPosition3D().x, 0.0, (int)wheel2->getPosition3D().z), myfarP2((int)wheel4->getPosition3D().x, 0.0, (int)wheel4->getPosition3D().z); Vec3 mydir(myfarP - mynearP); Vec3 mydir2(myfarP2 - mynearP2); Vec3 mylinearVel = (mydir+mydir2)/2; mylinearVel.normalize(); mylinearVel *= 50.0f; mylinearVel.y = 0; physics_rbd_wheel3->setLinearVelocity(mylinearVel); physics_rbd_wheel4->setLinearVelocity(mylinearVel); } }
void HelloWorld::onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event) { /** if (!shootBox) return; if (!touches.empty()) { auto location = touches[0]->getLocationInView(); Vec3 nearP(location.x, location.y, -1.0f), farP(location.x, location.y, 1.0f); nearP = camera->unproject(nearP); farP = camera->unproject(farP); Vec3 dir(farP - nearP); shootBoxfunc(camera->getPosition3D() + dir * 10.0f); event->stopPropagation(); }**/ Vec3 mynearP((int)wheel1->getPosition3D().x, 0.0, (int)wheel1->getPosition3D().z), myfarP((int)wheel3->getPosition3D().x, 0.0, (int)wheel3->getPosition3D().z); Vec3 mynearP2((int)wheel2->getPosition3D().x, 0.0, (int)wheel2->getPosition3D().z), myfarP2((int)wheel4->getPosition3D().x, 0.0, (int)wheel4->getPosition3D().z); Vec3 mydir(myfarP - mynearP); Vec3 mydir2(myfarP2 - mynearP2); Vec3 mylinearVel = (mydir + mydir2) / 2; mylinearVel.normalize(); mylinearVel *= 30.0f; mylinearVel.y = 0; shootBoxfunc(mylinearVel); }
void MovieMaker::makeMovie() { if(!initialized){ Initialize(); } if (!stopProcessing) { if (!input->isICMAInstance()) { processInstance(); } else { //Perform ICMA related processing //Output jpeg files unsigned int numFrames = input->getNumberOfFrames(); *frameCounter = numFrames; //Store for xml string description boost::filesystem::path dir(workingDir); boost::filesystem::path odir(outputDir); std::ostringstream ss; try { //Extract Overlay data and get mesh information gdcm::Reader gdcmReader; //Read the dicom file std::string dicomFile(input->getDICOMFile()); gdcmReader.SetFileName(dicomFile.c_str()); if (!gdcmReader.Read()) { std::cout << "Unable to read file " << dicomFile; processInstance(); return; } gdcm::File &file = gdcmReader.GetFile(); gdcm::DataSet &ds = file.GetDataSet(); gdcm::Tag oytag(0x6000, 0x3000); //Overlay data tag const gdcm::DataElement &de = ds.GetDataElement(oytag); const gdcm::ByteValue *bv = de.GetByteValue(); std::ostringstream cpd; cpd.write(bv->GetPointer(), bv->GetLength()); std::string imageViewEncoding = input->getTransducerData(); std::vector<std::string> views; boost::split(views, imageViewEncoding, boost::is_any_of("#")); if (views.size() > 0) { std::string targetDir = (odir / prefix).string(); boost::filesystem::create_directories(targetDir); boost::filesystem::path mydir(targetDir); std::string metaDataFile = ""; try { std::stringstream compressed; compressed << cpd.str(); std::stringstream decompressed; boost::iostreams::filtering_streambuf< boost::iostreams::input> in; in.push(boost::iostreams::gzip_decompressor()); in.push(compressed); boost::iostreams::copy(in, decompressed); metaDataFile = (mydir / "metaData.xml").string(); std::ofstream metaData(metaDataFile.c_str(), std::ios::out); metaData << decompressed.str(); metaData.close(); } catch (std::exception& gzipe) { //Copy of the dicom file is set as meta data metaDataFile = (mydir / "dicom.dcm").string(); boost::filesystem::copy_file( input->getDICOMFile().c_str(), metaDataFile.c_str(), boost::filesystem::copy_option::overwrite_if_exists); } //Create images int imageIndex = 0; for (int i = 0; i < views.size(); i++) { std::string vrec = views[i]; boost::trim(vrec); if (vrec.length() > 0) { int idx = vrec.find('|'); std::string viewName = vrec.substr(0, idx); int frameCount = atoi(vrec.substr(idx + 1).c_str()); std::string viewDir = (mydir / viewName).string(); boost::filesystem::create_directories(viewDir); boost::filesystem::path vdPath(viewDir); for (int j = 0; j < frameCount; j++) { ss.str(""); ss << viewName << std::setfill('0') << std::setw(3) << j << ".jpg"; std::string fn = (vdPath / ss.str()).string(); input->saveFrameAsJpeg(fn, j + imageIndex); } imageIndex += frameCount; } } std::string fn = prefix + ".properties"; std::ofstream properties((odir / fn).string().c_str(), std::ios::out); properties << "ICMA_FEM = TRUE" << std::endl; properties << "METADATAFILE = " << metaDataFile << std::endl; properties << "VIEWENCODING = " << imageViewEncoding << std::endl; properties << "SOPIUID = " << input->getSopInstanceUID() << std::endl; //TODO Add target ED EC data to mark the cardiac cycle times properties.close(); } } catch (std::exception& e) { std::cout << e.what() << std::endl; } } } }