示例#1
0
// return true iff column ancestorIndex is column descentIndex or its parent or the parent of the parent, etc.
bool isAncestorOf(int ancestorIndex, int descendentIndex)
{
	TStageObjectId ancestorId = TStageObjectId::ColumnId(ancestorIndex);
	TStageObjectId descendentId = TStageObjectId::ColumnId(descendentIndex);
	TXsheet *xsh = TTool::getApplication()->getCurrentXsheet()->getXsheet();
	while (descendentId != ancestorId && descendentId.isColumn())
		descendentId = xsh->getStageObjectParent(descendentId);
	return descendentId == ancestorId;
}
示例#2
0
TAffine TTool::getCurrentColumnParentMatrix() const {
  if (!m_application) return TAffine();

  TFrameHandle *fh = m_application->getCurrentFrame();
  if (fh->isEditingLevel()) return TAffine();
  int frame       = fh->getFrame();
  int columnIndex = m_application->getCurrentColumn()->getColumnIndex();
  TXsheet *xsh    = m_application->getCurrentXsheet()->getXsheet();
  TStageObjectId parentId =
      xsh->getStageObjectParent(TStageObjectId::ColumnId(columnIndex));
  return xsh->getPlacement(parentId, frame);
}
示例#3
0
TAffine TTool::getCurrentObjectParentMatrix() const {
  if (!m_application) return TAffine();

  TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
  int frame    = m_application->getCurrentFrame()->getFrame();
  TStageObjectId currentObjectId =
      m_application->getCurrentObject()->getObjectId();
  if (currentObjectId == TStageObjectId::NoneId) return TAffine();
  TStageObjectId parentId = xsh->getStageObjectParent(currentObjectId);
  if (parentId == TStageObjectId::NoneId)
    return TAffine();
  else
    return xsh->getPlacement(parentId, frame);
}
示例#4
0
	void notify() const
	{
		m_tool->invalidate();
		TXsheet *xsh = getXsheet();
		int index = m_columnIndex;
		if (index < 0)
			index = m_oldColumnIndex;
		if (index >= 0) {
			TStageObjectId id = TStageObjectId::ColumnId(index);
			TStageObjectId parentId;
			while (parentId = xsh->getStageObjectParent(id), parentId.isColumn())
				id = parentId;
			xsh->getStageObject(id)->invalidate();
			TTool::getApplication()->getCurrentXsheet()->notifyXsheetChanged();
			TTool::getApplication()->getCurrentObject()->notifyObjectIdChanged(false);
		}
	}
示例#5
0
TAffine TTool::getCurrentObjectParentMatrix2() const {
  TTool::Application *app = m_application;
  TFrameHandle *fh        = app->getCurrentFrame();
  if (fh->isEditingLevel()) return TAffine();
  int frame               = fh->getFrame();
  TXsheet *xsh            = app->getCurrentXsheet()->getXsheet();
  TStageObjectId id       = app->getCurrentObject()->getObjectId();
  double objZ             = xsh->getZ(id, frame);
  TStageObjectId parentId = xsh->getStageObjectParent(id);
  if (parentId == TStageObjectId::NoneId) return TAffine();
  id                   = parentId;
  TAffine objPlacement = xsh->getPlacement(id, frame);

  TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId();
  TStageObject *camera    = xsh->getStageObject(cameraId);
  TAffine cameraPlacement = camera->getPlacement(frame);
  double cameraZ          = camera->getZ(frame);

  TAffine placement;
  TStageObject::perspective(placement, cameraPlacement, cameraZ, objPlacement,
                            objZ, 0);
  return placement;
}
示例#6
0
void ColumnCmd::cloneChild(int index) {
  if (!canResequence(index)) return;

  /*-- カラムを取得 --*/
  TXsheet *xsh       = TApp::instance()->getCurrentXsheet()->getXsheet();
  TXshColumn *column = xsh->getColumn(index);
  assert(column);

  // get the subxsheet to clone (childLevel, childXsh)
  /*-- SubXsheetレベルを取得 --*/
  TXshLevelColumn *lcolumn = column->getLevelColumn();
  assert(lcolumn);
  int r0 = 0, r1 = -1;
  lcolumn->getRange(r0, r1);
  assert(r0 <= r1);
  /*-- SubXsheetの一番頭のセル --*/
  TXshCell cell = lcolumn->getCell(r0);
  assert(!cell.isEmpty());
  /*- cell内に格納されているLevelを取得 -*/
  TXshChildLevel *childLevel = cell.m_level->getChildLevel();
  assert(childLevel);
  /*- SubXsheetのXsheetを取得 -*/
  TXsheet *childXsh = childLevel->getXsheet();

  // insert a new empty column
  /*- 隣に空きColumnをInsertしてCloneに備える -*/
  int newColumnIndex = index + 1;
  xsh->insertColumn(newColumnIndex);

  // create a subxsheet (newChildLevel, newChildXsh)
  ToonzScene *scene      = TApp::instance()->getCurrentScene()->getScene();
  ChildStack *childStack = scene->getChildStack();
  TXshChildLevel *newChildLevel = childStack->createChild(0, newColumnIndex);
  TXsheet *newChildXsh          = newChildLevel->getXsheet();

  // copy columns.
  std::set<int> indices;
  for (int i = 0; i < childXsh->getColumnCount(); i++) indices.insert(i);
  StageObjectsData *data = new StageObjectsData();
  data->storeColumns(indices, childXsh, 0);
  data->storeColumnFxs(indices, childXsh, 0);
  std::list<int> restoredSplineIds;
  data->restoreObjects(indices, restoredSplineIds, newChildXsh,
                       StageObjectsData::eDoClone);
  delete data;

  cloneNotColumnLinkedFxsAndOutputsFx(childXsh, newChildXsh);
  cloneXsheetTStageObjectTree(childXsh, newChildXsh);
  /*--以下は、Clone SubXsheet
  するときに、SubXsheet内にある子SubXsheetをクローンする関数
  クローンされた中にある子SubXsheetは、同じもので良いので、スキップする --*/
  // cloneSubXsheets(newChildXsh);

  /*-- XSheetノードのFxSchematicでのDagNodePosを再現
  FxやColumnノードの位置の再現は上のsetColumnで行っている
--*/
  newChildXsh->getFxDag()->getXsheetFx()->getAttributes()->setDagNodePos(
      childXsh->getFxDag()->getXsheetFx()->getAttributes()->getDagNodePos());

  newChildXsh->updateFrameCount();

  /*-- TXshChildLevel作成時にsetCellした1つ目のセルを消去 --*/
  xsh->removeCells(0, newColumnIndex);
  /*-- CloneしたColumnのセル番号順を再現 --*/
  for (int r = r0; r <= r1; r++) {
    TXshCell cell = lcolumn->getCell(r);
    if (cell.isEmpty()) continue;

    cell.m_level = newChildLevel;
    xsh->setCell(r, newColumnIndex, cell);
  }

  TStageObjectId currentObjectId =
      TApp::instance()->getCurrentObject()->getObjectId();
  xsh->getStageObject(TStageObjectId::ColumnId(newColumnIndex))
      ->setParent(xsh->getStageObjectParent(currentObjectId));

  xsh->updateFrameCount();
  TUndoManager::manager()->add(
      new CloneChildUndo(newChildLevel, newColumnIndex));

  // notify changes
  TApp::instance()->getCurrentScene()->setDirtyFlag(true);
  TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
示例#7
0
void SkeletonTool::draw()
{
	// parent object reference system
	//glColor3d(1,0,0);
	//tglDrawRect(0,0,100,100);

	if (m_label != "")
		ToolUtils::drawBalloon(m_labelPos, m_label, TPixel32::Red, TPoint(20, -20), false);

	bool ikEnabled = m_mode.getValue() == INVERSE_KINEMATICS;
	assert(glGetError() == GL_NO_ERROR);

	// l'xsheet, oggetto (e relativo placement), frame corrente
	TTool::Application *app = TTool::getApplication();
	TXsheet *xsh = getXsheet();
	assert(xsh);
	TStageObjectId objId = app->getCurrentObject()->getObjectId();
	// se l'oggetto corrente non e' una colonna non disegno nulla
	if (!objId.isColumn())
		return;

	TStageObject *pegbar = xsh->getStageObject(objId);
	int col = objId.getIndex();

	int frame = app->getCurrentFrame()->getFrame();
	if (m_currentFrame != frame)
		m_temporaryPinnedColumns.clear();

	TAffine aff = getMatrix();
	// puo' suggere che il placement degeneri (es.: c'e' uno h-scale = 0%)
	if (fabs(aff.det()) < 0.00001)
		return;

	// m_unit = getPixelSize() * sqrt(fabs(aff.det()));

	if (!ikEnabled)
		drawLevelBoundingBox(frame, col);

	glPushMatrix();
	tglMultMatrix(aff.inv());

	// camera stand reference system
	//glColor3d(0,1,0);
	//tglDrawRect(0,0,100,100);

	bool changingParent = dynamic_cast<ParentChangeTool *>(m_dragTool) != 0;

	// !changingParent &&
	if (m_mode.getValue() == BUILD_SKELETON && !xsh->getStageObjectParent(objId).isColumn()) {
		if (!changingParent)
			drawHooks();
	}

	Skeleton skeleton;
	buildSkeleton(skeleton, col);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	drawSkeleton(skeleton, frame);
	glDisable(GL_BLEND);

	TXshCell cell = xsh->getCell(frame, objId.getIndex());
	Skeleton::Bone *rootBone = skeleton.getRootBone();
	for (int i = 0; i < skeleton.getBoneCount(); i++) {
		Skeleton::Bone *bone = skeleton.getBone(i);
		TStageObjectId currentId = bone->getStageObject()->getId();
		bool isCurrent = (currentId == objId);
		TPointD pos = bone->getCenter();
		if (isCurrent && m_mode.getValue() != BUILD_SKELETON) {
			drawDrawingBrowser(cell, pos);
		}

		bool isActiveChain = bone->isSelected();

		glColor3d(0, 1, 0);
		if (ikEnabled) {
			drawIKJoint(bone);
		} else {
			TPointD pos = bone->getCenter();
			if (isCurrent && m_mode.getValue() == ANIMATE) {
				drawMainGadget(pos);
			}
		}
	}
	m_currentFrame = frame;

	if (m_dragTool)
		m_dragTool->draw();
	glPopMatrix();
}