Exemplo n.º 1
0
QMatrix4x4 EditData::getNowSelectMatrix()
{
    QModelIndex index = getSelIndex();
    if (!getObjectModel()->isLayer(index))
    {
        return QMatrix4x4();
    }

    int frame = getSelectFrame();
    ObjectItem *pItem = getObjectModel()->getItemFromIndex(index);
    return pItem->getDisplayMatrix(frame);
}
Exemplo n.º 2
0
// ドロップ時のスロット
// レイヤ追加
void AnimationForm::slot_dropedImage( QRectF rect, QPoint pos, int imageIndex )
{
	CObjectModel *pModel = m_pEditData->getObjectModel() ;
	int frameNum  = ui->label_frame->value() ;
	QModelIndex index = ui->treeView->currentIndex() ;

	if ( !index.isValid() ) {
		qWarning() << "slot_dropedImage current index invalid 0" ;
		return ;
	}

	ObjectItem *pObjItem = pModel->getObject(index) ;
	if ( !pObjItem ) {
		qWarning() << "slot_dropedImage current obj 0" ;
		return ;
	}

	if ( !m_pSetting->getLayerHierarchy() ) {
		index = pObjItem->getIndex() ;
	}

	pos -= QPoint((m_pSetting->getAnmWindowW()/2), (m_pSetting->getAnmWindowH()/2)) ;	// GLWidgetのローカルポスに変換

	ObjectItem *pItem = pModel->getItemFromIndex(index) ;
	bool valid ;
	QMatrix4x4 mat = pItem->getDisplayMatrix(frameNum, &valid) ;
	if ( valid ) {
		QMatrix4x4 inv = mat.inverted(&valid) ;
		if ( valid ) {
			pos = inv.map(pos) ;
		}
	}

	index = m_pEditData->cmd_addItem(QString("Layer %1").arg(pObjItem->childCount()), index) ;
	ui->treeView->setCurrentIndex(index) ;
//	m_pEditData->setSelIndex(index) ;

	// ツリービューに追加
    FrameData frameData ;
	frameData.pos_x = pos.x() ;
	frameData.pos_y = pos.y() ;
	frameData.pos_z = 0 ;
	frameData.rot_x =
	frameData.rot_y =
	frameData.rot_z = 0 ;
	frameData.center_x = (rect.width()) / 2 ;
	frameData.center_y = (rect.height()) / 2 ;
	frameData.frame = frameNum ;
	frameData.fScaleX = frameData.fScaleY = 1.0f ;
	frameData.setRect(rect);
	frameData.nImage = imageIndex ;
	frameData.bUVAnime = false ;
	frameData.rgba[0] =
	frameData.rgba[1] =
	frameData.rgba[2] =
	frameData.rgba[3] = 255 ;

	QList<QWidget *> updateWidget ;
	updateWidget << m_pGlWidget ;
	updateWidget << m_pDataMarker ;

	m_pEditData->cmd_addFrameData(index, frameData, updateWidget) ;
}
Exemplo n.º 3
0
void AnimeGLWidget::drawLayers(ObjectItem *pLayerItem)
{
    int selFrame = m_pEditData->getSelectFrame();
    int flag = pLayerItem->data(Qt::CheckStateRole).toInt();
    if (m_pEditData->getObjectModel()->isLayer(pLayerItem->getIndex()) && (flag & ObjectItem::kState_Disp))
    {
        FrameData d;
        bool valid;
        d = pLayerItem->getDisplayFrameData(selFrame, &valid);
        if (valid)
        {
            QMatrix4x4 mat = pLayerItem->getDisplayMatrix(selFrame);
            if (m_pSetting->getUseZSort())
            {
                DRAW_FRAMEDATA draw;
                draw.mat = mat;
                draw.data = d;

                if (m_pSetting->getDrawFrame() && !m_pEditData->isExportPNG())
                {
                    ObjectItem *p = m_pEditData->getObjectModel()->getItemFromIndex(m_pEditData->getSelIndex());
                    if (pLayerItem == p)
                    {
                        if (m_bPressCtrl)
                        {
                            draw.frameCol = QColor(0, 255, 0, 255);
                        }
                        else
                        {
                            draw.frameCol = QColor(255, 0, 0, 255);
                        }
                    }
                    else
                    {
                        draw.frameCol = QColor(64, 64, 64, 255);
                    }
                }
                else
                {
                    draw.frameCol = QColor(0, 0, 0, 0);
                }

                m_drawList.append(draw);
            }
            else
            {
                drawFrameData(d, mat);

                if (m_pSetting->getDrawFrame() && !m_pEditData->isExportPNG())
                {
                    QColor col;
                    ObjectItem *p = m_pEditData->getObjectModel()->getItemFromIndex(m_pEditData->getSelIndex());
                    if (pLayerItem == p)
                    {
                        if (m_bPressCtrl)
                        {
                            col = QColor(0, 255, 0, 255);
                        }
                        else
                        {
                            col = QColor(255, 0, 0, 255);
                        }
                    }
                    else
                    {
                        col = QColor(64, 64, 64, 255);
                    }
                    drawFrame(d, mat, col);
                }
            }
        }
    }

    QList<ObjectItem *> children;
    for (int i = 0; i < pLayerItem->childCount(); i++)
    {
        ObjectItem *pChild = pLayerItem->child(i);
        bool valid;
        QMatrix4x4 m = pChild->getDisplayMatrix(selFrame, &valid);
        if (!valid)
        {
            children.append(pChild);
            continue;
        }

        int j;
        for (j = 0; j < children.size(); j++)
        {
            QMatrix4x4 m1 = children[j]->getDisplayMatrix(selFrame, &valid);
            if (!valid)
            {
                continue;
            }
            if (m.column(3).z() < m1.column(3).z())
            {
                children.insert(j, pChild);
                break;
            }
        }
        if (j == children.size())
        {
            children.append(pChild);
        }
    }

    foreach (ObjectItem *p, children)
    {
        drawLayers(p);
    }