本文整理汇总了C++中MaterialChunkUnrecPtr类的典型用法代码示例。如果您正苦于以下问题:C++ MaterialChunkUnrecPtr类的具体用法?C++ MaterialChunkUnrecPtr怎么用?C++ MaterialChunkUnrecPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MaterialChunkUnrecPtr类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLightPassMaterial
void ShaderShadowMapEngine::updateLightPassMaterial(SSMEngineData *data)
{
if(data->getMFLightPassMaterials()->empty() == true)
{
MaterialChunkUnrecPtr newMatChunk = MaterialChunk::createLocal();
newMatChunk->setLit (false );
newMatChunk->setColorMaterial(GL_NONE);
ColorMaskChunkUnrecPtr newCMaskChunk = ColorMaskChunk::create();
newCMaskChunk->setMaskR(false);
newCMaskChunk->setMaskG(false);
newCMaskChunk->setMaskB(false);
newCMaskChunk->setMaskA(false);
PolygonChunkUnrecPtr newPolyChunk = PolygonChunk::createLocal();
newPolyChunk->setOffsetFill (true );
newPolyChunk->setOffsetFactor(this->getOffsetFactor());
newPolyChunk->setOffsetBias (this->getOffsetBias ());
ChunkMaterialUnrecPtr newLightPassMat = ChunkMaterial::createLocal();
newLightPassMat->addChunk(newMatChunk );
newLightPassMat->addChunk(newCMaskChunk);
newLightPassMat->addChunk(newPolyChunk );
data->editMFLightPassMaterials()->push_back(newLightPassMat);
}
}
示例2: setupAnimation
void setupAnimation(void)
{
std::vector<BoostPath> _ImagePaths;
_ImagePaths.push_back(BoostPath("./Data/Anim001.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim002.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim003.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim004.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim005.jpg"));
//Make the textures
for(UInt32 i(0) ; i<_ImagePaths.size(); ++i)
{
ImageUnrecPtr AnimFrameImage = ImageFileHandler::the()->read(_ImagePaths[i].string().c_str());
_Images.push_back(AnimFrameImage);
}
TextureObjChunkUnrecPtr AnimFrameTexture = TextureObjChunk::create();
AnimFrameTexture->setImage(_Images.front());
//Box Material
MaterialChunkUnrecPtr TheMaterialChunk = MaterialChunk::create();
TheMaterialChunk->setAmbient(Color4f(0.4,0.4,0.4,1.0));
TheMaterialChunk->setDiffuse(Color4f(0.8,0.8,0.8,1.0));
TheMaterialChunk->setSpecular(Color4f(1.0,1.0,1.0,1.0));
TheBoxMaterial = ChunkMaterial::create();
TheBoxMaterial->addChunk(AnimFrameTexture);
//Texture Keyframe Sequence
KeyframeFCPtrSequenceUnrecPtr TextureKeyframes = KeyframeFCPtrSequenceImage::create();
for(UInt32 i(0) ; i<_Images.size(); ++i)
{
TextureKeyframes->addKeyframe(_Images[i],static_cast<Real32>(i)*0.5f);
}
//Animator
TutorialTextureAnimator = KeyframeAnimator::create();
TutorialTextureAnimator->setKeyframeSequence(TextureKeyframes);
//Animation
TutorialTextureAnimation = FieldAnimation::create();
TutorialTextureAnimation->setAnimator(TutorialTextureAnimator);
TutorialTextureAnimation->setInterpolationType(Animator::STEP_INTERPOLATION);
TutorialTextureAnimation->setCycling(-1);
TutorialTextureAnimation->setAnimatedField(AnimFrameTexture,TextureObjChunk::ImageFieldId);
//Animation Listener
TutorialTextureAnimation->addAnimationListener(&TutorialTextureAnimationListener);
TutorialTextureAnimation->attachUpdateProducer(TutorialWindow->editEventProducer());
TutorialTextureAnimation->start();
}
示例3:
MaterialUnrecPtr Graphics3DExtrude::createDefaultMaterial(void)
{
MaterialChunkUnrecPtr TheMaterialChunk = MaterialChunk::create();
TheMaterialChunk->setAmbient(Color4f(0.4,0.4,0.4,1.0));
TheMaterialChunk->setDiffuse(Color4f(0.8,0.8,0.8,1.0));
TheMaterialChunk->setSpecular(Color4f(0.85,0.85,0.85,1.0));
TheMaterialChunk->setEmission(Color4f(0.0,0.0,0.0,1.0));
TheMaterialChunk->setShininess(50.0);
TheMaterialChunk->setLit(true);
TheMaterialChunk->setColorMaterial(true);
ChunkMaterialUnrecPtr TheMaterial = ChunkMaterial::create();
TheMaterial->addChunk(TheMaterialChunk);
return TheMaterial;
}
示例4: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
//Joint Node Hierarchy
NodeRecPtr ExampleJointNode;
//Create a new skeleton
SkeletonBlendedGeometryRecPtr ExampleSkeleton;
//Load skeleton from an XML file
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/14Skeleton.xml"));
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
//We only want the skeleton; ignore anything else saved in the XML file
if( (*Itor)->getType() == (SkeletonBlendedGeometry::getClassType()))
{
ExampleSkeleton = (dynamic_pointer_cast<SkeletonBlendedGeometry>(*Itor));
}
if( (*Itor)->getType() == (Node::getClassType()) &&
(dynamic_pointer_cast<Node>(*Itor)->getParent() == NULL))
{
ExampleJointNode = (dynamic_pointer_cast<Node>(*Itor));
}
}
//SkeletonDrawer
SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
//Skeleton Node
NodeUnrecPtr SkeletonNode = Node::create();
SkeletonNode->setCore(ExampleSkeletonDrawable);
// Make Main Scene Node and add the Torus
NodeUnrecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(SkeletonNode);
mgr->setRoot(scene);
// Show the whole Scene
mgr->showAll();
//.........这里部分代码省略.........
示例5: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Shader Material
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
//Material Chunk
MaterialChunkUnrecPtr ShaderMaterialChunk = MaterialChunk::create();
ShaderMaterialChunk->setAmbient(Color4f(0.4f,0.4f,0.4f,1.0f));
ShaderMaterialChunk->setDiffuse(Color4f(0.7f,0.7f,0.7f,1.0f));
ShaderMaterialChunk->setSpecular(Color4f(1.0f,1.0f,1.0f,1.0f));
//Shader Chunk
SimpleSHLChunkUnrecPtr TheSHLChunk = SimpleSHLChunk::create();
TheSHLChunk->setVertexProgram(createSHLVertexProg());
TheSHLChunk->setFragmentProgram(createSHLFragProg());
//Color Parameter
ShaderVariableVec4fUnrecPtr Color1Parameter = ShaderVariableVec4f::create();
Color1Parameter->setName("Color1");
Color1Parameter->setValue(Vec4f(0.0f,1.0f,0.0f,1.0f));
ShaderVariableVec4fUnrecPtr Color2Parameter = ShaderVariableVec4f::create();
Color2Parameter->setName("Color2");
Color2Parameter->setValue(Vec4f(1.0f,1.0f,1.0f,1.0f));
//Shader Parameter Chunk
SHLParameterChunkUnrecPtr SHLParameters = SHLParameterChunk::create();
SHLParameters->getParameters().push_back(Color1Parameter);
SHLParameters->getParameters().push_back(Color2Parameter);
SHLParameters->setSHLChunk(TheSHLChunk);
ChunkMaterialUnrecPtr ShaderMaterial = ChunkMaterial::create();
ShaderMaterial->addChunk(ShaderMaterialChunk);
ShaderMaterial->addChunk(TheSHLChunk);
ShaderMaterial->addChunk(SHLParameters);
//Torus Node
GeometryUnrecPtr TorusGeometry = makeTorusGeo(5.0f,20.0f, 32,32);
TorusGeometry->setMaterial(ShaderMaterial);
NodeUnrecPtr TorusNode = Node::create();
TorusNode->setCore(TorusGeometry);
// Make Main Scene Node
NodeUnrecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(TorusNode);
mgr->setRoot(scene);
// Show the whole Scene
mgr->showAll();
//Create the Animations
initAnimations(Color1Parameter, "value");
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"04ShaderAnimation");
//Main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例6: setRoot
void VTKPolyDataMapper::initGeometries(void)
{
NodeUnrecPtr pRoot = Node::create();
pRoot->setCore(Group::create());
setRoot(pRoot);
for(UInt32 i = 0; i < 4; ++i)
{
GeometryUnrecPtr pGeo = Geometry::create();
ChunkMaterialUnrecPtr pMat = ChunkMaterial::create();
MaterialChunkUnrecPtr pMatChunk = MaterialChunk::create();
GeoPnt3fPropertyUnrecPtr pPoints = GeoPnt3fProperty ::create();
GeoUInt32PropertyUnrecPtr pLengths = GeoUInt32Property ::create();
GeoUInt8PropertyUnrecPtr pTypes = GeoUInt8Property ::create();
GeoColor4fPropertyUnrecPtr pColors = GeoColor4fProperty::create();
GeoVec3fPropertyUnrecPtr pNormals = GeoVec3fProperty ::create();
if(i < 2)
{
pMatChunk->setLit(false);
}
pMatChunk->setDiffuse (OSG::Color4f(1.0, 1.0, 1.0, 1.0));
pMatChunk->setSpecular (OSG::Color4f(0.0, 0.0, 0.0, 1.0));
pMatChunk->setShininess(10.0f);
pMat->addChunk(pMatChunk);
TwoSidedLightingChunkUnrecPtr pTSLChunk =
TwoSidedLightingChunk::create();
pMat->addChunk(pTSLChunk);
pGeo->setDlistCache(false );
pGeo->setMaterial (pMat );
pGeo->setPositions (pPoints );
pGeo->setLengths (pLengths);
pGeo->setTypes (pTypes );
pGeo->setColors (pColors );
if(i > 1)
{
pGeo->setNormals(pNormals);
}
OSG::NodeUnrecPtr pGeoRoot = OSG::Node::create();
pGeoRoot->setCore (pGeo);
pGeoRoot->setTravMask(0 );
pRoot->addChild(pGeoRoot);
this->pushToGeometries (pGeo );
this->pushToMaterials (pMat );
this->pushToMaterialChunks(pMatChunk);
this->pushToPositions (pPoints );
this->pushToLength (pLengths );
this->pushToTypes (pTypes );
this->pushToColors (pColors );
this->pushToNormals (pNormals );
this->pushToGeoRoots (pGeoRoot );
}
}
示例7: setupAnimation
AnimationTransitPtr setupAnimation(ChunkMaterial* const TheBoxMaterial)
{
std::vector<BoostPath> _ImagePaths;
_ImagePaths.push_back(BoostPath("./Data/Anim001.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim002.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim003.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim004.jpg"));
_ImagePaths.push_back(BoostPath("./Data/Anim005.jpg"));
TextureSelectChunkRefPtr AnimSequenceTexture = TextureSelectChunk::create();
AnimSequenceTexture->setChoice(0);
//Make the textures
for(UInt32 i(0) ; i<_ImagePaths.size(); ++i)
{
ImageRefPtr AnimFrameImage = ImageFileHandler::the()->read(_ImagePaths[i].string().c_str());
TextureObjChunkRefPtr AnimFrameTexture = TextureObjChunk::create();
AnimFrameTexture->setImage(AnimFrameImage);
AnimSequenceTexture->pushToTextures(AnimFrameTexture);
}
//Box Material
MaterialChunkUnrecPtr TheMaterialChunk = MaterialChunk::create();
TheMaterialChunk->setAmbient(Color4f(0.4,0.4,0.4,1.0));
TheMaterialChunk->setDiffuse(Color4f(0.8,0.8,0.8,1.0));
TheMaterialChunk->setSpecular(Color4f(1.0,1.0,1.0,1.0));
//Texture Env Chunk
TextureEnvChunkRefPtr TexEnv = TextureEnvChunk::create();
TexEnv->setEnvMode(GL_MODULATE);
TheBoxMaterial->addChunk(AnimSequenceTexture);
TheBoxMaterial->addChunk(TexEnv);
TheBoxMaterial->addChunk(TheMaterialChunk);
//Texture Keyframe Sequence
KeyframeNumberSequenceUInt32RefPtr FrameChoiceKeyframes = KeyframeNumberSequenceUInt32::create();
Real32 Rate(0.05f);
for(UInt32 i(0) ; i<AnimSequenceTexture->getMFTextures()->size(); ++i)
{
FrameChoiceKeyframes->addRawKeyframe(i,static_cast<Real32>(i)*Rate);
}
for(UInt32 i(0) ; i<AnimSequenceTexture->getMFTextures()->size(); ++i)
{
FrameChoiceKeyframes->addRawKeyframe(AnimSequenceTexture->getMFTextures()->size()-i-1,
static_cast<Real32>(i+AnimSequenceTexture->getMFTextures()->size())*Rate);
}
//Animator
KeyframeAnimatorUnrecPtr TutorialTextureAnimator = KeyframeAnimator::create();
TutorialTextureAnimator->setKeyframeSequence(FrameChoiceKeyframes);
//Animation
FieldAnimationUnrecPtr TutorialTextureAnimation = FieldAnimation::create();
TutorialTextureAnimation->setAnimator(TutorialTextureAnimator);
TutorialTextureAnimation->setInterpolationType(Animator::STEP_INTERPOLATION);
TutorialTextureAnimation->setCycling(-1);
TutorialTextureAnimation->setAnimatedField(AnimSequenceTexture,TextureSelectChunk::ChoiceFieldId);
return AnimationTransitPtr(TutorialTextureAnimation);
}
示例8: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
//Read skeleton from XML file
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(BoostPath("./Data/16Skeleton.xml"));
SkeletonUnrecPtr ExampleSkeleton;
FCFileType::FCPtrStore::iterator Itor;
for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor)
{
//Only import skeleton data; we ignore anything else saved in the XML file
if( (*Itor)->getType() == (Skeleton::getClassType()))
{
//Set the Skeleton to the one we just read in
ExampleSkeleton = (dynamic_pointer_cast<Skeleton>(*Itor));
}
}
//SkeletonDrawer
SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
//Skeleton Particle System Node
NodeUnrecPtr SkeletonNode = Node::create();
SkeletonNode->setCore(ExampleSkeletonDrawable);
//Torus Node
NodeUnrecPtr TorusNode = makeTorus(.5, 2, 32, 32);
// Make Main Scene Node and add the Torus
NodeUnrecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(SkeletonNode);
//scene->addChild(TorusNode);
scene->addChild(makeCoordAxis(10.0));
mgr->setRoot(scene);
mgr->turnHeadlightOff();
// Show the whole Scene
mgr->showAll();
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"16LoadXMLSkeleton");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
//.........这里部分代码省略.........
示例9: setRenderTarget
//.........这里部分代码省略.........
1,
1,
0.0,
0,
Image::OSG_FLOAT32_IMAGEDATA,
false);
pBlurTex2 ->setImage (pImg );
pBlurTex2 ->setMinFilter (GL_LINEAR );
pBlurTex2 ->setMagFilter (GL_LINEAR );
pBlurTex2 ->setWrapS (GL_CLAMP_TO_EDGE );
pBlurTex2 ->setWrapT (GL_CLAMP_TO_EDGE );
pBlurTex2 ->setInternalFormat(getBufferFormat());
pBlurTex2Env->setEnvMode (GL_REPLACE );
TextureBufferUnrecPtr pBlurTexBuffer2 = TextureBuffer::createLocal();
pBlurTexBuffer2->setTexture(pBlurTex2);
pBlurFBO->setSize(iPixelWidth / 4,
iPixelHeight / 4);
pBlurFBO->setColorAttachment(pBlurTexBuffer1, 0);
pBlurFBO->setColorAttachment(pBlurTexBuffer2, 1);
returnValue->setBlurRenderTarget(pBlurFBO);
// general mat chunk
MaterialChunkUnrecPtr pMatChunk = MaterialChunk::createLocal();
pMatChunk->setLit(false);
// tone map material
ChunkMaterialUnrecPtr pTonemapMat = ChunkMaterial ::createLocal();
pTonemapMat->addChunk(pMatChunk );
pTonemapMat->addChunk(pSceneTex, 0);
pTonemapMat->addChunk(pSceneTexEnv, 0);
pTonemapMat->addChunk(pBlurTex1, 1);
pTonemapMat->addChunk(pBlurTex1Env, 1);
SimpleSHLChunkUnrecPtr pTonemapShader = generateHDRFragmentProgram();
pTonemapShader->addUniformVariable("sceneTex", 0);
pTonemapShader->addUniformVariable("blurTex", 1);
pTonemapShader->addUniformVariable("blurAmount", getBlurAmount ());
pTonemapShader->addUniformVariable("exposure", getExposure ());
pTonemapShader->addUniformVariable("effectAmount", getEffectAmount());
pTonemapShader->addUniformVariable("gamma", getGamma ());
pTonemapMat->addChunk(pTonemapShader, 0);
returnValue->setToneMappingMaterial(pTonemapMat);
示例10: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(4.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
GeometryRefPtr SphereGeometry = makeSphereGeo(2, 0.25f);
GeometryRefPtr BoxGeometry = makeBoxGeo(0.5f,0.5f,0.5f,1,1,1);
//Skeleton
SkeletonBlendedGeometryUnrecPtr ExampleSkeleton = SkeletonBlendedGeometry::create();
//Joint
TransformRecPtr ExampleRootJoint = Transform::create();
NodeRecPtr ExampleRootJointNode = makeNodeFor(ExampleRootJoint);
//Add this joint to the skeleton
ExampleSkeleton->pushToJoints(ExampleRootJointNode, Matrix());
NodeRecPtr TempRootJointNode = ExampleRootJointNode;
NodeRefPtr GeoNode = makeNodeFor(BoxGeometry);
TempRootJointNode->addChild(GeoNode);
Matrix TempMat;
//Create a set of randomly placed child joints
for (Real32 i = 0.0f; i < 5.0f; ++i)
{
TransformRecPtr ExampleChildJoint = Transform::create();
NodeRecPtr ExampleChildJointNode = makeNodeFor(ExampleChildJoint);
GeoNode = makeNodeFor(SphereGeometry);
ExampleChildJointNode->addChild(GeoNode);
//TempMat.setTranslate(RandomPoolManager::getRandomReal32(0.0, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f));
switch((static_cast<UInt32>(i) % 3))
{
case 0:
TempMat.setTranslate(2.0f,0.0f,0.0f);
break;
case 1:
TempMat.setTranslate(0.0f,2.0f,0.0f);
break;
case 2:
TempMat.setTranslate(0.0f,0.0f,2.0f);
break;
}
//Set bind and current transformations to TempMat (calculated above)
ExampleChildJoint->setMatrix(TempMat);
//Add ExampleChildJoint as a child to the previous joint
TempRootJointNode->addChild(ExampleChildJointNode);//add a Child to the root joint
//ExampleChildJoint will be the next parent joint
TempRootJointNode = ExampleChildJointNode;
//Add this joint to the skeleton
Matrix InvBind(TempRootJointNode->getToWorld());
InvBind.invert();
ExampleSkeleton->pushToJoints(ExampleChildJointNode, InvBind);
//.........这里部分代码省略.........
示例11: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "space Play/Pause the animation" << std::endl;
std::cout << "B Show/Hide the bind pose skeleton" << std::endl;
std::cout << "P Show/Hide the current pose skeleton" << std::endl;
std::cout << "1 Play first example animation" << std::endl;
std::cout << "2 Play second example animation" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
GeometryRefPtr SphereGeometry = makeSphereGeo(2, 0.25f);
GeometryRefPtr BoxGeometry = makeBoxGeo(0.5f,0.5f,0.5f,1,1,1);
//Skeleton
SkeletonBlendedGeometryUnrecPtr ExampleSkeleton = SkeletonBlendedGeometry::create();
//Joint
JointRecPtr ExampleRootJoint = Joint::create();
//Add this joint to the skeleton
ExampleSkeleton->pushToJoints(ExampleRootJoint, Matrix());
NodeRecPtr ExampleRootJointNode = makeNodeFor(ExampleRootJoint);
NodeRecPtr TempRootJointNode = ExampleRootJointNode;
NodeRefPtr GeoNode = makeNodeFor(BoxGeometry);
TempRootJointNode->addChild(GeoNode);
Matrix TempMat;
//Create a set of randomly placed child joints
for (Real32 i = 0.0f; i < 5.0f; ++i)
{
JointRecPtr ExampleChildJoint = Joint::create();
NodeRecPtr ExampleChildJointNode = makeNodeFor(ExampleChildJoint);
GeoNode = makeNodeFor(SphereGeometry);
ExampleChildJointNode->addChild(GeoNode);
//TempMat.setTranslate(RandomPoolManager::getRandomReal32(0.0, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f));
switch((static_cast<UInt32>(i) % 3))
{
case 0:
TempMat.setTranslate(2.0f,0.0f,0.0f);
break;
case 1:
TempMat.setTranslate(0.0f,2.0f,0.0f);
break;
case 2:
TempMat.setTranslate(0.0f,0.0f,2.0f);
break;
}
//Set bind and current transformations to TempMat (calculated above)
ExampleChildJoint->setJointTransformation(TempMat);
//.........这里部分代码省略.........
示例12: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "space Play/Pause the animation" << std::endl;
std::cout << "B Show/Hide the bind pose skeleton" << std::endl;
std::cout << "P Show/Hide the current pose skeleton" << std::endl;
std::cout << "1 Play first example animation" << std::endl;
std::cout << "2 Play second example animation" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
//Joint
JointUnrecPtr ExampleRootJoint = Joint::create();
JointUnrecPtr TempRootJoint;
TempRootJoint = ExampleRootJoint;
Matrix TempMat;
//Create a set of randomly placed joints
for (Real32 i = 1.0f; i < 9.0f; i++)
{
JointUnrecPtr ExampleChildJoint;
TempMat.setTranslate(RandomPoolManager::getRandomReal32(0.0, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f), RandomPoolManager::getRandomReal32(0.0f, 10.0f));
ExampleChildJoint = Joint::create(); //create a joint called ExampleChildJoint
//Set ExampleChildJoint's current and bind transformations to TempMat (calculated above)
ExampleChildJoint->setRelativeTransformation(TempMat);
ExampleChildJoint->setBindRelativeTransformation(TempMat);
ExampleChildJoint->setUseParentTranslation(true);
//Add ExampleChildJoint as a child to the previously created joint
TempRootJoint->pushToChildJoints(ExampleChildJoint);//add a Child to the previous joint
//ExampleChildJoint will be the next parent joint
TempRootJoint = TempRootJoint->getChildJoints(0);
}
//Skeleton
SkeletonUnrecPtr ExampleSkeleton = Skeleton::create();
ExampleSkeleton->pushToRootJoints(ExampleRootJoint);
//SkeletonDrawer
SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
ExampleSkeletonDrawable->setDrawBindPose(false); //By default, we won't draw the skeleton's bind pose
ExampleSkeletonDrawable->setBindPoseColor(Color4f(0.0, 1.0, 0.0, 1.0)); //When the skeleton's bind pose is rendered, it will be green
ExampleSkeletonDrawable->setDrawPose(true); //By default, we do draw the skeleton's current pose
ExampleSkeletonDrawable->setPoseColor(Color4f(0.0, 0.0, 1.0, 1.0)); //The skeleton's current pose is rendered in blue
//Skeleton Node
SkeletonNode = Node::create();
SkeletonNode->setCore(ExampleSkeletonDrawable);
//.........这里部分代码省略.........
示例13: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "space Play/Pause the animation" << std::endl;
std::cout << "B Show/Hide the bind pose skeleton" << std::endl;
std::cout << "SHIFT-B Show/Hide the bind pose mesh" << std::endl;
std::cout << "P Show/Hide the current pose skeleton" << std::endl;
std::cout << "SHIFT-P Show/Hide the current pose mesh" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
//Skeleton
ExampleSkeleton = SkeletonBlendedGeometry::create();
//===========================================Joints==================================================================
Matrix TempMat;
Matrix InvBind;
/*================================================================================================*/
/* Pelvis */
Pelvis = Joint::create(); //create a joint called Pelvis
TempMat.setTranslate(0.0,7.0,0.0);
Pelvis->setJointTransformation(TempMat);
NodeRecPtr PelvisNode = makeNodeFor(Pelvis);
InvBind = PelvisNode->getToWorld();
InvBind.invert();
ExampleSkeleton->pushToJoints(Pelvis, InvBind);
setName(Pelvis, "Pelvis Joint");
setName(PelvisNode, "Pelvis Node");
/*================================================================================================*/
/* Clavicle */
Clavicle = Joint::create(); //create a joint called Clavicle
TempMat.setTranslate(0.0,5.0,0.0);
Clavicle->setJointTransformation(TempMat);
NodeRecPtr ClavicleNode = makeNodeFor(Clavicle);
PelvisNode->addChild(ClavicleNode);
InvBind = ClavicleNode->getToWorld();
InvBind.invert();
ExampleSkeleton->pushToJoints(Clavicle, InvBind);
setName(Clavicle, "Clavicle Joint");
setName(ClavicleNode, "Clavicle Node");
/*================================================================================================*/
/* Left Shoulder */
LeftShoulder = Joint::create(); //create a joint called LeftShoulder
TempMat.setTranslate(1.0,-0.5,0.0);
LeftShoulder->setJointTransformation(TempMat);
NodeRecPtr LeftShoulderNode = makeNodeFor(LeftShoulder);
ClavicleNode->addChild(LeftShoulderNode);
//.........这里部分代码省略.........
示例14: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl
<< "space Play/Pause the animation" << std::endl
<< "B Show/Hide the bind pose skeleton" << std::endl
<< "P Show/Hide the current pose skeleton" << std::endl
<< "CTRL-Q Exit\n\n" << std::endl;
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
//===========================================Joints==================================================================
Matrix TempMat;
/*================================================================================================*/
/* Left Fingers */
LeftFingers = Joint::create(); //create a joint called LeftFingers
TempMat.setTranslate(1.0,0.0,0.0);
LeftFingers->setRelativeTransformation(TempMat);
LeftFingers->setBindRelativeTransformation(TempMat);
/*================================================================================================*/
/* Right Fingers */
RightFingers = Joint::create(); //create a joint called RightFingers
TempMat.setTranslate(-1.0,0.0,0.0);
RightFingers->setRelativeTransformation(TempMat);
RightFingers->setBindRelativeTransformation(TempMat);
/*================================================================================================*/
/* Left Hand */
LeftHand = Joint::create(); //create a joint called LeftHand
TempMat.setTranslate(2.0,0.0,0.0);
LeftHand->setRelativeTransformation(TempMat);
LeftHand->setBindRelativeTransformation(TempMat);
LeftHand->pushToChildJoints(LeftFingers);
/*================================================================================================*/
/* Right Hand */
RightHand = Joint::create(); //create a joint called RightHand
TempMat.setTranslate(-2.0,0.0,0.0);
RightHand->setRelativeTransformation(TempMat);
RightHand->setBindRelativeTransformation(TempMat);
RightHand->pushToChildJoints(RightFingers);
/*================================================================================================*/
/* Left Elbow */
LeftElbow = Joint::create(); //create a joint called LeftElbow
TempMat.setTranslate(2.0,0.0,0.0);
LeftElbow->setRelativeTransformation(TempMat);
LeftElbow->setBindRelativeTransformation(TempMat);
LeftElbow->pushToChildJoints(LeftHand);
/*================================================================================================*/
/* Right Elbow */
RightElbow = Joint::create(); //create a joint called RightElbow
TempMat.setTranslate(-2.0,0.0,0.0);
RightElbow->setRelativeTransformation(TempMat);
RightElbow->setBindRelativeTransformation(TempMat);
RightElbow->pushToChildJoints(RightHand);
/*================================================================================================*/
//.........这里部分代码省略.........