Ejemplo n.º 1
0
rc_t archIndexTestSerialization(ss_m*, test_volume_t*)
{
    // ============================== DIR 1 ==============================
    LogArchiver::ArchiveDirectory dir1(test_env->archive_dir, BLOCK_SIZE,
            true /* createIndex */);
    EXPECT_TRUE(dir1.getIndex());

    unsigned total = 0;
    generateFakeArchive(&dir1, BLOCK_SIZE*1000, 10, total);
    // ===================================================================


    // ============================== DIR 2 ==============================
    LogArchiver::ArchiveDirectory dir2(test_env->archive_dir, BLOCK_SIZE,
            true /* createIndex */);
    EXPECT_TRUE(dir2.getIndex());
    // ===================================================================

    LogArchiver::ArchiveIndex* index1 = dir1.getIndex();
    LogArchiver::ArchiveIndex* index2 = dir2.getIndex();
    EXPECT_EQ(index1->runs.size(), index2->runs.size());

    for(unsigned i=0; i<index1->runs.size(); i++) {
        EXPECT_EQ(index1->runs[i].entries.size(), index2->runs[i].entries.size());
        for(unsigned j=0; j<index1->runs[i].entries.size(); j++) {
            EXPECT_EQ(index1->runs[i].entries[j].offset, index2->runs[i].entries[j].offset);
            EXPECT_EQ(index1->runs[i].entries[j].pid, index2->runs[i].entries[j].pid);
        }
    }

    return RCOK;
}
Ejemplo n.º 2
0
void CGenericParticleProjectile::Draw()
{
	inArray = true;

	if (directional) {
		float3 dif(pos-camera->GetPos());
		dif.ANormalize();
		float3 dir1(dif.cross(speed));
		dir1.ANormalize();
		float3 dir2(dif.cross(dir1));

		unsigned char color[4];

		colorMap->GetColor(color, life);

		va->AddVertexTC(drawPos - dir1 * size - dir2 * size, texture->xstart, texture->ystart, color);
		va->AddVertexTC(drawPos - dir1 * size + dir2 * size, texture->xend,   texture->ystart, color);
		va->AddVertexTC(drawPos + dir1 * size + dir2 * size, texture->xend,   texture->yend,   color);
		va->AddVertexTC(drawPos + dir1 * size - dir2 * size, texture->xstart, texture->yend,   color);
	} else {
		unsigned char color[4];

		colorMap->GetColor(color, life);

		va->AddVertexTC(drawPos - camera->right * size - camera->up * size, texture->xstart, texture->ystart, color);
		va->AddVertexTC(drawPos + camera->right * size - camera->up * size, texture->xend,   texture->ystart, color);
		va->AddVertexTC(drawPos + camera->right * size + camera->up * size, texture->xend,   texture->yend,   color);
		va->AddVertexTC(drawPos - camera->right * size + camera->up * size, texture->xstart, texture->yend,   color);
	}
}
Ejemplo n.º 3
0
void exportToHTML::createIndexFile(const QString &filePath,const  QString &catName)
{
    QDir dir1(filePath);
    QStringList fileList = dir1.entryList(QDir::NoDotAndDotDot|QDir::Files,QDir::NoSort);
    QString tempFileName;

    QFile indexFile(filePath+"/index.html");
    if(indexFile.open(QIODevice::WriteOnly))
    {
        QTextStream out(&indexFile);
        out<<"<html>";
        out<<"<head><title>"<<catName<<"</title></head>";
        out<<"<body align=\"justify\">";
        out<<"<h2 style='font-family:monospace'> Notes categorized under "<<catName<<"</h2>";
        out<<"<ul>";
        for(QStringList::const_iterator iter = fileList.begin(); iter!= fileList.end(); ++iter)
        {
            if(*iter == "index.html")
                continue;
            tempFileName = *iter;
            tempFileName.remove(tempFileName.size()-5,5);

            out<<"<li><a href=\"./"<<*iter<<"\">"<<tempFileName<<"</a></li>\n";
        }
        out<<"</ul>";
        out<<"</body>";
        out<<"</html>";

    }
}
void CGeoSquareProjectile::Draw(void)
{
	inArray=true;
	unsigned char col[4];
	col[0]=(unsigned char) (r*a*255);
	col[1]=(unsigned char) (g*a*255);
	col[2]=(unsigned char) (b*a*255);
	col[3]=(unsigned char) (a*255);

	float3 dif(p1-camera->pos);
	dif.Normalize();
	float3 dir1(dif.cross(v1));
	dir1.Normalize();
	float3 dif2(p2-camera->pos);
	dif2.Normalize();
	float3 dir2(dif2.cross(v2));
	dir2.Normalize();

	if(w2!=0){
		va->AddVertexTC(p1-dir1*w1,1.0/16,1.0/8,col);
		va->AddVertexTC(p1+dir1*w1,1.0/16,0.0/8,col);
		va->AddVertexTC(p2+dir2*w2,1.0/16,0.0/8,col);
		va->AddVertexTC(p2-dir2*w2,1.0/16,1.0/8,col);
	} else {
		va->AddVertexTC(p1-dir1*w1,1.0/16,1.0/8,col);
		va->AddVertexTC(p1+dir1*w1,1.0/16,0.0/8,col);
		va->AddVertexTC(p2+dir2*w2,1.0/16,0.5/8,col);
		va->AddVertexTC(p2-dir2*w2,1.0/16,1.5/8,col);
	}
}
Ejemplo n.º 5
0
void CGeoSquareProjectile::Draw()
{
	inArray = true;
	unsigned char col[4];
	col[0] = (unsigned char) (r * a * 255);
	col[1] = (unsigned char) (g * a * 255);
	col[2] = (unsigned char) (b * a * 255);
	col[3] = (unsigned char) (    a * 255);

	float3 dif(p1 - camera->GetPos());
	dif.ANormalize();
	float3 dir1(dif.cross(v1));
	dir1.ANormalize();
	float3 dif2(p2 - camera->GetPos());
	dif2.ANormalize();
	float3 dir2(dif2.cross(v2));
	dir2.ANormalize();


	const float u = (projectileDrawer->geosquaretex->xstart + projectileDrawer->geosquaretex->xend) / 2;
	const float v0 = projectileDrawer->geosquaretex->ystart;
	const float v1 = projectileDrawer->geosquaretex->yend;

	if (w2 != 0) {
		va->AddVertexTC(p1 - dir1 * w1, u, v1, col);
		va->AddVertexTC(p1 + dir1 * w1, u, v0, col);
		va->AddVertexTC(p2 + dir2 * w2, u, v0, col);
		va->AddVertexTC(p2 - dir2 * w2, u, v1, col);
	} else {
		va->AddVertexTC(p1 - dir1 * w1, u, v1,                    col);
		va->AddVertexTC(p1 + dir1 * w1, u, v0,                    col);
		va->AddVertexTC(p2,             u, v0 + (v1 - v0) * 0.5f, col);
		va->AddVertexTC(p2,             u, v0 + (v1 - v0) * 1.5f, col);
	}
}
Ejemplo n.º 6
0
void MainWindow::LoadContest(const QString& path)
{
    if (!QDir(path).exists())
    {
        QMessageBox::critical(this, "无法打开竞赛", QString("%1\n路径不存在或已被移除。").arg(path));
        QSettings set("ccr.ini", QSettings::IniFormat);
        QStringList list = set.value("RecentContestList").toStringList();
        list.removeAll(path);
        set.setValue("RecentContestList", list);
        UpdateRecentContest(true);
        return;
    }

    QDir dir1(path + "/src"), dir2(path + "/data");
    if (!dir1.exists() || !dir2.exists())
        if (QMessageBox::question(this, "找不到试题或选手目录", "是否继续打开并创建子目录?") == QMessageBox::No) return;

    if (!dir1.exists() && !QDir(path).mkdir("src"))
    {
        QMessageBox::critical(this, "无法创建子目录", "创建子目录失败!");
        return;
    }
    if (!dir2.exists() && !QDir(path).mkdir("data"))
    {
        QMessageBox::critical(this, "无法创建子目录", "创建子目录失败!");
        return;
    }

    if (!Global::g_is_contest_closed) CloseContest();
    lastContest = path;
    Global::g_contest.SetPath(path);

    QSettings set("ccr.ini", QSettings::IniFormat);
    QStringList list = set.value("RecentContestList").toStringList();
    if (!list.count(path)) list.prepend(path);
    set.setValue("RecentContestList", list);
    set.setValue("LastContest", lastContest);
    UpdateRecentContest(false);

    ui->label_top->hide();
    ui->label_bottom->hide();
    ui->listWidget_recent->hide();
    close_button->show();

    this->setWindowTitle(path + " - CCR Plus 测评器");
    ui->action_close->setEnabled(true);
    ui->action_configure->setEnabled(true);
    ui->action_set_list->setEnabled(true);
    ui->action_export->setEnabled(true);
    ui->action_refresh->setEnabled(true);
    ui->action_judge_selected->setEnabled(true);
    ui->action_judge_unjudged->setEnabled(true);
    ui->action_judge_all->setEnabled(true);
    ui->action_stop->setEnabled(false);

    Global::g_is_judge_stoped = false;
    Global::g_is_contest_closed = false;

    LoadTable();
}
Ejemplo n.º 7
0
TEST( ResourceDependenciesGraph, removingDir )
{
   ResourceDependenciesGraph graph;

   FilePath file( "/directory1/a.res" );
   FilePath res1( "/directory2/b.tmat" );
   FilePath res2( "/directory3/c.tmat" );
   FilePath dir1( "/directory1" );
   FilePath dir2( "/directory2" );
   FilePath dir3( "/directory3" );
   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );

   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onDirRemoved( dir2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 1, graph.getAffectedResources( file ).size() );
   CPPUNIT_ASSERT_EQUAL( res2.getRelativePath(), graph.getAffectedResources( file ).front().getRelativePath() );

   graph.onDirRemoved( dir3 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );

   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onDirRemoved( dir1 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );
}
Ejemplo n.º 8
0
void KBookmarkManager::slotNotify( const char *_url )
{
  if ( !m_bNotify )
    return;
  
  KURL u( _url );
  if ( strcmp( u.protocol(), "file" ) != 0 )
    return;
  
  QString p = kapp->localkdedir().data();
  p += "/share/apps/kfm/bookmarks";
  QDir dir2( p );
  QDir dir1( u.path() );

  QString p1( dir1.canonicalPath() );
  QString p2( dir2.canonicalPath() );
  if ( p1.isEmpty() )
    p1 = u.path();
  if ( p2.isEmpty() )
    p2 = p.data();
  
  if ( strncmp( p1.data(), p2.data(), p2.length() ) == 0 )
  {
    QString d = kapp->localkdedir().data();
    d += "/share/apps/kfm/bookmarks/";
    scan( d );
  }
}
Ejemplo n.º 9
0
	void test01_shRotation() {
		/* Generate a random SH expansion, rotate it and 
		   spot-check 100 times against the original evaluated
		   at appropriately rotated positions */

		ref<Random> random = new Random();
		int bands = 8;

		SHVector vec1(bands);
		for (int l=0; l<bands; ++l)
			for (int m=-l; m<=l; ++m)
				vec1(l, m) = random->nextFloat();

		Vector axis(squareToSphere(Point2(random->nextFloat(), random->nextFloat())));
		Transform trafo = Transform::rotate(axis, random->nextFloat()*360);
		Transform inv = trafo.inverse();
		SHRotation rot(vec1.getBands());

		SHVector::rotation(trafo, rot);
		SHVector vec2(bands);

		rot(vec1, vec2);

		for (int i=0; i<100; ++i) {
			Vector dir1(squareToSphere(Point2(random->nextFloat(), random->nextFloat()))), dir2;
			trafo(dir1, dir2);

			Float value1 = vec1.eval(dir2);
			Float value2 = vec2.eval(dir1);
			assertEqualsEpsilon(value1, value2, Epsilon);
		}
	}
Ejemplo n.º 10
0
void Request::modifyProduct(const std::vector<std::string> &splitVector) {
	std::string id = splitVector[1];
	std::string nombre = splitVector[2];
	std::string descripcion = splitVector[3];
	std::string cant = splitVector[4];
	std::stringstream s;
	int cantImagenes;
	s << cant;
	s >> cantImagenes;
	/**/
	this->getCommunication()->send(utils::OK_MESSAGE);
	catalog->updateProduct(id,nombre,descripcion);
	std::string pathIcono = catalog->getPathProductIcons(id);
	utils::Directory dir (pathIcono);
	dir.remove();
	dir.make(pathIcono);
	receiveImage(pathIcono);
	std::string path = catalog->getPathProductImages(id);
	utils::Directory dir1 (path);
	dir1.remove();
	dir1.make(path);
	for(unsigned int i = 0; i < cantImagenes; i++){
		receiveImage(path);
	}
}
Ejemplo n.º 11
0
void InMapDraw_QuadDrawer::DrawQuad(int x, int y)
{
	int drawQuadsX = imd->drawQuadsX;
	CInMapDraw::DrawQuad* dq = &imd->drawQuads[y * drawQuadsX + x];

	va->EnlargeArrays(dq->points.size()*12,0,VA_SIZE_TC);
	//! draw point markers
	for (std::list<CInMapDraw::MapPoint>::iterator pi = dq->points.begin(); pi != dq->points.end(); ++pi) {
		if (pi->MaySee(imd)) {
			float3 pos = pi->pos;
			float3 dif(pos - camera->pos);
			dif.ANormalize();
			float3 dir1(dif.cross(UpVector));
			dir1.ANormalize();
			float3 dir2(dif.cross(dir1));

			unsigned char col[4];
			col[0] = pi->color[0];
			col[1] = pi->color[1];
			col[2] = pi->color[2];
			col[3] = 200;

			float size = 6;
			float3 pos1 = pos;
			pos1.y += 5.0f;
			float3 pos2 = pos1;
			pos2.y += 100.0f;

			va->AddVertexQTC(pos1 - dir1 * size,               0.25f, 0, col);
			va->AddVertexQTC(pos1 + dir1 * size,               0.25f, 1, col);
			va->AddVertexQTC(pos1 + dir1 * size + dir2 * size, 0.00f, 1, col);
			va->AddVertexQTC(pos1 - dir1 * size + dir2 * size, 0.00f, 0, col);

			va->AddVertexQTC(pos1 - dir1 * size,               0.75f, 0, col);
			va->AddVertexQTC(pos1 + dir1 * size,               0.75f, 1, col);
			va->AddVertexQTC(pos2 + dir1 * size,               0.75f, 1, col);
			va->AddVertexQTC(pos2 - dir1 * size,               0.75f, 0, col);

			va->AddVertexQTC(pos2 - dir1 * size,               0.25f, 0, col);
			va->AddVertexQTC(pos2 + dir1 * size,               0.25f, 1, col);
			va->AddVertexQTC(pos2 + dir1 * size - dir2 * size, 0.00f, 1, col);
			va->AddVertexQTC(pos2 - dir1 * size - dir2 * size, 0.00f, 0, col);

			if (pi->label.size() > 0) {
				font->SetTextColor(pi->color[0]/255.0f, pi->color[1]/255.0f, pi->color[2]/255.0f, 1.0f); //FIXME (overload!)
				font->glWorldPrint(pos2 + UpVector * 6, 26.0f, pi->label);
			}
		}
	}

	lineva->EnlargeArrays(dq->lines.size()*2,0,VA_SIZE_C);
	//! draw line markers
	for (std::list<CInMapDraw::MapLine>::iterator li = dq->lines.begin(); li != dq->lines.end(); ++li) {
		if (li->MaySee(imd)) {
			lineva->AddVertexQC(li->pos - (li->pos - camera->pos).ANormalize() * 26, li->color);
			lineva->AddVertexQC(li->pos2 - (li->pos2 - camera->pos).ANormalize() * 26, li->color);
		}
	}
}
Ejemplo n.º 12
0
TEST(Path, list)
{
    cxx::sys::DirIterator dir1(cxx::sys::Path::curpath());
    while(dir1 != cxx::sys::DirIterator()) {
        printf("files: %s\n", dir1.name().c_str());
        ++dir1;
    }
}
Ejemplo n.º 13
0
void InMapDraw_QuadDrawer::DrawQuad (int x,int y)
{
	int drawQuadsX = imd->drawQuadsX;
	CInMapDraw::DrawQuad* dq=&imd->drawQuads[y*drawQuadsX+x];

	for(std::list<CInMapDraw::MapPoint>::iterator pi=dq->points.begin();pi!=dq->points.end();++pi){
		float3 pos=pi->pos;

		float3 dif(pos-camera->pos);
		float camDist=dif.Length();
		dif/=camDist;
		float3 dir1(dif.cross(UpVector));
		dir1.Normalize();
		float3 dir2(dif.cross(dir1));

		unsigned char col[4];
		col[0]=pi->color[0];
		col[1]=pi->color[1];
		col[2]=pi->color[2];
		col[3]=200;//intensity*255;

		float size=6;

		float3 pos1=pos;
		float3 pos2=pos1;
		pos2.y+=100;

		va->AddVertexTC(pos1-dir1*size,					  0.25f,0,col);
		va->AddVertexTC(pos1+dir1*size,					  0.25f,1,col);
		va->AddVertexTC(pos1+dir1*size+dir2*size, 0.00f,1,col);
		va->AddVertexTC(pos1-dir1*size+dir2*size, 0.00f,0,col);

		va->AddVertexTC(pos1-dir1*size,0.75f,0,col);
		va->AddVertexTC(pos1+dir1*size,0.75f,1,col);
		va->AddVertexTC(pos2+dir1*size,0.75f,1,col);
		va->AddVertexTC(pos2-dir1*size,0.75f,0,col);

		va->AddVertexTC(pos2-dir1*size,					  0.25f,0,col);
		va->AddVertexTC(pos2+dir1*size,					  0.25f,1,col);
		va->AddVertexTC(pos2+dir1*size-dir2*size, 0.00f,1,col);
		va->AddVertexTC(pos2-dir1*size-dir2*size, 0.00f,0,col);

		if(pi->label.size()>0){
			glPushMatrix();
			glTranslatef3(pi->pos+UpVector*105);
			glScalef(30,30,30);
			glColor4ub(pi->color[0],pi->color[1],pi->color[2],250);
			font->glWorldPrint("%s",pi->label.c_str());
			glPopMatrix();
			glBindTexture(GL_TEXTURE_2D, texture);
		}
	}
	for(std::list<CInMapDraw::MapLine>::iterator li=dq->lines.begin();li!=dq->lines.end();++li){
		lineva->AddVertexC(li->pos-(li->pos - camera->pos).Normalize()*26,li->color);
		lineva->AddVertexC(li->pos2-(li->pos2 - camera->pos).Normalize()*26,li->color);
	}
}
Ejemplo n.º 14
0
    void PhysicsSystem::doPhysics(float dt, const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
    {
        //set the DebugRenderingMode. To disable it,set it to 0
        //eng->setDebugRenderingMode(1);

        //set the walkdirection to 0 (no movement) for every actor)
        for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
        {
            OEngine::Physic::PhysicActor* act = it->second;
            act->setWalkDirection(btVector3(0,0,0));
        }
		playerMove::playercmd& pm_ref = playerphysics->cmd;

        pm_ref.rightmove = 0;
        pm_ref.forwardmove = 0;
        pm_ref.upmove = 0;

		//playerphysics->ps.move_type = PM_NOCLIP;
        for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
            iter!=actors.end(); ++iter)
        {
            //dirty stuff to get the camera orientation. Must be changed!

            Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first);
            Ogre::Vector3 dir;
            Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
            Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
			Ogre::Quaternion yawQuat = yawNode->getOrientation();
            Ogre::Quaternion pitchQuat = pitchNode->getOrientation();



            playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees();

			playerphysics->ps.viewangles.y = yawQuat.getYaw().valueDegrees() *-1 + 90;


                Ogre::Quaternion quat = yawNode->getOrientation();
                Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);

				pm_ref.rightmove = -iter->second.x;
				pm_ref.forwardmove = -iter->second.y;
				pm_ref.upmove = iter->second.z;



            }





        mEngine->stepSimulation(dt);
    }
Ejemplo n.º 15
0
void ProjectDialog::on_buttonBox_clicked(QAbstractButton *button)
{
    QString proj_name, proj_dir;
    QDialogButtonBox::StandardButton stdButton = ui->buttonBox->standardButton(button);
    if (stdButton != QDialogButtonBox::Cancel) {
        proj_name = ui->projectNameEdit->text().simplified();
        QRegExp rx("^[a-zA-Z0-9_\\.]+$");
        if(!rx.exactMatch(proj_name)) {
            xrs_error("Please insert a valid project name");
            return;
        }
        proj_dir = ui->projectFolderEdit->text().simplified();
        if (proj_dir=="") {
            xrs_error("Please insert a valid folder name");
            return;
        }
        QDir dir(proj_dir);
        if (!dir.exists()) {
            WarningDialog *cfd = new WarningDialog("Folder does not exist!\nDo you want to create it?");
            //xrs_error("Folder does dot exist");
            if (!cfd->exec()) return;
            else if(!dir.mkpath(".")) {
                xrs_error("Cannot create folder!");
                return;
            }
        }
        mainWindow->baseProjectFolder = proj_dir;
        proj_dir = proj_dir + "/" + proj_name;
        QDir dir1(proj_dir);
        if (dir1.exists()) {
            WarningDialog *efd = new WarningDialog(QString("Folder\n")+proj_dir+"\nalready exists!\nDo you want to overwrite it?");
            if (!efd->exec()) return;
        }
        else if(!dir1.mkpath(".")) {
            xrs_error("Cannot create folder!");
            return;
        }
        mainWindow->tmpProjectFolder = proj_dir;
        if (newProjectFlag) {
            ProjTemplateDialog *proj_templ = new ProjTemplateDialog(mainWindow);
            if (proj_templ->exec()) {
                mainWindow->projectName = proj_name;
                mainWindow->projectFolder = proj_dir;
                close();
            }
        }
        else {
            mainWindow->tmpProjectName = proj_name;
            mainWindow->tmpProjectFolder = proj_dir;
            close();
        }
    }
}
Ejemplo n.º 16
0
QString Database::commonPath(QString path1, QString path2)
{
	if(!path1.size() || !path2.size()) return "";
	QDir dir1(path1), dir2(path2);
	if(dir1.isRoot() || dir2.isRoot()) return "";
	path1 = dir1.canonicalPath();
	while(!dir2.isRoot()) {
		if(path1.startsWith(dir2.canonicalPath())) return dir2.canonicalPath();
		dir2.cdUp();
	}
	return "";
}
Ejemplo n.º 17
0
/**
 * Initialize by three points
 *
 * This points are used:
 *
 *	  normal
 * 		|    p3
 *      |   /
 * 		|  /
 * 		| /
 * 		p1---------------p2
 *
 * 		d1 = p2 - p1
 * 		d2 = p3 - p1
 * 		n = d1 x d2
 */
void srs::CTestingPlane::set(const tPoint & p1, const tPoint & p2, const tPoint & p3)
{
    // Compute directional vectors
    tPoint dir1( p2 - p1 ), dir2( p3 - p1 );

    // Get normal vector from cross-product
    m_plane = dir1;
    m_plane.cross(dir2);
    m_plane.normalize();

    // Compute last parameter
    m_d = - p1.dot( m_plane );
}
Ejemplo n.º 18
0
void CSimpleParticleSystem::Draw()
{
	inArray=true;

	va->EnlargeArrays(numParticles*4,0,VA_SIZE_TC);
	if(directional)
	{
		for(int i=0; i<numParticles; i++)
		{
			if(particles[i].life<1.0f)
			{
				float3 dif(particles[i].pos-camera->pos);
				dif.ANormalize();
				float3 dir1(dif.cross(particles[i].speed));
				dir1.ANormalize();
				float3 dir2(dif.cross(dir1));

				unsigned char color[4];

				colorMap->GetColor(color, particles[i].life);
				float3 interPos=particles[i].pos+particles[i].speed*gu->timeOffset;
				float size = particles[i].size;
				va->AddVertexQTC(interPos-dir1*size-dir2*size,texture->xstart,texture->ystart,color);
				va->AddVertexQTC(interPos-dir1*size+dir2*size,texture->xend ,texture->ystart,color);
				va->AddVertexQTC(interPos+dir1*size+dir2*size,texture->xend ,texture->yend ,color);
				va->AddVertexQTC(interPos+dir1*size-dir2*size,texture->xstart,texture->yend ,color);
			}
		}
	}
	else
	{
		unsigned char color[4];
		for(int i=0; i<numParticles; i++)
		{
			Particle* p = &particles[i];
			if(p->life<1.0f)
			{
				colorMap->GetColor(color, p->life);
				float3 interPos=p->pos+p->speed*gu->timeOffset;
				const float3 cameraRight = camera->right*p->size;
				const float3 cameraUp    = camera->up*p->size;

				va->AddVertexQTC(interPos-cameraRight-cameraUp,texture->xstart,texture->ystart,color);
				va->AddVertexQTC(interPos+cameraRight-cameraUp,texture->xend ,texture->ystart,color);
				va->AddVertexQTC(interPos+cameraRight+cameraUp,texture->xend ,texture->yend ,color);
				va->AddVertexQTC(interPos-cameraRight+cameraUp,texture->xstart,texture->yend ,color);
			}
		}
	}
}
Ejemplo n.º 19
0
QZip::QZip(const QString &zipFileName,const QString &zipPathName)
{
    _zipFileName = zipFileName;
    _zipPathName = zipPathName;

    QDir dir1(".");
    dir1.setCurrent(".");
    _zipFileName = dir1.absoluteFilePath(_zipFileName);

    QDir dir2(_zipPathName);
    if(!dir2.isAbsolute()){
        _zipPathName = dir2.absolutePath();
    }
}
void CBeamLaserProjectile::Draw(void)
{
	inArray=true;
	float3 dif(pos-camera->pos);
	float camDist=dif.Length();
	dif/=camDist;
	float3 dir=endPos-startPos;
	dir.Normalize();
	float3 dir1(dif.cross(dir));
	dir1.Normalize();
	float3 dir2(dif.cross(dir1));

	unsigned char col[4];
	col[0]=(unsigned char)(color.x*startAlpha);
	col[1]=(unsigned char)(color.y*startAlpha);
	col[2]=(unsigned char)(color.z*startAlpha);
	col[3]=1;//intensity*255;

	unsigned char col2[4];
	col2[0]=(unsigned char)(color.x*endAlpha);
	col2[1]=(unsigned char)(color.y*endAlpha);
	col2[2]=(unsigned char)(color.z*endAlpha);
	col2[3]=1;//intensity*255;

	float size=thickness;
	float3 pos1=startPos;
	float3 pos2=endPos;

	if(camDist<1000){
		va->AddVertexTC(pos1-dir1*size,					  15.0/16,0,    col);
		va->AddVertexTC(pos1+dir1*size,					  15.0/16,1.0/8,col);
		va->AddVertexTC(pos1+dir1*size-dir2*size, 14.0/16,1.0/8,col);
		va->AddVertexTC(pos1-dir1*size-dir2*size, 14.0/16,0		,col);

		va->AddVertexTC(pos1-dir1*size,11.0/16,0,    col);
		va->AddVertexTC(pos1+dir1*size,11.0/16,1.0/8,col);
		va->AddVertexTC(pos2+dir1*size,11.0/16,1.0/8,col2);
		va->AddVertexTC(pos2-dir1*size,11.0/16,0    ,col2);

		va->AddVertexTC(pos2-dir1*size,					  15.0/16,0,    col2);
		va->AddVertexTC(pos2+dir1*size,					  15.0/16,1.0/8,col2);
		va->AddVertexTC(pos2+dir1*size+dir2*size, 14.0/16,1.0/8,col2);
		va->AddVertexTC(pos2-dir1*size+dir2*size, 14.0/16,0		,col2);
	} else {
		va->AddVertexTC(pos1-dir1*size,11.0/16,0,    col);
		va->AddVertexTC(pos1+dir1*size,11.0/16,1.0/8,col);
		va->AddVertexTC(pos2+dir1*size,11.0/16,1.0/8,col2);
		va->AddVertexTC(pos2-dir1*size,11.0/16,0    ,col2);
	}
}
void CSimpleParticleSystem::Draw()
{
	inArray=true;

	if(directional)
	{
		for(int i=0; i<numParticles; i++)
		{
			if(particles[i].life<1.0f)
			{
				float3 dif(particles[i].pos-camera->pos);
				float camDist=dif.Length();
				dif/=camDist;
				float3 dir1(dif.cross(particles[i].speed));
				dir1.Normalize();
				float3 dir2(dif.cross(dir1));

				unsigned char color[4];

				colorMap->GetColor(color, particles[i].life);
				float3 interPos=particles[i].pos+particles[i].speed*gu->timeOffset;
				float size = particles[i].size;
				va->AddVertexTC(interPos-dir1*size-dir2*size,texture->xstart,texture->ystart,color);
				va->AddVertexTC(interPos-dir1*size+dir2*size,texture->xend ,texture->ystart,color);
				va->AddVertexTC(interPos+dir1*size+dir2*size,texture->xend ,texture->yend ,color);
				va->AddVertexTC(interPos+dir1*size-dir2*size,texture->xstart,texture->yend ,color);
			}
		}
	}
	else
	{
		for(int i=0; i<numParticles; i++)
		{
			if(particles[i].life<1.0f)
			{
				unsigned char color[4];

				colorMap->GetColor(color, particles[i].life);
				float3 interPos=particles[i].pos+particles[i].speed*gu->timeOffset;
				float size = particles[i].size;

				va->AddVertexTC(interPos-camera->right*size-camera->up*size,texture->xstart,texture->ystart,color);
				va->AddVertexTC(interPos+camera->right*size-camera->up*size,texture->xend ,texture->ystart,color);
				va->AddVertexTC(interPos+camera->right*size+camera->up*size,texture->xend ,texture->yend ,color);
				va->AddVertexTC(interPos-camera->right*size+camera->up*size,texture->xstart,texture->yend ,color);
			}
		}
	}
}
void CLaserProjectile::Draw(void)
{
	if(s3domodel)	//dont draw if a 3d model has been defined for us
		return;

	inArray=true;
	float3 dif(pos-camera->pos);
	float camDist=dif.Length();
	dif/=camDist;
	float3 dir1(dif.cross(dir));
	dir1.Normalize();
	float3 dir2(dif.cross(dir1));

	unsigned char col[4];
	col[0]=(unsigned char) (color.x*intensity*255);
	col[1]=(unsigned char) (color.y*intensity*255);
	col[2]=(unsigned char) (color.z*intensity*255);
	col[3]=1;//intensity*255;

	float size=weaponDef->thickness;

	if(camDist<1000){
		float3 pos1=pos+speed*gu->timeOffset;
		float3 pos2=pos1-dir*curLength;

		va->AddVertexTC(pos1-dir1*size,					  15.0/16,0,    col);
		va->AddVertexTC(pos1+dir1*size,					  15.0/16,1.0/8,col);
		va->AddVertexTC(pos1+dir1*size-dir2*size, 14.0/16,1.0/8,col);
		va->AddVertexTC(pos1-dir1*size-dir2*size, 14.0/16,0		,col);

		va->AddVertexTC(pos1-dir1*size,11.0/16,0,    col);
		va->AddVertexTC(pos1+dir1*size,11.0/16,1.0/8,col);
		va->AddVertexTC(pos2+dir1*size,11.0/16,1.0/8,col);
		va->AddVertexTC(pos2-dir1*size,11.0/16,0    ,col);

		va->AddVertexTC(pos2-dir1*size,					  15.0/16,0,    col);
		va->AddVertexTC(pos2+dir1*size,					  15.0/16,1.0/8,col);
		va->AddVertexTC(pos2+dir1*size+dir2*size, 14.0/16,1.0/8,col);
		va->AddVertexTC(pos2-dir1*size+dir2*size, 14.0/16,0		,col);
	} else {
		float3 pos1=pos+speed*gu->timeOffset+dir*(size*0.5);
		float3 pos2=pos1-dir*(curLength+size);

		va->AddVertexTC(pos1-dir1*size,11.0/16,0,    col);
		va->AddVertexTC(pos1+dir1*size,11.0/16,1.0/8,col);
		va->AddVertexTC(pos2+dir1*size,11.0/16,1.0/8,col);
		va->AddVertexTC(pos2-dir1*size,11.0/16,0    ,col);
	}
}
Ejemplo n.º 23
0
bool IfcGeom::is_convex(const TopoDS_Wire& wire) {
	for ( TopExp_Explorer exp1(wire,TopAbs_VERTEX); exp1.More(); exp1.Next() ) {
		TopoDS_Vertex V1 = TopoDS::Vertex(exp1.Current());
		gp_Pnt P1 = BRep_Tool::Pnt(V1);
		// Store the neighboring points
		std::vector<gp_Pnt> neighbors;
		for ( TopExp_Explorer exp3(wire,TopAbs_EDGE); exp3.More(); exp3.Next() ) {
			TopoDS_Edge edge = TopoDS::Edge(exp3.Current());
			std::vector<gp_Pnt> edge_points;
			for ( TopExp_Explorer exp2(edge,TopAbs_VERTEX); exp2.More(); exp2.Next() ) {
				TopoDS_Vertex V2 = TopoDS::Vertex(exp2.Current());
				gp_Pnt P2 = BRep_Tool::Pnt(V2);
				edge_points.push_back(P2);
			}
			if ( edge_points.size() != 2 ) continue;
			if ( edge_points[0].IsEqual(P1,GetValue(GV_POINT_EQUALITY_TOLERANCE))) neighbors.push_back(edge_points[1]);
			else if ( edge_points[1].IsEqual(P1, GetValue(GV_POINT_EQUALITY_TOLERANCE))) neighbors.push_back(edge_points[0]);
		}
		// There should be two of these
		if ( neighbors.size() != 2 ) return false;
		// Now find the non neighboring points
		std::vector<gp_Pnt> non_neighbors;
		for ( TopExp_Explorer exp2(wire,TopAbs_VERTEX); exp2.More(); exp2.Next() ) {
			TopoDS_Vertex V2 = TopoDS::Vertex(exp2.Current());
			gp_Pnt P2 = BRep_Tool::Pnt(V2);
			if ( P1.IsEqual(P2,GetValue(GV_POINT_EQUALITY_TOLERANCE)) ) continue;
			bool found = false;
			for( std::vector<gp_Pnt>::const_iterator it = neighbors.begin(); it != neighbors.end(); ++ it ) {
				if ( (*it).IsEqual(P2,GetValue(GV_POINT_EQUALITY_TOLERANCE)) ) { found = true; break; }
			}
			if ( ! found ) non_neighbors.push_back(P2);
		}
		// Calculate the angle between the two edges of the vertex
		gp_Dir dir1(neighbors[0].XYZ() - P1.XYZ());
		gp_Dir dir2(neighbors[1].XYZ() - P1.XYZ());
		const double angle = acos(dir1.Dot(dir2)) + 0.0001;
		// Now for the non-neighbors see whether a greater angle can be found with one of the edges
		for ( std::vector<gp_Pnt>::const_iterator it = non_neighbors.begin(); it != non_neighbors.end(); ++ it ) {
			gp_Dir dir3((*it).XYZ() - P1.XYZ());
			const double angle2 = acos(dir3.Dot(dir1));
			const double angle3 = acos(dir3.Dot(dir2));
			if ( angle2 > angle || angle3 > angle ) return false;
		}
	}
	return true;
}
Ejemplo n.º 24
0
void plCullTree::IVisPolyEdge(const hsPoint3& p0, const hsPoint3& p1, hsBool dark) const
{
    hsColorRGBA color;
    if( dark )
        color.Set(0.2f, 0.2f, 0.2f, 1.f);
    else
        color.Set(1.f, 1.f, 1.f, 1.f);

    int vertStart = fVisVerts.GetCount();

    hsVector3 dir0(&p0, &fViewPos);
    hsFastMath::NormalizeAppr(dir0);
    dir0 *= fVisYon;
    hsVector3 dir1(&p1, &fViewPos);
    hsFastMath::NormalizeAppr(dir1);
    dir1 *= fVisYon;

    hsPoint3 p3 = fViewPos;
    p3 += dir0;
    hsPoint3 p2 = fViewPos;
    p2 += dir1;

    hsVector3 norm = hsVector3(&p0, &fViewPos) % hsVector3(&p1, &fViewPos);
    hsFastMath::NormalizeAppr(norm);

    fVisVerts.Append(p0);
    fVisNorms.Append(norm);
    fVisColors.Append(color);
    fVisVerts.Append(p1);
    fVisNorms.Append(norm);
    fVisColors.Append(color);
    fVisVerts.Append(p2);
    fVisNorms.Append(norm);
    fVisColors.Append(color);
    fVisVerts.Append(p3);
    fVisNorms.Append(norm);
    fVisColors.Append(color);

    fVisTris.Append(vertStart + 0);
    fVisTris.Append(vertStart + 2);
    fVisTris.Append(vertStart + 1);

    fVisTris.Append(vertStart + 0);
    fVisTris.Append(vertStart + 3);
    fVisTris.Append(vertStart + 2);
}
Ejemplo n.º 25
0
    void CTriangle::Set(
        const SVector4& point0,
        const SVector4& point1,
        const SVector4& point2)
    {
        pt[0].Set(point0.x, point0.y, point0.z);
        pt[1].Set(point1.x, point1.y, point1.z);
        pt[2].Set(point2.x, point2.y, point2.z);

        CVector4 dir0(pt[1], pt[0], CVector4::INIT_SUB);
        CVector4 dir1(pt[2], pt[0], CVector4::INIT_SUB);

        SVector4::Cross(nml, dir0, dir1);
        SVector4::Normalize(nml, nml);

        d = -(a * pt[0].x + b * pt[0].y + c * pt[0].z);
    }
dgInt32 dgCollisionTaperedCapsule::CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut, dgFloat32 normalSign) const
{
	dgInt32 count = 0;
	dgVector p0 (m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
	dgVector dir0 (p0 - origin);
	dgFloat32 dist0 = dir0 % normal;
	if ((dist0 * dist0) < (m_radio0 * m_radio0)) {
		contactsOut[count] = p0 - normal.Scale3 (dist0);
		count ++;
	}

	dgVector p1 (-m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
	dgVector dir1 (p1 - origin);
	dgFloat32 dist1 = dir1 % normal;
	if ((dist1 * dist1) < (m_radio1 * m_radio1)) {
		contactsOut[count] = p1 - normal.Scale3 (dist1);
		count ++;
	}
	return count;
}
    void TestQueueRemovesAndCreatesDirectories() throw (Exception)
    {
        FileFinder checkpoints("checkpoints2", RelativeTo::ChasteTestOutput);
        // Remove directory in case it was there from previous executions.
        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-0");
        if (PetscTools::AmMaster())
        {
            ABORT_IF_THROWS(checkpoints.Remove());
        }
        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-1");
        TS_ASSERT(!checkpoints.Exists());
        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-2");

        OutputDirectoryFifoQueue fifo_queue("checkpoints2", 2);
        TS_ASSERT(checkpoints.IsDir());

        fifo_queue.CreateNextDir("0.1");
        FileFinder dir1("0.1", checkpoints);
        TS_ASSERT(dir1.IsDir());

        fifo_queue.CreateNextDir("0.2");
        FileFinder dir2("0.2", checkpoints);
        TS_ASSERT(dir2.IsDir());
        TS_ASSERT(dir1.IsDir());

        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-3");
        fifo_queue.CreateNextDir("0.3");
        FileFinder dir3("0.3", checkpoints);
        TS_ASSERT(dir3.IsDir());
        TS_ASSERT(dir2.IsDir());
        TS_ASSERT(!dir1.Exists());

        PetscTools::Barrier("TestQueueRemovesAndCreatesDirectories-4");
        fifo_queue.CreateNextDir("0.4");
        FileFinder dir4("0.4", checkpoints);
        TS_ASSERT(dir4.IsDir());
        TS_ASSERT(dir3.IsDir());
        TS_ASSERT(!dir2.Exists());
        TS_ASSERT(!dir1.Exists());
    }
Ejemplo n.º 28
0
dgVector dgBallConstraint::GetJointOmega () const
{
	dgAssert (m_body0);
	dgAssert (m_body1);
	const dgMatrix& matrix = m_body0->GetMatrix();

	dgVector dir0 (matrix.RotateVector (m_localMatrix0[0]));
	dgVector dir1 (matrix.RotateVector (m_localMatrix0[1]));
	dgVector dir2 (matrix.RotateVector (m_localMatrix0[2]));

	const dgVector& omega0 = m_body0->GetOmega();
	const dgVector& omega1 = m_body1->GetOmega();

//	dgVector omega1 (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
//	if (m_body1) {
//		omega1 = m_body1->GetOmega();
//	}

	dgVector relOmega (omega0 - omega1);
	return dgVector (relOmega % dir0, relOmega % dir1, relOmega % dir2, dgFloat32 (0.0f));

}
void CGeoSquareProjectile::Draw(void)
{
	inArray=true;
	unsigned char col[4];
	col[0]=(unsigned char) (r*a*255);
	col[1]=(unsigned char) (g*a*255);
	col[2]=(unsigned char) (b*a*255);
	col[3]=(unsigned char) (a*255);

	float3 dif(p1-camera->pos);
	dif.Normalize();
	float3 dir1(dif.cross(v1));
	dir1.Normalize();
	float3 dif2(p2-camera->pos);
	dif2.Normalize();
	float3 dir2(dif2.cross(v2));
	dir2.Normalize();

	/* FIXME this shouldn't use circularthingytex,
	it could look fugly if mods override it (through resources.tdf) */

	float u = (ph->circularthingytex.xstart + ph->circularthingytex.xend) / 2;
	float v0 = ph->circularthingytex.ystart;
	float v1 = ph->circularthingytex.yend;

	if(w2!=0){
		va->AddVertexTC(p1-dir1*w1,u,v1,col);
		va->AddVertexTC(p1+dir1*w1,u,v0,col);
		va->AddVertexTC(p2+dir2*w2,u,v0,col);
		va->AddVertexTC(p2-dir2*w2,u,v1,col);
	} else {
		va->AddVertexTC(p1-dir1*w1,u,v1,col);
		va->AddVertexTC(p1+dir1*w1,u,v0,col);
		va->AddVertexTC(p2,u,v0+(v1-v0)*0.5f,col);
		va->AddVertexTC(p2,u,v0+(v1-v0)*1.5f,col);
	}
}
void CLightingProjectile::Draw(void)
{
	inArray=true;
	unsigned char col[4];
	col[0]=(unsigned char) (color.x*255);
	col[1]=(unsigned char) (color.y*255);
	col[2]=(unsigned char) (color.z*255);
	col[3]=1;//intensity*255;

	float3 dir=(endPos-pos).Normalize();
	float3 dif(pos-camera->pos);
	float camDist=dif.Length();
	dif/=camDist;
	float3 dir1(dif.cross(dir));
	dir1.Normalize();
	float3 tempPos=pos;

	for(int a=0;a<9;++a){
		float f=(a+1)*0.111f;
		va->AddVertexTC(tempPos+dir1*(displacements[a]+weaponDef->thickness),weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->ystart,    col);
		va->AddVertexTC(tempPos+dir1*(displacements[a]-weaponDef->thickness),weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->yend,col);
		tempPos=pos*(1-f)+endPos*f;
		va->AddVertexTC(tempPos+dir1*(displacements[a+1]-weaponDef->thickness),weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->yend,col);
		va->AddVertexTC(tempPos+dir1*(displacements[a+1]+weaponDef->thickness),weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->ystart    ,col);
	}

	tempPos=pos;
	for(int a=0;a<9;++a){
		float f=(a+1)*0.111f;
		va->AddVertexTC(tempPos+dir1*(displacements2[a]+weaponDef->thickness),weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->ystart,    col);
		va->AddVertexTC(tempPos+dir1*(displacements2[a]-weaponDef->thickness),weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->yend,col);
		tempPos=pos*(1-f)+endPos*f;
		va->AddVertexTC(tempPos+dir1*(displacements2[a+1]-weaponDef->thickness),weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->yend,col);
		va->AddVertexTC(tempPos+dir1*(displacements2[a+1]+weaponDef->thickness),weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->ystart    ,col);
	}
}