void tBulletDebugObject::drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color) { line_position.push_back(tVec(from)); line_color.push_back(tVec(color)); line_position.push_back(tVec(to)); line_color.push_back(tVec(color)); }
qglviewer::Vec Cube::getTranslationVector() { qglviewer::Vec tVec(0, 0, 0); for (std::string::size_type j = 0; j < CubeType.size(); j++) { tVec += faceToNormal(CubeType[j]); } return tVec; }
VRPlayer::VRPlayer(tVector origin) { this->origin = origin; this->base_position = origin; teleport = false; teleport_dst = tVec(0.0f, 0.0f, 0.0f); }
void createPermutation(hash_map<int,int> hm,vector<int> cur,vector<vector<int> >& res){ if(hm.size()){ for(hash_map<int,int>::iterator it=hm.begin();it!=hm.end();it++){ vector<int> tVec(cur); hash_map<int,int> tMap(hm); tVec.push_back(it->first); if(tMap[it->first]==1) tMap.erase(it->first); else tMap[it->first]--; createPermutation(tMap,tVec,res); } } else res.push_back(cur); }
/** * @brief This function prepares data to be written to a file. */ void Streamer::zipWithTime( ) { size_t numEntriesInEachTable = tables_[0]->getVecSize( ); //LOG( moose::debug, "Entries in each table " << numEntriesInEachTable ); // Collect data from all table. If some table does not have enough data, // fill it with nan vector< vector< double > > collectedData; for( size_t i = 0; i < tables_.size( ); i++ ) { vector<double> tVec( tables_[i]->getVec( ) ); if( tVec.size( ) <= numEntriesInEachTable ) { #if 0 LOG( moose::debug , "Table " << tables_[i]->getName( ) << " is not functional. Filling with zero " ); #endif tVec.resize( numEntriesInEachTable, 0 ); } collectedData.push_back( tVec ); } // Turn it into a table format. Its like taking a transpose of vector< // vector >. double allTableDt = tableDt_[ 0 ]; for( size_t i = 0; i < collectedData[0].size( ); i++ ) { data_.push_back( currTime_ ); currTime_ += allTableDt; for( size_t ii = 0; ii < collectedData.size(); ii++ ) data_.push_back( collectedData[ ii ][ i ] ); } // After collection data from table, clear tables. for(size_t i = 0; i < tables_.size(); i++ ) tables_[i]->clearVec( ); return; }
void CSVIO::read(std::vector<std::vector<double> >& out){ CSVRow row; std::vector<string> rowStr; row.read(ifs); rowStr = row.getData(); std::vector<double> tVec(rowStr.size()); int rowindex = 0; while(!ifs.fail() && !ifs.eof() && (rowindex < nrow)){ row.read(ifs); rowStr = row.getData(); for(int i = 0; i < rowStr.size(); i++){ tVec[i] = std::stof(rowStr.at(i)); } out.push_back(tVec); ++rowindex; rowStr.clear(); } }
JNIEXPORT void JNICALL Java_osg_AndroidExample_osgNativeLib_setClearColor(JNIEnv * env, jobject obj, jint red, jint green, jint blue){ osg::Vec4 tVec((float) red / 255.0f, (float) green / 255.0f, (float) blue / 255.0f, 0.0f); mainApp.setClearColor(tVec); }
void CB_StateCameraTest2::draw() { float iPolRot = (-cos(interpolation * PI) / 2 + 0.5); glPushMatrix(); glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); if(!CB_StateManager::isDeactivating()) { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } float autoFL = 1 / ((sin(theta * 1.5) * 0.5 + 1.0)); float usedScale = 0; if(!manualMode) { CB_Screen::setOrthoZoom(autoFL); usedScale = autoFL; } else { CB_Screen::setOrthoZoom(fLScale); usedScale = fLScale; } CB_Screen::setProjection(interpolation); //CB_Screen::setOrthoZoom(1.0); if(!manualMode) { camera->setFocalLength(CB_Screen::getZ() * autoFL); camera->setPosition(160 + 64 * sin(theta), 120 + 64 * cos(theta), 0); camera->setRotation(sin(theta * 2) * 10 * iPolRot, cos(theta * 2) * 10 * iPolRot, 0); } else { camera->setFocalLength(CB_Screen::getZ() * fLScale); camera->setPosition(x, y, z); camera->setRotation(xRot * iPolRot, yRot * iPolRot, 0); } double zPosThing = CB_Screen::getZ(); double fovThing = CB_Screen::getFOV(); camera->doCamera(); CB_Vector3D tVec(0, 0, camera->getFocalLength() - zPosThing); tVec = camera->getRotation() * tVec * tVec.length(); tVec = tVec + camera->getPosition(); CB_Vector3D dVec = camera->getActualPosition() - tVec; CB_Vector3D aVec = tVec - (dVec * (tVec.z / dVec.z)); box->addBox(aVec.x, aVec.y, aVec.z, -1, -1, -1, 2, 2, 2, 0xFFFF0000, false); tVec = CB_Vector3D(64, 0, camera->getFocalLength() - zPosThing); tVec = camera->getRotation() * tVec * tVec.length(); tVec = tVec + camera->getPosition(); dVec = camera->getActualPosition() - tVec; aVec = tVec - (dVec * (tVec.z / dVec.z)); box->addBox(aVec.x, aVec.y, aVec.z, -1, -1, -1, 2, 2, 2, 0xFFFF0000, false); tVec = CB_Vector3D(0, 64, camera->getFocalLength() - zPosThing); tVec = camera->getRotation() * tVec * tVec.length(); tVec = tVec + camera->getPosition(); dVec = camera->getActualPosition() - tVec; aVec = tVec - (dVec * (tVec.z / dVec.z)); box->addBox(aVec.x, aVec.y, aVec.z, -1, -1, -1, 2, 2, 2, 0xFFFF0000, false); //glPushMatrix(); //glTranslated(160 + 64 * sin(theta), 120 + 64 * cos(theta), 0); //drawBox(-4, -4, -4, 8, 8, 8); box->addBox(160 + 64 * sin(theta), 120 + 64 * cos(theta), 0, -4, -4, -4, 8, 8, 8, 0xFF5588FF, false); CB_Renderer::process(); //glPopMatrix(); //drawBox(80, 0, -1280, 320, 240, 80); //drawBox(128, 64, -24, 32, 16, 48); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); addLight(0.25, 0.5, 1, 0, 0xFF808080, 0xFFFFFFFF, GL_LIGHT0); box->addBox(80, 0, -1280, 0, 0, 0, 320, 240, 80, 0xFF8855FF, false); box->addBox(128, 64, -24, 0, 0, 0, 32, 16, 48, 0xFFFF5588, false); //drawBox(160, 0, -520, 320, 64, 400, 0xFF5599FF); box->addBox(160, 0, -520, 0, 0, 0, 160, 64, 200, 0xFF5599FF, false); box->addBox(320, 0, -520, 0, 0, 0, 160, 64, 200, 0xFF5599FF, true); box->addBox(160, 0, -320, 0, 0, 0, 160, 64, 200, 0xFF5599FF, true); box->addBox(320, 0, -320, 0, 0, 0, 160, 64, 200, 0xFF5599FF, false); CB_Renderer::process(); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); drawBox(448, 64, -520, 32, 32, 32); drawBox(0, 0, -120, 320, 32, 80); drawBox(0, 0, -400, 128, 144, 32); drawBox(0, 0, -40, 128, 128, 32); drawBox(0, 0, -8, 32, 16, 16); drawBox(32, 16, -8, 32, 16, 16); glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); addLight(0, 0.25, 1, 0, 0xFF202020, 0xFFFFFFFF, 0xFFFFFFFF, GL_LIGHT0); glPushMatrix(); glTranslated(64, 40, 0); glRotated(theta * 45, 1.0, 0.0, 0.0); string sA1[] = {"h_right", "split_cross", "regular", "h_left", "h_right", "h_left"}; string sA2[] = {"h_center", "split_cross", "split_cross", "h_center", "h_center", "h_center"}; string sA3[] = {"h_left", "regular", "split_cross", "h_right", "h_left", "h_right"}; string sA4[] = {"regular", "regular", "regular", "regular", "regular", "regular"}; drawBox(0, -8, -8, 16, 16, 16, sheet, sA1); drawBox(16, -8, -8, 16, 16, 16, sheet, sA2); //drawBox(32, -8, -8, 16, 16, 16, sheet, sA2); //drawBox(48, -8, -8, 16, 16, 16, sheet, sA3); box->addBox(40, 0, 0, -8, -8, -8, 16, 16, 16, sheet, sA2, true); box->addBox(56, 0, 0, -8, -8, -8, 16, 16, 16, sheet, sA3, true); box->addBox(72, 0, 0, -8, -8, -8, 16, 16, 16, sheet, sA4, true); box->addBox(88, 0, 0, -8, -8, -8, 16, 16, 16, 0xFFFFFFFF, true); CB_SpriteRenderer * sprite = (CB_SpriteRenderer*)CB_Renderer::getRenderer("sprite"); sprite->addSprite(96, 8, 0, 0, 0, 0, sheet, "circle"); CB_Renderer::process(64, 40, 0); glPopMatrix(); CB_LineRenderer * lineRenderer = (CB_LineRenderer*)CB_Renderer::getRenderer("line"); CB_SphereRenderer * sphereRenderer = (CB_SphereRenderer*)CB_Renderer::getRenderer("sphere"); lineRenderer->addLine(120, 80, 0, -8, 0, 0, 8, 0, 0, 2); lineRenderer->addLine(120, 80, 0, 0, 0, 0, 0, 16, 0, 2); lineRenderer->addLine(136, 96, -8, -3, 0, 1, -1, 3, 1, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, -1, 3, 1, 0, 6, 0, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, 3, 0, -2, 3, 3.5, -2, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, 3, 3.5, -2, 0, 6, 0, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, 0, 6, 0, 0, 12, 0, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, 0, 12, 0, -2, 11, 3, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, -2, 11, 3, 1, 9, 4, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, 0, 12, 0, 3, 10, -2, 2, 0xFF0000FF); lineRenderer->addLine(136, 96, -8, 3, 10, -2, 6, 9, -2, 2, 0xFF0000FF); sphereRenderer->addSphere(136, 110, -8, 2, 32, 15, 0xFF0000FF, true); glDisable(GL_LIGHTING); CB_Renderer::process(); glEnable(GL_LIGHTING); glDepthFunc(GL_LEQUAL); drawBox(0, 80, -8, 16, 16, 8, sheet, sA4); glDisable(GL_TEXTURE_2D); sphereRenderer->addSphere(136, 128, -8, 2, 64, 31, 0xFF0000FF, true); //drawBox(96, 80, -8, 16, 16, 8, 0xFFFFFFFF); box->addBox(104, 88, -8, -8, -8, -8, 16, 16, 16, 0xFFFFFFFF, false); box->addBox(136, 88, -8, -8, -8, -8, 16, 16, 16, 0xFFFFFFFF, true); CB_Renderer::process(); glEnable(GL_TEXTURE_2D); glPushMatrix(); glEnable(GL_STENCIL_TEST); glClear(GL_STENCIL_BUFFER_BIT); glColorMask(0, 0, 0, 0); //glDisable(GL_DEPTH_TEST); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); //drawBox(96, 80, -8, 16, 16, 8, 0xFFFFFFFF); box->addBox(104, 88, -8, -8, -8, -8, 16, 16, 16, 0xFFFFFFFF, false); box->addBox(136, 88, -8, -8, -8, -8, 16, 16, 16, 0xFFFFFFFF, true); CB_Renderer::process(); glColorMask(1, 1, 1, 1); //glEnable(GL_DEPTH_TEST); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glMatrixMode(GL_PROJECTION); float fTest[16]; glGetFloatv(GL_PROJECTION_MATRIX, fTest); glLoadIdentity(); CB_Screen::setOrthoZoom((manualMode ? fLScale : autoFL)); CB_Screen::setOrtho(); CB_Screen::setOrthoZoom(1.0); glMatrixMode(GL_MODELVIEW); float fTest2[16]; glGetFloatv(GL_MODELVIEW_MATRIX, fTest2); glLoadIdentity(); glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDepthMask(false); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glTranslatef((manualMode ? yRot : cos(theta * 2) * 10) * iPolRot * PI / 180, (manualMode ? xRot : sin(theta * 2) * 10) * iPolRot * PI / 180, 0); glMatrixMode(GL_MODELVIEW); glBlendFunc(GL_DST_COLOR, GL_ZERO); glEnable(GL_BLEND); CB_Texture::getTexture("plaid")->bind(); glBegin(GL_QUADS); glTexCoord2d(0, 30); glVertex2d(-160, -120); glTexCoord2d(40, 30); glVertex2d(160, -120); glTexCoord2d(40, 0); glVertex2d(160, 120); glTexCoord2d(0, 0); glVertex2d(-160, 120); glEnd(); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glDepthMask(true); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glLoadMatrixf(fTest); glMatrixMode(GL_MODELVIEW); glDisable(GL_STENCIL_TEST); glLoadIdentity(); glLoadMatrixf(fTest2); glPopMatrix(); glPushMatrix(); glTranslated(0, 144, -384); drawBox(0, 0, -4, 128, 4, 8, 0xFF808080); drawBox(0, 4, -4, 4, 16, 8, 0xFF808080); drawBox(124, 4, -4, 4, 16, 8, 0xFF808080); drawBox(0, 20, -4, 128, 4, 8, 0xFF808080); drawBox(4, 4, -4, 120, 16, 2, 0xFF808080); drawBox(4, 4, -2, 120, 16, 1.9, 0xFF000000); glEnable(GL_STENCIL_TEST); glClear(GL_STENCIL_BUFFER_BIT); glColorMask(0, 0, 0, 0); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glBegin(GL_QUADS); glVertex2d(4, 4); glVertex2d(124, 4); glVertex2d(124, 20); glVertex2d(4, 20); glEnd(); glColorMask(1, 1, 1, 1); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); double rTheta = theta * 100; uint32_t iTheta = (uint32_t)rTheta; rTheta = rTheta - iTheta; iTheta = iTheta % (tickerWidth + 248); rTheta+= iTheta; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1.0, 1.0, 1.0); //font->drawString(ticker, 124 - rTheta, 8); glTranslated(-rTheta, 0.0, 0.0); glCallList(tickerList); glDisable(GL_BLEND); glDisable(GL_STENCIL_TEST); glPopMatrix(); glDisable(GL_TEXTURE_2D); glColor3d(1.0, 1.0, 1.0); /*glLineWidth(10 * (manualMode?1/fLScale:1/autoFL)); glPointSize(10 * (manualMode?1/fLScale:1/autoFL)); glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glBegin(GL_POINTS); glVertex3d(-32, 128, -512); glEnd(); glBegin(GL_LINES); glVertex3d(-32, 128, -512); glVertex3d(-32, 128, 0); glEnd(); glBegin(GL_POINTS); glVertex3d(-32, 128, 0); glEnd(); glBegin(GL_LINES); glVertex3d(-32, 128, 0); glVertex3d(32, 128, 0); glEnd(); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glBegin(GL_POINTS); glVertex3d(32, 128, 0); glEnd(); glBegin(GL_LINES); glVertex3d(32, 128, 0); glVertex3d(32, 96, 0); glEnd(); glBegin(GL_POINTS); glVertex3d(32, 96, 0); glEnd(); glDisable(GL_LINE_SMOOTH); glDisable(GL_POINT_SMOOTH);*/ glLineWidth(1); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); camera->resetCamera(); glPopMatrix(); glPushMatrix(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); CB_Screen::setOrthoZoom(2.0); CB_Screen::setOrtho(); CB_Screen::setOrthoZoom(1.0); glMatrixMode(GL_MODELVIEW); glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4d(1.0, 1.0, 1.0, 1.0); if(displayHelp) { glCallList(instructionList); } //font->drawString((char*)glGetString(GL_EXTENSIONS), 0, 220); //font->drawString("ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz", 0, 200); if(displayDebug) { for(int i = 0; i < 16; i++) { float cF = fTest[i]; stringstream cvt; cvt << cF; double cFX = -300 + (i / 4) * 100; double cFY = 50 - (i % 4) * 10; font->drawString(cvt.str(), cFX, cFY); } for(int i = 0; i < 16; i++) { float cF = fTest2[i]; stringstream cvt; cvt << cF; double cFX = -300 + (i / 4) * 100; double cFY = 0 - (i % 4) * 10; font->drawString(cvt.str(), cFX, cFY); } { stringstream cvt; cvt << zPosThing << " - " << fovThing; font->drawString(cvt.str(), -300, -50); } } glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); glBegin(GL_LINES); glColor3d(1, 1, 1); glVertex2d(0, 0); glVertex2d(sin(interpolation * PI) * 100, cos(interpolation * PI) * 100); glEnd(); glPopMatrix(); }