Ejemplo n.º 1
0
ezStatus ezToolsProject::Create()
{
  {
    ezOSFile ProjectFile;
    if (ProjectFile.Open(m_sProjectPath, ezFileMode::Write).Failed())
    {
      return ezStatus(ezFmt("Could not open/create the project file for writing: '{0}'", m_sProjectPath));
    }
    else
    {
      const char* szToken = "ezEditor Project File";

      ProjectFile.Write(szToken, ezStringUtils::GetStringElementCount(szToken) + 1);
      ProjectFile.Close();
    }
  }

  // Create default folders
  {
    CreateSubFolder("Scenes");
    CreateSubFolder("Prefabs");
  }

  ezToolsProjectEvent e;
  e.m_pProject = this;
  e.m_Type = ezToolsProjectEvent::Type::ProjectCreated;
  s_Events.Broadcast(e);

  return Open();
}
Ejemplo n.º 2
0
ezStatus ezPropertyAnimAssetDocumentManager::InternalCreateDocument(const char* szDocumentTypeName, const char* szPath,
                                                                    bool bCreateNewDocument, ezDocument*& out_pDocument)
{
  out_pDocument = new ezPropertyAnimAssetDocument(szPath);

  return ezStatus(EZ_SUCCESS);
}
Ejemplo n.º 3
0
ezStatus ezToolsProject::Open()
{
  ezOSFile ProjectFile;
  if (ProjectFile.Open(m_sProjectPath, ezFileMode::Read).Failed())
  {
    return ezStatus(ezFmt("Could not open the project file for reading: '{0}'", m_sProjectPath));
  }

  ProjectFile.Close();

  ezToolsProjectEvent e;
  e.m_pProject = this;
  e.m_Type = ezToolsProjectEvent::Type::ProjectOpened;
  s_Events.Broadcast(e);

  return ezStatus(EZ_SUCCESS);
}
Ejemplo n.º 4
0
  ezStatus Importer::ImportSkeleton(ezEditableSkeleton& out_Skeleton, const ezSharedPtr<Scene>& scene)
  {
    const float fScale = 1.0f;
    const ezMat3 mTransformation = ezMat3::IdentityMatrix();
    const ezMat3 mTransformRotations = ezMat3::IdentityMatrix();

    const ezUInt32 numJoints = scene->m_Skeleton.GetJointCount();

    ezDynamicArray<ezEditableSkeletonJoint*> allJoints;
    allJoints.SetCountUninitialized(numJoints);

    ezSet<ezString> jointNames;
    ezStringBuilder tmp;

    for (ezUInt32 b = 0; b < numJoints; ++b)
    {
      const ezTransform mJointTransform = scene->m_Skeleton.GetJointByIndex(b).GetBindPoseLocalTransform();

      allJoints[b] = EZ_DEFAULT_NEW(ezEditableSkeletonJoint);
      allJoints[b]->m_sName = scene->m_Skeleton.GetJointByIndex(b).GetName();
      allJoints[b]->m_Transform = mJointTransform;
      allJoints[b]->m_Transform.m_vScale.Set(1.0f);

      allJoints[b]->m_fLength = 0.1f;
      allJoints[b]->m_fThickness = 0.01f;
      allJoints[b]->m_fWidth = 0.01f;
      allJoints[b]->m_Geometry = ezSkeletonJointGeometryType::None;

      if (jointNames.Contains(allJoints[b]->m_sName))
      {
        tmp = allJoints[b]->m_sName.GetData();
        tmp.AppendFormat("_joint{0}", b);
        allJoints[b]->m_sName.Assign(tmp.GetData());
      }

      jointNames.Insert(allJoints[b]->m_sName.GetString());

      if (scene->m_Skeleton.GetJointByIndex(b).IsRootJoint())
      {
        allJoints[b]->m_Transform.m_vPosition = mTransformation * allJoints[b]->m_Transform.m_vPosition;
        allJoints[b]->m_Transform.m_qRotation.SetFromMat3(mTransformRotations * allJoints[b]->m_Transform.m_qRotation.GetAsMat3());

        out_Skeleton.m_Children.PushBack(allJoints[b]);
      }
      else
      {
        allJoints[b]->m_Transform.m_vPosition = fScale * allJoints[b]->m_Transform.m_vPosition;

        ezUInt32 parentIdx = scene->m_Skeleton.GetJointByIndex(b).GetParentIndex();
        EZ_ASSERT_DEBUG(parentIdx < b, "Invalid parent joint index");
        allJoints[parentIdx]->m_Children.PushBack(allJoints[b]);
      }
    }

    return ezStatus(EZ_SUCCESS);
  }
Ejemplo n.º 5
0
  ezStatus Importer::ImportMesh(const char* szSceneFile, const char* szSubMesh, bool bSkinnedMesh,
                                ezSharedPtr<ezModelImporter::Scene>& outScene, ezModelImporter::Mesh*& outMesh)
  {
    ezBitflags<ImportFlags> importFlags = ImportFlags::Meshes;

    if (bSkinnedMesh)
      importFlags |= ImportFlags::Skeleton;

    outScene = ezModelImporter::Importer::GetSingleton()->ImportScene(szSceneFile, importFlags);
    if (!outScene)
    {
      return ezStatus(ezFmt("Input file '{0}' could not be imported", szSceneFile));
    }

    if (outScene->GetMeshes().GetCount() == 0)
    {
      return ezStatus("Scene does not contain any meshes.");
    }

    if (ezStringUtils::IsNullOrEmpty(szSubMesh))
    {
      outMesh = outScene->MergeAllMeshes();
    }
    else
    {
      outMesh = nullptr;
      for (auto it = outScene->GetMeshes().GetIterator(); it.IsValid(); ++it)
      {
        if (it.Value()->m_Name == szSubMesh)
        {
          outMesh = it.Value().Borrow();
          break;
        }
      }

      if (outMesh == nullptr)
      {
        return ezStatus(ezFmt("Scene does not contain a mesh with name '{0}'.", szSubMesh));
      }
    }

    return ezStatus(EZ_SUCCESS);
  }
Ejemplo n.º 6
0
ezStatus ezToolsProject::CreateOrOpenProject(const char* szProjectPath, bool bCreate)
{
  CloseProject();

  new ezToolsProject(szProjectPath);

  ezStatus ret;

  if (bCreate)
    ret = GetSingleton()->Create();
  else
    ret = GetSingleton()->Open();

  if (ret.m_Result.Failed())
  {
    delete GetSingleton();
    return ret;
  }

  return ezStatus(EZ_SUCCESS);
}
Ejemplo n.º 7
0
void ezQtNodeScene::DisconnectPinsAction(ezQtPin* pPin)
{
  ezHybridArray<ezQtConnection*, 6> connections;
  for (ezQtConnection* pConnection : pPin->GetConnections())
  {
    connections.PushBack(pConnection);
  }

  ezCommandHistory* history = m_pManager->GetDocument()->GetCommandHistory();
  history->StartTransaction("Disconnect Pins");

  ezStatus res = ezStatus(EZ_SUCCESS);
  for (ezQtConnection* pConnection : connections)
  {
    DisconnectPinsAction(pConnection);
  }

  if (res.m_Result.Failed())
    history->CancelTransaction();
  else
    history->FinishTransaction();

  ezQtUiServices::GetSingleton()->MessageBoxStatus(res, "Adding sub-element to the property failed.");
}