Forum

How hightlight full object?

13 July 2017 14:36
Hi.

How can get the file path from a texture?.
I need to store this information for later retrieval with:

var m_globalvariables	= require("globalvariables"); // my module for global vars
// save original texture path:
m_globalvariables.texture = how?;

// when i need change for other texture:
var textures = m_tex.get_texture_names(obj);
m_tex.change_image(obj, textures[0], APP_ASSETS_PATH + "/my_new_temporal_texture.jpg");

// restore previous original texture:
var textures = m_tex.get_texture_names(obj);
m_tex.change_image(obj, textures[0], m_globalvariables.texture);


Thanks.
13 July 2017 14:55
I don't think you can load a texture or access it by its self. You may be able to use inherit_material() to get a texture from another object.
Maybe you can load a simple plane object in hidden mode and use it to pull your material from.
13 July 2017 14:58
Is for hightlight (fill complete object), to interactive objects, here one visual example mockup:


What would be the best way to do it?
Some objects have more than one material.
13 July 2017 15:41
I Now I'm testing with:

var m_tex = require("textures");
var m_textures = require("__textures");
var m_globalvariables	= require("globalvariables"); // my module for global vars

// save original texture path:
var textures = m_tex.get_texture_names(obj);
var fileTex = m_textures.get_texture_by_name(obj, textures[0]);
// m_globalvariables.texture = fileTex.img_name;
// m_globalvariables.texture = fileTex.img_filepath;
m_globalvariables.texture = fileTex.img_full_filepath;

// when i need change for other texture:
var textures = m_tex.get_texture_names(obj);
m_tex.change_image(obj, textures[0], APP_ASSETS_PATH + "/my_new_temporal_texture.jpg");

// restore previous original texture:
var textures = m_tex.get_texture_names(obj);
m_tex.change_image(obj, textures[0], m_globalvariables.texture);
13 July 2017 16:22
I have an example project in another post that might help you. LINK
Basically, you have two objects and you show one and hide the other. I did this with a few logic nodes. There is an example .blend file attached to the post linked above.
14 July 2017 12:53
How can get the file path from a texture?
This can't be done via API at the moment.

Reply to post of user sciremedia
I Now I'm testing with:

var m_tex = require("textures");
var m_textures = require("__textures");
var m_globalvariables	= require("globalvariables"); // my module for global vars

// save original texture path:
var textures = m_tex.get_texture_names(obj);
var fileTex = m_textures.get_texture_by_name(obj, textures[0]);
// m_globalvariables.texture = fileTex.img_name;
// m_globalvariables.texture = fileTex.img_filepath;
m_globalvariables.texture = fileTex.img_full_filepath;

// when i need change for other texture:
var textures = m_tex.get_texture_names(obj);
m_tex.change_image(obj, textures[0], APP_ASSETS_PATH + "/my_new_temporal_texture.jpg");

// restore previous original texture:
var textures = m_tex.get_texture_names(obj);
m_tex.change_image(obj, textures[0], m_globalvariables.texture);
Yes, this can work, but it has one drawback - you're using engine's internal methods/properties, that are not in the official API and tend to change over time, thus any engine update can broke the application code. I'd avoid such situation, but if you're not planning to update the engine version during/after the development, then this is not an issue.
Also, if you directly rely on the internal code you should concern about the compilation and building. The "advanced" obfuscation level (which is the best in matter of size) makes internal engine's code incompatible with external scripts unless you compile the application code and the engine together.

What would be the best way to do it?
It depends. The method suggested by Will is good, because it's simple and straightforward. Also, you can use a special node setup for node materials, when you mix the original and the highlight colors via the "MixRGB" node defining the mixing factor via the "Value" node, which is accessible from the API. However, these all require an additional work with objects and materials in a blend-file.

If you want to do it only by coding, you can use your current approach, but be aware of the aforementioned drawbacks.
 
Please register or log in to leave a reply.