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


C++ TextureChunkPtr::setEnvMode方法代码示例

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


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

示例1: finish

void VRMLAppearanceBinder::finish(VRMLToOSGAction *)
{
    ChunkMaterialPtr pChunkMat = 
        ChunkMaterialPtr::dcast(_pFieldContainer);

    TextureChunkPtr pTexChunk = 
        TextureChunkPtr::dcast(pChunkMat->find(TextureChunk::getClassType()));
    
    MaterialChunkPtr pMatChunk = 
        MaterialChunkPtr::dcast(
            pChunkMat->find(MaterialChunk::getClassType()));
    
    if(pTexChunk != NullFC)
    {    
        beginEditCP(pTexChunk, TextureChunk::EnvModeFieldMask);
        {
            if(pMatChunk == NullFC)
            {
                pTexChunk->setEnvMode(GL_REPLACE);
            }
            else
            {
                pTexChunk->setEnvMode(GL_MODULATE);
            }
        }
        endEditCP  (pTexChunk, TextureChunk::EnvModeFieldMask);
    }
    
    if(pChunkMat != NullFC && (pChunkMat->isTransparent() == true || 
                               _has_alpha))
    {
        BlendChunkPtr pBlendChunk = OSG::BlendChunk::create();

        beginEditCP(pBlendChunk, BlendChunk::SrcFactorFieldMask | 
                                 BlendChunk::DestFactorFieldMask);
        {
            pBlendChunk->setSrcFactor (GL_SRC_ALPHA);
            pBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
        }
        endEditCP  (pBlendChunk, BlendChunk::SrcFactorFieldMask | 
                                 BlendChunk::DestFactorFieldMask);

        beginEditCP(pChunkMat, ChunkMaterial::ChunksFieldMask);
        {
            pChunkMat->addChunk(pBlendChunk);
        }
        endEditCP  (pChunkMat, ChunkMaterial::ChunksFieldMask);
    }
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:49,代码来源:OSGVRMLAppearance.cpp

示例2: convertMaterials

void CharacterModel::convertMaterials(std::string configfile)
{
    getMaterials().clear();
    UInt32 mcnt = 0;
    PathHandler ph;
    
    ph.setBaseFile(configfile.c_str());
       
    for(int mid = 0; mid < _coreModel->getCoreMaterialCount(); mid++)
    {
        CalCoreMaterial *coremat = _coreModel->getCoreMaterial(mid);
        SimpleMaterialPtr mat = SimpleMaterial::create();

        beginEditCP(mat);

        CalCoreMaterial::Color &calamb = coremat->getAmbientColor();
        CalCoreMaterial::Color &caldif = coremat->getDiffuseColor();
        CalCoreMaterial::Color &calspec = coremat->getSpecularColor();

        mat->setAmbient(Color3f(calamb.red / 255.0f, calamb.green / 255.0f, calamb.blue / 255.0f));
        mat->setDiffuse(Color3f(caldif.red / 255.0f, caldif.green / 255.0f, caldif.blue / 255.0f));
        mat->setSpecular(Color3f(calspec.red / 255.0f, calspec.green / 255.0f, calspec.blue / 255.0f));
        
        mat->setShininess(coremat->getShininess() * 100.f);
        mat->setLit(true);
        mat->setColorMaterial(GL_NONE);
        
        for(int mapId = 0; mapId < coremat->getMapCount(); mapId++)
        {
            std::string file = coremat->getMapFilename(mapId);
            std::string pfile = ph.findFile(file.c_str());
            SINFO << "Loading texture '" << pfile << "'..." << endLog;

            ImagePtr img = Image::create();
            
             if(!img->read(pfile.c_str()))
            {
                SWARNING << "CharacterModel::convertMaterials: error "
                         << "loading image " << file << endLog;
            }
            else
            {
                // amz with my test scene paladin.cfg all textures were
                // upside down so I disabled the vertical flipping perhaps
                // they fixed the bug in Cal3D?
#if 0
                beginEditCP(img);
                {
                // For some reason Cal3D expects textures upside down ???
                UInt32 bpl = img->getBpp() * img->getWidth();
                UChar8 *t = img->getData(), 
                       *b = t + (img->getHeight() - 1) * bpl,
                        dum;

                for(UInt32 y = img->getHeight() / 2; y > 0; --y)
                {
                    for(UInt32 x = bpl; x > 0; --x, ++t, ++b)
                    {
                        dum = *t;
                        *t = *b;
                        *b = dum;
                    }
                    b -= bpl * 2;
                }
                }
                endEditCP(img);
#endif
                
                TextureChunkPtr tex = TextureChunk::create();
                
                beginEditCP(tex);
                tex->setImage(img);
                tex->setEnvMode(GL_MODULATE);
                endEditCP(tex);
                
                mat->addChunk(tex);
            }
        }
            
        endEditCP(mat);
        
        coremat->setUserData((Cal::UserData)mcnt);
        getMaterials().push_back(mat);
        mcnt ++;
    }    
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:86,代码来源:OSGCharacterModel.cpp

示例3: CreateMaterial


//.........这里部分代码省略.........
		ambientColor[1] << " " << ambientColor[2] << std::endl;
		std::cout << "      specular " << specular << " * " << specularColor[0] << " " <<
		specularColor[1] << " " << specularColor[2] << std::endl;
	}

	PolygonChunkPtr polygonChunk = PolygonChunk::create();
	beginEditCP(polygonChunk);
	{
		if (representation == VTK_SURFACE)
		{
			polygonChunk->setFrontMode(GL_FILL);
			polygonChunk->setBackMode(GL_FILL);
		}
		else if (representation == VTK_WIREFRAME)
		{
			polygonChunk->setFrontMode(GL_LINE);
			polygonChunk->setBackMode(GL_LINE);
		}
		else
		{
			polygonChunk->setFrontMode(GL_POINT);
			polygonChunk->setBackMode(GL_POINT);
		}
	} endEditCP(polygonChunk);

	MaterialChunkPtr osgMaterialChunk = MaterialChunk::create();
	beginEditCP(osgMaterialChunk);
	{
		osgMaterialChunk->setDiffuse(Color4f(diffuseColor[0] * diffuse, diffuseColor[1] *
		                                     diffuse, diffuseColor[2] * diffuse, opacity));
		osgMaterialChunk->setSpecular(Color4f(specularColor[0] * specular,
		                                      specularColor[1] * specular,
		                                      specularColor[2] * specular, 1.0));
		osgMaterialChunk->setAmbient(Color4f(ambientColor[0] * ambient, ambientColor[1] *
		                                     ambient, ambientColor[2] * ambient, opacity));
		osgMaterialChunk->setShininess(specularPower);

		//if(opacity < 1.0)
		//{
		// osgMaterialChunk->setColorMaterial(GL_AMBIENT); // HACK: Opacity does not work with GL_AMBIENT_AND_DIFFUSE
		//osgMaterialChunk->setTransparency(1.0f - opacity);
		//}
		//else
		osgMaterialChunk->setColorMaterial(GL_AMBIENT_AND_DIFFUSE);

		// On objects consisting only of points or lines, dont lit
		if(!lit)
			osgMaterialChunk->setLit(false);
	} endEditCP(osgMaterialChunk);

	ChunkMaterialPtr osgChunkMaterial = ChunkMaterial::create();
	beginEditCP(osgChunkMaterial);
	{
		osgChunkMaterial->addChunk(osgMaterialChunk);
		osgChunkMaterial->addChunk(TwoSidedLightingChunk::create());
		osgChunkMaterial->addChunk(polygonChunk);

		if(pointSize > 1.0f)
		{
			PointChunkPtr pointChunk = PointChunk::create();
			pointChunk->setSize(pointSize);
			osgChunkMaterial->addChunk(pointChunk);
		}

		if(lineWidth > 1.0f)
		{
			LineChunkPtr lineChunk = LineChunk::create();
			lineChunk->setWidth(lineWidth);
			osgChunkMaterial->addChunk(lineChunk);
		}

		// TEXTURE
		if (hasTexCoords)
		{
			vtkTexture* vtkTexture = _actor->GetTexture();
			if (vtkTexture)
			{
				TextureChunkPtr osgTextureChunk = NullFC;
				osgTextureChunk = CreateTexture(vtkTexture);

				if(osgTextureChunk != NullFC)
				{
					if (_verbose)
						std::cout << "    Add TextureChunk" << std::endl;
					osgChunkMaterial->addChunk(osgTextureChunk);
				}

				// Per default EnvMode is set to GL_REPLACE which does not lit the surface
				beginEditCP(osgTextureChunk);
				osgTextureChunk->setEnvMode(GL_MODULATE);
				endEditCP(osgTextureChunk);
			}
		}
	} endEditCP(osgChunkMaterial);

	if (_verbose)
		std::cout << "End CreateMaterial()" << std::endl;

	return osgChunkMaterial;
}
开发者ID:JobstM,项目名称:ogs,代码行数:101,代码来源:vtkOsgConverter.cpp

示例4: updateScene

void updateScene()
{
    statfg->editCollector().getElem(majorAlignDesc)->set(alignmentToString(layoutParam.majorAlignment));
    statfg->editCollector().getElem(minorAlignDesc)->set(alignmentToString(layoutParam.minorAlignment));
    statfg->editCollector().getElem(dirDesc)->set(layoutParam.horizontal ? "Horizontal" : "Vertical");
    statfg->editCollector().getElem(horiDirDesc)->set(layoutParam.leftToRight ? "Left to right" : "Right to left");
    statfg->editCollector().getElem(vertDirDesc)->set(layoutParam.topToBottom ? "Top to bottom" : "Bottom to top");

    if(face == NULL)
        return;

    // Put it all together into a Geometry NodeCore.
    TextLayoutResult layoutResult;
    Real32 scale = 2.f;
    face->layout(lines, layoutParam, layoutResult);
#if 0
    GeometryPtr geo = Geometry::create();
    face->fillGeo(geo, layoutResult, scale);
    NodePtr textNode = Node::create();
    beginEditCP(textNode, Node::CoreFieldMask);
    {
        textNode->setCore(geo);
    }
    endEditCP(textNode, Node::CoreFieldMask);
#else
    NodePtr textNode = face->makeNode(layoutResult, scale);
    GeometryPtr geo = GeometryPtr::dcast(textNode->getCore());
#endif
    NodePtr transNodePtr = Node::create();
    TransformPtr transPtr = Transform::create();
    Matrix transMatrix;
    transMatrix.setTranslate(0.f, 0.f, -0.03f);
    beginEditCP(transPtr);
    {
        transPtr->setMatrix(transMatrix);
    }
    endEditCP(transPtr);
    beginEditCP(transNodePtr, Node::CoreFieldMask | Node::ChildrenFieldMask);
    {
        transNodePtr->setCore(transPtr);
        transNodePtr->addChild(textNode);
    }
    endEditCP(transNodePtr, Node::CoreFieldMask | Node::ChildrenFieldMask);

    ImagePtr imagePtr = face->getTexture();
    TextureChunkPtr texChunk = TextureChunk::create();
    beginEditCP(texChunk);
    {
        texChunk->setImage(imagePtr);
        texChunk->setWrapS(GL_CLAMP);
        texChunk->setWrapT(GL_CLAMP);
        texChunk->setMagFilter(GL_NEAREST);
        texChunk->setMinFilter(GL_NEAREST);
        texChunk->setEnvMode(GL_MODULATE);
    }
    endEditCP(texChunk);

    MaterialChunkPtr matChunk = MaterialChunk::create();
    beginEditCP(matChunk);
    {
        matChunk->setAmbient(Color4f(1.f, 1.f, 1.f, 1.f));
        matChunk->setDiffuse(Color4f(1.f, 1.f, 1.f, 1.f));
        matChunk->setEmission(Color4f(0.f, 0.f, 0.f, 1.f));
        matChunk->setSpecular(Color4f(0.f, 0.f, 0.f, 1.f));
        matChunk->setShininess(0);
    }
    endEditCP(matChunk);

    BlendChunkPtr blendChunk = BlendChunk::create();
    beginEditCP(blendChunk);
    {
        blendChunk->setSrcFactor(GL_SRC_ALPHA);
        blendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
    }
    endEditCP(blendChunk);

    ChunkMaterialPtr m = ChunkMaterial::create();
    beginEditCP(m);
    {
        m->addChunk(texChunk);
        m->addChunk(matChunk);
        m->addChunk(blendChunk);
    }
    endEditCP(m);

    beginEditCP(geo, Geometry::MaterialFieldMask);
    {
        geo->setMaterial(m);
    }
    endEditCP(geo, Geometry::MaterialFieldMask);

    beginEditCP(scene, Node::ChildrenFieldMask);
    {
        scene->editMFChildren()->clear();
        scene->addChild(createCoordinateCross());
        scene->addChild(createMetrics(face, scale, layoutParam, layoutResult));
        scene->addChild(transNodePtr);
    }
    endEditCP(scene, Node::ChildrenFieldMask);

//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testTextTXFGeo.cpp

示例5: main

int main(int argc, char **argv)
{
    osgInit(argc,argv);

    // GLUT init
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    
    int id=glutCreateWindow("OpenSG");
    
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    GLUTWindowPtr gwin=GLUTWindow::create();
    gwin->setId(id);
    gwin->init();

    // create the scene
//    NodePtr scene = makeTorus(.5, 2, 16, 16);
    NodePtr scene = makeBox(1,1,1, 1,1,1);

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (scene);
    
    // Create the textured material
    UChar8 imgdata[] =
      {  255,0,0,128,  0,255,0,128,  0,0,255,255,  255,255,255,255 };
   
    ImagePtr img = Image::create();
    beginEditCP(img);
    if(argc > 1)
        img->read(argv[1]);
    else
        img->set( Image::OSG_RGBA_PF, 2, 2, 1, 1, 1, 0, imgdata );
    endEditCP(img);
    addRefCP(img);
   
    SimpleTexturedMaterialPtr mat = SimpleTexturedMaterial::create();
    beginEditCP(mat);
    mat->setLit(false);
    mat->setDiffuse(Color3f(0,1,0));
    mat->setImage(img);
    mat->setMinFilter(GL_NEAREST);
    mat->setMagFilter(GL_NEAREST);
    mat->setEnvMode(GL_REPLACE);
    endEditCP(mat);
    
    // Add the polygon foregrounds
    
    Pnt2f pos[][4] = { 
        { Vec2f(.4,.4), Vec2f(.6,.4), Vec2f(.6,.6), Vec2f(.4,.6) },
        { Vec2f(0,0), Vec2f(1,0), Vec2f(1,.1), Vec2f(0,.1) },
        { Vec2f(1,-100), Vec2f(-2,-100), Vec2f(-2,-2), Vec2f(1,-2) },
        { Vec2f(-1000,-1000), Vec2f(0,0), Vec2f(0,0), Vec2f(0,0) }
    };
    bool normx[] = { true, true, false };
    bool normy[] = { true, true, false };
    
    for(UInt16 ind = 0; pos[ind][0][0] != -1000; ++ind)
    {   
        PolygonForegroundPtr pg = PolygonForeground::create();

        beginEditCP(pg);
        pg->setMaterial(mat);
        pg->editMFTexCoords()->push_back(Vec3f( 0.,0.,0.));
        pg->editMFPositions()->push_back(pos[ind][0]);
        pg->editMFTexCoords()->push_back(Vec3f( 1.,0.,0.));
        pg->editMFPositions()->push_back(pos[ind][1]);
        pg->editMFTexCoords()->push_back(Vec3f( 1.,1.,0.));
        pg->editMFPositions()->push_back(pos[ind][2]);
        pg->editMFTexCoords()->push_back(Vec3f( 0.,1.,0.));
        pg->editMFPositions()->push_back(pos[ind][3]);
 
        pg->setNormalizedX(normx[ind]);
        pg->setNormalizedY(normy[ind]);
        endEditCP(pg);

        // take the viewport
        ViewportPtr vp = gwin->getPort(0);

        beginEditCP(vp);
        vp->editMFForegrounds()->push_back(pg);    
        endEditCP  (vp);
    }
     
    // Create the edgeblend foreground
    const int blendpixel = 50;
    
    UChar8 ebimgdata[] =
      {  0,0,0,0,  0,0,0,255 };
   
    ImagePtr ebimg = Image::create();
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testPolygonForeground.cpp

示例6: createSceneFBO


//.........这里部分代码省略.........
    // Make Torus Node (creates Torus in background of scene)
    NodePtr TorusGeometryNode = makeTorus(.5, 2, 24, 48);

    beginEditCP(TorusGeometryNode->getCore());
        GeometryPtr::dcast(TorusGeometryNode->getCore())->setMaterial(TheMaterial);
    endEditCP(TorusGeometryNode->getCore());
    calcVertexNormals(GeometryPtr::dcast(TorusGeometryNode->getCore()));
    calcVertexTangents(GeometryPtr::dcast(TorusGeometryNode->getCore()),0,Geometry::TexCoords7FieldId, Geometry::TexCoords6FieldId);

    RootTransformCore = Transform::create();

    NodePtr TorusTransformNode = Node::create();
    beginEditCP(TorusTransformNode, Node::CoreFieldMask);
        TorusTransformNode->setCore(RootTransformCore);
        TorusTransformNode->addChild(TorusGeometryNode);
    endEditCP(TorusTransformNode, Node::CoreFieldMask);

    //Create Light Beacon
    Matrix LightMat;
    LightMat.setTranslate(0.0f,10.0f,1.0f);
    TransformPtr LightBeconCore = Transform::create();
    beginEditCP(LightBeconCore, Transform::MatrixFieldMask);
        LightBeconCore->setMatrix(LightMat);
    endEditCP(LightBeconCore, Transform::MatrixFieldMask);

    NodePtr LightBeconNode = Node::create();
    beginEditCP(LightBeconNode, Node::CoreFieldMask);
        LightBeconNode->setCore(LightBeconCore);
    endEditCP(LightBeconNode, Node::CoreFieldMask);

    //Create Light
    TheLight = PointLight::create();
    beginEditCP(TheLight);
        TheLight->setBeacon(LightBeconNode);
    endEditCP(TheLight);

    NodePtr LightNode = Node::create();
    beginEditCP(LightNode, Node::CoreFieldMask);
        LightNode->setCore(TheLight);
        LightNode->addChild(TorusTransformNode);
    endEditCP(LightNode, Node::CoreFieldMask);


    //Create Root

    NodePtr TheRoot = Node::create();
    beginEditCP(TheRoot);
        TheRoot->setCore(Group::create());
        TheRoot->addChild(CameraBeconNode);
        TheRoot->addChild(LightNode);
        TheRoot->addChild(LightBeconNode);
    endEditCP(TheRoot);

    //Create Background
    SolidBackgroundPtr TheBackground = SolidBackground::create();
    TheBackground->setColor(Color3f(1.0,0.0,0.0));

    //DepthClearBackgroundPtr TheBackground = DepthClearBackground::create();

    //Create the Image
    ImagePtr TheColorImage = Image::create();
    TheColorImage->set(Image::OSG_RGB_PF,2,2,1,1,1,0.0f,0,Image::OSG_FLOAT16_IMAGEDATA);

    //Create the texture
    TextureChunkPtr TheColorTextureChunk = TextureChunk::create();
    beginEditCP(TheColorTextureChunk);
        TheColorTextureChunk->setImage(TheColorImage);

        TheColorTextureChunk->setMinFilter(GL_NEAREST);
        TheColorTextureChunk->setMagFilter(GL_NEAREST);

        TheColorTextureChunk->setWrapS(GL_CLAMP_TO_EDGE);
        TheColorTextureChunk->setWrapR(GL_CLAMP_TO_EDGE);

        TheColorTextureChunk->setScale(false);
        TheColorTextureChunk->setNPOTMatrixScale(true);
        
        TheColorTextureChunk->setEnvMode(GL_REPLACE);
        TheColorTextureChunk->setInternalFormat(GL_RGB16F);

    endEditCP(TheColorTextureChunk);


    //Create FBO
    FBOViewportPtr TheFBO = FBOViewport::create();
    beginEditCP(TheFBO);
        TheFBO->setBackground(TheBackground);
        TheFBO->setRoot(TheRoot);
        TheFBO->setCamera(TheCamera);

        TheFBO->setEnabled(true);
        TheFBO->getTextures().push_back(TheColorTextureChunk);

        TheFBO->setStorageWidth(TheColorTextureChunk->getImage()->getWidth());
        TheFBO->setStorageHeight(TheColorTextureChunk->getImage()->getHeight());
        
        TheFBO->setSize(0,0,TheColorTextureChunk->getImage()->getWidth()-1, TheColorTextureChunk->getImage()->getHeight()-1);
    endEditCP(TheFBO);
    return TheFBO;
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:101,代码来源:04HDRFilter.cpp

示例7: main


//.........这里部分代码省略.........
    mchunk1 = MaterialChunk::create();
    mchunk1->setDiffuse( Color4f( 1,0,0,0 ) );
    mchunk1->setAmbient( Color4f( 1,0,0,0 ) );
    mchunk1->setShininess( 20 );

    mchunk2 = MaterialChunk::create();
    mchunk2->setDiffuse( Color4f( 0,1,0,0 ) );
    mchunk2->setAmbient( Color4f( 0,1,0,0 ) );
    mchunk2->setShininess( 50 );

    // Texture chunk

//  UChar8 imgdata[] =
//      {  255,0,0,0,  0,255,0,0,  0,0,255,255,  255,255,255,255 };
    UChar8 imgdata[] =
        {  255,0,0,  255,0,0,  255,0,255,
           255,0,0,  255,0,0,  255,0,255,
           255,255,0,  255,255,0,  255,255,255,
           255,255,0,  255,255,0,  255,255,255, };
//  UChar8 limgdata[] =
//      {  0, 128, 64, 255 };
    pImage->set( Image::OSG_RGB_PF, 2, 2, 1, 1, 1, 0, imgdata );

    if ( argc > 1 )
        pImage->read( argv[1] );

    xchunk1 = TextureChunk::create();
    beginEditCP(xchunk1);
    xchunk1->setImage( pImage );
    xchunk1->setMinFilter( GL_LINEAR );
    xchunk1->setMagFilter( GL_NEAREST );
    xchunk1->setWrapS( GL_REPEAT );
    xchunk1->setWrapT( GL_REPEAT );
    xchunk1->setEnvMode( GL_REPLACE );
    xchunk1->setScale( false );
    endEditCP(xchunk1);

    xchunk1->imageContentChanged();

    beginEditCP(xchunk1);
    xchunk1->setImage( pImage );
    xchunk1->setLodBias( 10 );
    endEditCP(xchunk1);

    UChar8 imgdata2[] =
    {  255,0,0,  0,255,0,  0,0,255,  255,255,255 };

    ImagePtr pImage2 = Image::create();
    pImage2->set(Image::OSG_RGB_PF, 2, 2, 1, 1, 1, 0, imgdata2);

    xchunk2 = TextureChunk::create();
    beginEditCP(xchunk2);
    xchunk2->setImage( pImage2 );
    xchunk2->setMinFilter( GL_LINEAR );
    xchunk2->setMagFilter( GL_NEAREST );
    xchunk2->setWrapS( GL_REPEAT );
    xchunk2->setWrapT( GL_REPEAT );
    xchunk2->setEnvMode( GL_MODULATE );
    xchunk2->setLodBias( 10 );
    endEditCP(xchunk2);
    
    // Cube Texture chunk
    
    UChar8 negz[] = {  255,0,0,  128,0,0,  64,0,0,   255,255,255 },
           posz[] = {  0,255,0,  0,128,0,  0,64,0,  255,255,255 },
           negy[] = {  0,0,255,  0,0,128,  0,0,64,  255,255,255 },
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:67,代码来源:testCubeTextureRender.cpp

示例8: traverseGState


//.........这里部分代码省略.........
                    intformat = tex->getFormat(PFTEX_INTERNAL_FORMAT);
                    
                    
                    ImagePtr img = Image::create();
                    beginEditCP(img);
                    
                    img->set(pf, w, h, d, 1, 1, 0, NULL, type, 1, sides);
                    
                    if(sides == 1)
                    {
                        memcpy(img->getData(), pdata, img->getSize());
                    }
                    else
                    {
                        FWARNING(("PerformerLoader::traverseGState: "
                                  "CubeTex not impl yet!\n"));
                    }
                    
                    endEditCP(img);
                    
                    texc->setImage(img);
                    
                    texc->setInternalFormat(intformat);
                    
                    texc->setWrapS(tex->getRepeat(PFTEX_WRAP_S));
                    texc->setWrapT(tex->getRepeat(PFTEX_WRAP_T));
                    texc->setWrapR(tex->getRepeat(PFTEX_WRAP_R));
 
                    static int ptexfilter[] = { PFTEX_POINT,
                                                PFTEX_LINEAR,
                                                PFTEX_BILINEAR,
                                                PFTEX_TRILINEAR,
                                                PFTEX_QUADLINEAR,
                                                PFTEX_MIPMAP_POINT,
                                                PFTEX_MIPMAP_LINEAR,
                                                PFTEX_MIPMAP_BILINEAR,
                                                PFTEX_MIPMAP_TRILINEAR,
                                                PFTEX_MIPMAP_QUADLINEAR,
                                                -1
                                              };
                    static int otexfilter[] = { GL_NEAREST,
                                                GL_LINEAR,
                                                GL_LINEAR,
                                                GL_LINEAR,
                                                GL_LINEAR,
                                                GL_NEAREST_MIPMAP_NEAREST,
                                                GL_NEAREST_MIPMAP_LINEAR,
                                                GL_LINEAR_MIPMAP_NEAREST,
                                                GL_LINEAR_MIPMAP_LINEAR,
                                                GL_LINEAR_MIPMAP_LINEAR
                                              };

                    int ptf = tex->getFilter(PFTEX_MINFILTER);
                    UInt32 otf = GL_NONE;
                    for (UInt16 i = 0; ptexfilter[i] != -1; ++i)
                        if(ptexfilter[i] == ptf)
                            otf = otexfilter[i];
                    texc->setMinFilter(otf);

                    ptf = tex->getFilter(PFTEX_MAGFILTER);
                    otf = GL_NONE;
                    for (UInt16 i = 0; ptexfilter[i] != -1; ++i)
                        if(ptexfilter[i] == ptf)
                            otf = otexfilter[i];
                    texc->setMagFilter(otf);
                }

	            if (!(inherit & PFSTATE_TEXENV))
	            {
                    pfTexEnv *te = 
                        (pfTexEnv*)gstate->getMultiAttr(PFSTATE_TEXENV, t);
	                
                    if(te != NULL)
                    {
                        texc->setEnvMode(te->getMode());

                        float r,g,b,a;
                        te->getBlendColor(&r,&g,&b,&a);

                        texc->setEnvColor(Color4f(r,g,b,a));
                    }
	            }

                endEditCP(texc);
            }

            mat->addChunk(texc);
        } // for t
    }
 
    /* Unhandled: lightmodel, lights, fog, texgen, texlod, vtxprog, fragprog,
                  gprogparms, colortable, highlight, lpointstate, shadprog
    */

    endEditCP(mat);
    
    _materials[gstate] = mat;
    
    return mat;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:OSGPerformerLoader.cpp

示例9: main

int main (int argc, char **argv)
{

    // GLUT init

    osgInit(argc, argv);
    osgLog().setLogLevel ( OSG::LOG_DEBUG );

    FieldContainerPtr pProto = Geometry::getClassType().getPrototype();

    GeometryPtr pGeoProto = GeometryPtr::dcast(pProto);

    if(pGeoProto != NullFC)
    {
        pGeoProto->setDlistCache(true);
    }

    glutInit(&argc, argv);
    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    UInt32 id = glutCreateWindow("OpenSG");
    glutKeyboardFunc(key);
    glutReshapeFunc(resize);
    glutDisplayFunc(display);       
    // glutMouseFunc(mouse);   
    // glutMotionFunc(motion); 
    
    glutIdleFunc(display);
    
    // create a material (need that to test textures)
    
    ChunkMaterialPtr mat;  

    beginEditCP(mat);
    
    mat = ChunkMaterial::create();
   
    MaterialChunkPtr mc = MaterialChunk::create();  
 
    beginEditCP(mc);
    mc->setDiffuse( Color4f( 1,.8,.8,1 ) );
    mc->setAmbient( Color4f( 0.1,0.1,0.1,1 ) );
    mc->setSpecular( Color4f( 1,1,1,1 ) );
    mc->setShininess( 20 );
 
    mc->setBackMaterial(true);
    mc->setBackColorMaterial(GL_DIFFUSE);
    mc->setBackDiffuse( Color4f( 1,0,0,1 ) );
    mc->setBackAmbient( Color4f( 0.1,0.1,0.1,1 ) );
    mc->setBackSpecular( Color4f( 0,1,0,1 ) );
    mc->setBackShininess( 10 );
    mc->setLit(true);
 
    endEditCP(mc);

    mat->addChunk(mc);

    // Texture chunk
    
    UChar8 imgdata[] = 
        {  255,0,0,128,  0,255,0,128,  0,0,255,255,  255,255,255,255 };
    ImagePtr pImage = Image::create();
    pImage->set( Image::OSG_RGBA_PF, 2, 2, 1, 1, 1, 0, imgdata );

    if ( argc > 1 )
        pImage->read( argv[1] );
    
    TextureChunkPtr xchunk;
    xchunk = TextureChunk::create();
    xchunk->setImage( pImage );
    xchunk->setMinFilter( GL_NEAREST );
    xchunk->setMagFilter( GL_NEAREST );
    xchunk->setWrapS( GL_REPEAT );
    xchunk->setWrapT( GL_REPEAT );
    xchunk->setEnvMode( GL_MODULATE );

    mat->addChunk( xchunk );

    endEditCP(mat);

    objects[0] = makePolygon(ccwSquare, 
                             sizeof(ccwSquare)/sizeof(double[3]));
    objects[1] = makePolygon(ccwSquare, 
                             sizeof(ccwSquare)/sizeof(double[3]));
    
    objects[2] = makePolygon(star,
                             sizeof(star)/sizeof(double[3]));
    objects[3] = makePolygon(star,
                             sizeof(star)/sizeof(double[3]));
    
    objects[4] = makePolygon(cwSquare, 
                             sizeof(cwSquare)/sizeof(double[3]));
    objects[5] = makePolygon(cwSquare, 
                             sizeof(cwSquare)/sizeof(double[3]));
    
    objects[6] = makePolygon(doubleEight, 
                             sizeof(doubleEight)/sizeof(double[3]));
    objects[7] = makePolygon(doubleEight, 
                             sizeof(doubleEight)/sizeof(double[3]));

    //tesselate every second object
//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testCreateConvexPrimitives.cpp

示例10: main

int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindowEventProducer = createDefaultWindowEventProducer();
    WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();

    TutorialWindowEventProducer->setDisplayCallback(display);
    TutorialWindowEventProducer->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindowEventProducer->addKeyListener(&TheKeyListener);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(MainWindow);
	
										
    // Make Torus Node (creates Torus in background of scene)
    NodePtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

    // Make Main Scene Node and add the Torus
    NodePtr scene = osg::Node::create();
    beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
        scene->setCore(osg::Group::create());
        scene->addChild(TorusGeometryNode);
    endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);

    //Create the Image
    Path ImagePath("./Data/TutorialImage.jpg");
    ImagePtr TheImage = ImageFileHandler::the().read(ImagePath.string().c_str());

    //Create the texture
    TextureChunkPtr TheTextureChunk = TextureChunk::create();
    beginEditCP(TheTextureChunk);
        TheTextureChunk->setImage(TheImage);

        TheTextureChunk->setMinFilter(GL_NEAREST);
        TheTextureChunk->setMagFilter(GL_NEAREST);

        TheTextureChunk->setWrapS(GL_CLAMP_TO_EDGE);
        TheTextureChunk->setWrapR(GL_CLAMP_TO_EDGE);

        TheTextureChunk->setScale(false);
        TheTextureChunk->setNPOTMatrixScale(true);
        
        TheTextureChunk->setEnvMode(GL_REPLACE); 
    endEditCP(TheTextureChunk);

    //Create a Texture Source
    TextureSourceTextureFilterPtr TutorialTextureSourceTextureFilter = TextureSourceTextureFilter::create();
    beginEditCP(TutorialTextureSourceTextureFilter, TextureSourceTextureFilter::TextureFieldMask);
        TutorialTextureSourceTextureFilter->setTexture(TheTextureChunk);
    endEditCP(TutorialTextureSourceTextureFilter, TextureSourceTextureFilter::TextureFieldMask);

    //Create a Grayscale filter
    std::string GrayScaleFragProg = "uniform sampler2D Slot0Texture; void main() { gl_FragColor = vec4(vec3( dot(vec3(0.3,0.59,0.11), texture2D(Slot0Texture,gl_TexCoord[0].st).rgb)), 1.0); }";

    //Create a shader Filter
    ShaderTextureFilterPtr GrayscaleTextureFilter = ShaderTextureFilter::create();
    GrayscaleTextureFilter->attachSource(TutorialTextureSourceTextureFilter, 0, 0);
    GrayscaleTextureFilter->setFragmentSource(GrayScaleFragProg);

    //Create a Color Mult filter
    std::string ColorMultFragProg = "uniform sampler2D Slot0Texture; void main() { gl_FragColor = vec4(vec3(1.0,0.0,0.0) * texture2D(Slot0Texture,gl_TexCoord[0].st).rgb, 1.0); }";

    //Create a shader Filter
    ShaderTextureFilterPtr ColorMultTextureFilter = ShaderTextureFilter::create();
    ColorMultTextureFilter->attachSource(GrayscaleTextureFilter,0,0);
    ColorMultTextureFilter->setFragmentSource(ColorMultFragProg);

    
    ////Create a Blur filter
    //std::string BlurFragProg = "";
    //BlurFragProg += 
    //"uniform sampler2D Slot0Texture;"
    //"void main()"
    //"{"
    //"    vec2 offsets[9];"
    //"    offsets[0] = vec2(-0.000625,0.00111111111);"
    //"    offsets[1] = vec2(0.0,0.00111111111);"
    //"    offsets[2] = vec2(0.000625,0.00111111111);"
    //"    offsets[3] = vec2(-0.000625,0.0);"
    //"    offsets[4] = vec2(0.0,0.0);"
    //"    offsets[5] = vec2(0.0,0.0);"
    //"    offsets[6] = vec2(-0.000625,-0.00111111111);"
    //"    offsets[7] = vec2(0.0,-0.00111111111);"
    //"    offsets[8] = vec2(0.000625,-0.00111111111);"
    //"    vec4 kernel[9];"
    ////"    kernel[0] = vec4(0.0);"
    ////"    kernel[1] = vec4(0.0);"
    ////"    kernel[2] = vec4(0.0);"
    ////"    kernel[3] = vec4(0.0);"
    ////"    kernel[4] = vec4(1.0);"
    ////"    kernel[5] = vec4(0.0);"
    ////"    kernel[6] = vec4(0.0);"
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:101,代码来源:02SimpleImagePipeline.cpp

示例11: main


//.........这里部分代码省略.........
    mchunk1->setAmbient( Color4f( 1,0,0,0 ) );
    mchunk1->setShininess( 20 );

    mchunk2 = MaterialChunk::create();
    mchunk2->setDiffuse( Color4f( 0,1,0,0 ) );
    mchunk2->setAmbient( Color4f( 0,1,0,0 ) );
    mchunk2->setShininess( 50 );

    // Texture chunk

//  UChar8 imgdata[] =
//      {  255,0,0,0,  0,255,0,0,  0,0,255,255,  255,255,255,255 };
    UChar8 imgdata[] =
        {  255,0,0,  255,0,0,  255,0,255,
           255,0,0,  255,0,0,  255,0,255,
           255,255,0,  255,255,0,  255,255,255,
           255,255,0,  255,255,0,  255,255,255, };
//  UChar8 limgdata[] =
//      {  0, 128, 64, 255 };
    pImage->set( Image::OSG_RGB_PF, 2, 2, 1, 1, 1, 0, imgdata );

    if ( argc > 1 )
        pImage->read( argv[1] );

    xchunk1 = TextureChunk::create();
    beginEditCP(xchunk1);
    xchunk1->setImage( pImage ); // NOTE: the image is NOT copied, the variable
                                 // needs to be kept around as long as the 
                                 // texture is used
    xchunk1->setMinFilter( GL_LINEAR );
    xchunk1->setMagFilter( GL_NEAREST );
    xchunk1->setWrapS( GL_REPEAT );
    xchunk1->setWrapT( GL_REPEAT );
    xchunk1->setEnvMode( GL_REPLACE );
    xchunk1->setEnvColor( Color4f(.5,.5,.5,0) );
    xchunk1->setScale( false );
    
//    xchunk1->setShaderOperation(GL_PASS_THROUGH_NV);
    
    endEditCP(xchunk1);

    xchunk1->imageContentChanged();

    beginEditCP(xchunk1);
    xchunk1->setImage( pImage );
    endEditCP(xchunk1);

    // blend chunk

    blchunk = BlendChunk::create();
#ifdef GL_EXT_blend_color
    blchunk->setSrcFactor( GL_CONSTANT_ALPHA );
    blchunk->setDestFactor( GL_ONE_MINUS_CONSTANT_ALPHA );
#endif
    blchunk->setColor( Color4f( .5,.5,.5,0.1 ) );
    blchunk->setEquation(GL_FUNC_SUBTRACT);

    std::cout << "BlendChunk is trans:" << blchunk->isTransparent() << std::endl;
    
    // texture transform chunk

    txchunk = TextureTransformChunk::create();
    beginEditCP(txchunk);
    txchunk->setMatrix( Matrix(4,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1) );
    endEditCP(txchunk);
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:66,代码来源:testStateChunkRender.cpp


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