当前位置: 首页>>代码示例>>C++>>正文


C++ Obstacle::setup方法代码示例

本文整理汇总了C++中Obstacle::setup方法的典型用法代码示例。如果您正苦于以下问题:C++ Obstacle::setup方法的具体用法?C++ Obstacle::setup怎么用?C++ Obstacle::setup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Obstacle的用法示例。


在下文中一共展示了Obstacle::setup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pushObject

//--------------------------------------------------------------
void Scenario::pushObject(ofxBulletWorldRigid &world, int typeObject, ofVec3f pos){
    
 //   ScenarioObjects.push_back(&m_obstable1);

/*
    ofVec3f pos;
    pos.x = ScenarioXml.getValue("positionX",0.0, 0);
    pos.y = ScenarioXml.getValue("positionY",0.0, 0);
    pos.z = ScenarioXml.getValue("positionZ",0.0, 0);
*/

    switch(typeObject){

        case SimpleObject::ShapeTypeBall:{
            Ball *oBall = new Ball(currentMissions);
            oBall->setup(world, pos);
            oBall->setDefaultZ();
            ScenarioObjects.push_back(oBall);
        }
        break;
            
        case SimpleObject::ShapeTypeHammer:{
            Hammer *oHammer = new Hammer(currentMissions);
            oHammer->setup(world, pos);
            oHammer->setDefaultZ();
            ScenarioObjects.push_back(oHammer);
        }
        break;
            
        case SimpleObject::ShapeTypeLever:{
            Lever *oLever = new Lever(currentMissions);
            int dir = 0;
            oLever->setup(world, pos, "cylinder.stl", ofVec3f(0.05, 0.05, 0.05), dir);
            oLever->setDefaultZ();
            ScenarioObjects.push_back(oLever);
        }
        break;
            
        case SimpleObject::ShapeTypeObstacle:{
            Obstacle *oObstable = new Obstacle(currentMissions);
            oObstable->setup(world, pos, "cylinder.stl", ofVec3f(0.05, 0.05, 0.05));
            oObstable->setDefaultZ();
            ScenarioObjects.push_back(oObstable);
        }
        break;
            
    }
}
开发者ID:ChinosInternationalCC,项目名称:chinoPinball,代码行数:49,代码来源:Scenario.cpp

示例2: loadFromXml

void Scenario::loadFromXml(ofxBulletWorldRigid &world){
    ofxXmlSettings ScenarioXml;
    
    if(ScenarioXml.loadFile(PinballChinoManager::projectName+"/scenario.xml")){
        
        ScenarioXml.pushTag("scenario");
        
        int numberOfSavedObjects = ScenarioXml.getNumTags("object");
        
        for(int i = 0; i < numberOfSavedObjects; i++){
            
            ScenarioXml.pushTag("object", i);
            SimpleObject::shapeType Type = (SimpleObject::shapeType)ScenarioXml.getValue("type", 0);
            int objId = ScenarioXml.getValue("id", 0);
            
            
            ofVec3f pos, scale;
			
            pos.x = ScenarioXml.getValue("positionX",0.0, 0);
            pos.y = ScenarioXml.getValue("positionY",0.0, 0);
            pos.z = ScenarioXml.getValue("positionZ",0.0, 0);
            
            scale.x = ScenarioXml.getValue("scaleX",0.0, 0);
            scale.y = ScenarioXml.getValue("scaleY",0.0, 0);
            scale.z = ScenarioXml.getValue("scaleZ",0.0, 0);
			
			ofQuaternion rotation;
            ofVec4f rot;
			
			rot.x = ScenarioXml.getValue("rotationX",0.0,0);
			rot.y = ScenarioXml.getValue("rotationY",0.0,0);
			rot.z = ScenarioXml.getValue("rotationZ",0.0,0);
            rot.w = ScenarioXml.getValue("rotationW",0.0,0);
			rotation.set(rot);
			
            string path;
            path = ScenarioXml.getValue("path","", 0);
            
            //TODO uncomment the line below when the xml is properly configured
            //string strcolor = ScenarioXml.getValue("color", "0xFFFFFF", 0);
			int color = ScenarioXml.getValue("color", 0xFFFFFF, 0);
			
			int pointsCollision = ScenarioXml.getValue("pointsCollision", 0, 0);

			int invisible = 0; // Visible by default event if this value is not implemented in the Xml editor
			invisible = ScenarioXml.getValue("invisible", 0, 0);
			
            switch(Type){
                case SimpleObject::ShapeTypeBall:{
                    Ball *oBall = new Ball(currentMissions);
                    float mass = ScenarioXml.getValue("mass", 0.0);
                    float radius = ScenarioXml.getValue("radius", 0.0);
                    float restitution = ScenarioXml.getValue("restitution", 0.0);
                    float friction = ScenarioXml.getValue("friction", 0.0);
                    oBall->setup(world, pos, mass, radius, restitution, friction);
                    oBall->SetObjectId(objId);
					oBall->setRotation(rotation);
                    oBall->color = color;
					oBall->setVisibility(invisible);
					
                    ScenarioObjects.push_back(oBall);
                }
                break;
                    
                case SimpleObject::ShapeTypeHammer:{
                    Hammer *oHammer = new Hammer(currentMissions);
                    oHammer->setup(world, pos);
                    oHammer->SetObjectId(objId);
					oHammer->setRotation(rotation);
                    oHammer->color = color;
					oHammer->setVisibility(invisible);
                    ScenarioObjects.push_back(oHammer);
					
					oHammer->setupRot();
                }
                break;
                    
                case SimpleObject::ShapeTypeLever:{
                    Lever *oLever = new Lever(currentMissions);
                    int dir = ScenarioXml.getValue("LeverType", 0);
                    oLever->setup(world, pos, path, scale, dir);
                    oLever->SetObjectId(objId);
					oLever->setRotation(rotation);
                    oLever->color = color;
					oLever->setVisibility(invisible);
                    ScenarioObjects.push_back(oLever);

                }
                break;
                    
                case SimpleObject::ShapeTypeObstacle:{
                    Obstacle *oObstable = new Obstacle(currentMissions);
                    //oObstable->setup(world, pos, "3DModels/chino_6.dae");
                    oObstable->setup(world, pos, path, scale);
                    oObstable->SetObjectId(objId);
					oObstable->setRotation(rotation);
                    oObstable->color = color;
					oObstable->setVisibility(invisible);
                    ScenarioObjects.push_back(oObstable);
					oObstable->setPointsCollision(pointsCollision);
//.........这里部分代码省略.........
开发者ID:ChinosInternationalCC,项目名称:chinoPinball,代码行数:101,代码来源:Scenario.cpp

示例3: fWriteControls

vector< string >  Tutorial::setup( int _iScaler, int _iThirdOfScreen, bool _bIsLefty ) {
    
    fWriteControls( _bIsLefty );
    
    stringList.clear();
    obstacleList.clear();
    
    iScaler = _iScaler;
    iThirdOfScreen = _iThirdOfScreen;
    
    // Jump!
    float x = iScaler * 40;
    Obstacle tmp;
    tmp.setup( ofVec2f( x, iThirdOfScreen ), iScaler * 4, iScaler * 3, true );
    obstacleList.push_back( tmp );
    
    // Jump off a note to overcome an obstacle.
    float x2 = iScaler * 72;
    addObject( "d3", x2, -1 );
    Obstacle tmp2;
    tmp2.setup( ofVec2f( x2 + iScaler * 8, iThirdOfScreen ), iScaler * 4, iScaler * 6, true );
    obstacleList.push_back( tmp2 );
    
    // Record and replay a note to overcome an obstacle.
    float x3 = iScaler * 92;
    addObject( "d3", x3, -1 );
    addObject( "a3", x3 + iScaler * 29.8, -1 );
    Obstacle tmp3;
    tmp3.setup( ofVec2f( x3 + iScaler * 80, iThirdOfScreen ), iScaler * 4, iScaler * 6, true );
    obstacleList.push_back( tmp3 );
    
    // Spring off notes to get to higher notes and overcome a tall obstacle.
    float x4 = iScaler * 184;
    addObject( "d3", x4, -1 );
    //    addObject( "g4", x4 + iScaler * 8, -1 );
    addObject( "c4", x4 + iScaler * 16, -1 );
    addObject( "g3", x4 + iScaler * 28, -1 );
    
    float x5 = x4 + iScaler * 44;
    addObject( "g3", x5, -1 );
    addObject( "d3", x5 + iScaler * 4, -1 );
    //    addObject( "c5", x5 + iScaler * 8, -1 );
    Obstacle tmp4;
    tmp4.setup( ofVec2f( x5 + iScaler * 16, iThirdOfScreen ), iScaler * 4, iScaler * 12, true );
    obstacleList.push_back( tmp4 );
    
    // Record multiple notes before replaying to overcome a tall obstacle before the notes expire.
    addObject( "b3", x5 + iScaler * 24, -1 );
    addObject( "e3", x5 + iScaler * 28, -1 );
    
    float x6 = iScaler * 300;
    addObject( "b3", x6, -1 );
    addObject( "e3", x6 + iScaler * 8, -1 );
    Obstacle tmp5;
    tmp5.setup( ofVec2f( x6 + iScaler * 58, iThirdOfScreen ), iScaler * 4, iScaler * 12, true );
    obstacleList.push_back( tmp5 );
    
    // Ride a moving note to overcome a tall obstacle.
    Obstacle tmp6;
    tmp6.setup( ofVec2f( x6 + iScaler * 62, iThirdOfScreen ), iScaler * 4, iScaler * 8, true );
    obstacleList.push_back( tmp6 );
    Obstacle tmp7;
    tmp7.setup( ofVec2f( x6 + iScaler * 66, iThirdOfScreen ), iScaler * 4, iScaler * 4, true );
    obstacleList.push_back( tmp7 );
    
    float x7 = iScaler * 370;
    addObject( "b3", x7, -1 );
    //objectList[ objectList.size() - 1 ].vel.set( float( -( iScaler / 8.3333 ) ), 0.0 ); // Moved to testApp.cpp
    Obstacle tmp8;
    tmp8.setup( ofVec2f( x7 + iScaler * 30, iThirdOfScreen ), iScaler * 4, iScaler * 12, true );
    obstacleList.push_back( tmp8 );
    
    return stringList;
}
开发者ID:jmatthewgriffis,项目名称:Thesis,代码行数:74,代码来源:Tutorial.cpp


注:本文中的Obstacle::setup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。