コード例 #1
0
osg::Node* CreateScene()
{
	pGroup = new osg::Group;
	
	osg::Geode* pGeode1 = new osg::Geode();
	pGroup->addChild( pGeode1 );	
	osg::Geode* pGeode2 = new osg::Geode();
	pGroup->addChild( pGeode2 );	
	osg::Geode* pGeode3 = new osg::Geode();
	pGroup->addChild( pGeode3 );	
	osg::Geode* pGeode4 = new osg::Geode();
	pGroup->addChild( pGeode4 );	
	osg::Geode* pGeode5 = new osg::Geode();
	pGroup->addChild( pGeode5 );	

	// we create the simplest form of shapes in OpenSceneGraph
    pGeode1->addDrawable( new osg::ShapeDrawable( new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),0.5f) ) );
    pGeode2->addDrawable( new osg::ShapeDrawable( new osg::Box(osg::Vec3(2.0f,0.0f,0.0f),2.0f) ) );
    pGeode3->addDrawable( new osg::ShapeDrawable( new osg::Cone(osg::Vec3(4.0f,0.0f,0.0f),0.5f,3.0f) ) );
    pGeode4->addDrawable( new osg::ShapeDrawable( new osg::Cylinder(osg::Vec3(6.0f,0.0f,0.5f),0.5f,3.0f) ) );
    pGeode5->addDrawable( new osg::ShapeDrawable( new osg::Capsule(osg::Vec3(8.0f,0.0f,1.0f),0.5f,3.0f) ) );

	// create dummy sphere, so we can see where the collision should take place
	CSulGeodeSphere* pSphere = new CSulGeodeSphere( radius, osg::Vec3( 0, 0, 0 ) );

	mt = new osg::MatrixTransform;
	mt->addChild( pSphere );
	pGG->addChild( mt );
	updateTransform();

	// test collision
	g_pSI = new CSulSphereIntersector;
	pGG->addChild( g_pSI->enableDebug() );
	g_iv = new osgUtil::IntersectionVisitor;
	g_iv->setIntersector( g_pSI );

	g_pSI->setRadius( radius );
	g_pSI->setPosition( pos );

	testCol();

	return pGroup;
}
コード例 #2
0
void testDbColumns(struct htmlPage *dbPage, char *org, char *db, 
	struct slName *geneList)
/* Test on one database. */
{
struct htmlPage *emptyConfig;
struct slName *colList = NULL, *col;
struct htmlFormVar *var;
struct slName *gene;

uglyf("testDbColumns %s %s\n", org, db);
emptyConfig = emptyConfigPage(dbPage, org, db);
if (emptyConfig != NULL )
    {
    for (var = emptyConfig->forms->vars; var != NULL; var = var->next)
	{
	if (startsWith("near.col.", var->name) && endsWith(var->name, ".vis"))
	    {
	    char *colNameStart = var->name + strlen("near.col.");
	    char *colNameEnd = strchr(colNameStart, '.');
	    *colNameEnd = 0;
	    col = slNameNew(colNameStart);
	    slAddHead(&colList, col);
	    *colNameEnd = '.';
	    }
	}
    slReverse(&colList);

    for (gene = geneList; gene != NULL; gene = gene->next)
	{
	htmlPageSetVar(emptyConfig, NULL, searchVarName, gene->name);
	for (col = colList; col != NULL; col = col->next)
	    {
	    testCol(emptyConfig, org, db, col->name, gene->name);
	    }
	}
    for (col = colList; col != NULL; col = col->next)
        {
	testColInfo(dbPage, org, db, col->name);
	}
    }
htmlPageFree(&emptyConfig);
}
コード例 #3
0
ファイル: winner.cpp プロジェクト: wobbol/tic-tac-toe
bool winnerTest(int player){ //return true on 'player' win
int i;
	for(i = 0; i < NUMCOL; i++){
		if(testCol(i,player)) {
			return 1;
		}
	}
	for(i = 0; i < NUMROW; i++){
		if(testRow(i,player)) {
			return 1;
		}
	}
	if(testDiagUp(player)) {
		return 1;
	}
	if(testDiagDown(player)) {
		return 1;
	}
return 0;
}
コード例 #4
0
	virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* pObject, osg::NodeVisitor* pNodeVisitor )
	{
		osgViewer::Viewer* pViewer = dynamic_cast<osgViewer::Viewer*>(&aa);
        if ( !pViewer )
		{
			return false;
		}

		if ( ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN )
		{
			if ( ea.getKey()==osgGA::GUIEventAdapter::KEY_Up )
			{
				pos.z() += 1.0f;
				updateTransform();
			}

			if ( ea.getKey()==osgGA::GUIEventAdapter::KEY_Down )
			{
				pos.z() -= 1.0f;
				updateTransform();
			}

			if ( ea.getKey()==osgGA::GUIEventAdapter::KEY_Left )
			{
				pos.x() -= 1.0f;
				updateTransform();
			}

			if ( ea.getKey()==osgGA::GUIEventAdapter::KEY_Right )
			{
				pos.x() += 1.0f;
				updateTransform();
			}

			g_pSI->reset();
			g_pSI->setPosition( pos );
			testCol();
		}

		return false;
	}