Commit b5c2a6de authored by Ilya Prokhorov's avatar Ilya Prokhorov

Fixed by aStyle

parent 0647d42e
......@@ -59,7 +59,7 @@ public:
private:
float testCameraRotation = 0;
float testCameraRotation = 0;
unique_ptr<FSGLCore> core;
};
......
......@@ -23,24 +23,24 @@ FSGLCamera::FSGLCamera()
glm::mat4 FSGLCamera::matrix()
{
auto cameraMatrix = FSGLObject::matrix();
auto cameraPositionVector = cameraMatrix * glm::vec4(0.f, 0.f, 0.f, 1.f);
auto cameraMatrix = FSGLObject::matrix();
auto cameraPositionVector = cameraMatrix * glm::vec4(0.f, 0.f, 0.f, 1.f);
auto yaw = glm::radians(cameraX - rotationVector->x);
auto pitch = glm::radians(cameraY - rotationVector->y);
auto yaw = glm::radians(cameraX - rotationVector->x);
auto pitch = glm::radians(cameraY - rotationVector->y);
glm::vec3 front;
front.x = cos(pitch) * cos(yaw);
front.y = sin(pitch);
front.z = cos(pitch) * sin(yaw);
glm::vec3 front;
front.x = cos(pitch) * cos(yaw);
front.y = sin(pitch);
front.z = cos(pitch) * sin(yaw);
auto cameraFront = glm::normalize(front);
auto targetPosition = glm::vec3(cameraPositionVector) + glm::vec3(cameraFront);
auto cameraFront = glm::normalize(front);
auto targetPosition = glm::vec3(cameraPositionVector) + glm::vec3(cameraFront);
auto upVector = glm::normalize(glm::vec4(0.0f,1.0f,0.0f,0.0f));
cameraMatrix = glm::lookAt(glm::vec3(cameraPositionVector), targetPosition, glm::vec3(upVector));
auto upVector = glm::normalize(glm::vec4(0.0f,1.0f,0.0f,0.0f));
cameraMatrix = glm::lookAt(glm::vec3(cameraPositionVector), targetPosition, glm::vec3(upVector));
return cameraMatrix;
return cameraMatrix;
}
FSGLCamera::~FSGLCamera()
......
......@@ -25,8 +25,8 @@ public:
virtual glm::mat4 matrix();
private:
float cameraX = -90.0f;
float cameraY = 0;
float cameraX = -90.0f;
float cameraY = 0;
};
......
......@@ -32,7 +32,6 @@ int FSGLMesh::glVertexCount()
{
vector<string> vertexFieldsDescription =
{
"x",
"y",
"z",
......@@ -173,7 +172,7 @@ void FSGLMesh::updateGlData()
glIndicesBufferSize = indices.size() * sizeof (GLushort);
glIndicesCount = indices.size();
isGLDataPrepared = true;
isGLDataPrepared = true;
}
......
......@@ -82,7 +82,7 @@ public:
shared_ptr<AnimationTransformationMatrix> animationTransformationMatrixWithName(shared_ptr<string> name);
bool isGLDataPrepared = false;
bool isGLDataPrepared = false;
};
......
......@@ -89,10 +89,10 @@ bool FSGLModel::isValid()
cout << "No material for mesh - not valid" << endl;
return false;
}
if (mesh->verticesObjects.size() < 1) {
if (mesh->verticesObjects.size() < 1) {
cout << "No vertices in mesh - not valid" << endl;
return false;
}
return false;
}
}
return true;
......@@ -175,7 +175,7 @@ shared_ptr<FSGLModel> FSGLModel::deserializeFromString(shared_ptr<string> serial
while (std::getline(f, line))
{
std::cout << line << std::endl;
std::cout << line << std::endl;
if (line.find("Mesh") != std::string::npos)
{
......@@ -492,6 +492,7 @@ std::cout << line << std::endl;
else if (line.find("Vertex - ") != std::string::npos)
{
//std::regex r(".*x = (.*), y = (.*), z = (.*), u = (.*), v = (.*), vN = (.*)");
std::regex r(".*x = (.*), y = (.*), z = (.*), u = (.*), v = (.*)");
std::smatch m;
std::regex_search(line, m, r);
......@@ -501,6 +502,7 @@ std::cout << line << std::endl;
float z = stof(m[3].str());
float u = stof(m[4].str());
float v = stof(m[5].str());
//float vN = stof(m[6].str());
if (mesh.get() == nullptr)
{
......@@ -509,6 +511,7 @@ std::cout << line << std::endl;
exit(1);
}
//auto vertexObject = make_shared<FSGLVertex>(x, y, z, u, v, vN);
auto vertexObject = make_shared<FSGLVertex>(x, y, z, u, v);
mesh->verticesObjects.push_back(vertexObject);
......@@ -553,32 +556,32 @@ std::cout << line << std::endl;
if (convertedMaterial.get() == nullptr)
{
convertedMaterial = make_shared<FSGLMaterial>(texturePath);
if (*texturePath == string("<No Path>")) {
}
else {
if (*texturePath == string("<No Path>")) {
}
else {
auto surface = IMG_Load(convertedMaterial->texturePath->c_str());
if (surface == nullptr)
{
auto surface = IMG_Load(convertedMaterial->texturePath->c_str());
string errorString = "FSGLModelLoaderAssimp: cannot load texture: ";
errorString += convertedMaterial->texturePath->c_str();
if (surface == nullptr)
{
throw runtime_error(errorString);
}
string errorString = "FSGLModelLoaderAssimp: cannot load texture: ";
errorString += convertedMaterial->texturePath->c_str();
throw runtime_error(errorString);
}
SDL_PixelFormat *pixelFormat = SDL_AllocFormat(SDL_PIXELFORMAT_RGBA32);
SDL_Surface *resultSurface = SDL_ConvertSurface(surface, pixelFormat, 0);
SDL_FreeSurface(surface);
SDL_FreeFormat(pixelFormat);
SDL_PixelFormat *pixelFormat = SDL_AllocFormat(SDL_PIXELFORMAT_RGBA32);
SDL_Surface *resultSurface = SDL_ConvertSurface(surface, pixelFormat, 0);
SDL_FreeSurface(surface);
SDL_FreeFormat(pixelFormat);
convertedMaterial->surface = resultSurface;
convertedMaterial->surface = resultSurface;
materialLibrary->setMaterialForPath(convertedMaterial, texturePath);
}
materialLibrary->setMaterialForPath(convertedMaterial, texturePath);
}
}
mesh->material = convertedMaterial;
......@@ -598,7 +601,7 @@ std::cout << line << std::endl;
}
}
cout << "FSGLModel: deserialized from string with meshes count: " << model->meshes.size() << endl;
cout << "FSGLModel: deserialized from string with meshes count: " << model->meshes.size() << endl;
return model;
}
......
#ifndef FSGLVERTEX_H
#define FSGLVERTEX_H
#include <memory>
#include <map>
......@@ -22,10 +21,12 @@ class FSGLVertex
{
public:
//FSGLVertex(float x, float y, float z, float u, float v, float vertexNormal);
FSGLVertex(float x, float y, float z, float u, float v);
shared_ptr<FSGLVector> position;
shared_ptr<FSGLUVTextureCoordinates> uvTextureCoordinates;
weak_ptr<FSGLMesh> mesh;
void setWeigthForMatrixAtIndex(float vertexWeight, int matrixIndex);
......
......@@ -311,13 +311,13 @@ SDL_Window* OGLNewAgeRenderer::initializeWindow(shared_ptr<IOSystemParams> param
height = mode.h;
window = SDL_CreateWindow(
title,
0,
0,
width,
height,
SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE
);
title,
0,
0,
width,
height,
SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE
);
#else
window = SDL_CreateWindow(
title,
......@@ -328,7 +328,7 @@ SDL_Window* OGLNewAgeRenderer::initializeWindow(shared_ptr<IOSystemParams> param
flags
);
#endif
if (window == NULL)
{
......@@ -432,7 +432,7 @@ SDL_Window* OGLNewAgeRenderer::initializeWindow(shared_ptr<IOSystemParams> param
void OGLNewAgeRenderer::addObject(shared_ptr<FSGLObject> object)
{
cout << "OGLNewAgeRenderer::addObject(shared_ptr<FSGLObject> object)" << endl;
cout << "OGLNewAgeRenderer::addObject(shared_ptr<FSGLObject> object)" << endl;
auto model = object->model;
auto size = model->meshes.size();
......@@ -465,7 +465,7 @@ void OGLNewAgeRenderer::addObject(shared_ptr<FSGLObject> object)
void OGLNewAgeRenderer::render()
{
//cout << "OGLNewAgeRenderer::render()" << endl;
//cout << "OGLNewAgeRenderer::render()" << endl;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearDepthf(1.0f);
......@@ -480,7 +480,7 @@ void OGLNewAgeRenderer::render()
glClear(GL_DEPTH_BUFFER_BIT);
glClearDepthf(1.0f);
//cout << "OGLNewAgeRenderer::render objects: " << objects.size() << endl;
//cout << "OGLNewAgeRenderer::render objects: " << objects.size() << endl;
for (auto object : objects)
{
......@@ -507,7 +507,7 @@ void OGLNewAgeRenderer::render()
}
}
glFinish();
glFinish();
SDL_GL_SwapWindow(window);
}
......@@ -533,21 +533,21 @@ shared_ptr<FSGLObject> OGLNewAgeRenderer::getObjectWithID(string id)
void OGLNewAgeRenderer::renderObject(shared_ptr<FSGLObject> object)
{
//cout << "Render object" << endl;
//cout << "Render object" << endl;
auto model = object->model;
if (model->isValid() != true) {
throwRuntimeException("Can't render - model self validation return false. Malformed model data?");
}
if (model->isValid() != true) {
throwRuntimeException("Can't render - model self validation return false. Malformed model data?");
}
for (unsigned int meshIndex = 0; meshIndex < model->meshes.size(); meshIndex++)
{
auto mesh = model->meshes[meshIndex];
if (mesh->isGLDataPrepared != true) {
throwRuntimeException("Can't render mesh, vertices data was never updated");
}
if (mesh->isGLDataPrepared != true) {
throwRuntimeException("Can't render mesh, vertices data was never updated");
}
GLint vertexSlot = glGetAttribLocation(shader_program, "vertex");
......@@ -641,9 +641,9 @@ void OGLNewAgeRenderer::renderObject(shared_ptr<FSGLObject> object)
auto animationTransformationMatrices = mesh->animationTransformationMatrices;
#if FSGL_BONES_ENABLED
int kMaxBones = 64;
int kMaxBones = 64;
#else
int kMaxBones = 1;
int kMaxBones = 1;
#endif
glm::mat4 glmMatrices[64];
auto unitMatrix = make_shared<FSGLMatrix>();
......
......@@ -56,9 +56,9 @@ void OGLNewAgeRendererElements::fillTexture()
auto surface = mesh->material->surface;
if (surface == nullptr) {
throwRuntimeException(string("material surface is null, crashing"));
}
if (surface == nullptr) {
throwRuntimeException(string("material surface is null, crashing"));
}
auto palleteMode = GL_RGBA;
......@@ -87,7 +87,7 @@ OGLNewAgeRendererElements::~OGLNewAgeRendererElements()
#if CUBE_ART_PROJECT_ANDROID_NDK_BUILD != 1
glDeleteVertexArrays(1, &vao);
#else
glDeleteVertexArraysOES(1, &vao);
glDeleteVertexArraysOES(1, &vao);
#endif
glDeleteBuffers(1, &vbo);
glDeleteBuffers(1, &indexBuffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment