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


C++ World::AddObject方法代码示例

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


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

示例1: NewNugget

	void NewNugget(int num = 1)
	{
		for (int i=0; i<num; ++i)
		{
			int gx = rand() % 500 + 100;
			int gy = rand() % 300 + 100;

			Sprite &gspr = sprite_list.GetSprite("gold");
			Object * nug = new GoldObject(gx, gy, gspr);

			world.AddObject(nug);
		}
	}
开发者ID:lasty,项目名称:ld29_surface,代码行数:13,代码来源:main.cpp

示例2: Play

void Client::Play() {
    OgreEasy::SimpleOgreInit lOgreInit;
    if(!lOgreInit.initOgre()) {
        std::cout<<"Could not init ogre"<<std::endl;
        return;
    }
    Ogre::Root* lRoot = lOgreInit.mRoot.get();
    Ogre::RenderWindow* lWindow = lOgreInit.mWindow;
    World* w = new World();
    w->SetDebugMode(false);
    GameObject camObject = w->AddObject("camera");
    camObject.AddCameraComponent("camera");
    camObject.SetPosition(Ogre::Vector3(0,0,0));
    camObject.LookAt(Ogre::Vector3(0,0,0));

    GameObject& light2 = w->AddObject("point_light");
    light2.AddLightComponent(Ogre::Light::LT_DIRECTIONAL);
    light2.SetPosition(Ogre::Vector3(0,0,40));
    light2.LookAt(Ogre::Vector3(0,100,0));

    GameObject& c = w->AddPhysicsObject("esine", "cube/Cube.mesh");
    c.SetPosition(Ogre::Vector3(0,0,0));
    c.AddBoxCollider(1,1,1);
    PhysicsComponent phys = c.GetPhysicsComponent();
    phys.SetMass(1.0);
    c.SetMaterial("tex");

    GameObject& c2 = w->AddPhysicsObject("esine2", "cube/Cube.mesh");
    c2.SetPosition(Ogre::Vector3(1,2,1));
    c2.AddBoxCollider(1,1,1);
    PhysicsComponent phys2 = c2.GetPhysicsComponent();
    phys2.SetMass(1.0);
    c2.SetMaterial("tex");

    GameObject& taso = w->AddPhysicsObject("taso", "cube/other/Cube.mesh");
    taso.SetPosition(Ogre::Vector3(0, -10, 0));
    taso.AddBoxCollider(10,0.1,10);
    taso.SetMaterial("plane");
    PhysicsComponent phys3 = taso.GetPhysicsComponent();
    phys3.SetMass(0.0);

    GameObject& anim = w->AddObject("anim"  , "second_anim/Cube.mesh");
    anim.SetPosition(Ogre::Vector3(0, -5, 0));
    anim.SetMaterial("tex");

    lRoot->clearEventTimes();
    float f=0.0;
    unsigned long t=0;
    double d;
    Ogre::Timer* a = new Ogre::Timer();
    while(!lWindow->isClosed()) {
        t=a->getMicroseconds();

        camObject.SetPosition(Ogre::Vector3(cos(f)*15.0, -5, sin(f)*15.0));
        camObject.LookAt(Ogre::Vector3(-0,-10,-0), Ogre::Vector3::UNIT_Y);
        w->Update(d);

        f+=d*.5;
        d = (double)(a->getMicroseconds()-t)/1000000;
    }
    delete w;
}
开发者ID:Kilves,项目名称:ogretest,代码行数:62,代码来源:Client.cpp


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