• Advertisement
Sign in to follow this  

No Texture Coordinates loaded afterall?

Recommended Posts

const aiScene* scene=aiImportFile(filename,
        aiProcess_GenSmoothNormals | aiProcess_TransformUVCoords |
        aiProcess_JoinIdenticalVertices |
        aiProcess_Triangulate | aiProcess_ConvertToLeftHanded);
mesh* meshLoader::processMesh(aiMesh* m,const aiScene* scene, const D3DXMATRIX& l_localMat)
{
    std::vector<vertexData> data;
    std::vector<unsigned int> indices;
    std::vector<textureData> textures;
    materialData material;
    aiColor4D col;
    aiMaterial* mat = scene->mMaterials[m->mMaterialIndex];
    

    materialData tmpMat;

    unsigned int l_matId = m->mMaterialIndex;

    tmpMat.matId = l_matId;

    material.matId = tmpMat.matId;
    

    for(int i=0;i<m->mNumVertices;i++)
    {
        vertexData tmp;
        materialData tmpMat;
        vector3d tmpVec;

        //position
        tmpVec.x=m->mVertices[i].x;
        tmpVec.y=m->mVertices[i].y;
        tmpVec.z=m->mVertices[i].z;
        tmp.position=tmpVec;

        //normals
        if (m->HasNormals())
        {
            tmpVec.x=m->mNormals[i].x;
            tmpVec.y=m->mNormals[i].y;
            tmpVec.z=m->mNormals[i].z;
            tmp.normal=tmpVec;
        }
        else
        {
            tmp.normal.x = 0.0f;
            tmp.normal.y = 0.0f;
            tmp.normal.z = 0.0f;
        }


        //tangent
        if(m->HasTangentsAndBitangents())
        {
            tmpVec.x=m->mTangents[i].x;
            tmpVec.y=m->mTangents[i].y;
            tmpVec.z=m->mTangents[i].z;
        }
        else
        {
            tmpVec.x=1.0;
            tmpVec.y=tmpVec.z=0;
        }
        tmp.tangent=tmpVec;


        

        // vertex colors
        //if(m->HasVertexColors(0))
        //{
            //!= material color
        //    tmpVec.x=m->mColors[0][i].r;
        //    tmpVec.y=m->mColors[0][i].g;
        //    tmpVec.z=m->mColors[0][i].b;
        //}
        //else
        //{
        //    tmpVec.x = defaultColor.r;
        //    tmpVec.y = defaultColor.g;
        //    tmpVec.z = defaultColor.b;

        //}
        //tmp.color=tmpVec;

        

        // Texture UV <<<<<< What the heck is going on????
        if(m->mTextureCoords[0])
        {
            tmpVec.x=m->mTextureCoords[0][i].x;
            tmpVec.y=m->mTextureCoords[0][i].y;
        }
        else
        {
            tmpVec.x=tmpVec.y=tmpVec.z=0.0;
        }
        tmp.U=tmpVec.x;
        tmp.V=tmpVec.y;
        data.push_back(tmp);
    }

    // Indices
    for(int i=0;i<m->mNumFaces;i++)
    {
        const aiFace& face=m->mFaces[i];

        for(int j=0;j<face.mNumIndices;j++)
        {
            indices.push_back(face.mIndices[j]);
        }
    }
 
    mesh* _m = new mesh(m_pDevice);
    bool success = _m->init(data, indices, material, textures);  
    if (success)
    {
        return _m;
    }
    
    return NULL;
    
}

When I was iterating the meshes using assimp, each mesh has the mTextureCoordinates set, but all of them are undefined (???)

Strange enough was the texture itself got loaded, but I can't seem to find a way to load the texture coordinates...

any help please...

Thanks

Jack

xof 0303txt 0032
template ColorRGBA {
 <35ff44e0-6c7c-11cf-8f52-0040333594a3>
 FLOAT red;
 FLOAT green;
 FLOAT blue;
 FLOAT alpha;
}

template ColorRGB {
 <d3e16e81-7835-11cf-8f52-0040333594a3>
 FLOAT red;
 FLOAT green;
 FLOAT blue;
}

template Material {
 <3d82ab4d-62da-11cf-ab39-0020af71e433>
 ColorRGBA faceColor;
 FLOAT power;
 ColorRGB specularColor;
 ColorRGB emissiveColor;
 [...]
}

template TextureFilename {
 <a42790e1-7810-11cf-8f52-0040333594a3>
 STRING filename;
}

template Frame {
 <3d82ab46-62da-11cf-ab39-0020af71e433>
 [...]
}

template Matrix4x4 {
 <f6f23f45-7686-11cf-8f52-0040333594a3>
 array FLOAT matrix[16];
}

template FrameTransformMatrix {
 <f6f23f41-7686-11cf-8f52-0040333594a3>
 Matrix4x4 frameMatrix;
}

template Vector {
 <3d82ab5e-62da-11cf-ab39-0020af71e433>
 FLOAT x;
 FLOAT y;
 FLOAT z;
}

template MeshFace {
 <3d82ab5f-62da-11cf-ab39-0020af71e433>
 DWORD nFaceVertexIndices;
 array DWORD faceVertexIndices[nFaceVertexIndices];
}

template Mesh {
 <3d82ab44-62da-11cf-ab39-0020af71e433>
 DWORD nVertices;
 array Vector vertices[nVertices];
 DWORD nFaces;
 array MeshFace faces[nFaces];
 [...]
}

template MeshMaterialList {
 <f6f23f42-7686-11cf-8f52-0040333594a3>
 DWORD nMaterials;
 DWORD nFaceIndexes;
 array DWORD faceIndexes[nFaceIndexes];
 [Material <3d82ab4d-62da-11cf-ab39-0020af71e433>]
}

template VertexElement {
 <f752461c-1e23-48f6-b9f8-8350850f336f>
 DWORD Type;
 DWORD Method;
 DWORD Usage;
 DWORD UsageIndex;
}

template DeclData {
 <bf22e553-292c-4781-9fea-62bd554bdd93>
 DWORD nElements;
 array VertexElement Elements[nElements];
 DWORD nDWords;
 array DWORD data[nDWords];
}


Material _01_-_Default {
 1.000000;1.000000;1.000000;1.000000;;
 9.999999;
 1.000000;1.000000;1.000000;;
 1.000000;1.000000;1.000000;;

 TextureFilename {
  "p1.jpg";
 }
}

Frame SceneRoot {
 

 FrameTransformMatrix {
  1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000;;
 }

 Frame Pallet {
 

  FrameTransformMatrix {
   0.742813,0.000000,0.000000,0.000000,0.000000,0.735100,0.000000,0.000000,0.000000,0.000000,0.742813,0.000000,0.000000,0.000000,-0.000000,1.000000;;
  }

  Frame Box001 {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000;;
   }

   Mesh Box001 {
    24;
    -1.000000;0.000000;-1.000000;,
    1.000000;0.000000;1.000000;,
    -1.000000;0.000000;1.000000;,
    1.000000;0.000000;-1.000000;,
    -1.000000;2.020000;-1.000000;,
    1.000000;2.020000;1.000000;,
    1.000000;2.020000;-1.000000;,
    -1.000000;2.020000;1.000000;,
    -1.000000;0.000000;-1.000000;,
    1.000000;2.020000;-1.000000;,
    1.000000;0.000000;-1.000000;,
    -1.000000;2.020000;-1.000000;,
    1.000000;0.000000;-1.000000;,
    1.000000;2.020000;1.000000;,
    1.000000;0.000000;1.000000;,
    1.000000;2.020000;-1.000000;,
    1.000000;0.000000;1.000000;,
    -1.000000;2.020000;1.000000;,
    -1.000000;0.000000;1.000000;,
    1.000000;2.020000;1.000000;,
    -1.000000;0.000000;1.000000;,
    -1.000000;2.020000;-1.000000;,
    -1.000000;0.000000;-1.000000;,
    -1.000000;2.020000;1.000000;;
    12;
    3;0,1,2;,
    3;1,0,3;,
    3;4,5,6;,
    3;5,4,7;,
    3;8,9,10;,
    3;9,8,11;,
    3;12,13,14;,
    3;13,12,15;,
    3;16,17,18;,
    3;17,16,19;,
    3;20,21,22;,
    3;21,20,23;;

    MeshMaterialList {
     1;
     12;
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0,
     0;
     { _01_-_Default }
    }

    DeclData {
     2;
     2;0;3;0;,
     1;0;5;0;;
     120;
     0,
     3212836864,
     0,
     1065353216,
     1065353216,
     0,
     3212836864,
     0,
     0,
     0,
     0,
     3212836864,
     0,
     1065353216,
     0,
     0,
     3212836864,
     0,
     0,
     1065353216,
     0,
     1065353216,
     0,
     0,
     1065353216,
     0,
     1065353216,
     0,
     1065353216,
     0,
     0,
     1065353216,
     0,
     1065353216,
     1065353216,
     0,
     1065353216,
     0,
     0,
     0,
     0,
     0,
     3212836864,
     0,
     1065353216,
     0,
     0,
     3212836864,
     1065353216,
     0,
     0,
     0,
     3212836864,
     1065353216,
     1065353216,
     0,
     0,
     3212836864,
     0,
     0,
     1065353216,
     0,
     0,
     0,
     1065353216,
     1065353216,
     0,
     0,
     1065353216,
     0,
     1065353216,
     0,
     0,
     1065353216,
     1065353216,
     1065353216,
     0,
     0,
     0,
     0,
     0,
     0,
     1065353216,
     0,
     1065353216,
     0,
     0,
     1065353216,
     1065353216,
     0,
     0,
     0,
     1065353216,
     1065353216,
     1065353216,
     0,
     0,
     1065353216,
     0,
     0,
     3212836864,
     0,
     0,
     0,
     1065353216,
     3212836864,
     0,
     0,
     1065353216,
     0,
     3212836864,
     0,
     0,
     1065353216,
     1065353216,
     3212836864,
     0,
     0,
     0,
     0;
    }
   }
  }

  Frame LeftLowOut {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,-1.000000,0.000000,1.000000,1.000000;;
   }
  }

  Frame MidLowOut {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,1.000000,1.000000;;
   }
  }

  Frame RightLowOut {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.000000,0.000000,1.000000,1.000000;;
   }
  }

  Frame LeftLowMid {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,-1.000000,0.000000,0.000000,1.000000;;
   }
  }

  Frame RightLowMid {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.000000,0.000000,0.000000,1.000000;;
   }
  }

  Frame LeftLowOut_ {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,-1.000000,0.000000,-1.000000,1.000000;;
   }
  }

  Frame MidLowIn {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,-1.000000,1.000000;;
   }
  }

  Frame RightLowIn {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.000000,0.000000,-1.000000,1.000000;;
   }
  }

  Frame LeftUpOut {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,-1.000000,2.020000,1.000000,1.000000;;
   }
  }

  Frame MidUpOut {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,2.020000,1.000000,1.000000;;
   }
  }

  Frame RightUpOut {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.000000,2.020000,1.000000,1.000000;;
   }
  }

  Frame LeftUpMid {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,-1.000000,2.020000,0.000000,1.000000;;
   }
  }

  Frame MidUpMid {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,2.020000,0.000000,1.000000;;
   }
  }

  Frame RightUpMid {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.000000,2.020000,0.000000,1.000000;;
   }
  }

  Frame LeftUpIn {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,-1.000000,2.020000,-1.000000,1.000000;;
   }
  }

  Frame MidUpMid_ {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,2.020000,-1.000000,1.000000;;
   }
  }

  Frame RightUpIn {
   

   FrameTransformMatrix {
    1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,1.000000,2.020000,-1.000000,1.000000;;
   }
  }
 }
}
Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement