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


C++ MaterialManager类代码示例

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


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

示例1: NewMaterialDialog

void WorkspaceWidget::showDialog()
{
    NewMaterialDialog *newMaterial = new NewMaterialDialog(this);
    newMaterial->show();
    MaterialManager *matMgr = MaterialManager::getSingletonPtr();
    Ogre::LogManager::getSingleton().logMessage("Working dir: " + matMgr->getWorkDir().toStdString());
}
开发者ID:ironsteel,项目名称:QtOME,代码行数:7,代码来源:WorkspaceWidget.cpp

示例2: updateFromLabel

void SceneLabel::updateFromLabel() {

	MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();	
	if(texture)
		materialManager->deleteTexture(texture);

	texture = materialManager->createTextureFromImage(label, materialManager->clampDefault, materialManager->mipmapsDefault);

	if(material) {
		localShaderOptions->clearTexture("diffuse");
		localShaderOptions->addTexture("diffuse", texture);	
	}

	delete mesh;
	mesh = new Mesh(Mesh::QUAD_MESH);
	mesh->createVPlane(label->getWidth()*scale,label->getHeight()*scale);
	
	bBox.x = label->getWidth()*scale;
	bBox.y = label->getHeight()*scale;
	bBox.z = 0;
	
	
	if(useVertexBuffer)
		CoreServices::getInstance()->getRenderer()->createVertexBufferForMesh(mesh);
	
	// TODO: resize it here
	
	bBoxRadius = label->getWidth()*scale;

}
开发者ID:AmeliaMesdag,项目名称:Polycode,代码行数:30,代码来源:PolySceneLabel.cpp

示例3: delete0

//----------------------------------------------------------------------------
GraphicsRoot::~GraphicsRoot ()
{
	MaterialManager *mi = MaterialManager::GetSingletonPtr();
	if (mi)
	{
		mi->Terminate();

		delete0(mi);
		MaterialManager::Set(0);
	}
}
开发者ID:PhoenixSteam,项目名称:Phoenix3D,代码行数:12,代码来源:PX2GraphicsRoot.cpp

示例4: ResourceGroupManager

void MeshWithoutIndexDataTests::setUp()
{
	LogManager::getSingleton().createLog("MeshWithoutIndexDataTests.log", true);
	OGRE_NEW ResourceGroupManager();
	OGRE_NEW LodStrategyManager();
    mBufMgr = OGRE_NEW DefaultHardwareBufferManager();
    mMeshMgr = OGRE_NEW MeshManager();
    archiveMgr = OGRE_NEW ArchiveManager();
    archiveMgr->addArchiveFactory(OGRE_NEW FileSystemArchiveFactory());

	MaterialManager* matMgr = OGRE_NEW MaterialManager();
	matMgr->initialise();
}
开发者ID:brunobg,项目名称:TuxSinbad,代码行数:13,代码来源:MeshWithoutIndexDataTests.cpp

示例5: printf

Geometry* SceneLoader::LoadGeometry(QDomElement element)
{
  Geometry* geom = GeometryPool::Get()->GetGeometry(_geometryName, _geometryIdx);
  if (geom)
    {
      return geom;
    }

  if (element.nodeName() != QString ("geometry"))
    {
      printf ("ceXMLDataLoader::LoadGeometry: Illegal data format: '%s' != 'geometry'\n", element.nodeName().toStdString().c_str()); fflush (stdout);
      return 0;
    }

  geom = new Geometry ();

  QDomElement staticElement = element.firstChildElement("staticmesh");
  if (!staticElement.isNull())
    {
      ceMesh* mesh = LoadMesh (staticElement);
      if (!mesh)
        {
          geom->Release();
          return 0;
        }
      iStaticMesh* staticMesh = _engine->GetDevice()->CreateStaticMesh();
      staticMesh->SetMesh(mesh);
      geom->SetMesh(staticMesh);
      geom->SetMetaMesh(MT_Static,
      staticElement.firstChildElement("mesh").attribute("filename"));
    }

  MaterialManager* matMgr = Session::Get()->GetMaterialManager();

  QDomElement materialElement = element.firstChildElement("material");
  Material* mat = 0;
  if (!materialElement.isNull())
    {
      mat = matMgr->GetMaterial(materialElement.text());
    }

  if (!mat)
    {
      mat = matMgr->GetDefaultMaterial();
    }
  geom->SetMetaMaterial(mat);

  GeometryPool::Get()->Set(_geometryName, _geometryIdx, geom);
  return geom;

}
开发者ID:BtbN,项目名称:crimson-core,代码行数:51,代码来源:sceneloader.cpp

示例6: texData

	Texture* MdlFileImport::loadTexture( mstudiotexture_t& texDesc , uint8* data )
	{
		int texArea = texDesc.height * texDesc.width;
		uint8* pal = data + texArea;

		std::vector< uint8 > texData( texArea * 4 );

		uint32* pColor = (uint32*) &texData[0];
		for( int i = 0 ; i < texArea ; ++i )
		{
			uint8* palC = pal + 3 * data[i];
			pColor[i] = Color::toARGB( palC[0] , palC[1], palC[2] , 255 );
		}

		MaterialManager* manager = mScene->getWorld()->_getMaterialManager();
		Texture* texture =  manager->createTexture2D( texDesc.name , CF_TEX_FMT_ARGB32 , &texData[0] , texDesc.width , texDesc.height );

		return texture;
	}
开发者ID:uvbs,项目名称:GameProject,代码行数:19,代码来源:MdlFileLoader.cpp

示例7: renderTexture

void ImpostorTexture::renderTextures(bool force)
{
#ifdef IMPOSTOR_FILE_SAVE
	TexturePtr renderTexture;
#else
	TexturePtr renderTexture(texture);
	//if we're not using a file image we need to set up a resource loader, so that the texture is regenerated if it's ever unloaded (such as switching between fullscreen and the desktop in win32)
	loader = std::auto_ptr<ImpostorTextureResourceLoader>(new ImpostorTextureResourceLoader(*this));
#endif
	RenderTexture *renderTarget;
	Camera *renderCamera;
	Viewport *renderViewport;
	SceneNode *camNode;

	//Set up RTT texture
	uint32 textureSize = ImpostorPage::impostorResolution;
	if (renderTexture.isNull()) {
	renderTexture = TextureManager::getSingleton().createManual(getUniqueID("ImpostorTexture"), "Impostors",
				TEX_TYPE_2D, textureSize * IMPOSTOR_YAW_ANGLES, textureSize * IMPOSTOR_PITCH_ANGLES, 0, PF_A8R8G8B8, TU_RENDERTARGET, loader.get());
	}
	renderTexture->setNumMipmaps(MIP_UNLIMITED);
	
	//Set up render target
	renderTarget = renderTexture->getBuffer()->getRenderTarget(); 
	renderTarget->setAutoUpdated(false);
	
	//Set up camera
	camNode = sceneMgr->getSceneNode("ImpostorPage::cameraNode");
	renderCamera = sceneMgr->createCamera(getUniqueID("ImpostorCam"));
	camNode->attachObject(renderCamera);
	renderCamera->setLodBias(1000.0f);
	renderViewport = renderTarget->addViewport(renderCamera);
	renderViewport->setOverlaysEnabled(false);
	renderViewport->setClearEveryFrame(true);
	renderViewport->setShadowsEnabled(false);
	renderViewport->setBackgroundColour(ImpostorPage::impostorBackgroundColor);
	
	//Set up scene node
	SceneNode* node = sceneMgr->getSceneNode("ImpostorPage::renderNode");
	
	Ogre::SceneNode* oldSceneNode = entity->getParentSceneNode();
	if (oldSceneNode) {
		oldSceneNode->detachObject(entity);
	}
	node->attachObject(entity);
	node->setPosition(-entityCenter);
	
	//Set up camera FOV
	const Real objDist = entityRadius * 100;
	const Real nearDist = objDist - (entityRadius + 1); 
	const Real farDist = objDist + (entityRadius + 1);
	
	renderCamera->setAspectRatio(1.0f);
	renderCamera->setFOVy(Math::ATan(entityDiameter / objDist));
	renderCamera->setNearClipDistance(nearDist);
	renderCamera->setFarClipDistance(farDist);
	
	//Disable mipmapping (without this, masked textures look bad)
	MaterialManager *mm = MaterialManager::getSingletonPtr();
	FilterOptions oldMinFilter = mm->getDefaultTextureFiltering(FT_MIN);
	FilterOptions oldMagFilter = mm->getDefaultTextureFiltering(FT_MAG);
	FilterOptions oldMipFilter = mm->getDefaultTextureFiltering(FT_MIP);
	mm->setDefaultTextureFiltering(FO_POINT, FO_LINEAR, FO_NONE);

	//Disable fog
	FogMode oldFogMode = sceneMgr->getFogMode();
	ColourValue oldFogColor = sceneMgr->getFogColour();
	Real oldFogDensity = sceneMgr->getFogDensity();
	Real oldFogStart = sceneMgr->getFogStart();
	Real oldFogEnd = sceneMgr->getFogEnd();
	sceneMgr->setFog(Ogre::FOG_EXP2, Ogre::ColourValue(0,0,0,0), 0.0f, 0.0f, 0.0f); //Ember change
	
	//We need to disable all lightning and render it full bright
	Ogre::ColourValue oldAmbientColour = sceneMgr->getAmbientLight();
	sceneMgr->setAmbientLight(ColourValue::White);

	std::vector<Ogre::MovableObject*> lightStore;
	Ogre::SceneManager::MovableObjectIterator lightIterator = sceneMgr->getMovableObjectIterator(Ogre::LightFactory::FACTORY_TYPE_NAME);
	while (lightIterator.hasMoreElements()) {
		Ogre::MovableObject* light = lightIterator.getNext();
		if (light) {
			if (light->getVisible()) {
				lightStore.push_back(light);
				light->setVisible(false);
			}
		}
	}

	// Get current status of the queue mode
	Ogre::SceneManager::SpecialCaseRenderQueueMode OldSpecialCaseRenderQueueMode = sceneMgr->getSpecialCaseRenderQueueMode();
	//Only render the entity
	sceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE); 
	sceneMgr->addSpecialCaseRenderQueue(group->geom->getRenderQueue() + 1);

	uint8 oldRenderQueueGroup = entity->getRenderQueueGroup();
	entity->setRenderQueueGroup(group->geom->getRenderQueue() + 1);
	bool oldVisible = entity->getVisible();
	entity->setVisible(true);
	float oldMaxDistance = entity->getRenderingDistance();
	entity->setRenderingDistance(0);
//.........这里部分代码省略.........
开发者ID:Arsakes,项目名称:ember,代码行数:101,代码来源:ImpostorPage.cpp

示例8: printf

void LevelManager::loadLevel(Level* lvl) {
    printf("STARTING TO LOAD LEVEL \n" );

    std::cout << "Entities::start " << cg::Registry::instance()->size() << "\n";

    _currentLevel = lvl;
    _currentClues = 0;
    static_cast<Scene*>(cg::Registry::instance()->get("Scene"))->reset();

    MaterialManager* materialManager = dynamic_cast<MaterialManager*>(cg::Registry::instance()->get("MaterialManager"));
    TextureManager* textureManager = dynamic_cast<TextureManager*>(cg::Registry::instance()->get("TextureManager"));

    materialManager->clear();
    std::list<Material*>::iterator matit;
    for(matit = lvl->getMaterials()->begin(); matit != lvl->getMaterials()->end(); matit++) {
        materialManager->add(*matit);
    }

    textureManager->clear();
    std::list<Texture*>::iterator texit;
    textureManager->addMap(lvl->getMapTex());
    for(texit = lvl->getTextures()->begin(); texit != lvl->getTextures()->end(); texit++) {
        textureManager->add(*texit);
    }


    printf("LEVEL MANAGER: REMOVING PREVIOUS ENTITIES\n");
    //clearing old ones (if there are any)
    cg::View* v1 = static_cast<cg::View*>(cg::Registry::instance()->get("view1"));
    std::list<std::string>::iterator entitiesit;
    for(entitiesit = _currentEntities->begin(); entitiesit != _currentEntities->end(); entitiesit++) {
        v1->unlinkEntity(*entitiesit);
        cg::Registry::instance()->remove(*entitiesit);
    }

    std::cout << "Entities::after_unlink " << cg::Registry::instance()->size() << "\n";
    DebugManager* dm = static_cast<DebugManager*>(cg::Registry::instance()->get("DebugManager"));
    std::cout << "Debugmanager::Before " << dm->getListsSize() << "\n";


    printf("LEVEL MANAGER: REMOVING DEBUG LISTENERS\n");
    //removing everything registered for Debug (Ninja is always there)
    //DebugManager* dm = static_cast<DebugManager*>(cg::Registry::instance()->get("DebugManager"));
    dm->dispose();
    dm->disableDebug();

    std::cout << "Debugmanager::After " << dm->getListsSize() << "\n";

    CollisionManager* cm = static_cast<CollisionManager*>(cg::Registry::instance()->get("CollisionManager"));
    std::cout << "Collision::Before " << cm->getListsSize() << "\n";


    printf("LEVEL MANAGER: REMOVING COLLISION LISTENERS\n");
    //removing everything except Ninja from Collisions
    //CollisionManager* cm = static_cast<CollisionManager*>(cg::Registry::instance()->get("CollisionManager"));
    cm->dispose();


    std::cout << "Collision::After " << cm->getListsSize() << "\n";
    std::cout << "Entities::after_managers " << cg::Registry::instance()->size() << "\n";

    _currentEntities->clear();

    std::cout << "Entities::after_clean_entities " << cg::Registry::instance()->size() << "\n";

    printf("LEVEL MANAGER: STARTING TO LOAD HEIGHT MAP\n");
    ImageLoaderHeightMap* ilhm = static_cast<ImageLoaderHeightMap*>(cg::Registry::instance()->get("mappedterrain"));
    if(ilhm != NULL)
        ilhm->setHeightMap(LEVEL_PATH + _currentLevel->getHeightMap());
    else {
        ilhm = new ImageLoaderHeightMap("mappedterrain", LEVEL_PATH + _currentLevel->getHeightMap());
        cg::Registry::instance()->add(ilhm);
    }

    std::cout << "Entities::after_heightmap " << cg::Registry::instance()->size() << "\n";

    printf("LEVEL MANAGER: STARTING TO LOAD ITEM MAP\n");
    ImageLoaderItemMap* ilim = static_cast<ImageLoaderItemMap*>(cg::Registry::instance()->get("mappeditems"));
    if(ilim != NULL)
        ilim->setItemMap(LEVEL_PATH + _currentLevel->getHeightMap(), LEVEL_PATH + _currentLevel->getItemMap());
    else {
        ilim = new ImageLoaderItemMap("mappeditems", LEVEL_PATH + _currentLevel->getHeightMap(), LEVEL_PATH + _currentLevel->getItemMap());
        cg::Registry::instance()->add(ilim);
    }


    for(entitiesit = _currentEntities->begin(); entitiesit != _currentEntities->end(); entitiesit++) {
        cg::Registry::instance()->get(*entitiesit)->init();
    }

    //reset ninja position
    printf("LEVEL MANAGER: RESETING NINJA POSITION\n");
    Ninja* ninja = dynamic_cast<Ninja*>(cg::Registry::instance()->get("Ninja"));
    ninja->reset();

    static_cast<Camera*>(cg::Registry::instance()->get("Camera"))->mainCamera();

    std::cout << "Entities::after_itemmap " << cg::Registry::instance()->size() << "\n";
    std::cout << "Debugmanager::After " << dm->getListsSize() << "\n";
    std::cout << "Collision::After " << cm->getListsSize() << "\n";
//.........这里部分代码省略.........
开发者ID:Meldow,项目名称:HarudoboirudoNinja,代码行数:101,代码来源:LevelManager.cpp

示例9: Real

void RenderState::enter()
{
        OgreFramework* framework = OgreFramework::getSingletonPtr();
        
        framework->_viewport->setVisibilityMask(RF_MAIN);
        //framework->_log->logMessage("Entering RenderState...");

        _sceneMgr = framework->_root->createSceneManager(ST_GENERIC, "RenderSceneMgr");
        _sceneMgr->setAmbientLight(Ogre::ColourValue(0.7f, 0.7f, 0.7f));

        _sceneMgr->addRenderQueueListener(framework->_overlaySystem);

        /////////////////// Setup Ray queries (unused)
        _rsq = _sceneMgr->createRayQuery(Ray());
        _rsq->setQueryMask(OGRE_HEAD_MASK);

        ////////////////// Setup Camera
        _camera = _sceneMgr->createCamera("GameCamera");
        _camera->setPosition(Vector3(5, 60, 60));
        _camera->lookAt(Vector3(5, 20, 0));
        _camera->setNearClipDistance(5);

        Real vpWidth  = Real(framework->_viewport->getActualWidth());
        Real vpHeight = Real(framework->_viewport->getActualHeight());
        _camera->setAspectRatio(vpWidth / vpHeight);

        framework->_viewport->setCamera(_camera);
        _currentObject = 0;

        ////////////////// Setup GUI
        buildGUI();

        ////////////////// Setup Scene
        createScene();

        ////////////////// Create render textures
        // PixelFormat format = PF_A8B8G8R8;
        PixelFormat format = PF_FLOAT16_RGBA;
        float rtWidth = vpWidth;
        float rtHeight = vpHeight;
        if (rayPositions.create("rayPos", rtWidth, rtHeight, format, _camera, _sceneMgr)) {
                std::cout << "Error creating ray positions texture\n";
        }

        if (rayDirections.create("rayDir", rtWidth, rtHeight, format, _camera, _sceneMgr)) {
                std::cout << "Error creating ray directions texture\n";
        }

        rayPositions.setupThumbnail(0.74, 0.99, -0.74, -0.99);
        rayPositions.showThumbnail();

        rayDirections.setupThumbnail(0.45, 0.7, -0.74, -0.99);
        rayDirections.showThumbnail();

        ////////////////// Setup parameters for ray materials
        MaterialManager* matMgr = MaterialManager::getSingletonPtr();
        MaterialPtr rayDirMat = matMgr->getByName("BoundingCubesDirections");
        GpuProgramParametersSharedPtr fragParameters;
        fragParameters = 
                rayDirMat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();

        float rt_width_inv = 1.0 / rtWidth;
        float rt_height_inv = 1.0 / rtHeight;
        try {
                fragParameters->setNamedConstant("width_inv", rt_width_inv);
                fragParameters->setNamedConstant("height_inv", rt_height_inv);
        } 
        catch (Exception e) {}

        float width_inv = 1.0 / vpWidth;
        float height_inv = 1.0 / vpHeight;
        fragParameters = 
                breadMat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
        try {
                fragParameters->setNamedConstant("width_inv", width_inv);
                fragParameters->setNamedConstant("height_inv", height_inv);
        } 
        catch (Exception e) {}

        ////////////////// Setup shadow params
        _sceneMgr->setShadowFarDistance(100);
        _sceneMgr->setShadowTextureCount(2);
        _sceneMgr->setShadowTextureSelfShadow(true);
        _sceneMgr->setShadowCasterRenderBackFaces(false);
        _sceneMgr->setShadowTextureCasterMaterial("DepthShadowmap/Caster/Bread");
        _sceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
        _sceneMgr->setShadowTextureConfig( 0, 2048, 2048, PF_FLOAT32_R );

        tableEntity->getSubEntity(0)->getMaterial()->setReceiveShadows(true);
        tableEntity->getSubEntity(0)->setMaterialName("DepthShadowmap/Receiver/Float",
                                                      "General");

        breadEntity->getSubEntity(0)->getMaterial()->setReceiveShadows(true);
        breadEntity->setCastShadows(true);
        
}
开发者ID:rbaravalle,项目名称:breaddemo,代码行数:96,代码来源:RenderState.cpp

示例10: sscanf

void WFLoader::parseMaterialFile( const char *line )
{
    /* Variables
     */
    char                tempStr[20] = "\0";
    MaterialManager     *matMngrPtr = NULL;
    MaterialData        matData;
    float               r, g, b;

    /* Code
     */
    matMngrPtr = MaterialManager::getInstance();

    if( strlen( line ) > 0 )
    {
        if( line[ 0 ] == 'n' )
        {
            sscanf( line, "%s", tempStr );
            /* Material name */
            if( strcmp( tempStr, "newmtl" ) == 0 )
            {
                sscanf( line, "%*s %s", m_CurrentMatName );
                matMngrPtr->addMaterial( m_CurrentMatName, matData );
            }
        }
        else if( line[ 0 ] == 'N' )
        {
            switch( line[ 1 ] )
            {
            case 's':
                /* Specular exponent ( shininess ) */
                sscanf( line, "%*s %f", &r );
                /* Even though Color4f is used, only the value of r gets
                   saved into the Material values */
                matMngrPtr->setValue( m_CurrentMatName,
                                      MaterialManager::MAT_SHININESS,
                                      Color4f( r, 0.0, 0.0, 1.0 ) );
                break;
            }
        }
        /* Reflectivity information */
        else if( line[ 0 ] == 'K' )
        {

            switch( line[ 1 ] ) //if( line[ 1 ] == 'a' )
            {
            case 'a':
                /* Ambient */
                sscanf( line, "%*s %f %f %f", &r, &g, &b );
                matMngrPtr->setValue( m_CurrentMatName,
                                      MaterialManager::MAT_AMBIENT,
                                      Color4f( r, g, b, 1.0 ) );
                break;
            case 'd':
                /* Diffuse */
                sscanf( line, "%*s %f %f %f", &r, &g, &b );
                matMngrPtr->setValue( m_CurrentMatName,
                                      MaterialManager::MAT_DIFFUSE,
                                      Color4f( r, g, b, 1.0 ) );
                break;
            case 's':
                /* Specular */
                sscanf( line, "%*s %f %f %f", &r, &g, &b );
                matMngrPtr->setValue( m_CurrentMatName,
                                      MaterialManager::MAT_SPECULAR,
                                      Color4f( r, g, b, 1.0 ) );
                break;
            }
        }
    }
}
开发者ID:kilppari,项目名称:turtleRenderer,代码行数:71,代码来源:wf_loader.cpp

示例11: loadTexture

void UIRect::loadTexture(String fileName) {
	MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();
	texture = materialManager->createTextureFromFile(fileName, materialManager->clampDefault, false);
}
开发者ID:0x81c,项目名称:Polycode,代码行数:4,代码来源:PolyUIElement.cpp

示例12: main

int main(int argc, char** argv ){
    
  if( argc != 8 ) {
    std::cout << " usage: print_materials compact.xml x0 y0 z0 x1 y1 z1 " << std::endl 
              << "        -> prints the materials on a straight line between the two given points ( unit is cm) "  
              << std::endl ;
    exit(1) ;
  }
  
  std::string inFile =  argv[1] ;

  std::stringstream sstr ;
  sstr << argv[2] << " " << argv[3] << " " << argv[4] << " " << argv[5] << " " << argv[6] << " " << argv[7] ;

  double x0,y0,z0,x1,y1,z1 ;
  sstr >> x0 ;
  sstr >> y0 ;
  sstr >> z0 ;
  sstr >> x1 ;
  sstr >> y1 ;
  sstr >> z1 ;

  LCDD& lcdd = LCDD::getInstance();

  lcdd.fromCompact( inFile );

  Vector3D p0( x0, y0, z0 ) ;
  Vector3D p1( x1, y1, z1 ) ;

  MaterialManager matMgr ;

  const MaterialVec& materials = matMgr.materialsBetween( p0 , p1  ) ;
	
  std::cout  << std::endl  << " #######  materials between the two  points : " << p0 << "*cm  and " << p1 << "*cm :  "  << std::endl ;

  double sum_x0 = 0 ;
  double sum_lambda = 0 ;
  double path_length = 0 ;
  for( unsigned i=0,n=materials.size();i<n;++i){

    Material mat =  materials[i].first  ;
    double length = materials[i].second  ;

    double nx0 = length / mat.radLength()  ;
    sum_x0 += nx0 ;

    double nLambda = length / mat.intLength()  ;
    sum_lambda += nLambda ;

    path_length += length ;

    std::cout <<  "      " << mat << " thickness: " <<  length << " path_length:" << path_length  << " integrated_X0: " <<  sum_x0 << " integrated_lambda: " <<  sum_lambda << std::endl ;
  }

  std::cout << "############################################################################### "  << std::endl  << std::endl  ;
	

  const MaterialData& avMat = matMgr.createAveragedMaterial( materials ) ;

  std::cout << "     averaged Material : " << " Z: " << avMat.Z() << " A: " << avMat.A() << " densitiy: " << avMat.density()
            << " radiationLength: " <<  avMat.radiationLength() 
            << " interactionLength: " << avMat.interactionLength()  << std::endl << std::endl  ;
  

  std::cout << "     Total length : "  << path_length / dd4hep::mm << " mm "  << std::endl  ;

  std::cout << "     Integrated radiation lengths : "     << path_length / avMat.radiationLength()  << " X0 " << std::endl  ;

  std::cout << "     Integrated interaction lengths : "  << path_length / avMat.interactionLength() << " lambda "   << std::endl  ;

  std::cout << "############################################################################### "  << std::endl  << std::endl  ;


  return 0;
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:75,代码来源:print_materials.cpp

示例13: getCvarAddress_S

bool ObjModel::loadMTLFile(const char* fileName)	{
	cout << "Loading material file: " << fileName << endl;

	FILE* fp;
	string* modelPath = getCvarAddress_S("r_modelPath");

	string canonicalPath = *modelPath + "obj/" + fileName;

	cout << "From file path: " << canonicalPath << endl;

	if( !(fp=fopen(canonicalPath.c_str(), "r")) )	{
		error = "OBJ Materials file not found";
		Con_print("Obj: File not found - %s", canonicalPath.c_str());
		return false;
	}

	MaterialManager* tm = getMaterialManager();

	material_t* mat;

	while( !feof(fp) )	{
		char in[MAX_OBJ_LINE_LEN];
		fgets(in, MAX_OBJ_LINE_LEN, fp);
		char incpy[MAX_OBJ_LINE_LEN];
#ifdef OBJMATDEBUG
		cout << "MAT Line: " << in << endl;
#endif
		strcpy(incpy, in);

		// if its a comment or whitespace skip it
		if( in[0] == '#' || in[0] == ' ' || in[0] == '\n' ||
				in[0] == '\r'  || in[0] == '\t')
			continue;
		else	{	// otherwise we need to process some data
			char* token = strtok(in, WHITESPACE);

			if( token == NULL )
				break;

			if( !strcmp(token, "newmtl") )	{
				material_t* newmat = new material_t;
				initializeMaterial(newmat);

				token = strtok(NULL, WHITESPACE);
				if( !tm->hasMaterial(token) )	{
					tm->addMaterial(token, newmat);
					mat = newmat;
#ifdef OBJMATDEBUG
					cout << "New material created: " << token << endl;
#endif
				}
				else	{
#ifdef OBJMATDEBUG
					cout << "MTL Error: Material redefinition: " << token << endl;
#endif
				}
			}
			else if( !strcmp(token, "Ns") )	{
				sscanf(incpy, "Ns %f", &mat->Ns);
			}
			else if( !strcmp(token, "Ka") )	{
				sscanf(incpy, "Ka %f %f %f", &mat->Ka[0], &mat->Ka[1], &mat->Ka[2]);
			}
			else if( !strcmp(token, "Kd") )	{
				sscanf(incpy, "Kd %f %f %f", &mat->Kd[0], &mat->Kd[1], &mat->Kd[2]);
			}
			else if( !strcmp(token, "Ks") )	{
				sscanf(incpy, "Ks %f %f %f", &mat->Ks[0], &mat->Ks[1],& mat->Ks[2]);
			}
			else if( !strcmp(token, "Ni") )	{
				sscanf(incpy, "Ni %f", &mat->Ni);
			}
			else if( !strcmp(token, "d") )	{
				sscanf(incpy, "d %f", &mat->d);
			}
			else if( !strcmp(token, "illum") )	{
				sscanf(incpy, "illum %d", &mat->illum);
			}
			else if( !strcmp(token, "map_Kd") )	{
				token = strtok(NULL, WHITESPACE);
				strcpy(mat->map_Kd, token);
#ifdef OBJMATDEBUG
				cout << "Loading texture: " << mat->map_Kd << endl;
#endif
				getMaterialManager()->loadBitmap(mat->map_Kd);
			}
		}
	}

	fclose(fp);

	return true;
}
开发者ID:nonsensicalthinking,项目名称:rendar,代码行数:93,代码来源:WavefrontObj.cpp

示例14: loadTextureFromImage

void SceneMesh::loadTextureFromImage(Image *image) {
	MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();
	texture = materialManager->createTextureFromImage(image, materialManager->clampDefault, materialManager->mipmapsDefault);	
}
开发者ID:Mr-Nil,项目名称:Polycode,代码行数:4,代码来源:PolySceneMesh.cpp

示例15: switch

	void GodRaysManager::_createMaterials(const HydraxComponent& HC)
	{
		Ogre::String VertexProgramData, FragmentProgramData;
		Ogre::GpuProgramParametersSharedPtr VP_Parameters, FP_Parameters;
		Ogre::String EntryPoints[2]     = {"main_vp", "main_fp"};
		Ogre::String GpuProgramsData[2]; Ogre::String GpuProgramNames[2];
		MaterialManager *mMaterialManager = mHydrax->getMaterialManager();

		int NumberOfDepthChannels = 0;
		Ogre::String GB[2] = {"0, 1, 0", "0, 0, 1"};

		if (_isComponent(HC, HYDRAX_COMPONENT_CAUSTICS))
		{
		    NumberOfDepthChannels++;
		}

		// God Rays material

		VertexProgramData = "";
		FragmentProgramData = "";

		// Vertex program

		switch (mHydrax->getShaderMode())
		{
		    case MaterialManager::SM_HLSL: case MaterialManager::SM_CG:
			{
				VertexProgramData +=
					Ogre::String(
					"void main_vp(\n") +
					    // IN
						"float4 iPosition      : POSITION,\n" +
						// OUT
						"out float4 oPosition  : POSITION,\n";
				if (mObjectsIntersections)
				{
					VertexProgramData += Ogre::String(
						"out float3 oPosition_ : TEXCOORD0,\n") +
						"out float4 oProjUV    : TEXCOORD1,\n" +
						// UNIFORM
						"uniform float4x4 uWorld,\n" +
						"uniform float4x4 uTexViewProj,\n";
				}
				    VertexProgramData += Ogre::String(
						"uniform float4x4 uWorldViewProj)\n") +
					"{\n" +
					    "oPosition   = mul(uWorldViewProj, iPosition);\n";
			   if (mObjectsIntersections)
			   {
				   VertexProgramData += Ogre::String(
						"float4 wPos = mul(uWorld, iPosition);\n")+
						"oPosition_  = wPos.xyz;\n"+
						"oProjUV     = mul(uTexViewProj, wPos);\n";
			   }
			       VertexProgramData +=
					"}\n";
			}
			break;

			case MaterialManager::SM_GLSL:
			{}
			break;
		}

		// Fragment program

		switch (mHydrax->getShaderMode())
		{
		    case MaterialManager::SM_HLSL: case MaterialManager::SM_CG:
			{
				if (mObjectsIntersections)
				FragmentProgramData +=
					Ogre::String(
				    "void main_fp(\n") +
						// IN
						"float3 iPosition     : TEXCOORD0,\n" +
	                    "float4 iProjUV       : TEXCOORD1,\n" +
					    // OUT
						"out float4 oColor    : COLOR,\n" +
						// UNIFORM
						"uniform float3    uLightPosition,\n"+
	                    "uniform float     uLightFarClipDistance,\n" +
	                    "uniform sampler2D uDepthMap : register(s0))\n" +
					"{\n" +
					    "iProjUV = iProjUV / iProjUV.w;\n"+
						"float Depth  = tex2D(uDepthMap,  iProjUV.xy).r;\n"+
						"if (Depth < saturate( length(iPosition-uLightPosition) / uLightFarClipDistance ))\n"+
						"{\n"+
						    "oColor = float4(0,0,0,1);\n"+
						"}\n"+
						"else\n"+
						"{\n"+
							"oColor = float4(float3(" + GB[NumberOfDepthChannels] + ") * 0.1, 1);\n"+
						"}\n"+
					"}\n";
				else
				FragmentProgramData +=
					Ogre::String(
				    "void main_fp(\n") +
					    // OUT
//.........这里部分代码省略.........
开发者ID:LucRyan,项目名称:Assignment4-Final,代码行数:101,代码来源:GodRaysManager.cpp


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