Sorry for bumping, I solved the problem. I just realized that Assimp can take .blend files.
Blender and rectangles?
What you can try is exporting the blender model to an 3ds format and then using a 3dslib to import it in your game.
Here : http://www.opengl.org/resources/faq/technical/miscellaneous.htm some more information.
Here : http://www.opengl.org/resources/faq/technical/miscellaneous.htm some more information.
What you can try is exporting the blender model to an 3ds format and then using a 3dslib to import it in your game.
Here : http://www.opengl.or...scellaneous.htm some more information.
So many options! I'll look through and find one I like.
Check out open asset import library: http://sourceforge.net/projects/assimp/
That will let you import data from blender or a number of other sources. You have full access to the data at that point so you can manipulate anything you want.
That will let you import data from blender or a number of other sources. You have full access to the data at that point so you can manipulate anything you want.
Check out open asset import library: http://sourceforge.n...rojects/assimp/
That will let you import data from blender or a number of other sources. You have full access to the data at that point so you can manipulate anything you want.
I decided to go with Assimp, and it sounds like it will work great. I do have one question I forgot to ask earlier. Will this library only handle triangle meshes? I'm not very experienced with 3D graphics, and so far I have been drawing cubes onto the screen just as placeholders. The model that I made in blend is very basic and includes rectangles, but I'm assuming I will eventually want to switch over to a triangle-only mesh system. Does this matter?
IIRC assimp will give you quads or triangles if you specify the proper input flags.
If your mesh has quads in it and you want only triangles, you can give it a flag to triangulate the mesh and give you only triangles. Not sure if you could go the other way (though don't know why you would want to).
If your mesh has quads in it and you want only triangles, you can give it a flag to triangulate the mesh and give you only triangles. Not sure if you could go the other way (though don't know why you would want to).
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
I'm having trouble accessing the faces of the meshes. I used triangulate to make things simpler, but I can't find a way to get individual Triangles and/or points out of
scene->mMeshes[]->mFaces[]
//OR
mFaces[].mIndices
What do you mean by "having trouble". The arrays are empty? You don't understand the data?
Here's a little snippet of my loading code. Cut and pasted from a couple places so not guaranteed to be syntactically perfect.
Here's a little snippet of my loading code. Cut and pasted from a couple places so not guaranteed to be syntactically perfect.
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(RESOURCE_PATH + meshname,aiProcess_GenUVCoords|aiProcess_Triangulate|aiProcess_ValidateDataStructure);
if(!scene){
ALERT(importer.GetErrorString());
}
for(uint i=0;i<scene->mNumMeshes;i++){
aiMesh = scene->mMeshes;
uint numVertices = aiMesh->mNumVertices;
uint numFaces = aiMesh->mNumFaces;
for(uint i=0;i<numVertices;i+=1){
vertices[i*vertexSize] = aiMesh->mVertices.x;
vertices[i*vertexSize+1] = aiMesh->mVertices.y;
vertices[i*vertexSize+2] = aiMesh->mVertices.z;
}
int numIndices = numFaces*3;
uint * indices = new uint[numIndices];
for(uint i=0;i<numFaces;i++){
indices[i*3] = aiMesh->mFaces.mIndices[0];
indices[i*3+1] = aiMesh->mFaces.mIndices[1];
indices[i*3+2] = aiMesh->mFaces.mIndices[2];
}
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Before I read your code, I'd like to say that I got something to work: I can get a bunch of triangles and I finally got the right vertices to show up; however, the triangles connect to the vertices in the wrong order. So I think I am accessing the right points at the wrong times. Earlier I could get triangles, but none of the vertices were right at all. Here is my ugly attempt at loading faces:
edit: I hate this code poster
//Faces
for(UINT j = 0; j < rawMeshes[meshid]->mNumFaces; ++j){
UINT* indices = (UINT*)rawMeshes[meshid[0]]->mFaces[j].mIndices;
Point p0, p1, p2;
p0.x = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[0]].x;
p0.y = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[0]].y;
p0.z = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[0]].z;
p1.x = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[1]].x;
p1.y = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[1]].y;
p1.z = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[1]].z;
p2.x = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[2]].x;
p2.y = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[2]].y;
p2.z = (GLfloat) rawMeshes[meshid[0]]->mVertices[indices[2]].z;
tempTriangle = Triangle(p0, p1, p2);
model->triangle.push_back(tempTriangle);
}
edit: I hate this code poster
I would recommend you start with a very simple model (cube or just a square) and analyze the output to see what might be the problem, nothing you've shown there looks terribly wrong.
I only notice that you are intermixing i and 0 for the mesh you are accessing, which may or may not be a problem.
I only notice that you are intermixing i and 0 for the mesh you are accessing, which may or may not be a problem.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement