예제 #1
0
void fakeHaskell()
{
    DemoApp* da = initDemo();
    
    Ogre::SceneManager* sm = getSceneManager();
    Ogre::SceneNode* rnode = getRootSceneNode(sm);
    
    /*	OgreFramework::getSingletonPtr()->m_pSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
     
     m_pCubeEntity = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Cube", "ogrehead.mesh");
     m_pCubeNode = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("CubeNode");
     m_pCubeNode->attachObject(m_pCubeEntity);
     
     m_pCube2E = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Steve", Ogre::SceneManager::PT_CUBE);
     m_pCube2N = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("SteveN");
     m_pCube2N->attachObject(m_pCube2E);*/
    
    setSkybox(sm, true, "Examples/SpaceSkyBox");
    
    Ogre::Entity* cubeEntity = createEntity(sm, "Cube", "ogrehead.mesh");
    Ogre::SceneNode* cubeNode = createChildSceneNode(rnode, "CubeNode");
    attachObject(cubeNode, cubeEntity);
    
    finishSetupAndRun(da);
}
예제 #2
0
void init()
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glEnable(GL_DEPTH_TEST);

	initDemo();
	

	{
//		char txt[128];
//		sprintf(txt,"Dem: %dK(%d)", m_pSim->m_numParticles/1024, m_pSim->m_numParticles);
//		glutSetWindowTitle(txt);
	}
}
예제 #3
0
void DefracDemo::initPhysics()
{
	m_dispatcher=0;
	m_collisionConfiguration = new btDefaultCollisionConfiguration();
	m_dispatcher = new	btCollisionDispatcher(m_collisionConfiguration);

	btVector3 worldAabbMin(-1000,-1000,-1000);
	btVector3 worldAabbMax(1000,1000,1000);

	m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);

	btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
	
	m_solver = solver;
	
	btDiscreteDynamicsWorld* world = new btDefracDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
	m_dynamicsWorld = world;

	m_dynamicsWorld->setGravity(btVector3(0,-10,0));

	///create concave ground mesh
	m_azi = 0;
	btCollisionShape* groundShape = 0;
	{
		int i;
		int j;

		const int NUM_VERTS_X = 30;
		const int NUM_VERTS_Y = 30;
		const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
		const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1);

		gGroundVertices = new btVector3[totalVerts];
		gGroundIndices = new int[totalTriangles*3];

		btScalar offset(-50);

		for ( i=0;i<NUM_VERTS_X;i++)
		{
			for (j=0;j<NUM_VERTS_Y;j++)
			{
				gGroundVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
					//0.f,
					waveheight*sinf((float)i)*cosf((float)j+offset),
					(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
			}
		}

		int vertStride = sizeof(btVector3);
		int indexStride = 3*sizeof(int);

		int index=0;
		for ( i=0;i<NUM_VERTS_X-1;i++)
		{
			for (int j=0;j<NUM_VERTS_Y-1;j++)
			{
				gGroundIndices[index++] = j*NUM_VERTS_X+i;
				gGroundIndices[index++] = j*NUM_VERTS_X+i+1;
				gGroundIndices[index++] = (j+1)*NUM_VERTS_X+i+1;

				gGroundIndices[index++] = j*NUM_VERTS_X+i;
				gGroundIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
				gGroundIndices[index++] = (j+1)*NUM_VERTS_X+i;
			}
		}

		btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
			gGroundIndices,
			indexStride,
			totalVerts,(btScalar*) &gGroundVertices[0].x(),vertStride);

		bool useQuantizedAabbCompression = true;

		groundShape = new btBvhTriangleMeshShape(indexVertexArrays,useQuantizedAabbCompression);
		groundShape->setMargin(0.5);
	}

	m_collisionShapes.push_back(groundShape);

	btCollisionShape* groundBox = new btBoxShape (btVector3(100,CUBE_HALF_EXTENTS,100));
	m_collisionShapes.push_back(groundBox);

	btTransform tr;
	tr.setIdentity();
	tr.setOrigin(btVector3(0,-30.f,0));
	localCreateRigidBody(0, tr, groundBox);
	
	//	clientResetScene();

	initDemo();
	clientResetScene();
}
예제 #4
0
파일: CEngine.cpp 프로젝트: whztt07/CG2015
bool CEngine::init(const char* configFile)
{
    // Init log file
    std::string logFile = "log/" + createTimeStamp() + ".log";
    if (!CLogger::initLogFile(logFile))
    {
        LOG_WARNING("Failed to create log file at %s.", logFile.c_str());
    }

	// Config data with default values
	std::string modeType = "demo"; // Startup mode for the application
	std::string sceneFile = "data/world/test_1.json"; // Scene file to load and render if mode is demo
	std::string gameFile = "data/game/defenders_of_cthedra/game.json"; // Game file to load if mode is game
	std::string rendererType = "deferred"; // Renderer type to use
	
	// Window parameters
	unsigned int windowWidth = 800;
	unsigned int windowHeight = 600;
	std::string windowTitle = "CG 2015";

	// Load config file based on extension
	bool loadSuccess = false;
	if (getFileExtension(configFile) == "ini")
	{
		CIniFile configIni;
		if (configIni.load(configFile))
		{
			// Load values
			modeType = configIni.getValue("mode", "type", "demo");
			sceneFile = configIni.getValue("scene", "file", "data/world/test_1.json");
			gameFile = configIni.getValue("game", "file", "data/game/defenders_of_cthedra/game.json");
			rendererType = configIni.getValue("renderer", "type", "forward");
			windowWidth = configIni.getValue("window", "width", 800);
			windowHeight = configIni.getValue("window", "height", 600);
			windowTitle = configIni.getValue("window", "type", "CG 2015");
			loadSuccess = true;
		}
	}
	else if (getFileExtension(configFile) == "json")
	{
		Json::Value root;
		if (load(configFile, root))
		{
			// Sub nodes
			Json::Value game = root["game"];
			Json::Value renderer = root["renderer"];
			Json::Value window = root["window"];

			// Load values
			modeType = "game"; // Json only supports game mode
			sceneFile = ""; // Scene file not supported/legacy
			load(game, "file", gameFile);
			load(renderer, "type", rendererType);
			load(window, "width", windowWidth);
			load(window, "height", windowHeight);
			load(window, "title", windowTitle);
			loadSuccess = true;
		}
	}
	else
	{
		LOG_WARNING("The config file %s has an unknown file extension.");
	}

	// Check if config loaded successfully
	if (!loadSuccess)
	{
		LOG_WARNING("Failed to load config file %s. Starting with default settings.", configFile);
		// TODO Return if no config exists?
	}

    // Create window for rendering
    if (!initWindow(windowWidth, windowHeight, windowTitle))
    {
        LOG_ERROR("Failed to initialize window.");
        return false;
    }
	// TODO GLFW handle not properly wrapped away, GFLW should not be used directly
	m_inputProvider = std::make_shared<CGlfwInputProvider>(m_window->getGlfwHandle());

    // Create central resource manager
    m_resourceManager.reset(createResourceManager());
    if (m_resourceManager == nullptr)
    {
        LOG_ERROR("Failed to initialize resource manager.");
        return false;
    }

	// Create and initialize graphics system
	m_graphicsSystem = std::make_shared<CGraphicsSystem>();
	if (!m_graphicsSystem->init(*m_resourceManager))
	{
		LOG_ERROR("Failed to initialize graphics system.");
		return false;
	}

	// Legacy stuff to keep demo mode working
	// TODO Should be removed
	if (modeType == "demo")
	{
		if (!initDemo(sceneFile))
		{
			LOG_ERROR("Failed to initialize demo mode.");
			return false;
		}
	}
	else // Create and initialize game system
	{
		if (!initGameSystem(gameFile))
		{
			LOG_ERROR("Failed to initialize game system.");
			return false;
		}
	}
    return true;
}