//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AlembicCurves::AlembicCurves(SceneNodePtr eNode, AlembicWriteJob *in_Job,
                             Abc::OObject oParent)
    : AlembicObject(eNode, in_Job, oParent)
{
  MObject nRef = GetRef();
  MFnNurbsCurve node(nRef);
  MStatus status;
  MObject abcCurveId = node.attribute("abcCurveId", &status);
  if (status == MStatus::kSuccess) {
    const int cId = MPlug(nRef, abcCurveId).asInt();
    if (cId != 0) {
      this->accumRef = AlembicCurveAccumulator::GetAccumulator(cId, nRef, eNode,
                                                               in_Job, oParent);
      return;
    }
  }

  const bool animTS = (GetJob()->GetAnimatedTs() > 0);
  mObject = AbcG::OCurves(GetMyParent(), eNode->name, animTS);
  mSchema = mObject.getSchema();

  // create all properties
  Abc::OCompoundProperty comp = mSchema.getArbGeomParams();
  mRadiusProperty =
      Abc::OFloatArrayProperty(comp, ".radius", mSchema.getMetaData(), animTS);
  mColorProperty =
      Abc::OC4fArrayProperty(comp, ".color", mSchema.getMetaData(), animTS);
  mFaceIndexProperty = Abc::OInt32ArrayProperty(comp, ".face_index",
                                                mSchema.getMetaData(), animTS);
  mVertexIndexProperty = Abc::OInt32ArrayProperty(
      comp, ".vertex_index", mSchema.getMetaData(), animTS);
  mKnotVectorProperty = Abc::OFloatArrayProperty(comp, ".knot_vector",
                                                 mSchema.getMetaData(), animTS);
}
AlembicHair::AlembicHair(SceneNodePtr eNode, AlembicWriteJob *in_Job,
                         Abc::OObject oParent)
    : AlembicObject(eNode, in_Job, oParent)
{
  const bool animTS = (GetJob()->GetAnimatedTs() > 0);
  mObject = AbcG::OCurves(GetMyParent(), eNode->name, animTS);
  mSchema = mObject.getSchema();

  // create all properties
  mRadiusProperty = Abc::OFloatArrayProperty(mSchema, ".radius",
                                             mSchema.getMetaData(), animTS);
  mColorProperty =
      Abc::OC4fArrayProperty(mSchema, ".color", mSchema.getMetaData(), animTS);
}
MStatus AlembicHair::Save(double time, unsigned int timeIndex,
    bool isFirstFrame)
{
  ESS_PROFILE_SCOPE("AlembicHair::Save");
  MStatus status;

  // access the geometry
  MFnPfxGeometry node(GetRef());

  // save the metadata
  SaveMetaData(this);

  // save the attributes
  if (isFirstFrame) {
    Abc::OCompoundProperty cp;
    Abc::OCompoundProperty up;
    if (AttributesWriter::hasAnyAttr(node, *GetJob())) {
      cp = mSchema.getArbGeomParams();
      up = mSchema.getUserProperties();
    }

    mAttrs = AttributesWriterPtr(
        new AttributesWriter(cp, up, GetMyParent(), node, timeIndex, *GetJob())
        );
  }
  else {
    mAttrs->write();
  }

  // prepare the bounding box
  Abc::Box3d bbox;

  // check if we have the global cache option
  const bool globalCache =
      GetJob()->GetOption(L"exportInGlobalSpace").asInt() > 0;

  MRenderLineArray mainLines, leafLines, flowerLines;
  node.getLineData(mainLines, leafLines, flowerLines, true, false,
                   mNumSamples == 0, false, false, mNumSamples == 0, false,
                   true, globalCache);

  // first we need to count the number of points
  unsigned int vertexCount = 0;
  for (unsigned int i = 0; i < (unsigned int)mainLines.length(); i++) {
    vertexCount += mainLines.renderLine(i, &status).getLine().length();
  }

  mPosVec.resize(vertexCount);
  unsigned int offset = 0;
  if (mNumSamples == 0) {
    mNbVertices.resize((size_t)mainLines.length());
    mRadiusVec.resize(vertexCount);
    mColorVec.resize(vertexCount);
    for (unsigned int i = 0; i < (unsigned int)mainLines.length(); i++) {
      const MRenderLine &line = mainLines.renderLine(i, &status);
      const MVectorArray &positions = line.getLine();
      const MDoubleArray &radii = line.getWidth();
      const MVectorArray &colors = line.getColor();
      const MVectorArray &transparencies = line.getTransparency();
      mNbVertices[i] = positions.length();

      for (unsigned int j = 0; j < positions.length(); j++) {
        const MVector &opos = positions[j];
        Imath::V3f &ipos = mPosVec[offset];
        ipos.x = (float)opos.x;
        ipos.y = (float)opos.y;
        ipos.z = (float)opos.z;
        bbox.extendBy(Imath::V3d(ipos));

        mRadiusVec[offset] = (float)radii[j];

        const MVector &ocol = colors[j];
        Imath::C4f &icol = mColorVec[offset];
        icol.r = (float)ocol.x;
        icol.g = (float)ocol.y;
        icol.b = (float)ocol.z;
        icol.a = 1.0f - (float)transparencies[j].x;
        offset++;
      }
    }
  }
  else {
    for (unsigned int i = 0; i < (unsigned int)mainLines.length(); i++) {
      const MRenderLine &line = mainLines.renderLine(i, &status);
      const MVectorArray &positions = line.getLine();
      for (unsigned int j = 0; j < positions.length(); j++) {
        const MVector &opos = positions[j];
        Imath::V3f &ipos = mPosVec[offset];
        ipos.x = (float)opos.x;
        ipos.y = (float)opos.y;
        ipos.z = (float)opos.z;
        bbox.extendBy(Imath::V3d(ipos));
        offset++;
      }
    }
  }

  // store the positions to the samples
  mSample.setPositions(Abc::P3fArraySample(&mPosVec.front(), mPosVec.size()));
  mSample.setSelfBounds(bbox);

  if (mNumSamples == 0) {
    mSample.setCurvesNumVertices(Abc::Int32ArraySample(mNbVertices));
    mSample.setWrap(AbcG::kNonPeriodic);
    mSample.setType(AbcG::kLinear);

    mRadiusProperty.set(
        Abc::FloatArraySample(&mRadiusVec.front(), mRadiusVec.size()));
    mColorProperty.set(
        Abc::C4fArraySample(&mColorVec.front(), mColorVec.size()));
  }

  // save the sample
  mSchema.set(mSample);
  mNumSamples++;

  return MStatus::kSuccess;
}
Beispiel #4
0
void CTextEditWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	switch(nChar)
	{
	case VK_CONTROL:
		m_bKeyControl = TRUE;
		break;
	case VK_SHIFT:
		m_bKeyShift = TRUE;
		break;
	case VK_BACK:
		if (m_bKeyControl == TRUE)
		{
			AvcOneStepBack((CFrameMain *)GetParent());
		}
		break;
	case VK_F11:
		if (m_bKeyShift && m_bKeyControl)
		{
			GetMyParent()->OnSettingsAyanamsavalue();
		}
		break;
	case 'A':
		if (m_bKeyControl == TRUE)
			OnEditSelectall();
		break;
	case 'C':
		if (m_bKeyControl == TRUE)
			OnEditCopy();
		break;
	case 'F':
		if (m_bKeyControl == TRUE)
			GetMyParent()->OnToolsFindMhd();
		break;
	case VK_F9:
		GetMyParent()->OnCalculateAppearanceday();
		break;
	case 'E':
		if (m_bKeyControl == TRUE)
			GetMyParent()->OnCalculateEvents();
		break;
	case 'M':
		if (m_bKeyControl == TRUE)
			GetMyParent()->OnCalculateMasalisting();
		break;
	case VK_F5:
		GetMyParent()->OnCalculatePreviousday();
		break;
	case VK_F6:
		GetMyParent()->OnCalculateToday();
		break;
	case VK_F7:
		GetMyParent()->OnCalculateNextday();
		break;
	case VK_F8:
		GetMyParent()->OnCalculateCalendar();
		break;

	default:
		break;
	}

	
	CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
MStatus AlembicCurves::Save(double time, unsigned int timeIndex,
    bool isFirstFrame)
{
  ESS_PROFILE_SCOPE("AlembicCurves::Save");

  if (this->accumRef.get() != 0) {
    accumRef->save(GetRef(), time);
    ++mNumSamples;
    return MStatus::kSuccess;
  }

  // access the geometry
  MFnNurbsCurve node(GetRef());

  // save the metadata
  SaveMetaData(this);

  // save the attributes
  if (isFirstFrame) {
    Abc::OCompoundProperty cp;
    Abc::OCompoundProperty up;
    if (AttributesWriter::hasAnyAttr(node, *GetJob())) {
      cp = mSchema.getArbGeomParams();
      up = mSchema.getUserProperties();
    }

    mAttrs = AttributesWriterPtr(
        new AttributesWriter(cp, up, GetMyParent(), node, timeIndex, *GetJob())
        );
  }
  else {
    mAttrs->write();
  }

  // prepare the bounding box
  Abc::Box3d bbox;

  // check if we have the global cache option
  const bool globalCache =
      GetJob()->GetOption(L"exportInGlobalSpace").asInt() > 0;
  Abc::M44f globalXfo;
  if (globalCache) {
    globalXfo = GetGlobalMatrix(GetRef());
  }

  MPointArray positions;
  node.getCVs(positions);

  mPosVec.resize(positions.length());
  for (unsigned int i = 0; i < positions.length(); i++) {
    const MPoint &outPos = positions[i];
    Imath::V3f &inPos = mPosVec[i];
    inPos.x = (float)outPos.x;
    inPos.y = (float)outPos.y;
    inPos.z = (float)outPos.z;
    if (globalCache) {
      globalXfo.multVecMatrix(inPos, inPos);
    }
    bbox.extendBy(inPos);
  }

  // store the positions to the samples
  mSample.setPositions(Abc::P3fArraySample(&mPosVec.front(), mPosVec.size()));
  mSample.setSelfBounds(bbox);

  if (mNumSamples == 0) {
    // knot vector!
    MDoubleArray knots;
    node.getKnots(knots);

    mKnotVec.resize(knots.length());
    for (unsigned int i = 0; i < knots.length(); ++i) {
      mKnotVec[i] = (float)knots[i];
    }

    mKnotVectorProperty.set(Abc::FloatArraySample(mKnotVec));

    mNbVertices.push_back(node.numCVs());
    mSample.setCurvesNumVertices(Abc::Int32ArraySample(mNbVertices));

    if (node.form() == MFnNurbsCurve::kOpen) {
      mSample.setWrap(AbcG::kNonPeriodic);
    }
    else {
      mSample.setWrap(AbcG::kPeriodic);
    }

    if (node.degree() == 3) {
      mSample.setType(AbcG::kCubic);
    }
    else {
      mSample.setType(AbcG::kLinear);
    }

    MPlug widthPlug = node.findPlug("width");
    if (!widthPlug.isNull()) {
      mRadiusVec.push_back(widthPlug.asFloat());
    }
    else {
      mRadiusVec.push_back(1.0);
    }

    mRadiusProperty.set(
        Abc::FloatArraySample(&mRadiusVec.front(), mRadiusVec.size()));
  }

  // save the sample
  mSchema.set(mSample);
  mNumSamples++;

  return MStatus::kSuccess;
}