Exemple #1
0
float ATOM_CurveEditor::coordToTimeInSecond (int coord) const
{
	int coordInCanvas = coord + getScrollValue().x;
	unsigned canvasSize = (getClientRect().size.w > getCanvasSize().w) ? getClientRect().size.w : getCanvasSize().w;
	float origin = canvasSize * _originTimeAxis;
	return (coordInCanvas - origin) / _timeAxisUnitResolution;
}
Exemple #2
0
float ATOM_CurveEditor::coordToKeyValue (int coord) const
{
	int coordInCanvas = coord + getScrollValue().y;
	unsigned canvasSize = (getClientRect().size.h > getCanvasSize().h) ? getClientRect().size.h : getCanvasSize().h;
	float origin = canvasSize * _originValueAxis;
	return (origin - coordInCanvas) / _valueAxisUnitResolution;
}
Exemple #3
0
void ATOM_CurveEditor::onMouseMove (ATOM_WidgetMouseMoveEvent *event)
{
	if (_dragTarget == DRAG_CLIENT)
	{
		unsigned canvasSizeX = (getClientRect().size.w > getCanvasSize().w) ? getClientRect().size.w : getCanvasSize().w;
		unsigned canvasSizeY = (getClientRect().size.h > getCanvasSize().h) ? getClientRect().size.h : getCanvasSize().h;
		int xrel = event->xrel;
		int yrel = event->yrel;
		_originTimeAxis += float(event->xrel)/float(canvasSizeX);
		_originValueAxis += float(event->yrel)/float(canvasSizeY);
	}
	else if (_dragTarget == DRAG_POINT)
	{
		long time = coordToTimeInSecond (event->x) * 1000;
		if (time <= _minTimeValue)
		{
			if (_animationCurve.findKey(_minTimeValue) != unsigned(-1))
			{
				return;
			}
			time = _minTimeValue;
		}
		else if (time >= _maxTimeValue)
		{
			if (_animationCurve.findKey(_maxTimeValue) != unsigned(-1))
			{
				return;
			}
			time = _maxTimeValue;
		}

		_animationCurve.removeKey (_selectedControlPoint);
		float value = coordToKeyValue (event->y);
		if (value < _minValue)
		{
			value = _minValue;
		}
		else if (value > _maxValue)
		{
			value = _maxValue;
		}
		_selectedControlPoint = _animationCurve.insertKey (time , value);
	}
}
Exemple #4
0
    fzPoint Director::convertToGL(fzPoint point, bool isFlippedY) const
    {
        fzSize canvasSize = getCanvasSize();
        if(getOrientation() == kFZOrientation_LandscapeLeft)
            FZ_SWAP(canvasSize.width, canvasSize.height);
        
        fzAffineTransform transform;

        if(isFlippedY) {
            transform.scale(1, -1);
            transform.translate(0, -canvasSize.height);
        }
        transform.scale(canvasSize.width / m_renderingRect.size.width, canvasSize.height / m_renderingRect.size.height);
        transform.concat(m_orientationTransform);
        
        return point.applyTransform(transform);
    }
Exemple #5
0
    void Director::updateProjection()
    {
        FZ_ASSERT(OSW::Instance(), "OS Wrapper is not defined.");

        updateViewRect();

        if(!(m_dirtyFlags & kFZDDirty_projection))
            return;
        
        // VIEW PORT
        // The view port must be the display size in pixels.
        // Display size is not equal to the screen size, an application could not use the whole screen.
        fzSize viewPort = getViewPort();
        glViewport(0, 0, viewPort.width, viewPort.height);
        
        
        // PROJECTION
        // The projection must be calculated using the canvas size. No pixels here.
        fzSize canvasSize = getCanvasSize();
        fzOrientation orientation = getOrientation();
        if(orientation == kFZOrientation_LandscapeLeft || orientation == kFZOrientation_LandscapeRight)
            FZ_SWAP(canvasSize.width, canvasSize.height);
        
        
        switch (m_projection) {
            case kFZProjection2D:
            {
                fzMath_mat4OrthoProjection(0, canvasSize.width, 0, canvasSize.height, -1024, 1024, m_transformMV);
                break;
            }
            default:
                FZ_RAISE("Director: Unrecognized projection.");
        }
        
        m_orientationTransform = FZAffineTransformIdentity;
        if(orientation == kFZOrientation_LandscapeLeft) {

            m_orientationTransform.translate(canvasSize.width, 0);
            m_orientationTransform.rotate(FZ_DEGREES_TO_RADIANS(90));
            
            fzMat4 mat;
            fzMath_mat4Multiply(m_transformMV, m_orientationTransform, mat);
            fzMath_mat4Copy(mat, m_transformMV);
            
        }else if(orientation == kFZOrientation_LandscapeRight) {
            m_orientationTransform.translate(0, canvasSize.height);
            m_orientationTransform.rotate(FZ_DEGREES_TO_RADIANS(-90));
            
            fzMat4 mat;
            fzMath_mat4Multiply(m_transformMV, m_orientationTransform, mat);
            fzMath_mat4Copy(mat, m_transformMV);
        }
        m_orientationTransform = m_orientationTransform.getInverse();
        
        m_dirtyFlags &= ~kFZDDirty_projection;

        if(p_runningScene) {
            p_runningScene->updateLayout();
            if(p_hud)
                p_hud->updateLayout();
        }
    }
Exemple #6
0
int ATOM_CurveEditor::timeValueToCoord (float timeInSecond) const
{
	unsigned canvasSize = (getClientRect().size.w > getCanvasSize().w) ? getClientRect().size.w : getCanvasSize().w;
	return timeInSecond * _timeAxisUnitResolution + canvasSize * _originTimeAxis - getScrollValue().x;
}
Exemple #7
0
int ATOM_CurveEditor::keyValueToCoord (float value) const
{
	unsigned canvasSize = (getClientRect().size.h > getCanvasSize().h) ? getClientRect().size.h : getCanvasSize().h;
	return canvasSize * _originValueAxis - value * _valueAxisUnitResolution - getScrollValue().y;
}