BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Archicad C++ API
About Archicad add-on development using the C++ API.

How to get texture filename using rendering API

Anonymous
Not applicable
Hi

I am using the Rendering Dev Kit, and wish to obtain the texturemap FILENAME for a give material. Does anyone know how to do this for a given GSModeler::Polygon?

Also, I have been trying to use ACAPI_Goodies (APIAny_GetTextureCoordID, &texCoordPars, &uvCoord, NULL) to get UV coordinates (using the standard dev kit, not the rendering dev kit), however the call always return an invalid index error - even with valid bodyIdx, elemIdx and pgonIndex). Is this a bug - or am I doing it wrong? Code is :
					// Get the UVs for vert1
					API_TexCoordPars texCoordPars;
					API_UVCoord uvCoord;
					texCoordPars.bodyIdx = iBody;
					texCoordPars.elemIdx = elementId;
					texCoordPars.pgonIndex =  iPoly;

					texCoordPars.surfacePoint.x = comp3D.vert.x;
					texCoordPars.surfacePoint.y = comp3D.vert.y;
					texCoordPars.surfacePoint.z = comp3D.vert.z;

					err = ACAPI_Goodies (APIAny_GetTextureCoordID, &texCoordPars, &uvCoord, NULL);
Thanks in advance.
4 REPLIES 4
Ralph Wessel
Mentor
paulk wrote:
I am using the Rendering Dev Kit, and wish to obtain the texturemap FILENAME for a give material. Does anyone know how to do this for a given GSModeler::Polygon?
I haven't used the Rendering kit, but I'm not certain that you can get anything beyond the texture name (as opposed to a file name). Retrieve the GSModeler::Texture for the material and call its GetName method.
paulk wrote:
Also, I have been trying to use ACAPI_Goodies (APIAny_GetTextureCoordID, &texCoordPars, &uvCoord, NULL) to get UV coordinates
Try using the ModelAccess API instead. I haven't tested APIAny_GetTextureCoordID, but the GetTextureCoordinate method of the GSModeler::Polygon class does the trick.
Ralph Wessel BArch
Anonymous
Not applicable
Thanks Ralph
Retrieve the GSModeler::Texture for the material and call its GetName method.
This only gives me the texture name (like "concrete"). I need the source filename (ie. directoryname + concrete.jpg).
Try using the ModelAccess API instead. I haven't tested APIAny_GetTextureCoordID, but the GetTextureCoordinate method of the GSModeler::Polygon class does the trick.
If I use the ModelAccess API instead - then I cannot get the full filename of the texturemaps.

Older API = no UV's
ModelAccess API = no texturemap filenames.

Unfortunately I need both.

Also - GetTextureCoordinate does not seem to work - is returns UV's well outside the 0-1 range (the v coordinates always seems to be the same as the vertex x coords that was input).

Paul
Anonymous
Not applicable
I have largely been able to answer my own questions. For anyone else wanted to do this...

1) The can get the full path name using the GSModeler API by iterating through scene materials with ACAPI_Attribute_Get and matching the material name.

2) The uv's can be calculated, however GetTextureCoordinate is only part of the story. You need to convert the result of GetTextureCoordinate into uv coords, check the code in ExampleRenderingAddOn, specifically NewRend::GetTextureUV for how to do this.
Ralph Wessel
Mentor
paulk wrote:
1) The can get the full path name using the GSModeler API by iterating through scene materials with ACAPI_Attribute_Get and matching the material name.
That's not necessarily the same thing. For example, objects can contain embedded texture maps and create material definitions on the fly that won't be picked up by ACAPI_Attribute_Get. I'm guessing the reason ModelAccess objects don't return a file path is simply because a texture image may not have one. If you need the image data, however, you can always retrieve that without a file path.
Ralph Wessel BArch
Learn and get certified!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!