mercredi 1 août 2018

vector push_back() gives the compiler error C2280

I am trying to append a custom class object to a vector of the same type, however when i try to compile my code, the compiler gives the following error

gltf::gltf(const gltf &): attempting to reference a deleted function

my function takes a string (file name) as an argument and loads that file, then parses the file and populates it's variables

the function is as follows:-

void enigma::loadModel(std::string file)
{       

    gltf stagingModel;
    stagingModel.loadAsset(file);   // populates my object with data
    model.push_back(stagingModel);  // appends the populated object to a vector array (this line generates the error)

    ....   // the rest of the code
}

my gltf class decleration is as follows:-

#pragma once
#include <iostream>
#include <vector>
#include <sstream>
#include <fstream>
#include "meshClass.h"
#include "bufferClass.h"
#include <gtx/quaternion.hpp>
#include <gtx/transform.hpp>

#include"stagingNodeClass.h"
#include"stagingMeshClass.h"
#include"stagingAccessorClass.h"
#include"stagingBufferViewClass.h"
#include"stagingImageClass.h"
#include"stagingSamplerClass.h"
#include"stagingTextureClass.h"
#include"stagingMaterialClass.h"
#include"stagingSkinClass.h"

class gltf
{
public:
    gltf();
    ~gltf();

    std::vector<meshClass> mesh;
    std::vector<char> bin;
    glm::mat4 camera;
    glm::mat4 scale;
    void loadAsset(std::string);

private:
    std::vector<stagingNodeClass> stagingNode;
    std::vector<stagingMeshClass> stagingMesh;
    std::vector<stagingAccessorClass> stagingAccessor;
    std::vector<stagingBufferViewClass>  stagingBufferView;
    std::vector<stagingImageClass> stagingImage;
    stagingSamplerClass stagingSampler;
    std::vector<stagingTextureClass> stagingTexture;
    std::vector<stagingMaterialClass> stagingMaterial;
    stagingSkinClass stagingSkins;
    bufferClass stagingBuffer;
    bool isCamera = false;

    bool node(std::string, std::string);
    int getValue(std::string);
    int getCamIndex(std::string);
    glm::mat4 getMatrix(std::string);
    glm::vec3 getVec3();
    glm::vec4 getVec4();
    float getFloatValue(std::string);
    void initScale();

    std::vector<int> getIntArray();
    std::vector<float> getFloatArray();

    std::string getName(std::string);

    std::fstream  asset;
    std::string line;

};

Aucun commentaire:

Enregistrer un commentaire