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


C++ MaterialManager::compile方法代码示例

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


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

示例1: display

void display()
{

	Core::init(512,512);
	Core::getInstance()->initImageRendering();


    Camera * cam = new Camera();

    cam->setPosition(Vector4I(0,-8,-8,1));
    cam->setDirection(Vector4I(0,-1,-1,0),Vector4I(0,1,0,0));
    cam->setFovDeg(30,30);
    cam->flush();

    MaterialManager * materials = new MaterialManager("/home/rulk/src/raytracer-wsp/StingRay/src/material/"
    		,"/home/rulk/src/raytracer-wsp/StingRay/src/material/");
    materials->loadFile("basic.material");

    materials->compile();
    Material * mat = materials->getMaterial("simpleColor");
    Material * mat1 = materials->getMaterial("complexColor");
    std::cout<<mat<<std::endl;


    RenderableManager * renderables = new RenderableManager();

    Sphere * sphere = new Sphere(mat,Fvec4(2,0,-8,1),1);
    Sphere * sphere1 = new Sphere(mat1,Fvec4(-2,0,-8,1),1);
    Sphere * sphere2 = new Sphere(mat1,Fvec4(0,2,-8,1),1);
    ManualMesh manual;





    TriMesh *themesh = TriMesh::read("/home/rulk/src/raytracer-wsp/StingRay/cube.obj");
    if (!themesh)
    			THROW(0,"No such mesh...");
    themesh->need_normals();
    themesh->need_tstrips();
    themesh->need_bsphere();
    int offset = 0,len = 0,pIndex;
    manual.begin(mat);
    bool needdub = false;
    for(int i=0;i<themesh->tstrips.size();i++)
    {
    	if( i >= offset+len)
    	{

    		offset = i+1;
    		len = themesh->tstrips[i];
    		//manual.beginStrip();
    		if(i != 0)
    		{
    			manual.duplicateLast();
    			needdub = true;
    		}
    		continue;
    	}
    	pIndex = themesh->tstrips[i];
    	manual.position(themesh->vertices[pIndex][0],themesh->vertices[pIndex][1],themesh->vertices[pIndex][2]);
    	if(needdub)
    	{
    		manual.duplicateLast();
    		needdub = false;
    	}
    }
    manual.normal(Fvec4(0,1,0,0));
    std::cout<<"Size:"<<themesh->tstrips.size()<<std::endl;
    TriangelMesh * mesh = manual.getTriangelMesh();

    /*SphereStream * spheres = new SphereStream(1,STREAM_READ);
    spheres->put(Vector4I(2,0,-8,1),1,Vector3I(0,0,1));
    spheres->flush();
     */
   // renderables->registerRendarable(sphere);
   // renderables->registerRendarable(sphere1);
   // renderables->registerRendarable(sphere2);
    renderables->registerRendarable(mesh);
    MaterialKernel * kernel = new MaterialKernel("/home/rulk/src/raytracer-wsp/StingRay/cl/sphere_tracer.cl");
    kernel->setMaterialManager(materials);
    kernel->setRenderableManager(renderables);
    kernel->compileKernel();

    kernel->setCamera(cam);


	size_t global_item_size = 512*512; // Process the entire lists
    size_t local_item_size = 512;

	kernel->run(Core::getInstance()->getQue(),&global_item_size,&local_item_size);

	//streamC.sync();

	Core::getInstance()->dumpImage("out.png");
	Core::getInstance()->flushQue();
	Core::getInstance()->finishQue();
	delete kernel;

	Core::destroy();
//.........这里部分代码省略.........
开发者ID:rulk,项目名称:StingRay,代码行数:101,代码来源:simpleRayTracer.cpp


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