Created
November 10, 2014 23:08
-
-
Save mattnewport/1352a031be58bde028c0 to your computer and use it in GitHub Desktop.
Simple Mesh initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
using namespace std; | |
struct Vector3 { float x, y, z; }; | |
struct Mesh { | |
vector<Vector3> positions; | |
vector<int> indices; | |
}; | |
int main() { | |
// initialize a Mesh with explicit verts and indices | |
Mesh myMesh { { { 0.f, 0.f, 0.f }, { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f } }, | |
{ 0, 1, 2 } }; | |
// initialize a Mesh with iterator pairs | |
Mesh mySecondMesh { { begin(myMesh.positions), end(myMesh.positions) }, | |
{ begin(myMesh.indices), end(myMesh.indices) } }; | |
// initialize a Mesh as a copy of an existing mesh | |
Mesh myThirdMesh = myMesh; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment