• Content count

  • Joined

  • Last visited

  1. I think you need to download and install the legacy june 2010 directx SDK, because the bewerkt SDK's dont include d3dx11, which is used in luna's book and examples. You can find it on github, might need to build the libs (debug and release) yourself. Which should be relatively easy with some googling (if you've never did this before).
  2. Reinventing the wheel

    My 2 cents; what is your goal? Do you want to learn tech programming because eventually you want to be part of a team/ studio as a engine/ tech developer? Or is learning in general the goal, then you should do and try things you want to learn more about. If your goal is to finish a full game within the shortest time with minimal resources, then using an existing engine and/or framework could work. In short; I'd always start with some goal
  3. Thanks Kylotan. The .data works great. I've decided to stick with reading and writing of uint's, size_t and float. The first 2 I write and read as uint_32t.
  4. Hey. I went for a std::vector of floats which can hold all vertex data independent of the elements. With this I have an enum that tells which elements there are per vertex. This same enum I can now also use for my inputlayouts. Also added a simple helper to retrieve the number of floats for one of the enum values.
  5. Thanks, I think I understand what you mean. For now I've split the pre-processing of the asset to a tool. The resulting mesh file is then read into the runtime engine.
  6. Thanks guys and sorry for the late response. I've adder the ReadXxx and WriteXxx helpers, the code's much cleaner now. I decided to stick with writing/ casting only the individual standard types (float, uint etc). What I didn't figure out yet is how I can read a full chunk of data and "place" that in a std::vector. For example, say that I know that there are 100 floats in the file, would it be possible to read them all at once and place them in a std::vector<float> (with a size of 100)?
  7. Thanks. I actually already splitted that up to the asset pipeline tool. The mesh data I'm loading is already "made ready" to be loaded at runtime. The only problem is that I want to store the mesh data in my intermediate data structure, in a way that I can directly send it to the GPU (in the mesh class). Which so far I only schiefer by having a std::vector of all possible vertex formats in the struct (and using the one that's applicable for the specific mesh. If I use one big struct with all possible vertex elementen and just use the ones I need, then I need to copy all data to the correct struct right before creating the buffer (within the mesh class).
  8. Hi all, I'm struggling with the following workflow I have in my engine: 1. Prepare mesh in my asset tool, resulting in a nicely organized/ stripped chunk of mesh data (in a binary file) 2. Load the binary file with meshdata (deserialization) 3. Create a mesh object with it's GPU buffers etc. Currently I've split the deserialization from the mesh class, because I think it's a good idea to have all binary IO/ serealization code separated from the logics that use the data. When something has to change on the IO side, I can simply change that piece of code. The downside of this, is that steps 2 and 3 need some intermediate data structure, where the mesh data is stored, and which is then used by the mesh class for creating buffers, setting properties etc. Consider this struct: struct MESHDATA { std::vector<Vertex::PosNormTanTex> VerticesA; std::vector<uint> Indices; uint NrChunks; PHYSMATH::CR_BV BoundingVolume; std::vector<SUBMESH> Chunks; MESHDATA() : NrChunks(0) { } }; This all works fine as long as the mesh's vertices have a Position, Normal, Tangent and texcoord. One solution would be to give the meshdata struct a vector of the 'maxxed out' vertex type (with all possible elements), and then only store the elements that are available (leaving the rest empty). This would work, but then right before I create the GPU vertexbuffer, I would need to copy over all data to a vector of the right struct, before I create the buffer. My goal is to prevent this additional copy of all vertices on the CPU side. The only solution I've come up with so far, is this: struct MESHDATA { std::vector<Vertex::PosNormTanTex> VerticesA; std::vector<Vertex::PosNormCol> VerticesB; std::vector<Vertex::PosNormCol> .... ; // for all vertex types Vertex::Type VertexType; // used to select the applicable std::vector std::vector<uint> Indices; uint NrChunks; PHYSMATH::CR_BV BoundingVolume; std::vector<SUBMESH> Chunks; MESHDATA() : VertexType(Vertex::Type::UNKNOWN), NrChunks(0) { } }; I know this works, but I was wondering if someone has better thoughts on how to tackle this. The only downside here, I think, is having a bunch of unused std::vector's, but this doesn't really has to be an issue since it's only temporary/ on the stack when I load up meshes. Note; I understand how I can determine the inputlayout/ vertexlayout, it's just that I'm looking for a way to store the data in the intermediate datastructure, and being able to use the data directly for sending it to the GPU (in the right format/ struct). Any input is appreciated.
  9. Do you mean first writing everything to a char array (aka buffer) and then write that buffer to file? That could work, but then I have to calculate the index manually, which could be a risk if some type has a different bytesize on another problem (writing per variable and using sizeof, I think prevents this). In your example, shouldn't 3 be 4 (bytes for a float)? But perhaps there's a way to use a buffer while keeping this in mind (or don't manually calculate the index of each variable).
  10. Thanks. The VECTOR3 is my struct, so it's working for both an individual struct as a std::vector of them. Thanks
  11. What's with the downvote? Can someone enlighten me so I know how to do it right/ better.
  12. Thanks guys. I've been playing around using this input. Unfortunately writing the struct or array (std::vector) at once, doesn't work by trying to cast to (myType*), it does work when I cast it to (char*). See the code samples below, tested all 3 positive. Would I have any risks on this approach, depending on platform? (size of float etc.). I'll make sure the struct I use as a POD struct, which is the case in the example below. void ReadWriteStruct() { std::ofstream writeFile;"data.bin", std::ios::out, std::ios::binary); writeFile.write((char*)&srcVector, sizeof(VECTOR3)); writeFile.close(); MessageBox(NULL, L"Vector written to binary file - full struct!", L"Done", MB_OK); std::ifstream readFile;"data.bin", std::ios::in, std::ios::binary); VECTOR3 myReadVec3;*)&myReadVec3, sizeof(VECTOR3)); readFile.close(); char tempText[100]; sprintf_s(tempText, "Read: %f, %f, %f\n", myReadVec3.x, myReadVec3.y, myReadVec3.z); OutputDebugStringA(tempText); } void ReadWriteArray() { std::vector<VECTOR3> myVectors(2); myVectors[0].x = 0.2f; myVectors[0].y = 0.7f; myVectors[0].z = 0.95f; myVectors[1].x = 5.2f; myVectors[1].y = 4.7f; myVectors[1].z = 7.75f; std::ofstream writeFile;"data.bin", std::ios::out, std::ios::binary); writeFile.write((char*)&myVectors[0], myVectors.size() * sizeof(VECTOR3)); writeFile.close(); MessageBox(NULL, L"Vector written to binary file - full struct!", L"Done", MB_OK); std::ifstream readFile;"data.bin", std::ios::in, std::ios::binary); std::vector<VECTOR3> readVectors(2);*)&readVectors[0], sizeof(VECTOR3));*)&readVectors[1], sizeof(VECTOR3)); readFile.close(); char tempText[100]; sprintf_s(tempText, "Read 1: %f, %f, %f\n", readVectors[0].x, readVectors[0].y, readVectors[0].z); OutputDebugStringA(tempText); sprintf_s(tempText, "Read 2: %f, %f, %f\n", readVectors[1].x, readVectors[1].y, readVectors[1].z); OutputDebugStringA(tempText); }
  13. Hi all, For practice I'm trying to write 3D mesh data to a binary format. To eventually also be able to read meshes from binary files (provided by the asset pipeline). I understand how to write floats, vectors of floats, ints etc by using a write((char*)myVar, sizeof(type) to the file, for which I'm using std::ofstream. My goal is to write a 3D vector or other type (struct) to the file and be able to read it back the same way. From what I understand, I need to create function that returns a char array combining all members of the struct. So in short; how can I create this char array, in a "safe" way? So far I've come up with this approach: - calculate number of needed bytes/chars, i.e 12 bytes for a 3D vector with 3 floats - char result[12] - cast the 3 individual floats to char[4]'s and use strcpy to result for the 1st and strcat for the others Is this the way to go or would you suggest other approaches? question 2; How would I read/convert the char array back to the 3 floats when reading it from the binary file? Any input is appreciated.
  14. 3D Mesh data (format)

    My bad, appearantly I misread. Thanks all, enough thinking; time to experiment
  15. 3D Mesh data (format)

    @_Silence_ : assimp can import .max according to the documentation. I think I'll make a branch for the transform (offsets versus matrix), depending on animated or not. I also like the idea to "pre-transform" static mesh children, this can save quite some realtime matrix muls.