In this section, we need to write the vertex layout in the file. For convenience, it is inconvenient to place a large string of very abstract coordinates together with CPP and programs.
The following are all c ++ knowledge to read data in a specific format in the file:
Vertex Count: 36Data:-1.0 1.0 -1.0 0.0 0.0 0.0 0.0 -1.0 1.0 1.0 -1.0 1.0 0.0 0.0 0.0 -1.0-1.0 -1.0 -1.0 0.0 1.0 0.0 0.0 -1.0-1.0 -1.0 -1.0 0.0 1.0 0.0 0.0 -1.0 1.0 1.0 -1.0 1.0 0.0 0.0 0.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 0.0 0.0 -1.0 1.0 1.0 -1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0 1.0 0.0 0.0 1.0 -1.0 -1.0 0.0 1.0 1.0 0.0 0.0 1.0 -1.0 -1.0 0.0 1.0 1.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0 1.0 0.0 0.0 1.0 -1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0-1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0 1.0 -1.0 1.0 0.0 1.0 0.0 0.0 1.0 1.0 -1.0 1.0 0.0 1.0 0.0 0.0 1.0-1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0-1.0 -1.0 1.0 1.0 1.0 0.0 0.0 1.0-1.0 1.0 1.0 0.0 0.0 -1.0 0.0 0.0-1.0 1.0 -1.0 1.0 0.0 -1.0 0.0 0.0-1.0 -1.0 1.0 0.0 1.0 -1.0 0.0 0.0-1.0 -1.0 1.0 0.0 1.0 -1.0 0.0 0.0-1.0 1.0 -1.0 1.0 0.0 -1.0 0.0 0.0-1.0 -1.0 -1.0 1.0 1.0 -1.0 0.0 0.0-1.0 1.0 1.0 0.0 0.0 0.0 1.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0-1.0 1.0 -1.0 0.0 1.0 0.0 1.0 0.0-1.0 1.0 -1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 -1.0 1.0 1.0 0.0 1.0 0.0-1.0 -1.0 -1.0 0.0 0.0 0.0 -1.0 0.0 1.0 -1.0 -1.0 1.0 0.0 0.0 -1.0 0.0-1.0 -1.0 1.0 0.0 1.0 0.0 -1.0 0.0-1.0 -1.0 1.0 0.0 1.0 0.0 -1.0 0.0 1.0 -1.0 -1.0 1.0 0.0 0.0 -1.0 0.0 1.0 -1.0 1.0 1.0 1.0 0.0 -1.0 0.0
The data is like the above, so there will be no index points, and each vertex will automatically repeat.
# Include <iostream> # include <fstream> using namespace STD; int main () {ifstream in; In. Open ("cube.txt"); If (! In) {cout <"Open failed" <Endl ;}else {cout <"Open successful" <Endl ;}char ch; int count; float f [8]; while (CH = in. get (), ch! = ':'); // Skip "vertex count:" In> count; cout <count <Endl; while (CH = in. Get (), ch! = ':'); // Skip "data:" While (! In. EOF () {for (INT I = 0; I <8; I ++) in> F [I]; for (INT I = 0; I <8; I ++) cout <F [I] <""; cout <Endl;} In. close (); In. clear (); getchar ();}
The above is pure C ++ code, just a read column. Next, we will update how to apply it in model initialization.
Please note: younfor blog notes, http://blog.csdn.net/cq361106306/article/details/40300205
Directx11 Study Notes 10-use a file to store the vertex Layout