Commit 5093b40a authored by Arnaud Blanchard's avatar Arnaud Blanchard

Remove projets blibs/blgl_viewer and blibs/blglm_simulator which are external submodules

parent 9cb92d29
Pipeline #36 canceled with stage
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#else
#include <GL/glew.h>
#endif
#include "blc_core.h"
#include "blgl_viewer.h"
int *shaders_ids=NULL;
int shaders_nb=0;
//shader_type=GL_VERTEX_SHADER|GL_FRAGMENT_SHADER
GLuint blgl_create_shader(char const *source, GLenum shader_type){
char *log_buffer;
GLuint shader_id;
shader_id = glCreateShader(shader_type);
GLint result, log_length;
glShaderSource(shader_id, 1, &source , NULL);
glCompileShader(shader_id);
APPEND_ITEM(&shaders_ids, &shaders_nb, &shader_id);
// Check Vertex Shader
glGetShaderiv(shader_id, GL_COMPILE_STATUS, &result);
glGetShaderiv(shader_id, GL_INFO_LOG_LENGTH, &log_length);
if ( log_length){
log_buffer=MANY_ALLOCATIONS(log_length+1, char);
glGetShaderInfoLog(shader_id, log_length, NULL, log_buffer);
fprintf(stderr, "%s\n", log_buffer);
FREE(log_buffer);
}
if (result==GL_FALSE) EXIT_ON_ERROR("Compiling shader '%s'.", source);
return shader_id;
}
/* You need to create the shader ( blgl_create_shader ) before */
GLint blgl_create_program(){
char *log_buffer;
GLint result, log_length, program_id;
int i;
if (shaders_nb==0) EXIT_ON_ERROR("You need to create at least a shader before");
program_id = glCreateProgram();
FOR(i, shaders_nb){
glAttachShader(program_id, shaders_ids[i]);
}
glLinkProgram(program_id);
// Check the program
glGetProgramiv(program_id, GL_LINK_STATUS, &result);
glGetProgramiv(program_id, GL_INFO_LOG_LENGTH, &log_length);
if (log_length > 0 ){
log_buffer=MANY_ALLOCATIONS(log_length+1, char);
glGetProgramInfoLog(program_id, log_length, NULL, log_buffer);
fprintf(stderr, "%s\n", log_buffer);
FREE(log_buffer);
if (result==0) EXIT_ON_ERROR("Linking GL program");
}
FOR(i, shaders_nb){
glDetachShader(program_id, shaders_ids[i]);
glDeleteShader(shaders_ids[i]);
}
FREE(shaders_ids);
shaders_nb=0;
return program_id;
}
# Copyright ETIS — ENSEA, Université de Cergy-Pontoise, CNRS (2011 - 2018)
# Author: Arnaud Blanchard
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
#Basic Library for robotique simulator with gem
cmake_minimum_required(VERSION 2.6)
project(blglm_simulator)
find_package(blc_core REQUIRED)
find_package(glm REQUIRED)
set(sources blglm_simulator.cpp)
set(DEFINITIONS ${BL_DEFINITIONS})
set(INCLUDES ${BL_INCLUDE_DIRS} ${GLM_INCLUDE_DIRS} include)
set(LIBRARIES ${BL_LIBRARIES})
message(include: ${GLM_INCLUDE_DIRS})
add_definitions(${DEFINITIONS})
include_directories(${INCLUDES})
add_library(blglm_simulator SHARED ${sources})
target_link_libraries(blglm_simulator ${LIBRARIES})
#static_version
add_library(static_blglm_simulator STATIC ${sources})
set_target_properties(static_blglm_simulator PROPERTIES OUTPUT_NAME blglm_simulator)
#Describe what will be to install or in the package
install(DIRECTORY include/ DESTINATION include/blglm_simulator)
install(TARGETS blglm_simulator static_blglm_simulator DESTINATION lib)
install(FILES blglm_simulator-config.cmake DESTINATION share/blglm_simulator)
find_package(blc_core REQUIRED)
find_package(glm REQUIRED)
find_path(BLGLM_SIMULATOR_INCLUDE_DIR blglm_simulator.h PATH_SUFFIXES blglm_simulator)
find_library(BLGLM_SIMULATOR_LIBRARY blglm_simulator)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(blglm_simulator DEFAULT_MSG BLGLM_SIMULATOR_INCLUDE_DIR BLGLM_SIMULATOR_LIBRARY)
#No access outide this file
mark_as_advanced(BLGLM_SIMULATOR_INCLUDE_DIR BLGLM_SIMULATOR_LIBRARY)
list(APPEND BL_INCLUDE_DIRS ${BLGLM_SIMULATOR_INCLUDE_DIR} ${GLM_INCLUDE_DIRS})
list(APPEND BL_LIBRARIES ${BLGLM_SIMULATOR_LIBRARY} ${BL_LIBRARIES})
list(REMOVE_DUPLICATES BL_INCLUDE_DIRS)
list(REMOVE_DUPLICATES BL_LIBRARIES)
//
// opengl.cpp
// tino_viewer
//
// Created by Arnaud Blanchard on 29/11/2017.
//
//
#include "blglm_simulator.h"
#include "blc_core.h" //APPEND_ITEM, FOR, FREE...
#include <glm/glm.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/quaternion.hpp>
int blglm_simulator_joint::root_joints_nb=0;
blglm_simulator_joint **blglm_simulator_joint::root_joints=NULL;
blglm_simulator_joint::blglm_simulator_joint(blglm_simulator_joint *support, glm::vec3 pos, glm::vec3 axis, float *angle_pt ,float limit_min, float limit_max)
:angle_pt(angle_pt), limit_min(limit_min), limit_max(limit_max), pos(pos), axis(axis), joints(NULL), joints_nb(0){
blglm_simulator_joint *this_joint=this;
if (support) APPEND_ITEM(&support->joints, &support->joints_nb, &this_joint);
else APPEND_ITEM(&root_joints, &root_joints_nb, &this_joint);
}
/*
blgl_joint::blgl_ball_joint(blgl_joint *support, glm::vec3 pos, float *angle_pt ,float limit_min, float limit_max)
:angle_pt(angle_pt), limit_min(limit_min), limit_max(limit_max), pos(pos), joints(NULL), joints_nb(0){
blgl_joint *this_joint=this;
if (support) APPEND_ITEM(&support->joints, &support->joints_nb, &this_joint);
else APPEND_ITEM(&root_joints, &root_joints_nb, &this_joint);
}*/
blglm_simulator_joint::~blglm_simulator_joint(){
int i;
FOR(i, joints_nb) delete joints[i];
FREE(joints);
}
void blglm_simulator_joint::update(glm::mat4 current_model){
float absolute_angle;
glm::quat quaternion; //We need to use quaternion to have local rotation
int i;
if (*angle_pt>1 || *angle_pt<0) EXIT_ON_ERROR("Value of angle '%f' outside the range [0,1]", *angle_pt);
absolute_angle=*angle_pt*(limit_max-limit_min)+limit_min;
current_model = glm::translate(current_model, pos);
quaternion=glm::angleAxis(absolute_angle, axis);
model=current_model*glm::toMat4(quaternion);
FOR(i, joints_nb) joints[i]->update(model);
}
void blglm_simulator_joint::update_all(){
int i;
glm::mat4 identity;
FOR(i, root_joints_nb) root_joints[i]->update(identity);
}
void blglm_simulator_joint::remove_all(){
int i;
FOR(i, root_joints_nb) delete root_joints[i];
FREE(root_joints);
}
#ifndef BLGLM_SIMULATOR_H
#define BLGLM_SIMULATOR_H
#include <glm/glm.hpp>
typedef struct blglm_simulator_joint{
float *angle_pt, limit_min, limit_max;
glm::mat4 model;
glm::vec3 pos, axis;
blglm_simulator_joint **joints;
int joints_nb;
static blglm_simulator_joint **root_joints;
static int root_joints_nb;
blglm_simulator_joint(blglm_simulator_joint *support, glm::vec3 pos, glm::vec3 axis, float *angle_pt, float limit_min=-M_PI, float limit_max=M_PI);
// blgl_ball_joint(blgl_joint *support, glm::vec3 pos, float angles_pt[3], float limit_min=-M_PI, float limit_max=M_PI);
~blglm_simulator_joint();
void update(glm::mat4 model);
static void update_all();
static void remove_all();
}blglm_simulator_joint;
#endif /* _3DMODEL_H */
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