Material* MaterialManager::getMaterialFor(video::ITexture* t, video::E_MATERIAL_TYPE material_type) { if (t == NULL) return getDefaultMaterial(material_type); core::stringc img_path = core::stringc(t->getName()); img_path.make_lower(); if (!img_path.empty() && (img_path.findFirst('/') != -1 || img_path.findFirst('\\') != -1)) { // Search backward so that temporary (track) textures are found first for (int i = (int)m_materials.size() - 1; i >= 0; i--) { core::stringc fullpath = core::stringc(m_materials[i]->getTexFullPath().c_str()); fullpath.make_lower(); if (fullpath == img_path.c_str()) { return m_materials[i]; } } } else { core::stringc image(StringUtils::getBasename(img_path.c_str()).c_str()); image.make_lower(); for (int i = (int)m_materials.size() - 1; i >= 0; i--) { core::stringc texfname(m_materials[i]->getTexFname().c_str()); texfname.make_lower(); if (texfname == image) { return m_materials[i]; } } // for i } return getDefaultMaterial(material_type); }
void CPUSkinningAlgorithm::renderGeometry( RenderAction *ract, SkinnedGeometry *skinGeo, CPUSkinningDataAttachment *data ) { Material *pMat = ract->getMaterial(); PrimeMaterial *pPrimeMat = NULL; if(pMat == NULL) { if(skinGeo->getMaterial() != NULL) { pPrimeMat = skinGeo->getMaterial()->finalize( ract->getRenderProperties(), ract->getWindow()); } } else { pPrimeMat = pMat->finalize( ract->getRenderProperties(), ract->getWindow()); } if(pPrimeMat == NULL) { SNOTICE << "CPUSkinningAlgorithm::preDrawPrimitives: No Material " << "for SkinnedGeometry " << skinGeo << std::endl; pPrimeMat = getDefaultMaterial(); } DrawEnv::DrawFunctor drawFunc = boost::bind( &CPUSkinningAlgorithm::drawPrimitives, this, skinGeo, data, _1); UInt32 uiNPasses = pPrimeMat->getNPasses(); for(UInt32 uiPass = 0; uiPass < uiNPasses; ++uiPass) { State *st = pPrimeMat->getState(uiPass); if(st != NULL) { ract->dropFunctor(drawFunc, st, pPrimeMat->getSortKey() + uiPass); } else { FINFO(("%s: Material %p has NULL state for pass %d\n", OSG_FUNCNAME_MACRO, pPrimeMat, uiPass)); } } }
/** Searches for the material in the given texture, and calls a function * in the material to set the irrlicht material flags. * \param t Pointer to the texture. * \param mb Pointer to the mesh buffer. */ void MaterialManager::setAllMaterialFlags(video::ITexture* t, scene::IMeshBuffer *mb) { Material* mat = getMaterialFor(t, mb); if (mat != NULL) { mat->setMaterialProperties(&(mb->getMaterial()), mb); return; } Material* default_material = getDefaultMaterial(mb->getMaterial().MaterialType); default_material->setMaterialProperties(&(mb->getMaterial()), mb); } // setAllMaterialFlags
void MaterialManager::setAllUntexturedMaterialFlags(scene::IMeshBuffer *mb) { irr::video::SMaterial& material = mb->getMaterial(); if (material.getTexture(0) == NULL) { //material.AmbientColor = video::SColor(255, 50, 50, 50); //material.DiffuseColor = video::SColor(255, 150, 150, 150); material.EmissiveColor = video::SColor(255, 0, 0, 0); material.SpecularColor = video::SColor(255, 0, 0, 0); //material.Shininess = 0.0f; material.ColorMaterial = irr::video::ECM_DIFFUSE_AND_AMBIENT; material.MaterialType = irr::video::EMT_SOLID; } Material* default_material = getDefaultMaterial(mb->getMaterial().MaterialType); default_material->setMaterialProperties(&(mb->getMaterial()), mb); }
// Initialize GLUT & OpenSG and set up the scene int main(int argc, char **argv) { // OSG init glutInit(&argc, argv); osgInit(argc, argv); std::string fontfile("testfont.ttf"); std::string testtext("Test Text"); UInt32 drawmode; if(argc > 1) testtext = argv[1]; if(argc > 2) fontfile = argv[2]; if(argc < 4 || sscanf(argv[3], "%d", &drawmode) != 1 ) drawmode = FTGLFont::Outline; // GLUT int winid = setupGLUT(&argc, argv); GLUTWindowPtr gwin= GLUTWindow::create(); gwin->setId(winid); gwin->init(); // Create the Cubes node NodePtr scene = makeCoredNode<Group>(); beginEditCP(scene); scene->addChild( makeBox(200,200,200, 1,1,1) ); // scene->addChild( SceneFileHandler::the().read("tie.wrl") ); endEditCP(scene); // Create the text FTGLFontPtr font = FTGLFont::create(); beginEditCP(font); font->setName(fontfile); font->setDrawType(drawmode); font->setSize(40); font->setRes(72); font->setDepth(20); endEditCP(font); FTGLTextPtr text; NodePtr tnode = makeCoredNode<FTGLText>(&text); beginEditCP(text); text->setFont(font); text->setText(testtext); text->setPosition(Pnt3f(0,300,0)); text->setMaterial(getDefaultMaterial()); endEditCP(text); beginEditCP(scene); scene->addChild(tnode); endEditCP(scene); // create the SimpleSceneManager helper mgr = new SimpleSceneManager; // tell the manager what to manage mgr->setWindow(gwin ); mgr->setRoot (scene); // show the whole scene mgr->showAll(); // copy to second window int winid2 = setupGLUT(&argc, argv); gwin2= GLUTWindow::create(); gwin2->setId(winid2); gwin2->init(); ViewportPtr ovp = gwin->getPort()[0]; ViewportPtr vp = Viewport::create(); beginEditCP(vp); vp->setLeft(0); vp->setRight(400); vp->setBottom(0); vp->setTop(400); vp->setCamera(ovp->getCamera()); vp->setRoot(ovp->getRoot()); vp->setBackground(ovp->getBackground()); vp->setParent(gwin2); endEditCP(vp); beginEditCP(gwin2); gwin2->getPort().push_back(vp); endEditCP(gwin2); // GLUT main loop glutMainLoop(); return 0; }
// Initialize GLUT & OpenSG and set up the scene int main(int argc, char **argv) { // OSG init osgInit(argc,argv); // GLUT init int winid = setupGLUT(&argc, argv); // the connection between GLUT and OpenSG GLUTWindowPtr gwin= GLUTWindow::create(); gwin->setId(winid); gwin->init(); // create the scene /* In the previous example, the colors and positions used the same indices. That might not always be the preferred way, and it might not make sense for other properties, e.g. normals. It is possible to assign a different index for every property. See the indices section below for details. */ /* The initial setup is the same as in the single indexed geometry... */ GeoPTypesPtr type = GeoPTypesUI8::create(); beginEditCP(type, GeoPTypesUI8::GeoPropDataFieldMask); { type->push_back(GL_POLYGON ); type->push_back(GL_TRIANGLES); type->push_back(GL_QUADS ); } endEditCP (type, GeoPTypesUI8::GeoPropDataFieldMask); GeoPLengthsPtr lens = GeoPLengthsUI32::create(); beginEditCP(lens, GeoPLengthsUI32::GeoPropDataFieldMask); { lens->push_back(4); lens->push_back(6); lens->push_back(8); } endEditCP (lens, GeoPLengthsUI32::GeoPropDataFieldMask); GeoPositions3fPtr pnts = GeoPositions3f::create(); beginEditCP(pnts, GeoPositions3f::GeoPropDataFieldMask); { // the base pnts->push_back(Pnt3f(-1, -1, -1)); pnts->push_back(Pnt3f(-1, -1, 1)); pnts->push_back(Pnt3f( 1, -1, 1)); pnts->push_back(Pnt3f( 1, -1, -1)); // the roof base pnts->push_back(Pnt3f(-1, 0, -1)); pnts->push_back(Pnt3f(-1, 0, 1)); pnts->push_back(Pnt3f( 1, 0, 1)); pnts->push_back(Pnt3f( 1, 0, -1)); // the gable pnts->push_back(Pnt3f( 0, 1, -1)); pnts->push_back(Pnt3f( 0, 1, 1)); } endEditCP (pnts, GeoPositions3f::GeoPropDataFieldMask); GeoColors3fPtr colors = GeoColors3f::create(); beginEditCP(colors, GeoColors3f::GeoPropDataFieldMask); { colors->push_back(Color3f(1, 1, 0)); colors->push_back(Color3f(1, 0, 0)); colors->push_back(Color3f(1, 0, 0)); colors->push_back(Color3f(1, 1, 0)); colors->push_back(Color3f(0, 1, 1)); colors->push_back(Color3f(1, 0, 1)); } endEditCP (colors, GeoPositions3f::GeoPropDataFieldMask); /* A new property: normals. They are used for lighting calculations and have to point away from the surface. Normals are standard vectors. */ GeoNormals3fPtr norms = GeoNormals3f::create(); beginEditCP(norms, GeoNormals3f::GeoPropDataFieldMask); { norms->push_back(Vec3f(-1, 0, 0)); norms->push_back(Vec3f( 1, 0, 0)); norms->push_back(Vec3f( 0, -1, 0)); norms->push_back(Vec3f( 0, 1, 0)); norms->push_back(Vec3f( 0, 0, -1)); norms->push_back(Vec3f( 0, 0, 1)); } endEditCP (norms, GeoNormals3f::GeoPropDataFieldMask); /* To use different indices for different attributes they have to be specified. This is done within the single index property, by using more than one index per vertex. In this case every vertex reads multiple indices from the Indices property. The meaning of every index is defined by the indexMapping given below. */ GeoIndicesUI32Ptr indices = GeoIndicesUI32::create(); beginEditCP(indices, GeoIndicesUI32::GeoPropDataFieldMask); { // indices for the polygon indices->push_back(0); // position index indices->push_back(3); // color/normal index indices->push_back(1); // position index indices->push_back(3); // color/normal index indices->push_back(2); // position index indices->push_back(3); // color/normal index indices->push_back(3); // position index indices->push_back(3); // color/normal index // indices for the triangles indices->push_back(7); // position index indices->push_back(4); // color/normal index indices->push_back(4); // position index indices->push_back(4); // color/normal index indices->push_back(8); // position index indices->push_back(4); // color/normal index indices->push_back(5); // position index indices->push_back(5); // color/normal index indices->push_back(6); // position index indices->push_back(5); // color/normal index indices->push_back(9); // position index indices->push_back(5); // color/normal index // indices for the quads indices->push_back(1); // position index indices->push_back(5); // color/normal index indices->push_back(2); // position index indices->push_back(5); // color/normal index indices->push_back(6); // position index indices->push_back(5); // color/normal index indices->push_back(5); // position index indices->push_back(5); // color/normal index indices->push_back(3); // position index indices->push_back(4); // color/normal index indices->push_back(0); // position index indices->push_back(4); // color/normal index indices->push_back(4); // position index indices->push_back(4); // color/normal index indices->push_back(7); // position index indices->push_back(4); // color/normal index } endEditCP (indices, GeoIndicesUI32::GeoPropDataFieldMask); /* Put it all together into a Geometry NodeCore. */ GeometryPtr geo=Geometry::create(); beginEditCP(geo, Geometry::TypesFieldMask | Geometry::LengthsFieldMask | Geometry::IndicesFieldMask | Geometry::IndexMappingFieldMask | Geometry::PositionsFieldMask | Geometry::NormalsFieldMask | Geometry::ColorsFieldMask | Geometry::MaterialFieldMask ); { geo->setTypes (type); geo->setLengths (lens); geo->setIndices (indices); /* The meaning of the different indices is given by the indexMapping field. If contains an entry that defines which index for a vertex selects which attribute. In this example the first index selects the positions, the second is used for colors and normals. The number of elements in the indexMapping field defines the number of indices used for every vertex. */ geo->editMFIndexMapping()->push_back(Geometry::MapPosition ); geo->editMFIndexMapping()->push_back(Geometry::MapColor | Geometry::MapNormal ); geo->setPositions(pnts ); geo->setColors (colors); geo->setNormals (norms ); /* Use a lit material this time, to show the effect of the normals. */ geo->setMaterial (getDefaultMaterial()); } endEditCP (geo, Geometry::TypesFieldMask | Geometry::LengthsFieldMask | Geometry::IndicesFieldMask | Geometry::IndexMappingFieldMask | Geometry::PositionsFieldMask | Geometry::NormalsFieldMask | Geometry::ColorsFieldMask | Geometry::MaterialFieldMask ); // put the geometry core into a node NodePtr n = Node::create(); beginEditCP(n, Node::CoreFieldMask); { n->setCore(geo); } endEditCP (n, Node::CoreFieldMask); // add a transformation to make it move NodePtr scene = Node::create(); trans = Transform::create(); beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask ); { scene->setCore(trans); scene->addChild(n); } endEditCP (scene, Node::CoreFieldMask | Node::ChildrenFieldMask ); // create the SimpleSceneManager helper mgr = new SimpleSceneManager; // tell the manager what to manage mgr->setWindow(gwin ); mgr->setRoot (scene); // show the whole scene mgr->showAll(); // GLUT main loop glutMainLoop(); return 0; }
void ColladaGeometry::handleBindMaterial( const GeoInfo &geoInfo, Geometry *geo, ColladaInstanceGeometry *colInstGeo) { typedef ColladaInstanceGeometry::MaterialMap MaterialMap; typedef ColladaInstanceGeometry::MaterialMapConstIt MaterialMapConstIt; const MaterialMap &matMap = colInstGeo->getMaterialMap(); MaterialMapConstIt mmIt = matMap.find(geoInfo._matSymbol); Material *material = NULL; ColladaInstanceMaterial *colInstMat = NULL; ColladaInstanceEffect *colInstEffect = NULL; if(mmIt != matMap.end()) { colInstMat = mmIt->second; OSG_ASSERT(colInstMat != NULL); OSG_ASSERT(colInstMat->getTargetElem() != NULL); ColladaInstInfoRefPtr colInstInfo = ColladaMaterial::ColladaMaterialInstInfo::create(this, colInstMat); material = colInstMat->getTargetElem()->createInstance(colInstInfo); colInstEffect = colInstMat->getInstanceEffect(); } else { SWARNING << "ColladaGeometry::handleBindMaterial: No material found " << "for symbol [" << geoInfo._matSymbol << "]." << std::endl; geo->setMaterial(getDefaultMaterial()); return; } const BindStore &bindStore = colInstMat->getBindStore (); const BindVertexStore &bindVertexStore = colInstMat->getBindVertexStore(); PropStoreConstIt psIt = geoInfo._propStore .begin(); PropStoreConstIt psEnd = geoInfo._propStore .end (); IndexStoreConstIt isIt = geoInfo._indexStore.begin(); IndexStoreConstIt isEnd = geoInfo._indexStore.end (); // for every property in geoInfo we need to check if it gets remapped by a // <bind> or <bind_vertex_input> for(UInt32 i = 0; psIt != psEnd && isIt != isEnd; ++psIt, ++isIt, ++i) { if(psIt->_prop == NULL || *isIt == NULL) continue; bool handledProperty = false; UInt32 bindOffset = 0; UInt32 bindVertexOffset = 0; const BindInfo *bi = findBind (bindStore, psIt->_semantic, bindOffset ); const BindVertexInfo *bvi = findBindVertex(bindVertexStore, psIt->_semantic, psIt->_set, bindVertexOffset ); // there may be multiple consumers for a property, keep looping // until no more consumers are found while(bi != NULL || bvi != NULL) { UInt32 mappedProp = i; if(bi != NULL && bvi != NULL) { // is it a problem if there is a <bind> AND a // <bind_vertex_input> for the same property ?? SWARNING << "ColladaGeometry::handleBindMaterial: " << "Found <bind> AND <bind_vertex_input> for " << "semantic [" << bi->semantic << "] target/inSemantic [" << bi->target << "/" << bvi->inSemantic << "] inSet [" << bvi->inSet << "]" << std::endl; } if(bi != NULL) { if(colInstEffect->findTC(bi->target, mappedProp) == true) { OSG_COLLADA_LOG(("ColladaGeometry::handleBindMaterial: " "Resolved <bind> semantic [%s] " "target [%s] to property [%d]\n", bi->semantic.c_str(), bi->target.c_str(), mappedProp)); geo->setProperty( psIt->_prop, mappedProp); geo->setIndex (*isIt, mappedProp); handledProperty = true; } else { SWARNING << "ColladaGeometry::handleBindMaterial: " << "Failed to resolve <bind> semantic [" << bi->semantic << "] target [" << bi->target << "]." << std::endl; } } else if(bvi != NULL) { if(colInstEffect->findTC(bvi->semantic, mappedProp) == true) { OSG_COLLADA_LOG(("ColladaGeometry::handleBindMaterial: " "Resolved <bind_vertex_input> " "inSemantic [%s] inSet [%d] semantic [%s] " "to property [%d]\n", bvi->inSemantic.c_str(), bvi->inSet, bvi->semantic.c_str(), mappedProp)); geo->setProperty( psIt->_prop, mappedProp); geo->setIndex (*isIt, mappedProp); handledProperty = true; } else { SWARNING << "ColladaGeometry::handleBindMaterial: " << "Failed to resolve <bind_vertex_input> " << "inSemantic [" << bvi->inSemantic << "] inSet [" << bvi->inSet << "] semantic [" << bvi->semantic << "]." << std::endl; } } // find next consumers if any ++bindOffset; ++bindVertexOffset; bi = findBind (bindStore, psIt->_semantic, bindOffset ); bvi = findBindVertex(bindVertexStore, psIt->_semantic, psIt->_set, bindVertexOffset); } // if the property is not remapped by <bind> or <bind_vertex_input> // we just put it at the location it received at read time // this is for properties that are not of interest to the material // directly (e.g. positions, normals) if(handledProperty == false) { OSG_COLLADA_LOG(("ColladaGeometry::handleBindMaterial: " "Setting property [%d] (semantic [%s] set [%d]) " "without <bind>/<bind_vertex_input> mapping.\n", i, psIt->_semantic.c_str(), psIt->_set)); geo->setProperty( psIt->_prop, i); geo->setIndex (*isIt, i); } } if(material != NULL) { geo->setMaterial(material); } else { SWARNING << "ColladaGeometry::handleBindMaterial: No material created " << "for symbol [" << geoInfo._matSymbol << "]." << std::endl; geo->setMaterial(getDefaultMaterial()); } }
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); InvBind = LeftShoulderNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftShoulder, InvBind); setName(LeftShoulder, "Left Shoulder Joint"); setName(LeftShoulderNode, "Left Shoulder Node"); /*================================================================================================*/ /* Left Elbow */ LeftElbow = Joint::create(); //create a joint called LeftElbow TempMat.setTranslate(2.0,0.0,0.0); LeftElbow->setJointTransformation(TempMat); NodeRecPtr LeftElbowNode = makeNodeFor(LeftElbow); LeftShoulderNode->addChild(LeftElbowNode); InvBind = LeftElbowNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftElbow, InvBind); setName(LeftElbow, "Left Elbow Joint"); setName(LeftElbowNode, "Left Elbow Node"); /*================================================================================================*/ /* Left Hand */ LeftHand = Joint::create(); //create a joint called LeftHand TempMat.setTranslate(2.0,0.0,0.0); LeftHand->setJointTransformation(TempMat); NodeRecPtr LeftHandNode = makeNodeFor(LeftHand); LeftElbowNode->addChild(LeftHandNode); InvBind = LeftHandNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftHand, InvBind); setName(LeftHand, "Left Hand Joint"); setName(LeftHandNode, "Left Hand Node"); /*================================================================================================*/ /* Left Fingers */ LeftFingers = Joint::create(); //create a joint called LeftFingers TempMat.setTranslate(1.0,0.0,0.0); LeftFingers->setJointTransformation(TempMat); NodeRecPtr LeftFingersNode = makeNodeFor(LeftFingers); LeftHandNode->addChild(LeftFingersNode); InvBind = LeftFingersNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftFingers, InvBind); setName(LeftFingers, "Left Fingers Joint"); setName(LeftFingersNode, "Left Fingers Node"); /*================================================================================================*/ /* Right Shoulder */ RightShoulder = Joint::create(); //create a joint called RightShoulder TempMat.setTranslate(-1.0,-0.5,0.0); RightShoulder->setJointTransformation(TempMat); NodeRecPtr RightShoulderNode = makeNodeFor(RightShoulder); ClavicleNode->addChild(RightShoulderNode); InvBind = RightShoulderNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightShoulder, InvBind); setName(RightShoulder, "Right Shoulder Joint"); setName(RightShoulderNode, "Right Shoulder Node"); /*================================================================================================*/ /* Right Elbow */ RightElbow = Joint::create(); //create a joint called RightElbow TempMat.setTranslate(-2.0,0.0,0.0); RightElbow->setJointTransformation(TempMat); NodeRecPtr RightElbowNode = makeNodeFor(RightElbow); RightShoulderNode->addChild(RightElbowNode); InvBind = RightElbowNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightElbow, InvBind); setName(RightElbow, "Right Elbow Joint"); setName(RightElbowNode, "Right Elbow Node"); /*================================================================================================*/ /* Right Hand */ RightHand = Joint::create(); //create a joint called RightHand TempMat.setTranslate(-2.0,0.0,0.0); RightHand->setJointTransformation(TempMat); NodeRecPtr RightHandNode = makeNodeFor(RightHand); RightElbowNode->addChild(RightHandNode); InvBind = RightHandNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightHand, InvBind); setName(RightHand, "Right Hand Joint"); setName(RightHandNode, "Right Hand Node"); /*================================================================================================*/ /* Right Fingers */ RightFingers = Joint::create(); //create a joint called RightFingers TempMat.setTranslate(-1.0,0.0,0.0); RightFingers->setJointTransformation(TempMat); NodeRecPtr RightFingersNode = makeNodeFor(RightFingers); RightHandNode->addChild(RightFingersNode); InvBind = RightFingersNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightFingers, InvBind); setName(RightFingers, "Right Fingers Joint"); setName(RightFingersNode, "Right Fingers Node"); /*================================================================================================*/ /* Head */ Head = Joint::create(); //create a joint called Head TempMat.setTranslate(0.0,1.0,0.0); Head->setJointTransformation(TempMat); NodeRecPtr HeadNode = makeNodeFor(Head); ClavicleNode->addChild(HeadNode); InvBind = HeadNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(Head, InvBind); setName(Head, "Head Joint"); setName(HeadNode, "Head Node"); /*================================================================================================*/ /* Left Hip */ LeftHip = Joint::create(); //create a joint called LeftHip TempMat.setTranslate(1.0,-1.0,0.0); LeftHip->setJointTransformation(TempMat); NodeRecPtr LeftHipNode = makeNodeFor(LeftHip); PelvisNode->addChild(LeftHipNode); InvBind = LeftHipNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftHip, InvBind); setName(LeftHip, "Left Hip Joint"); setName(LeftHipNode, "Left Hip Node"); /*================================================================================================*/ /* Left Knee */ LeftKnee = Joint::create(); //create a joint called LeftKnee TempMat.setTranslate(0.0,-3.0,0.0); LeftKnee->setJointTransformation(TempMat); NodeRecPtr LeftKneeNode = makeNodeFor(LeftKnee); LeftHipNode->addChild(LeftKneeNode); InvBind = LeftKneeNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftKnee, InvBind); setName(LeftKnee, "Left Knee Joint"); setName(LeftKneeNode, "Left Knee Node"); /*================================================================================================*/ /* Left Foot */ LeftFoot = Joint::create(); //create a joint called LeftFoot TempMat.setTranslate(0.0,-3.0,0.0); LeftFoot->setJointTransformation(TempMat); NodeRecPtr LeftFootNode = makeNodeFor(LeftFoot); LeftKneeNode->addChild(LeftFootNode); InvBind = LeftFootNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftFoot, InvBind); setName(LeftFoot, "Left Foot Joint"); setName(LeftFootNode, "Left Foot Node"); /*================================================================================================*/ /* Left Toes */ LeftToes = Joint::create(); //create a bone called ExampleChildbone TempMat.setTranslate(0.0,0.0,1.0); LeftToes->setJointTransformation(TempMat); NodeRecPtr LeftToesNode = makeNodeFor(LeftToes); LeftFootNode->addChild(LeftToesNode); InvBind = LeftToesNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(LeftToes, InvBind); setName(LeftToes, "Left Toes Joint"); setName(LeftToesNode, "Left Toes Node"); /*================================================================================================*/ /* Right Hip */ RightHip = Joint::create(); //create a joint called RightHip TempMat.setTranslate(-1.0,-1.0,0.0); RightHip->setJointTransformation(TempMat); NodeRecPtr RightHipNode = makeNodeFor(RightHip); PelvisNode->addChild(RightHipNode); InvBind = RightHipNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightHip, InvBind); setName(RightHip, "Right Hip Joint"); setName(RightHipNode, "Right Hip Node"); /*================================================================================================*/ /* Right Knee */ RightKnee = Joint::create(); //create a joint called RightKnee TempMat.setTranslate(0.0,-3.0,0.0); RightKnee->setJointTransformation(TempMat); NodeRecPtr RightKneeNode = makeNodeFor(RightKnee); RightHipNode->addChild(RightKneeNode); InvBind = RightKneeNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightKnee, InvBind); setName(RightKnee, "Right Knee Joint"); setName(RightKneeNode, "Right Knee Node"); /*================================================================================================*/ /* Right Foot */ RightFoot = Joint::create(); //create a joint called RightFoot TempMat.setTranslate(0.0,-3.0,0.0); RightFoot->setJointTransformation(TempMat); NodeRecPtr RightFootNode = makeNodeFor(RightFoot); RightKneeNode->addChild(RightFootNode); InvBind = RightFootNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightFoot, InvBind); setName(RightFoot, "Right Foot Joint"); setName(RightFootNode, "Right Foot Node"); /*================================================================================================*/ /* Right Toes */ RightToes = Joint::create(); //create a joint called RightToes TempMat.setTranslate(0.0,0.0,1.0); RightToes->setJointTransformation(TempMat); NodeRecPtr RightToesNode = makeNodeFor(RightToes); RightFootNode->addChild(RightToesNode); InvBind = RightToesNode->getToWorld(); InvBind.invert(); ExampleSkeleton->pushToJoints(RightToes, InvBind); setName(RightToes, "Right Toes Joint"); setName(RightToesNode, "Right Toes Node"); //Create a geometry to attach to the skeleton (i.e-> skin) GeoUInt8PropertyUnrecPtr type = GeoUInt8Property::create(); type->push_back(GL_QUADS); GeoUInt32PropertyUnrecPtr lens = GeoUInt32Property::create(); lens->push_back(72); GeoPnt3fPropertyUnrecPtr pnts = GeoPnt3fProperty ::create(); // the points of the Quads //Back pnts->push_back(Pnt3f(-0.5, 6.0, 0)); pnts->push_back(Pnt3f( 0.5, 6.0, 0)); pnts->push_back(Pnt3f( 0.5, 12.0, 0)); pnts->push_back(Pnt3f(-0.5, 12.0, 0)); //Head pnts->push_back(Pnt3f(-0.5, 12, 0)); pnts->push_back(Pnt3f( 0.5, 12, 0)); pnts->push_back(Pnt3f( 0.5, 13, 0)); pnts->push_back(Pnt3f(-0.5, 13, 0)); //Left Shoulder pnts->push_back(Pnt3f(0.0, 11.5, 0)); pnts->push_back(Pnt3f(0.0, 12.5, 0)); pnts->push_back(Pnt3f(1.0, 12.0, 0)); pnts->push_back(Pnt3f(1.0, 11.0, 0)); //Left Humerus pnts->push_back(Pnt3f(1.0, 11.0, 0)); pnts->push_back(Pnt3f(1.0, 12.0, 0)); pnts->push_back(Pnt3f(3.0, 12.0, 0)); pnts->push_back(Pnt3f(3.0, 11.0, 0)); //Left Radius pnts->push_back(Pnt3f(3.0, 11.0, 0)); pnts->push_back(Pnt3f(3.0, 12.0, 0)); pnts->push_back(Pnt3f(5.0, 12.0, 0)); pnts->push_back(Pnt3f(5.0, 11.0, 0)); //Left Hand pnts->push_back(Pnt3f(5.0, 11.0, 0)); pnts->push_back(Pnt3f(5.0, 12.0, 0)); pnts->push_back(Pnt3f(6.0, 12.0, 0)); pnts->push_back(Pnt3f(6.0, 11.0, 0)); //Right Shoulder pnts->push_back(Pnt3f(0.0, 11.5, 0)); pnts->push_back(Pnt3f(0.0, 12.5, 0)); pnts->push_back(Pnt3f(-1.0, 12.0, 0)); pnts->push_back(Pnt3f(-1.0, 11.0, 0)); //Right Humerus pnts->push_back(Pnt3f(-1.0, 11.0, 0)); pnts->push_back(Pnt3f(-1.0, 12.0, 0)); pnts->push_back(Pnt3f(-3.0, 12.0, 0)); pnts->push_back(Pnt3f(-3.0, 11.0, 0)); //Right Radius pnts->push_back(Pnt3f(-3.0, 11.0, 0)); pnts->push_back(Pnt3f(-3.0, 12.0, 0)); pnts->push_back(Pnt3f(-5.0, 12.0, 0)); pnts->push_back(Pnt3f(-5.0, 11.0, 0)); //Right Hand pnts->push_back(Pnt3f(-5.0, 11.0, 0)); pnts->push_back(Pnt3f(-5.0, 12.0, 0)); pnts->push_back(Pnt3f(-6.0, 12.0, 0)); pnts->push_back(Pnt3f(-6.0, 11.0, 0)); //Left Hip pnts->push_back(Pnt3f(0.0, 6.5, 0)); pnts->push_back(Pnt3f(0.5, 7.5, 0)); pnts->push_back(Pnt3f( 1.5, 6.0, 0)); pnts->push_back(Pnt3f(0.5, 6.0, 0)); //Left Femur pnts->push_back(Pnt3f(0.5, 6.0, 0)); pnts->push_back(Pnt3f( 1.5, 6.0, 0)); pnts->push_back(Pnt3f( 1.5, 3.0, 0)); pnts->push_back(Pnt3f(0.5, 3.0, 0)); //Left Tibia pnts->push_back(Pnt3f(0.5, 3.0, 0)); pnts->push_back(Pnt3f( 1.5, 3.0, 0)); pnts->push_back(Pnt3f( 1.5, 0.0, 0)); pnts->push_back(Pnt3f(0.5, 0.0, 0)); //Left Foot pnts->push_back(Pnt3f(0.5, 0.0, 0)); pnts->push_back(Pnt3f( 1.5, 0.0, 0)); pnts->push_back(Pnt3f( 1.5, 0.0, 1.0)); pnts->push_back(Pnt3f(0.5, 0.0, 1.0)); //Right Hip pnts->push_back(Pnt3f(0.0, 6.5, 0)); pnts->push_back(Pnt3f(-0.5, 7.5, 0)); pnts->push_back(Pnt3f( -1.5, 6.0, 0)); pnts->push_back(Pnt3f(-0.5, 6.0, 0)); //Right Femur pnts->push_back(Pnt3f(-0.5, 6.0, 0)); pnts->push_back(Pnt3f( -1.5, 6.0, 0)); pnts->push_back(Pnt3f( -1.5, 3.0, 0)); pnts->push_back(Pnt3f(-0.5, 3.0, 0)); //Right Tibia pnts->push_back(Pnt3f(-0.5, 3.0, 0)); pnts->push_back(Pnt3f( -1.5, 3.0, 0)); pnts->push_back(Pnt3f( -1.5, 0.0, 0)); pnts->push_back(Pnt3f(-0.5, 0.0, 0)); //Right Foot pnts->push_back(Pnt3f(-0.5, 0.0, 0)); pnts->push_back(Pnt3f( -1.5, 0.0, 0)); pnts->push_back(Pnt3f( -1.5, 0.0, 1.0)); pnts->push_back(Pnt3f(-0.5, 0.0, 1.0)); //Normals GeoVec3fPropertyUnrecPtr norms = GeoVec3fProperty ::create(); geo=Geometry::create(); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); //Left Hip norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); //Left Femur norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); //Left Tibia norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); //Left Foot norms->push_back(Vec3f( 0.0,1.0,0.0)); norms->push_back(Vec3f( 0.0,1.0,0.0)); norms->push_back(Vec3f( 0.0,1.0,0.0)); norms->push_back(Vec3f( 0.0,1.0,0.0)); //Right Hip norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); //Right Femur norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); //Right Tibia norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); norms->push_back(Vec3f( 0.0,0.0,1.0)); //Right Foot norms->push_back(Vec3f( 0.0,1.0,0.0)); norms->push_back(Vec3f( 0.0,1.0,0.0)); norms->push_back(Vec3f( 0.0,1.0,0.0)); norms->push_back(Vec3f( 0.0,1.0,0.0)); //Tell the geometry (geo) to use the points and normals we just defined geo->setTypes (type); geo->setLengths (lens); geo->setPositions(pnts); geo->setNormals(norms); // assign a material to the geometry to make it visible. The details // of materials are defined later. geo->setMaterial(getDefaultMaterial()); //Create unbound geometry node (for displaying mesh in its bind pose) UnboundGeometry = Node::create(); UnboundGeometry->setCore(geo); UnboundGeometry->setTravMask(0); //By default, we won't show the mesh's bind pose //SkeletonDrawer SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create(); ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton); ExampleSkeletonDrawable->setMaterial(ExampleMaterial); ExampleSkeletonDrawable->setDrawBindPose(false); //By default, we don't draw the skeleton's bind pose ExampleSkeletonDrawable->setBindPoseColor(Color4f(0.0, 1.0, 0.0, 1.0)); //When drawn, the skeleton's bind pose renders 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 renders blue //Skeleton Node SkeletonNode = Node::create(); SkeletonNode->setCore(ExampleSkeletonDrawable); // Skeleton Blended Geometry // Here we are attaching the "skin" to the skeleton so that when the skeleton is animated, the skin moves with it ExampleSkeleton->setBaseGeometry(geo); //Back ExampleSkeleton->addJointBlending(0,Pelvis,1.0f); ExampleSkeleton->addJointBlending(1,Pelvis,1.0f); ExampleSkeleton->addJointBlending(2,Clavicle,1.0f); ExampleSkeleton->addJointBlending(3,Clavicle,1.0f); //Head ExampleSkeleton->addJointBlending(4,Clavicle,1.0f); ExampleSkeleton->addJointBlending(5,Clavicle,1.0f); ExampleSkeleton->addJointBlending(6,Head,1.0f); ExampleSkeleton->addJointBlending(7,Head,1.0f); //Left Shoulder ExampleSkeleton->addJointBlending(8,Clavicle,1.0f); ExampleSkeleton->addJointBlending(9,Clavicle,1.0f); ExampleSkeleton->addJointBlending(10,LeftShoulder,1.0f); ExampleSkeleton->addJointBlending(11,LeftShoulder,1.0f); //Left Humerus ExampleSkeleton->addJointBlending(12,LeftShoulder,1.0f); ExampleSkeleton->addJointBlending(13,LeftShoulder,1.0f); ExampleSkeleton->addJointBlending(14,LeftElbow,0.8f); ExampleSkeleton->addJointBlending(15,LeftElbow,0.8f); ExampleSkeleton->addJointBlending(14,LeftHand,0.2f); ExampleSkeleton->addJointBlending(15,LeftHand,0.2f); //Left Radius ExampleSkeleton->addJointBlending(16,LeftElbow,1.0f); ExampleSkeleton->addJointBlending(17,LeftElbow,1.0f); ExampleSkeleton->addJointBlending(18,LeftHand,1.0f); ExampleSkeleton->addJointBlending(19,LeftHand,1.0f); //Left Hand ExampleSkeleton->addJointBlending(20,LeftHand,1.0f); ExampleSkeleton->addJointBlending(21,LeftHand,1.0f); ExampleSkeleton->addJointBlending(22,LeftFingers,1.0f); ExampleSkeleton->addJointBlending(23,LeftFingers,1.0f); //Right Shoulder ExampleSkeleton->addJointBlending(24,Clavicle,1.0f); ExampleSkeleton->addJointBlending(25,Clavicle,1.0f); ExampleSkeleton->addJointBlending(26,RightShoulder,1.0f); ExampleSkeleton->addJointBlending(27,RightShoulder,1.0f); //Right Humerus ExampleSkeleton->addJointBlending(28,RightShoulder,1.0f); ExampleSkeleton->addJointBlending(29,RightShoulder,1.0f); ExampleSkeleton->addJointBlending(30,RightElbow,1.0f); ExampleSkeleton->addJointBlending(31,RightElbow,1.0f); //Right Radius ExampleSkeleton->addJointBlending(32,RightElbow,1.0f); ExampleSkeleton->addJointBlending(33,RightElbow,1.0f); ExampleSkeleton->addJointBlending(34,RightHand,1.0f); ExampleSkeleton->addJointBlending(35,RightHand,1.0f); //Right Hand ExampleSkeleton->addJointBlending(36,RightHand,1.0f); ExampleSkeleton->addJointBlending(37,RightHand,1.0f); ExampleSkeleton->addJointBlending(38,RightFingers,1.0f); ExampleSkeleton->addJointBlending(39,RightFingers,1.0f); //Left Hip ExampleSkeleton->addJointBlending(40,Pelvis,1.0f); ExampleSkeleton->addJointBlending(41,Pelvis,1.0f); ExampleSkeleton->addJointBlending(42,LeftHip,1.0f); ExampleSkeleton->addJointBlending(43,LeftHip,1.0f); //Left Femur ExampleSkeleton->addJointBlending(44,LeftHip,1.0f); ExampleSkeleton->addJointBlending(45,LeftHip,1.0f); ExampleSkeleton->addJointBlending(46,LeftKnee,1.0f); ExampleSkeleton->addJointBlending(47,LeftKnee,1.0f); //Left Tibia ExampleSkeleton->addJointBlending(48,LeftKnee,1.0f); ExampleSkeleton->addJointBlending(49,LeftKnee,1.0f); ExampleSkeleton->addJointBlending(50,LeftFoot,1.0f); ExampleSkeleton->addJointBlending(51,LeftFoot,1.0f); //Left Foot ExampleSkeleton->addJointBlending(52,LeftFoot,1.0f); ExampleSkeleton->addJointBlending(53,LeftFoot,1.0f); ExampleSkeleton->addJointBlending(54,LeftToes,1.0f); ExampleSkeleton->addJointBlending(55,LeftToes,1.0f); //Right Hip ExampleSkeleton->addJointBlending(56,Pelvis,1.0f); ExampleSkeleton->addJointBlending(57,Pelvis,1.0f); ExampleSkeleton->addJointBlending(58,RightHip,1.0f); ExampleSkeleton->addJointBlending(59,RightHip,1.0f); //Right Femur ExampleSkeleton->addJointBlending(60,RightHip,1.0f); ExampleSkeleton->addJointBlending(61,RightHip,1.0f); ExampleSkeleton->addJointBlending(62,RightKnee,1.0f); ExampleSkeleton->addJointBlending(63,RightKnee,1.0f); //Right Tibia ExampleSkeleton->addJointBlending(64,RightKnee,1.0f); ExampleSkeleton->addJointBlending(65,RightKnee,1.0f); ExampleSkeleton->addJointBlending(66,RightFoot,1.0f); ExampleSkeleton->addJointBlending(67,RightFoot,1.0f); //Right Foot ExampleSkeleton->addJointBlending(68,RightFoot,1.0f); ExampleSkeleton->addJointBlending(69,RightFoot,1.0f); ExampleSkeleton->addJointBlending(70,RightToes,1.0f); ExampleSkeleton->addJointBlending(71,RightToes,1.0f); MeshNode = Node::create(); MeshNode->setCore(ExampleSkeleton); //Create scene node NodeUnrecPtr scene = Node::create(); scene->setCore(Group::create()); scene->addChild(UnboundGeometry); scene->addChild(SkeletonNode); scene->addChild(MeshNode); mgr->setRoot(scene); //Setup the Animation setupAnimation(); //Save to an xml file FCFileType::FCPtrStore Containers; Containers.insert(ExampleSkeleton); Containers.insert(PelvisNode); Containers.insert(TheSkeletonAnimation); //Use an empty Ignore types vector FCFileType::FCTypeVector IgnoreTypes; //IgnoreTypes.push_back(Node::getClassType().getId()); //Write the Field Containers to a xml file FCFileHandler::the()->write(Containers,BoostPath("./13Output.xml"),IgnoreTypes); // Show the whole Scene mgr->showAll(); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "13MeshBlending"); //Main Loop TutorialWindow->mainLoop(); osgExit(); return 0; }
Action::ResultE MaterialDrawable::renderEnter(Action *action) { RenderAction *a = dynamic_cast<RenderAction *>(action); Material *m = a->getMaterial(); PrimeMaterial *pPrimeMat = NULL; if(m == NULL) { if(this->getMaterial() != NULL) { pPrimeMat = this->getMaterial()->finalize(a->getRenderProperties(), a->getCurrentOverrides(), a->getWindow() ); } } else { pPrimeMat = m->finalize(a->getRenderProperties(), a->getCurrentOverrides(), a->getWindow ()); } if(pPrimeMat == NULL) { pPrimeMat = getDefaultMaterial(); FNOTICE(("MaterialDrawable::render: no Material!?!\n")); } UInt32 uiNPasses = pPrimeMat->getNPasses(); for(UInt32 uiPass = 0; uiPass < uiNPasses; ++uiPass) { State *st = pPrimeMat->getState(uiPass); if(st != NULL) { a->dropFunctor(_drawFunc, st, pPrimeMat->getSortKey() + uiPass); } else { FINFO(("%s: Material %p has NULL state for pass %d\n", OSG_FUNCNAME_MACRO, pPrimeMat, uiPass)); } } if(a->pushVisibility()) { if(a->selectVisibles() == 0) { a->popVisibility(); return Action::Skip; } } return Action::Continue; }