Skip to content
Snippets Groups Projects
Select Git revision
  • 9f0dcff29a789a8fac8b79801539875da76fffb1
  • master default protected
  • deploy
  • develop
4 results

meetingController.js

Blame
  • ResourceLoader.cpp 6.77 KiB
    #define STB_IMAGE_IMPLEMENTATION
    #include <stb_image.h>
    
    #include "ResourceLoader.h"
    
    Image::Image(int _width, int _height, int _cahnnel, unsigned char *_data)
    {
    	width = _width;
    	height = _height;
    	channel = _cahnnel;
    	data = _data;
    }
    
    int Image::getWidth()
    {
    	return width;
    }
    
    int Image::getHeight()
    {
    	return height;
    }
    
    unsigned char *Image::getData()
    {
    	return data;
    }
    
    std::string get_extension(const std::string &filePath)
    {
    	return filePath.substr(filePath.find_last_of(".") + 1);
    }
    
    bool openObj(const std::string fileName, std::vector<glm::vec3> &vertices, std::vector<glm::vec2> &vertexTexCoord, std::vector<glm::vec3> &vertexNormals)
    {
    	vertices.clear();
    	vertexTexCoord.clear();
    	vertexNormals.clear();
    
    	std::ifstream ifs;
    	std::string line;
    
    	char op[3];
    	std::vector<glm::vec3> vertexIndices;
    	std::vector<glm::vec2> vertexTexCoordIndices;
    	std::vector<glm::vec3> vertexNormalIndices;
    
    	ifs.open("../Models/" + fileName);
    
    	int charPos = 0;
    	while (std::getline(ifs, line))
    	{
    		if (line[0] == NULL || line[0] == '\n' || line[0] == '#' || line[0] == '!' || line[0] == '$' || line[0] == 'o' || line[0] == 'm' || line[0] == 'u') continue;
    
    		sscanf_s(line.c_str(), "%s", op, sizeof(op));
    
    		charPos = 0;
    		if ((charPos = line.find(' ')) != std::string::npos)
    		{
    			line.erase(0, charPos + 1);
    		}
    
    		if (line[0] == ' ')
    		{
    			line.erase(0, 1);
    		}
    
    		if (strcmp(op, "v") == false)
    		{
    			glm::vec3 pos = { 0,0,0 };