Hi List,
Thanks for all the support.Now I am able to build Osg with opengl ES 2.0
without Qt and can run the sample programs.
I am able to load the .3ds file but I am unable to render the correct material
on the screen.
Following is the source code I m using:
Code:
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/MatrixTransform>
#include <iostream>
#include <osg/ShapeDrawable>
#include <osg/Geode>
#include <osgDB/ReadFile>
#include<stdio.h>
//#include<osg/vec3>
#include<Uniform>
using namespace osg;
osg::Uniform* _ClrUniform;
static const char* vertSource = {
"// colors a fragment based on its position\n"
"uniform vec3 color; \n"
"varying mediump vec4 Finalcolor;\n"
"void main(void) {\n"
"Finalcolor = color;\n"
"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
"}\n"
};
static const char* fragSource = {
//SHADER_COMPAT
"varying mediump vec4 Finalcolor;\n"
"void main(void) {\n"
"gl_FragColor = Finalcolor;\n"
"}\n"
};
int main( int, char ** )
{
osgViewer::Viewer viewer;
osg::setNotifyLevel(osg::INFO);
ref_ptr<Group> m_root = new Group;
osg::Geode* geode = (osg::Geode* )osgDB::readNodeFile( "info_icon.3ds" );
osg::Program* program = new osg::Program;
program->setName("shader");
program->addShader(new osg::Shader(osg::Shader::VERTEX, vertSource));
program->addShader(new osg::Shader(osg::Shader::FRAGMENT, fragSource));
geode->getOrCreateStateSet()->setAttributeAndModes(program,
osg::StateAttribute::ON);
_ClrUniform = new osg::Uniform("color",osg::Vec3(1.0,0.0,0.0));//Initializing
the uniform
osg::StateSet *stateSet = geode->getOrCreateStateSet();
stateSet->addUniform(_ClrUniform);
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
m_root->addChild(geode);
viewer.setUpViewInWindow( 32, 32, 1024, 600 );
viewer.setSceneData(m_root.get());
return viewer.run();
}
I have looked at material.cpp and tried to set the Uniform for material.But
somehow its not updating in the application.It is taking black color by default.
I think that, they have not handled the material property for ES 2.0 in
material.cpp
I have tried modifying the code in material.cpp in void
Material::apply(State&) const function.
The modified code is as follows:
osg::Uniform* _myClrUniform;
_myClrUniform->set( osg::Vec3(_diffuseFront.x(), _diffuseFront.y(),
_diffuseFront.z()) );
[/code]
How can I set the material property of every object through application for
.3DS file?
Any help will be appreciated.
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=31514#31514
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org