Exemplo n.º 1
0
// Inits parameters for the camera
void Camera::init()
{
    // View Data
    // Camera position and orientation
    this->c[0]=0.0;  this->c[1]=0.0; this->c[2]=1.0; // Camera position    
    this->x[0]=1.0;  this->x[1]=0.0; this->x[2]=0.0; normalize(this->x); // x axis
    this->y[0]=0.0;  this->y[1]=1.0; this->y[2]=0.0; normalize(this->y); // y axis
    this->z[0]=0.0;  this->z[1]=0.0; this->z[2]=1.0; normalize(this->z); // z axis
    setToIdentity(this->view);
    this->updateView();
    
    // Projection data
    // Projection type : perspective:true / orthographic:false
    this->perspectiveProjection=false;
    // Projection frustum data
    GLfloat l=1.0;
    this->left=-l; 
    this->right=l;
    this->bottom=-l;
    this->top=l; 
    this->near=0.4;/*0.1 à l'origine*/
    this->far=100;/*100 à l'origine*/
    setToIdentity(this->projection);
    updateProjection();
}
Exemplo n.º 2
0
bool WireCreator::checkPath(QVector<int> path)
{
    auto modifiedPath=pathToPoints(path);
    auto basicPath=modifiedPath;

    m_wire.read_Input(modifiedPath);


    for(float rot=0.0f;rot<360.0f; rot+=5.0f ){

        while(!m_wire.nextPoint3()){
            //qDebug()<<"no collision for: "<<m_wire.outerPoints;
            if(m_wire.success){

               cPath=modifiedPath;
                return true;
        }
        }

        auto rotMat=QMatrix4x4();
        rotMat.setToIdentity();
        rotMat.rotate(rot,1.0f, 0.0f, 0.0f);
        //qDebug()<<"old path"<<modifiedPath;
        modifiedPath=applyMatrix(basicPath, rotMat);
        //qDebug()<<"new path"<<modifiedPath;
        m_wire.read_Input(modifiedPath);
    }
    //qDebug()<<"no rotation found";
    return false;

}
Exemplo n.º 3
0
// Updates view
void Camera::updateView()
{
    // Rotation to be aligned with correct camera axis
    float RcInv[]= {this->x[0], this->y[0], this->z[0], 0.0,
                    this->x[1], this->y[1], this->z[1], 0.0,
                    this->x[2], this->y[2], this->z[2], 0.0,
                    0.0,        0.0,        0.0,        1.0
                   };

    // Translation to be at the right distance from the scene
    float TcInv[]= {1.0,         0.0,         0.0,         0.0,
                    0.0,         1.0,         0.0,         0.0,
                    0.0,         0.0,         1.0,         0.0,
                    -this->c[0], -this->c[1], -this->c[2], 1.0
                   };

    // Initializes
    setToIdentity(this->view);
    // Rotates
    multMatrixBtoMatrixA(this->view, RcInv);
    // Translates
    multMatrixBtoMatrixA(this->view, TcInv);

    // Updates in shaders
    this->shaders.setView(this->view, this->c);
}
Exemplo n.º 4
0
/*
 * Main display of the ColorSpaceKeyerOverlay class
 * @param args current arg (time/renderScale/pixelScale....
 * @return if there is something drawed by the function (y or n)
 */
bool ColorSpaceKeyerOverlay::draw( const OFX::DrawArgs& args )
{
	bool displaySomethings = false;
	if( _plugin->_paramBoolPointCloudDisplay->getValue() ) //Is CloudPointData displayed ? (GUI)
	{
		glPushMatrix();								//new transformation
		prepareOpenGLScene(args);					//prepare frustum and projection settings
		if(_plugin->_updateVBO )					//VBO need to be updated
		{
			//update VBO
			getData().updateVBO();					//update VBO from VBO data (already computed)
			_plugin->_updateVBO = false;			//VBO has been recomputed
		}
		if(_plugin->_resetViewParameters)			//View parameters need to be reseted
		{
			_rotateX = _rotateY = 0;				//reset parameters
			_rotateXForm = _rotateYForm = 0;		//reset geodesic form center rotation parameters
			_plugin->_resetViewParameters = false;	//view parameters has been changed
			setToIdentity(_modelViewMatrix);		//reset model-view matrix to identity
		}
		//OpenGL parameters
		glEnable(GL_DEPTH_TEST);					//active depth (better for understand results)
		
		//drawing Axes
		drawAxes();									//draw the X, Y and Z axes
		//drawing VBO
		if(getData()._isVBOBuilt)					//if VBO has already been built
			getData()._imgVBO.draw();				//draw VBO
		
		//drawing color selection VBO
		if(getData()._isSelectionVBOBuilt && _plugin->_paramBoolSeeSelection->getValue())	//color selection VBO data is built
		{
			glColor3f(1.0f,1.0f,1.0f);														//color is white
			getData()._selectionColorVBO.draw();											//draw selection VBO
		}
		//drawing spill selection VBO
		if(getData()._isSpillSelectionVBOBuilt && _plugin->_paramBoolSeeSpillSelection->getValue()) //spill selection VBO data is built
		{
			glColor3f(.3f,.3f,.3f);														//color is white
			getData()._selectionSpillVBO.draw();										//draw selection VBO
		}
		
		//drawing average
		getData()._averageColor.draw();								//draw average (cross)
		//drawing geodesic form
		if(_plugin->_paramBoolDisplayGeodesicForm->getValue())		//does user want to display color geodesic form
			getData()._geodesicFormColor.draw(false);				//draw geodesic form on screen without alpha
		if(_plugin->_paramBoolDisplaySpillGF->getValue())			//does user want to display spill geodesic form
			getData()._geodesicFormSpill.draw(true);				//draw spill geodesic form on screen with alpha
		
		//OpenGL end of parameters
		glDisable(GL_DEPTH_TEST);	//disable deep
		glPopMatrix();				//pop matrix
		displaySomethings = true;	//something has been drown on screen
	}
	return displaySomethings;		//return if overlay has displayed something (y or n)
}
Exemplo n.º 5
0
Matrix2d& Matrix2d::setToMirroring(const Point2d& pnt, const Vector2d& dir)
{
    float d2 = dir.lengthSquare();
    if (mgIsZero(d2))
        setToIdentity();
    else
    {
        float s2 = 2.f * dir.x * dir.y / d2;
        float c2 = (dir.x * dir.x - dir.y * dir.y) / d2;
        set(c2, s2, s2, -c2, (1 - c2) * pnt.x - s2 * pnt.y, 
            (1 + c2) * pnt.y - s2 * pnt.x);
    }
    return *this;
}
Exemplo n.º 6
0
// Moves
void Camera::move(const bool spherical, const float * const moves, const float * const angles, const float radius)
{
    float cameraNewPos[3];
    for (unsigned int iCoord=0 ; iCoord<3 ; ++iCoord)
    {
        cameraNewPos[iCoord]=this->c[iCoord]
                             +this->x[iCoord]*moves[0]
                             +this->y[iCoord]*moves[1]
                             +this->z[iCoord]*moves[2];
    }

    float xAxis[]= {1.0, 0.0, 0.0};
    float yAxis[]= {0.0, 1.0, 0.0};
    float rotateAroundX[16];
    setToRotate(rotateAroundX, -angles[1], xAxis);
    float rotateAroundY[16];
    setToRotate(rotateAroundY, angles[0], yAxis);
    float t[]= {-cameraNewPos[0], -cameraNewPos[1], -cameraNewPos[2]};
    float translate[16];
    setToTranslate(translate, t);

    setToIdentity(this->view);

    if (spherical)
    {
        float tRadius[]= {0.0, 0.0, -radius};
        float translateRadius[16];
        setToTranslate(translateRadius, tRadius);
        multMatrixBtoMatrixA(this->view, translateRadius);
    }

    multMatrixBtoMatrixA(this->view, rotateAroundX);
    multMatrixBtoMatrixA(this->view, rotateAroundY);
    multMatrixBtoMatrixA(this->view, translate);

    for (unsigned int iCoord=0 ; iCoord<3 ; ++iCoord)
    {
        // Updates the axis with values in view
        this->x[iCoord]=this->view[iCoord*4+0];
        this->y[iCoord]=this->view[iCoord*4+1];
        this->z[iCoord]=this->view[iCoord*4+2];
        // Updates the position of the camera c
        this->c[iCoord]=cameraNewPos[iCoord];
    }

    // Updates in shaders
    this->shaders.setView(this->view, this->c);
}
Exemplo n.º 7
0
bool Matrix2d::invert()
{
    float d = m11 * m22 - m12 * m21;
    if (mgIsZero(d))
    {
        setToIdentity();
        return false;
    }
    
    d = 1.f / d;
    set(m22 * d, -m12 * d, 
        -m21 * d, m11 * d,
        (m21 * dy - m22 * dx) * d, 
        (m12 * dx - m11 * dy) * d);
    return true;
}
Exemplo n.º 8
0
/*
 * Constructor
 * @param handle
 * @param effect
 */
ColorSpaceKeyerOverlay::ColorSpaceKeyerOverlay(OfxInteractHandle handle,OFX::ImageEffect* effect)
: OFX::OverlayInteract(handle)
, _infos(effect)
{	
	_plugin = static_cast<ColorSpaceKeyerPlugin*>(_effect); //get plugin
	_plugin->addRefCloudPointData();				//create pointer to overlay data
	
	_isPenDown = false;								//mouse is not under control by default
	_isCtrlKeyDown = false;							//Ctrl key is not pressed by default
	_rotateX = _rotateY = 0.0;						//initialize rotation to 0
	_rotateXForm = _rotateYForm = 0.0;				//initialize rotation centered to geodesic form to 0
	_origin.x = _origin.y = _end.x = _end.y = 0;	//initialize mouse positions to 0
	
	setToIdentity(_modelViewMatrix);				//set model view matrix to identity
	
	///HACK : to initialize correctly overlay display data
	OFX::InstanceChangedArgs args;					//create instance changed arguments
	_plugin->changedParam(args,kPointCloudDisplay);	//call changed parameters function to initialize overlay data
}
Exemplo n.º 9
0
// Initializes all the pointers to NULL
// and sets the numbers of objects to 0
void Scene::init()
{
    // Fixed max sizes for arrays
    this->maxStoredObjects=50;
    this->maxDrawnObjects=200;
    
	// Initialisation of the numbers of objets filled
	this->nbStoredObjects=0;
    this->nbDrawnObjects=0;
    
    // Array creation (with fixed size)
    this->storedObjects=new Object *[this->maxStoredObjects];
    this->drawnObjects=new GLuint[this->maxDrawnObjects];
    this->drawnObjectsColors=new GLfloat[this->maxDrawnObjects*4];
    this->drawnObjectsModels=new GLfloat[this->maxDrawnObjects*16];
    this->drawnObjectsShaderIDs=new GLuint[this->maxDrawnObjects];

           
    // Default color
    GLfloat grey[16]={0.2, 0.2, 0.2, 1.0}; setDefaultColor(grey);
    // Default model
    GLfloat I[16]; setToIdentity(I); setDefaultModel(I);
    // Default shader ID
    setDefaultShaderID(1);
    
     // Initalisation of storedObjects
	for (GLuint iStoredObjects=0 ; iStoredObjects<this->maxStoredObjects ; iStoredObjects++)
		this->storedObjects[iStoredObjects]=NULL;
		
    // Light creation
    GLfloat lightPosition[]={0.0, 5.0, 0.0, 1.0}; GLfloat lightPower=1.0;
    this->setLight(lightPosition, lightPower);

    // Creation and initialisation of a camera
    this->camera=new Camera();

// in Scene::init()    
    this->drawnObjectsTexture0IDs=new GLuint[this->maxDrawnObjects];
    this->drawnObjectsTexture1IDs=new GLuint[this->maxDrawnObjects];
    // Default texture ID	
    setDefaultTextureID(1);
}
Exemplo n.º 10
0
/*
 * Create rotation matrix with rotation center (translate + rotates + inverse translate)
 */
Matrix4 constructRotationMatrix(const Ofx3DPointD& rotationCenter, const double& angleX, const double& angleY,
                                const double& angleZ)
{
    // define axes
    Axis axisX = {{1, 0, 0}}; // define axe X
    Axis axisY = {{0, 1, 0}}; // define axe Y
    Axis axisZ = {{0, 0, 1}}; // define axe Z

    // Define and create rotation + translation matrix
    Matrix4 rotationTranslationMatrix;        // initialize
    setToIdentity(rotationTranslationMatrix); // set matrix center to identity

    // Define  and construct rotation matrices
    Matrix4 rotationMatrixX;                            // initialize rotation matrix X
    setToRotate(rotationMatrixX, angleX / 10.0, axisX); // construct rotation matrix X
    Matrix4 rotationMatrixY;                            // initialize rotation matrix Y
    setToRotate(rotationMatrixY, angleY / 10.0, axisY); // construct rotation matrix Y
    Matrix4 rotationMatrixZ;                            // initialize rotation matrix Z
    setToRotate(rotationMatrixZ, angleZ / 10.0, axisZ); // construct rotation matrix Z

    // Define and construct translation matrix
    Matrix4 translationMatrix; // initialize translation matrix
    // Construct translation vector
    Vect4 translationVector = {{rotationCenter.x, rotationCenter.y, rotationCenter.z, 1.0}};
    setToTranslate(translationMatrix, translationVector); // construct translation matrix

    // Define and construct inverse translation matrix
    Matrix4 translationInverseMatrix; // initialize inverse translation matrix
    // Construct inverse translation vector
    Vect4 inverseTranslationVector = {{-rotationCenter.x, -rotationCenter.y, -rotationCenter.z, 1.0}};
    setToTranslate(translationInverseMatrix, inverseTranslationVector); // construct inverse translation matrix

    // Construct final reference center matrix (inverse order of application)
    multMatrixBtoMatrixA(rotationTranslationMatrix, translationMatrix);        // translation matrix
    multMatrixBtoMatrixA(rotationTranslationMatrix, rotationMatrixZ);          // rotation Z axis
    multMatrixBtoMatrixA(rotationTranslationMatrix, rotationMatrixY);          // rotation Y axis
    multMatrixBtoMatrixA(rotationTranslationMatrix, rotationMatrixX);          // rotation X axis
    multMatrixBtoMatrixA(rotationTranslationMatrix, translationInverseMatrix); // inverse translation matrix
    // return result
    return rotationTranslationMatrix;
}
Exemplo n.º 11
0
// Inits parameters for the camera
void Camera::init()
{
    // View Data
    // Camera position and orientation
    float c[]= {0.0, 1.0, 3.0}; // Camera position
    float aim[]= {0.0, 0.0, 0.0}; // Where we look
    float up[]= {0.0, 1.0, 0.0}; // Vector pointing over the camera
    lookAt(c, aim, up);

    // Projection data
    // Projection type : perspective:true / orthographic:false
    this->perspectiveProjection=true;
    // Projection frustum data
    float l=1.0;
    this->left=-l;
    this->right=l;
    this->bottom=-l;
    this->top=l;
    this->near=0.1;
    this->far=100.0;
    setToIdentity(this->projection);
    updateProjection();
}
TransformMatrix::TransformMatrix()
{
   setToIdentity();
}
Exemplo n.º 13
0
Mat4::Mat4()
{
    setToIdentity();
}
Exemplo n.º 14
0
Matrix44::Matrix44()
{
    setToIdentity();
}
Exemplo n.º 15
0
 GLMatrix()
 {
     setToIdentity();
 }