-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2098 Archicad Connector geometry fidelity
- Loading branch information
József L. Kiss
committed
Feb 10, 2023
1 parent
36e8a97
commit 5e6a102
Showing
39 changed files
with
1,927 additions
and
703 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
ConnectorArchicad/AddOn/Sources/AddOn/AttributeManager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include "AttributeManager.hpp" | ||
|
||
GSErrCode AttributeManager::GetMaterial (const ModelInfo::Material& material, API_Attribute& attribute) | ||
{ | ||
GS::UniString materialName (material.GetName ()); | ||
char typeId = API_MaterialID; | ||
GS::UniString key = materialName + typeId; | ||
|
||
if (cache.Get (key, &attribute)) { | ||
return NoError; | ||
} else { | ||
BNZeroMemory (&attribute, sizeof (API_Attribute)); | ||
|
||
attribute.header.uniStringNamePtr = &materialName; | ||
attribute.header.typeID = API_MaterialID; | ||
|
||
GSErrCode err = ACAPI_Attribute_Get (&attribute); | ||
if (NoError == err) { | ||
cache.Add (key, attribute); | ||
} | ||
|
||
if (APIERR_BADNAME == err) { | ||
attribute.material.mtype = APIMater_GeneralID; | ||
attribute.material.ambientPc = 100; | ||
attribute.material.diffusePc = 0; | ||
attribute.material.specularPc = 0; | ||
|
||
attribute.material.transpPc = material.GetTransparency (); | ||
attribute.material.shine = 50; | ||
attribute.material.transpAtt = 400; | ||
attribute.material.emissionAtt = 0; | ||
|
||
attribute.material.surfaceRGB.f_red = material.GetAmbientColor ().red / 65535.0; | ||
attribute.material.surfaceRGB.f_green = material.GetAmbientColor ().green / 65535.0; | ||
attribute.material.surfaceRGB.f_blue = material.GetAmbientColor ().blue / 65535.0; | ||
|
||
attribute.material.specularRGB.f_red = .0; | ||
attribute.material.specularRGB.f_green = .0; | ||
attribute.material.specularRGB.f_blue = .0; | ||
|
||
attribute.material.emissionRGB.f_red = material.GetEmissionColor ().red / 65535.0; | ||
attribute.material.emissionRGB.f_green = material.GetEmissionColor ().green / 65535.0; | ||
attribute.material.emissionRGB.f_blue = material.GetEmissionColor ().blue / 65535.0; | ||
|
||
err = ACAPI_Attribute_Create (&attribute, 0); | ||
if (NoError == err) { | ||
cache.Add (key, attribute); | ||
} | ||
} | ||
|
||
return err; | ||
} | ||
} | ||
|
||
|
||
GSErrCode AttributeManager::GetDefaultMaterial (API_Attribute& attribute, GS::UniString& name) | ||
{ | ||
GS_RGBColor ambientColor; | ||
ambientColor.red = 0x7f * 256; | ||
ambientColor.green = 0x7f * 256; | ||
ambientColor.blue = 0x7f * 256; | ||
|
||
GS_RGBColor emissionColor; | ||
emissionColor.red = 0x0; | ||
emissionColor.green = 0x0; | ||
emissionColor.blue = 0x0; | ||
|
||
name = "Default Speckle Surface"; | ||
ModelInfo::Material material (name, 0.0, ambientColor, emissionColor); | ||
|
||
return GetMaterial (material, attribute); | ||
} |
15 changes: 15 additions & 0 deletions
15
ConnectorArchicad/AddOn/Sources/AddOn/AttributeManager.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef ATTRIBUTE_MANAGER_HPP | ||
#define ATTRIBUTE_MANAGER_HPP | ||
|
||
#include "ModelInfo.hpp" | ||
|
||
class AttributeManager { | ||
private: | ||
GS::HashTable< GS::UniString, API_Attribute> cache; | ||
|
||
public: | ||
GSErrCode GetMaterial (const ModelInfo::Material& material, API_Attribute& attribute); | ||
GSErrCode GetDefaultMaterial (API_Attribute& attribute, GS::UniString& name); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.