Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added NURBSCircleSphere.pdf
Binary file not shown.
171 changes: 157 additions & 14 deletions Prototipo-1/DOT_CPP/BSplines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,56 @@
/* Public */

// Construtores

BSplines::BSplines(BSplines * bspline):Object()
{

this->translation = bspline->translation;
this->rotation = bspline->rotation;
this->scale = bspline->scale;

// Quantidade de Pontos da Curva
this->quant = bspline->getQuant();

// Ordem da Curva B-Spline
this->ordCurva = bspline->getOrdCurva();

// Lista de Nos usados para geração da curva B-Spline
this->nos = bspline->getNo();

// Lista de Pontos da Curva B-Spline
// A Cada 3 elementos da lista tem-se um ponto representando
// px,py,pz
this->ptsCurv = bspline->getPtsCurva();

// Lista Bidimensional Representando os Pontos de Controle
this->ptControle = bspline->getPtControle();

this->updatePtsCurv();

this->setTipo("BSplines");
}

BSplines::BSplines(vector < vector <float > > ptControle, vector<double > nos):Object()
{
vector<float> p1,p2,p3,p4;

quant = 80;
ordCurva = 4;
ptcSelec = -1;
noSelec = -1;
this->ptControle = ptControle;
this->nos = nos;

// Tipo Curva BSpline
setTipo("BSplines");
//iniNo();

this->updatePtsCurv();
}



BSplines::BSplines(float x, float y, float z):Object()
{
vector<float> p1,p2,p3,p4;
Expand Down Expand Up @@ -248,16 +298,17 @@ int BSplines::incNo(double inc)
if(j + 1 > ordCurva){

nos = noscopia;

normaNos();
return 0;

} else {

normaNos();
return 1;
}

} else {

normaNos();
return 0;
}
}
Expand Down Expand Up @@ -333,9 +384,30 @@ void BSplines::setPtControle(float x, float y, float z)
{
if(ptcSelec >= 0){

ptControle[ptcSelec][0] = x-translation[0];
ptControle[ptcSelec][1] = y-translation[1];
ptControle[ptcSelec][2] = z-translation[2];
//int count = 0;
vector <float > r = getRotation();
//GLfloat matrix[16];
glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE));
glm::quat quaternion = quat ;
glm::mat4 mat = glm::toMat4(quaternion);
/*for (int k = 0; k < 4; ++k){
for (int j = 0; j < 4; ++j){
matrix[count] = mat[k][j];
count++;
}
}*/

glm::mat4 INVERSE_ROTATE = glm::inverse(mat);
glm::vec4 reverse_point = INVERSE_ROTATE * glm::vec4(
(x-translation[0])/scale[0],
(y-translation[1])/scale[1],
(z-translation[2])/scale[2],
1.0f
);

ptControle[ptcSelec][0] = reverse_point[0];
ptControle[ptcSelec][1] = reverse_point[1];
ptControle[ptcSelec][2] = reverse_point[2];
}
}

Expand All @@ -351,6 +423,9 @@ void BSplines::setQuant(int valor)
quant = valor;
}




// Atualiza/Processa os Pontos da Curva B-Spline
void BSplines::updatePtsCurv()
{
Expand All @@ -368,7 +443,7 @@ void BSplines::updatePtsCurv()
inc = ( fim - inic ) / quant;
}

for(t = inic; t <= fim; t+=inc){
for(t = 0; t < fim; t+=inc){

x = y = z = 0;

Expand All @@ -392,6 +467,9 @@ void BSplines::updatePtsCurv()
ptsCurv = pts;
}




/* Private */

// Gerencia os Nos
Expand Down Expand Up @@ -558,7 +636,7 @@ void BSplines::rmvNode(int tipo)

// Normaliza a lista de nós
void BSplines::normaNos(){
/*

int i = 0;
int n = nos.size();
double dif = 0 - nos[0];
Expand All @@ -567,7 +645,7 @@ void BSplines::normaNos(){
for(i = 0; i < n; i++){

nos[i] = (nos[i]+dif) * coef;
}*/
}
}

// Inicializa os Nos
Expand Down Expand Up @@ -617,7 +695,8 @@ double BSplines::bspline(int i, int k, double u)
}
}

void BSplines::draw(int index_load, bool is_selecting)

void BSplines::draw(int index_load, bool is_selecting, int size_world)
{
int i,k,j;
int sizePtc = (int) ptControle.size();
Expand Down Expand Up @@ -645,9 +724,9 @@ void BSplines::draw(int index_load, bool is_selecting)
glPushMatrix();
// Aplicar Transformações Geométricas
glColor3f(c[0],c[1],c[2]);
glScalef(s[0], s[1], s[2]);
glTranslatef(t[0],t[1],t[2]);
glMultMatrixf(m);
glScalef(s[0], s[1], s[2]);
glMultMatrixf(m);

if( !render_mode && this->is_selected){

Expand All @@ -666,8 +745,10 @@ void BSplines::draw(int index_load, bool is_selecting)
}

glPushMatrix();
glTranslatef(ptControle[i][0],ptControle[i][1],ptControle[i][2]);
glutSolidCube(2);
glPointSize(5);
glBegin(GL_POINTS);
glVertex3f(ptControle[i][0],ptControle[i][1],ptControle[i][2]);
glEnd();
glPopMatrix();
}

Expand Down Expand Up @@ -755,4 +836,66 @@ void BSplines::draw(int index_load, bool is_selecting)
}

glPopMatrix();
}


//modificador
if(render_mode && is_selected){

glPushMatrix();
glTranslatef(translation[0], translation[1]-20, translation[2]);
glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]);
modifier.draw( size_world-1, true);
glPopMatrix();

} else if (!render_mode && is_selected && hit_index_internal >= 1){


//index_internal++;
glPushMatrix();
glTranslatef(t[0],t[1],t[2]);
glScalef(s[0], s[1], s[2]);
glMultMatrixf(m);
glTranslatef(ptControle[ptcSelec][0], ptControle[ptcSelec][1], ptControle[ptcSelec][2]);
glScalef(0.8, 0.8, 0.8);
glScalef(1/s[0], 1/s[1], 1/s[2]);
glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]);
modifier.draw(index_internal, true);
glPopMatrix();
}

}

int BSplines::getSizeControlPoints()
{
return (int) ptControle.size();
}


vector <float > BSplines::getControlPointSelected()
{

if( ptcSelec >= 0 ){

return ptControle[ptcSelec];

} else {
return ptControle[0];
}
}

void BSplines::setPtControleModifier(float x, float y, float z)
{
if( ptcSelec >= 0 ){

ptControle[ptcSelec][0] = x;
ptControle[ptcSelec][1] = y;
ptControle[ptcSelec][2] = z;

updatePtsCurv();
}
}

void BSplines::setModifier(int tp)
{
modifier.setModifierType(tp);
}
12 changes: 6 additions & 6 deletions Prototipo-1/DOT_CPP/BezierCubic.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "BezierCubic.h"

// Construtor
// Construtor
BezierCubic::BezierCubic(void)
{
}

// Destrutor
// Destrutor
BezierCubic::~BezierCubic(void)
{
}

// Função que calcula e retorna os pontos da curva de Beizer
// Recebe o paramêtro t, que representa a a quantidade de pontos
// Função que calcula e retorna os pontos da curva de Beizer
// Recebe o paramêtro t, que representa a a quantidade de pontos
vector<float> BezierCubic::processaPontoControle(int quant)
{
double t = 0;
Expand Down Expand Up @@ -42,8 +42,8 @@ vector<float> BezierCubic::processaPontoControle(int quant)
return pontosCurva;
}

// Define os 4 pontos de controle da curva de Bezier Cubica
// Recebe como paramêtro os 4 pontos de controle
// Define os 4 pontos de controle da curva de Bezier Cubica
// Recebe como paramêtro os 4 pontos de controle
void BezierCubic::setPtControles(float p1[], float p2[], float p3[], float p4[])
{
ptC1[0] = p1[0];
Expand Down
Loading