Esempio n. 1
0
 // method to open output files for writing
 bool ParamList::openFiles()
 {
     std::string msg;
     if (exportMaterial)
     {
         outMaterial.open(materialFilename.c_str());
         if (!outMaterial)
         {
             FxOgreFBXLog( "Error opening file: %s\n", materialFilename.c_str());
             return false;
         }
     }
     if (exportAnimCurves)
     {
         outAnim.open(animFilename.c_str());
         if (!outAnim)
         {
             FxOgreFBXLog( "Error opening file: %s\n", animFilename.c_str());
             return false;
         }
     }
     if (exportCameras)
     {
         outCameras.open(camerasFilename.c_str());
         if (!outCameras)
         {
             FxOgreFBXLog( "Error opening file: %s\n", camerasFilename.c_str());
             return false;
         }
     }
     if (exportParticles)
     {
         outParticles.open(particlesFilename.c_str());
         if (!outParticles)
         {
             FxOgreFBXLog( "Error opening file: %s\n", particlesFilename.c_str());
             return false;
         }
     }
     return true;
 }
Esempio n. 2
0
std::string FxOgreScene::getLightTypeString(FxOgreLightType type)
{
    switch( type )
    {
    case OGRE_LIGHT_POINT:
        return std::string("point");
    case OGRE_LIGHT_DIRECTIONAL:
        return std::string("directional");
    case OGRE_LIGHT_SPOT:
        return std::string("spot");
    case OGRE_LIGHT_RADPOINT:
        return std::string("radpoint");
    }
    FxOgreFBXLog( "Invalid light type detected. Using point light as default.\n");
    return("point");
}
Esempio n. 3
0
    bool Submesh::load(FbxNode* pNode, FbxMesh* pMesh, const std::vector<face>& faces, const std::vector<vertexInfo>& vertInfo, const std::vector<FbxVector4>& points, 
        const std::vector<FbxVector4>& normals, const std::vector<int>& texcoordsets, ParamList& params, const FbxAMatrix& bindPose, bool opposite )
    {
        //save the mesh from which this submesh will be created
        m_pNode = pNode;

        size_t i,j,k;
        FxOgreFBXLog( "Loading submesh associated to material: %s ...\n", m_pMaterial->name().c_str());
        
        //save uvsets info
        for (i=m_uvsets.size(); i<texcoordsets.size(); i++)
        {
            uvset uv;
            uv.size = 2;
            m_uvsets.push_back(uv);
        }
        //iterate over faces array, to retrieve vertices info
        for (i=0; i<faces.size(); i++)
        {
            face newFace;
            // if we are using shared geometry, indexes refer to the vertex buffer of the whole mesh
            if (params.useSharedGeom)
            {
                if(opposite)
                {	// reverse order of face vertices for correct culling
                    newFace.v[0] = faces[i].v[2];
                    newFace.v[1] = faces[i].v[1];
                    newFace.v[2] = faces[i].v[0];
                }
                else
                {
                    newFace.v[0] = faces[i].v[0];
                    newFace.v[1] = faces[i].v[1];
                    newFace.v[2] = faces[i].v[2];
                }
            }
            // otherwise we create a vertex buffer for this submesh
            else
            {	// faces are triangles, so retrieve index of the three vertices
                for (j=0; j<3; j++)
                {
                    vertex v;
                    vertexInfo vInfo = vertInfo[faces[i].v[j]];
                    // save vertex coordinates (rescale to desired length unit)
                    assert(vInfo.pointIdx >= 0 && vInfo.pointIdx < static_cast<int>(points.size()));
                    FbxVector4 point = points[vInfo.pointIdx] * params.lum;
                    if (fabs(point[0]) < PRECISION)
                        point[0] = 0;
                    if (fabs(point[1]) < PRECISION)
                        point[1] = 0;
                    if (fabs(point[2]) < PRECISION)
                        point[2] = 0;
                    v.x = point[0];
                    v.y = point[1];
                    v.z = point[2];
                    // save vertex normal
                    assert(vInfo.normalIdx >= 0 && vInfo.normalIdx < static_cast<int>(normals.size()));
                    FbxVector4 normal = normals[vInfo.normalIdx];
                    if (fabs(normal[0]) < PRECISION)
                        normal[0] = 0;
                    if (fabs(normal[1]) < PRECISION)
                        normal[1] = 0;
                    if (fabs(normal[2]) < PRECISION)
                        normal[2] = 0;
                    v.n.x = normal[0];
                    v.n.y = normal[1];
                    v.n.z = normal[2];
                    if (opposite)
                    {
                        // Reversing the winding order appears to be sufficent.
                        v.n.x = -normal[0];
                        v.n.y = -normal[1];
                        v.n.z = -normal[2];
                    }
                    v.n.Normalize();

                    // save vertex color
                    v.r = vInfo.r;
                    v.g = vInfo.g;
                    v.b = vInfo.b;
                    v.a = vInfo.a;
                    // save vertex bone assignements
                    for (k=0; k<vInfo.vba.size(); k++)
                    {
                        vba newVba;
                        newVba.jointIdx = vInfo.jointIds[k];
                        newVba.weight = vInfo.vba[k];
                        v.vbas.push_back(newVba);
                    }
                    // save texture coordinates
                    for (k=0; k<vInfo.u.size(); k++)
                    {
                        texcoord newTexCoords;
                        newTexCoords.u = vInfo.u[k];
                        newTexCoords.v = vInfo.v[k];
                        newTexCoords.w = 0;
                        v.texcoords.push_back(newTexCoords);
                    }
                    // save vertex index in mesh, to retrieve future positions of the same vertex
                    v.index = vInfo.pointIdx;
                    // add newly created vertex to vertex list
                    m_vertices.push_back(v);
                    if (opposite)	// reverse order of face vertices to get correct culling
                        newFace.v[2-j] = static_cast<int>(m_vertices.size()) - 1;
                    else
                        newFace.v[j] = static_cast<int>(m_vertices.size()) - 1;
                }
            }
            m_faces.push_back(newFace);
        }
        // set use32bitIndexes flag
        if (params.useSharedGeom || (m_vertices.size() > 65535) || (m_faces.size() > 65535))
            m_use32bitIndexes = true;
        else
            m_use32bitIndexes = false;

        pMesh->ComputeBBox();
        FbxDouble3 minDouble = pMesh->BBoxMin.Get();
        FbxDouble3 maxDouble = pMesh->BBoxMax.Get();

        FbxVector4 min = bindPose.MultT( FbxVector4(minDouble[0],minDouble[1],minDouble[2],0));
        FbxVector4 max = bindPose.MultT( FbxVector4(maxDouble[0],maxDouble[1],maxDouble[2],0));

        m_bbox.merge(Point3(max[0], max[1], max[2]));
        m_bbox.merge(Point3(min[0], min[1], min[2]));
        

        // add submesh pointer to m_params list
        params.loadedSubmeshes.push_back(this);

        FxOgreFBXLog( "DONE\n");
        
        return true;
    }