Exemple #1
0
void init(void){
	gouraudShading = createShaderProgram("vertexShaderSource.vert","fragmentShaderSource.frag", g_projectionBlockIndex);
	if(gouraudShading->linkStatus == GL_FALSE)
		exit(0);
	initWireRect();

	setPrespectiveProjection();
	genUniformBuffer();

	loadLights();

	gLoadIdentity();
	gSaveTop(orientationMatrix);

	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	glFrontFace(GL_CCW);

	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);
	glDepthFunc(GL_LEQUAL);
	glDepthRange(0.0f, 1.0f);
	glEnable(GL_DEPTH_CLAMP);

	objectsArray = (meshObject**)malloc(sizeof(meshObject*) * MAX_OBJECTS);
	loadPointMeshFile();
	loadPointMeshFile();
	userDefinedSegmentVertex = createArrayListf();
	userDefinedSegmentColor = createArrayListui();
	setMarkingColor();
}
Object* ObjectLoader::loadObjectFromFile(const char* filename){
	Object* object = NULL;
	//Leo el archivo y lo parseo en un arbol
	XmlTree* xmlTree = XmlParser::parse(string(WindowConnector::getBaseApplicationPath() + filename).c_str());
	//***Transformo el arbol en un Object***
	XmlTreeNode* root =  xmlTree->getRootNode();
	//Primiero busco la etiqueta de Object
	XmlTreeNode* objectNode = NULL;
	for(unsigned int i=0; i < root->getChildNodes().size(); i++){
		objectNode = root->getChildNodes()[i];
		if(objectNode->getName().compare("Object")==0){	
			//Cargo el mesh y le seteo los valores del xml
			object = initObject(objectNode);
			break;
		}
	}
    if(object == NULL){
        if(xmlTree != NULL){ delete xmlTree; }
		return NULL; //Error
    }

	//Busco las etiquetas de Mesh y reemplazo los valores del xml
	Mesh* mesh = object->getMesh();
	if(mesh->getChilds()->size() > 0){		
		loadMesh(mesh, objectNode);		
	}
	//Busco las etiquetas de Light y las agrego a las luces del objeto
	loadLights(object, objectNode);

	//Guardo el path en el object
	object->setFilename(filename);

    delete xmlTree;
	return object;
}
void AssetImporter::importScene(
    ID3D11Device* d3dDevice,
    std::wstring& path,
    GRAPHICS::Scene& outScene
)
{
    Assimp::Importer importer;
    std::string assetPath(path.begin(), path.end());
    const aiScene* scene = importer.ReadFile(assetPath.c_str(),
                           aiProcess_ConvertToLeftHanded |
                           aiProcess_CalcTangentSpace |
                           aiProcess_Triangulate |
                           aiProcess_JoinIdenticalVertices |
                           aiProcess_FlipWindingOrder |
                           aiProcess_GenUVCoords |
                           aiProcess_GenSmoothNormals |
                           aiProcess_SortByPType);

    if (!scene)
    {
        printf("Failed to import asset: %s", assetPath.c_str());
    }

    GRAPHICS::RESOURCES::Mesh* meshArr = loadMeshes(d3dDevice, scene);
    GRAPHICS::RESOURCES::Material* materialArr = loadMaterials(d3dDevice, scene);

    nextNode(d3dDevice, scene, scene->mRootNode, scene->mRootNode->mTransformation, meshArr, materialArr, outScene);

    loadLights(d3dDevice, outScene, scene);

    delete[] meshArr;
    delete[] materialArr;
}
void RayTracerCuda::start()
{
    Bitmap bitmap;
    bitmap.width = theScene->camera->getViewportWidth();
    bitmap.height = theScene->camera->getViewportHeight();
    bitmap.pixelWidth = theScene->camera->getWindowWidth() / bitmap.width;
    bitmap.pixelHeight = theScene->camera->getWindowHeight() / bitmap.height;
    bitmap.firstPixel = Float3D(theScene->camera->windowLeft + bitmap.pixelWidth / 2, theScene->camera->windowBottom + bitmap.pixelHeight / 2, -theScene->camera->near);

    doViewTrans();

    int numObjects = theScene->objects.size();
    Mesh objects[numObjects];
    loadObjects(objects);

    int numLights = 0;
    for (int x = 0; x < 8; x++)
    {
        if (theScene->lights->lights[x].lightSwitch == Lights::Light::ON)
            numLights++;
    }
    LightCuda lights[numLights];
    loadLights(lights);

    Options options;
    options.spheresOnly = rayTracer->spheresOnly;
    options.reflections = rayTracer->reflections;
    options.refractions = rayTracer->refractions;
    options.shadows = rayTracer->shadows;
    options.maxRecursiveDepth = rayTracer->maxRecursiveDepth;

    cudaStart(&bitmap, objects, numObjects, lights, numLights, &options);

    if (rayTracer->data != nullptr)
    {
        free(rayTracer->data);
        rayTracer->data = nullptr;
    }
    rayTracer->data = bitmap.data;
}
Exemple #5
0
// TODO move this function to the constructor ? 
void Scene::loadSceneFromFile(const char* filename){
	XMLDocument doc;
	doc.LoadFile(filename);

    // Check for errors in the XML
    if (doc.ErrorID() != 0)
    {
        doc.PrintError();
    }

    XMLElement *music = doc.FirstChildElement("scene");
    pathMusic = music->FirstChildElement("music")->GetText();

    XMLElement *end = doc.FirstChildElement("scene");
    if(end->FirstChildElement("end")) this->end = atoi(end->FirstChildElement("end")->GetText());
    else this->end = 0;

	loadModels(doc);
	loadDialogues(doc);
	loadLights(doc);
	loadRoom(doc);
}
/*public*/ bool InternalLightManagerXml::load(QDomElement lights)throw (Exception) {
    // load individual lights
    loadLights(lights);
    return true;
}