Skip to content

Commit

Permalink
Minor modifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Apr 13, 2024
1 parent 6ed1db0 commit 7815dbc
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 44 deletions.
6 changes: 3 additions & 3 deletions RFIX/AddOnFix.grc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "ResourceIds.hpp"

'MDID' ID_ADDON_ID "Add-On Identifier" {
826567491
4078716927
826567491
4078716927
}

'GICN' ID_ADDON_ICON "AddOnIcon" {
"AddOnIcon"
"AddOnIcon"
}
32 changes: 16 additions & 16 deletions RINT/AddOn.grc
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#include "ResourceIds.hpp"

'STR#' ID_ADDON_INFO "Add-On Name and Description" {
/* [ 1] */ "Dotbim Add-On"
/* [ 2] */ "Add-On to import and export Dotbim (.bim) files.\n\nVersion 0.0.7"
/* [ 1] */ "Dotbim Add-On"
/* [ 2] */ "Add-On to import and export Dotbim (.bim) files.\n\nVersion 0.0.7"
}

'STR#' ID_ADDON_MENU "Strings for the Menu" {
/* [ 1] */ "Export Dotbim File... ^E3 ^ES ^EE ^EI ^ED ^ET ^10001"
/* [ 1] */ "Export Dotbim File... ^E3 ^ES ^EE ^EI ^ED ^ET ^10001"
}

'STR#' ID_ADDON_STRS "Add-on Strings" {
/* [ 1] */ "Dotbim File"
/* [ 2] */ "Merge Dotbim File"
/* [ 3] */ "Dotbim Material %T"
/* [ 1] */ "Dotbim File"
/* [ 2] */ "Merge Dotbim File"
/* [ 3] */ "Dotbim Material %T"
}

'STR#' ID_ADDON_PROP_STRS "Add-on Property Strings" {
/* [ 1] */ "ID"
/* [ 2] */ "Project Name"
/* [ 3] */ "Generated By"
/* [ 4] */ "Untitled"
/* [ 1] */ "ID"
/* [ 2] */ "Project Name"
/* [ 3] */ "Generated By"
/* [ 4] */ "Untitled"
}

'STR#' ID_ADDON_WARN3D_STRS "Switch to 3D Warning Strings" {
/* [ 1] */ "Open 3D Window"
/* [ 2] */ "To export the model you must open the 3D window. What would you like to do?"
/* [ 3] */ "Open 3D"
/* [ 4] */ "Cancel"
/* [ 5] */ "Failed to import dotbim file."
/* [ 6] */ "OK"
/* [ 1] */ "Open 3D Window"
/* [ 2] */ "To export the model you must open the 3D window. What would you like to do?"
/* [ 3] */ "Open 3D"
/* [ 4] */ "Cancel"
/* [ 5] */ "Failed to import dotbim file."
/* [ 6] */ "OK"
}
6 changes: 3 additions & 3 deletions Source/AddOnMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ static GSErrCode ExportDotbimFromMenu ()

DG::FileDialog saveFileDialog (DG::FileDialog::Type::Save);
GS::UniString fileTypeString = RSGetIndString (AddOnStrsID, FormatNameID, ACAPI_GetOwnResModule ());
FTM::FileTypeManager fileTypeManager (fileTypeString.ToCStr ());
FTM::FileType fileType (nullptr, "bim", 0, 0, 0);
FTM::TypeID fileTypeId = FTM::FileTypeManager::SearchForType (fileType);
FTM::FileTypeManager fileTypeManager ("Dotbim");
FTM::FileType fileType (fileTypeString.ToCStr (CC_UTF8), "bim", 0, 0, 0);
FTM::TypeID fileTypeId = fileTypeManager.AddType (fileType);
saveFileDialog.AddFilter (fileTypeId);

IO::Location fileLoc = saveFileDialog.GetSelectedFolder ();
Expand Down
21 changes: 17 additions & 4 deletions Source/DotbimExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
#include <stringbuffer.h>

#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>

namespace std
{

template <>
struct hash<Color>
{
Expand All @@ -32,6 +34,16 @@ struct hash<Color>
return color.r + 12289 * color.g + 24593 * color.b + 49157 * color.a;
}
};

template <>
struct hash<ModelerAPI::BaseElemId>
{
size_t operator() (const ModelerAPI::BaseElemId& baseElemId) const noexcept
{
return baseElemId.GenerateHashValue ();
}
};

}

static const Color DefaultElemColor (200, 200, 200, 255);
Expand Down Expand Up @@ -111,7 +123,7 @@ class JsonBuilderEnumerator : public TriangleEnumerator
std::unordered_set<Color> usedColors;
};

using BaseElemIdToMeshIndex = GS::HashTable<ModelerAPI::BaseElemId, rapidjson::SizeType>;
using BaseElemIdToMeshIndex = std::unordered_map<ModelerAPI::BaseElemId, rapidjson::SizeType>;

static void ExportElement (
const ModelEnumerator& enumerator,
Expand All @@ -137,11 +149,12 @@ static void ExportElement (
rapidjson::SizeType meshId = meshesArray.Size ();
ModelerAPI::BaseElemId baseElemId;
if (enumerator.GetElementBaseElementId (elementIndex, baseElemId)) {
if (baseElemIdToMeshIndex.ContainsKey (baseElemId)) {
auto found = baseElemIdToMeshIndex.find (baseElemId);
if (found != baseElemIdToMeshIndex.end ()) {
needToAddNewMesh = false;
meshId = baseElemIdToMeshIndex.Get (baseElemId);
meshId = found->second;
} else {
baseElemIdToMeshIndex.Add (baseElemId, meshId);
baseElemIdToMeshIndex.insert ({ baseElemId, meshId });
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/DotbimImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static GSErrCode ImportDotbimElement (
morphElement.morph.tranmat.tmx[10] = matrix.Get (2, 2);
morphElement.morph.tranmat.tmx[11] = matrix.Get (2, 3);

// TODO: seems like it doesn't have any effect
// seems like it doesn't have any effect
morphElement.morph.edgeType = APIMorphEdgeType_HardHiddenEdge;
err = ACAPI_Element_Create (&morphElement, &bodyMemo);
if (err != NoError) {
Expand Down
20 changes: 10 additions & 10 deletions Source/ModelEnumerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ class ModelEnumerator
public:
ModelEnumerator (const ModelerAPI::Model& model);

USize GetElementCount () const;
USize GetElementCount () const;
const GS::Guid& GetElementGuid (UIndex index) const;
bool GetElementBaseElementId (UIndex index, ModelerAPI::BaseElemId& baseElemId) const;
bool GetElementTransformation (UIndex index, ModelerAPI::Transformation& transformation) const;
void EnumerateElementGeometry (UIndex index, TriangleEnumerator& enumerator) const;
bool GetElementBaseElementId (UIndex index, ModelerAPI::BaseElemId& baseElemId) const;
bool GetElementTransformation (UIndex index, ModelerAPI::Transformation& transformation) const;
void EnumerateElementGeometry (UIndex index, TriangleEnumerator& enumerator) const;

private:
void BuildHierarchy ();
bool IsHierarchicalMainElement (const GS::Guid& elementGuid) const;
Int32 EnumerateElement (const ModelerAPI::Element& element, ModelerAPI::CoordinateSystem coordSystem, Int32 vertexOffset, TriangleEnumerator& enumerator) const;
void BuildHierarchy ();
bool IsHierarchicalMainElement (const GS::Guid& elementGuid) const;
Int32 EnumerateElement (const ModelerAPI::Element& element, ModelerAPI::CoordinateSystem coordSystem, Int32 vertexOffset, TriangleEnumerator& enumerator) const;

const ModelerAPI::Model& model;
GS::Array<GuidAndType> topLevelElements;
GS::HashTable<GS::Guid, ModelerAPI::Element> guidToElement;
GS::HashTable<GS::Guid, GS::Array<GS::Guid>> elemHierarchy;
GS::Array<GuidAndType> topLevelElements;
GS::HashTable<GS::Guid, ModelerAPI::Element> guidToElement;
GS::HashTable<GS::Guid, GS::Array<GS::Guid>> elemHierarchy;
};
14 changes: 7 additions & 7 deletions Source/ResourceIds.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#define ID_ADDON_INFO 32000
#define ID_ADDON_MENU 32001
#define ID_ADDON_STRS 32002
#define ID_ADDON_PROP_STRS 32003
#define ID_ADDON_WARN3D_STRS 32004
#define ID_ADDON_INFO 32000
#define ID_ADDON_MENU 32001
#define ID_ADDON_STRS 32002
#define ID_ADDON_PROP_STRS 32003
#define ID_ADDON_WARN3D_STRS 32004

#define ID_ADDON_ID 32500
#define ID_ADDON_ICON 10001
#define ID_ADDON_ID 32500
#define ID_ADDON_ICON 10001

0 comments on commit 7815dbc

Please sign in to comment.