ModelEntitySP LightEntityFactory::createLightEntity(const string& name, const LightSP& light, const vector<AnimationStackSP>& allAnimStacks)
{
	ModelFactory modelFactory;

	ModelSP model = modelFactory.createModel(name, BoundingSphere(Point4(), Light::getDebugRadius()), light, allAnimStacks);

	ModelEntitySP modelEntity = ModelEntitySP(new ModelEntity(name, model, 1.0f, 1.0f, 1.0f));

	return modelEntity;
}
Exemple #2
0
int main(int argc, const char * argv[]) {
    
    ModelFactory modelFactory;
    teapot = modelFactory.BuildModel("teapot.obj");

    std::cout << teapot.m_Info.vertCount << std::endl;
    
    if (!glfwInit())
        exit(EXIT_FAILURE);
    
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, GL_VERSION_MAJOR);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, GL_VERSION_MINOR);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_SAMPLES, 8);
    
    GLFWwindow* window = glfwCreateWindow(WIN_WIDTH, WIN_HEIGHT, WIN_TITLE, NULL, NULL);
    
    gScreenWidth = WIN_WIDTH;
    gScreenHeight = WIN_HEIGHT;
    
    if (!window) {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }
    
    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);
    
    glInit();
    
    std::cout << glGetString(GL_RENDERER) << std::endl;
    std::cout << glGetString(GL_VERSION) << std::endl;
    
    glfwSetKeyCallback(window, KeyCallback);
    glfwSetWindowSizeCallback(window, ResizeCallback);
    
    while (!glfwWindowShouldClose(window)) {
        glLoop();
        glfwPollEvents();
        glfwSwapBuffers(window);
    }
    
    glShutdown();
    
    glfwDestroyWindow(window);
    
    glfwTerminate();
    return 0;
}
ModelEntitySP PrimitiveEntityFactory::createCubePrimitiveEntity(const string& name, float scaleX, float scaleY, float scaleZ, const SurfaceMaterialSP& surfaceMaterial, const vector<AnimationStackSP>& allAnimStacks) const
{
	ModelFactory modelFactory;

	GLUSshape shape;

	float halfExtend = 0.5f;

	glusCreateCubef(&shape, halfExtend);

	BoundingSphere boundingSphere;

	boundingSphere.setRadius(glusLengthf(halfExtend, halfExtend, halfExtend));

	return ModelEntitySP(new ModelEntity(name, modelFactory.createModel(name, boundingSphere, shape, surfaceMaterial, allAnimStacks), scaleX, scaleY, scaleZ));
}
ModelEntitySP PrimitiveEntityFactory::createDomePrimitiveEntity(const string& name, float scaleX, float scaleY, float scaleZ, const SurfaceMaterialSP& surfaceMaterial) const
{
	ModelFactory modelFactory;

	GLUSshape shape;

	float radius = 0.5f;

	uint32_t numberSlices = 32;

	glusCreateDomef(&shape, radius, numberSlices);

	BoundingSphere boundingSphere;

	boundingSphere.setRadius(radius);

	return ModelEntitySP(new ModelEntity(name, modelFactory.createModel(name, boundingSphere, shape, surfaceMaterial), scaleX, scaleY, scaleZ));
}
ModelEntitySP PrimitiveEntityFactory::createConePrimitiveEntity(const string& name, float scaleX, float scaleY, float scaleZ, const SurfaceMaterialSP& surfaceMaterial) const
{
	ModelFactory modelFactory;

	GLUSshape shape;

	float halfExtend = 0.5f;
	float radius = 0.5f;
	uint32_t numberSlices = 32;
	uint32_t numberStacks = 32;

	glusCreateConef(&shape, halfExtend, radius, numberSlices, numberStacks);

	BoundingSphere boundingSphere;

	boundingSphere.setRadius(glusLengthf(halfExtend, radius, 0.0f));

	return ModelEntitySP(new ModelEntity(name, modelFactory.createModel(name, boundingSphere, shape, surfaceMaterial), scaleX, scaleY, scaleZ));
}
ModelEntitySP PrimitiveEntityFactory::createTorusPrimitiveEntity(const string& name, float scaleX, float scaleY, float scaleZ, const SurfaceMaterialSP& surfaceMaterial, const vector<AnimationStackSP>& allAnimStacks) const
{
	ModelFactory modelFactory;

	GLUSshape shape;

	float innerRadius = 0.25f;
	float outerRadius = 0.5f;
	uint32_t numberSlices = 32;
	uint32_t numberStacks = 32;

	glusCreateTorusf(&shape, innerRadius, outerRadius, numberSlices, numberStacks);

	BoundingSphere boundingSphere;

	boundingSphere.setRadius(outerRadius);

	return ModelEntitySP(new ModelEntity(name, modelFactory.createModel(name, boundingSphere, shape, surfaceMaterial, allAnimStacks), scaleX, scaleY, scaleZ));
}
Exemple #7
0
// Choose a random number up to INT_MAX - 1, not INT_MAX,
// because MbRandom adds 1 internally, causing an overflow
MCMC::MCMC(Random& seeder, Settings& settings, ModelFactory& modelFactory) :
    _random(seeder.uniformInteger(0, INT_MAX - 1))
{
    _model = modelFactory.createModel(_random, settings);
 
}
void CreatePrismRectangle(SimpleTree& _rRoot, const Matrix44& _rTransformation)
{
	Entity* pPrismRectangle = new Entity();
	ModelFactory* pFactory = ModelFactory::getInstance();

	SimpleTree* pRootNode = new SimpleTree;
	pRootNode->setTransformation(_rTransformation);
	_rRoot.addChild(pRootNode);

	//Model* pSquare = pFactory->createSquareMesh(5.0f, Vector4(1.0f, 1.0f, 0.0f, 1.0f), true);
	Model* pSquare = pFactory->createBoxMesh(5.0f, 5.0f, 0.1f, Vector4(1.0f, 1.0f, 0.0f, 1.0f), true);
	pSquare->setMaterial(CreatePrismRectangleModelMaterial());
	pPrismRectangle->addComponent(pSquare);
	pSquare->setEntity(pPrismRectangle);

	SimpleTree* pSquareNode = new SimpleTree;
	//getTranslation3(pSquareNode->getTransformation()).Y() = 5.0f;
	getTranslation3(pSquareNode->getTransformation()).Y() = 4.9f;
	pSquareNode->setModel(pSquare);
	pRootNode->addChild(pSquareNode);

	Body* pSquareBody = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pSquare,
		pSquareNode->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pSquareBody)->setNode(pSquareNode);
	static_cast<PhysXBody*>(pSquareBody)->setNode(pSquareNode);
	pPrismRectangle->addComponent(pSquareBody);
	pSquareBody->setEntity(pPrismRectangle);

	Model* pPrism0 = pFactory->createPrismMesh(5.0f, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
	pPrism0->setMaterial(CreatePrismRectangleModelMaterial());
	pPrismRectangle->addComponent(pPrism0);
	pPrism0->setEntity(pPrismRectangle);

	SimpleTree* pPrism0Node = new SimpleTree;
	rotate(pPrism0Node->getTransformation(), Math::PI, Vector4(0.0f, 1.0f, 0.0f, 1.0f));
	getTranslation3(pPrism0Node->getTransformation()).Z() = 10.0f;
	pPrism0Node->setModel(pPrism0);
	pRootNode->addChild(pPrism0Node);

	Body* pPrism0Body = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pPrism0,
		pPrism0Node->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pPrism0Body)->setNode(pPrism0Node);
	static_cast<PhysXBody*>(pPrism0Body)->setNode(pPrism0Node);
	pPrismRectangle->addComponent(pPrism0Body);
	pPrism0Body->setEntity(pPrismRectangle);

	Model* pPrism1 = pFactory->createPrismMesh(5.0f, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
	pPrism1->setMaterial(CreatePrismRectangleModelMaterial());
	pPrismRectangle->addComponent(pPrism1);
	pPrism1->setEntity(pPrismRectangle);

	SimpleTree* pPrism1Node = new SimpleTree;
	getTranslation3(pPrism1Node->getTransformation()).Z() = -10.0f;
	pPrism1Node->setModel(pPrism1);
	pRootNode->addChild(pPrism1Node);

	Body* pPrism1Body = PhysicsFactory::getInstance()->createBody(CreateObstacleBodyMaterial(), pPrism1,
		pPrism1Node->getAbsoluteTransformation(), false);
	//static_cast<BulletBody*>(pPrism1Body)->setNode(pPrism1Node);
	static_cast<PhysXBody*>(pPrism1Body)->setNode(pPrism1Node);
	pPrismRectangle->addComponent(pPrism1Body);
	pPrism1Body->setEntity(pPrismRectangle);

	GazEngine::addEntity(pPrismRectangle);
}
Exemple #9
0
int main(int argc, char** argv) 
{

/* Necessary if MPI support is enabled during compilation. */
#ifdef _MPI
    MPI_Init(&argc, &argv);
    int rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
#else
    /* In our MPI implementation the process with rank 0 is the master. */
    int rank = 0;
#endif
    
    try {
        
        if(argc != 3){
            /* Print usage and exit. */
            if (rank == 0) std::cout << "\nusage: " << argv[0] << " ModelConf.conf MonteCarlo.conf\n" << std::endl;
            return EXIT_SUCCESS;
        }

        /* Define the model configuration file.                                */
        /* Here it is passed as the first argument to the executable. The      */
        /* model configuration file provides the values with errors for the    */
        /* mandatory model parameters, as well as the list of observables,     */
        /* observables2D, correlated Gaussian observables.                     */
        /* See documentation for details.                                      */
        std::string ModelConf = argv[1];
        
        /* Define the Monte Carlo configuration file.                         */
        /* Here it is passed as the second argument to the executable. The    */
        /* Monte Carlo configuration file provides the parameters used in the */
        /* Monte Carlo run. See documentation for details.                    */
        std::string MCMCConf = argv[2];
        
        /* Define the ROOT output file (w/o extension, empty string will set it to MCout) */
        std::string FileOut = "";        
        
        /* Define the optional job tag. */
        std::string JobTag = "";
        
        /* Create objects of the classes ModelFactory and ThObsFactory */
        ThObsFactory ThObsF;
        ModelFactory ModelF;
        myModel my_model;

        /* register user-defined model named ModelName defined in class ModelClass using the following syntax: */
        ModelF.addModelToFactory("myModel", boost::factory<myModel*>() );
        
        /* register user-defined ThObservable named ThObsName defined in class ThObsClass using the following syntax: */
        ThObsF.addObsToFactory("BIN1", boost::bind(boost::factory<yield*>(), _1, 1) );
        ThObsF.addObsToFactory("BIN2", boost::bind(boost::factory<yield*>(), _1, 2) );
        ThObsF.addObsToFactory("BIN3", boost::bind(boost::factory<yield*>(), _1, 3) );
        ThObsF.addObsToFactory("BIN4", boost::bind(boost::factory<yield*>(), _1, 4) );
        ThObsF.addObsToFactory("BIN5", boost::bind(boost::factory<yield*>(), _1, 5) );
        ThObsF.addObsToFactory("BIN6", boost::bind(boost::factory<yield*>(), _1, 6) );
        ThObsF.addObsToFactory("C_3", boost::factory<C_3*>() );
        ThObsF.addObsToFactory("C_4", boost::factory<C_4*>() );
        
        /* Create an object of the class MonteCarlo. */        
        MonteCarlo MC(ModelF, ThObsF, ModelConf, MCMCConf, FileOut, JobTag);
        
        /* Do a test run if you wish to see the values of the observables      */
        /* and the correlated Gaussian observables defined in the model        */
        /* configuration file computed with the central value of the mandatory */
        /* parameters defined in the same file.                                */
        // MC.TestRun(rank);
        
        /* Initiate the Mote Carlo run. */
        MC.Run(rank);

/* Necessary if MPI support is enabled during compilation. */
#ifdef _MPI
        MPI_Finalize();
#endif
        
        return EXIT_SUCCESS;
    } catch (const std::runtime_error& e) {
        std::cerr << e.what() << std::endl;
        return EXIT_FAILURE;
    }
}