Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /
- // main.cpp
- // 3d_test
- //
- #include <iostream>
- #include "assimp/Importer.hpp"
- #include "assimp/cimport.h"
- #include "assimp/scene.h"
- #include "assimp/postprocess.h"
- // Includes for Embree:
- #include "embree2/rtcore.h"
- #include "embree2/rtcore_ray.h"
- // Embree boost:
- #include <xmmintrin.h>
- #include <pmmintrin.h>
- // Vectors:
- #include <vector>
- using std::vector;
- class Buffer {
- vector<aiVector3D> vertices;
- vector<int> indices;
- };
- void importer() {
- Assimp::Importer importer;
- const char * path = "model.obj";
- auto scene = importer.ReadFile(path, aiProcess_Triangulate
- | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_JoinIdenticalVertices);
- // Keeping the data here for now
- unsigned int num_of_vertices = 0;
- unsigned int num_of_faces = 0;
- if (!scene) {
- printf("WTF, MAN?\n");
- }
- else {
- auto pmesh = scene -> mMeshes;
- auto mesh = *pmesh;
- auto geomID = rtcNewTriangleMesh(new_scene, RTC_GEOMETRY_STATIC, mesh->mNumFaces, mesh->mNumVertices);
- auto num_of_mashes = scene -> mNumMeshes;
- auto meshes = scene -> mMeshes;
- for (; pmesh < meshes + num_of_mashes; pmesh++) {
- auto mesh = *pmesh;
- auto vertices = mesh->mVertices;
- num_of_vertices = mesh->mNumVertices;
- //auto num_of_faces = mesh->mNumFaces;
- num_of_faces = mesh->mNumFaces;
- auto faces = mesh->mFaces;
- for (auto face = faces; face < faces + num_of_faces; face++) {
- auto idx = face->mIndices;
- auto p1 = vertices[idx[0]];
- auto p2 = vertices[idx[1]];
- auto p3 = vertices[idx[2]];
- printf("%u : {%.2f, %.2f, %.2f}, %u : {%.2f, %.2f, %.2f}, %u : {%.2f, %.2f, %.2f}\n",
- idx[0], p1.x, p1.y, p1.z, idx[1], p2.x, p2.y, p2.z, idx[2], p3.x, p3.y, p3.z);
- }
- }
- }
- }
- int main(int argc, const char * argv[]) {
- // Embree boost enabled:
- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
- _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
- importer();
- // Object imported
- // Setting up scene:
- //Init app startup:
- RTCDevice device = rtcNewDevice(NULL);
- // Create scene
- RTCScene new_scene = rtcDeviceNewScene(device, RTC_SCENE_STATIC, RTC_INTERSECT1);
- // Add geometry
- // Construct of type: unsigned int geomID = rtcNewTriangleMesh(main_scene, numTriangles, numVertices, 1);
- //unsigned int geomID = rtcNewTriangleMesh(new_scene, size_t(num_of_faces), size_t(num_of_vertices), 1);
- // Commit changes
- rtcCommit(new_scene);
- // Raytrace
- // Cleanup
- rtcDeleteScene(new_scene);
- rtcDeleteDevice(device);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement