Is there a way to automate the command in the title? <Edit> <Mesh> <ConvertTexture / Material to RGB. I didn't see it as an option in the Command Line interface, but I am pretty new to that sort of thing.
Thanks,
CC is an amazing piece of software. Thanks!
<Edit> <Mesh> <ConvertTexture / Material to RGB in Command Line?
Re: <Edit> <Mesh> <ConvertTexture / Material to RGB in Command Line?
I don't think so sadly!
Daniel, CloudCompare admin
Re: <Edit> <Mesh> <ConvertTexture / Material to RGB in Command Line?
Thank you for your reply! Is it possible to create a plugin based on the original menu code (i.e. <Edit><Mesh><ConvertTexture> and then load that as a plugin and call the plugin from the command line? How difficult is that?
-
- Posts: 187
- Joined: Tue Mar 05, 2019 3:59 pm
Re: <Edit> <Mesh> <ConvertTexture / Material to RGB in Command Line?
it would make more sense to just add the tool to the standard command line in CC if you have some C++ experience or want to learn I can provide some example info to help get it going.
Re: <Edit> <Mesh> <ConvertTexture / Material to RGB in Command Line?
WargodHernandez, That would be great! I would appreciate it if you could point me in the right direction.
-
- Posts: 187
- Joined: Tue Mar 05, 2019 3:59 pm
Re: <Edit> <Mesh> <ConvertTexture / Material to RGB in Command Line?
Sorry for the delay, I missed this reply,
The action you will want to call is located here:
ccEntityAction::convertTextureToColor
This is a super easy function to call just pass the commandline Mesh group to it
Here is one example command to examine to understand the requirements, this converts Normals to Dip and Dip Dir, just copy the two functions changing names and relevant content
You'll need to create a command string, here is the Normals to dip dir
I would change it to something like:
and place it somewhere in the list of commands in ccCommandLineCommands.cpp
Here are the two main functions to modify:
Add these two functions (but changed for the command you want to implement) to ccCommandLineCommands.cpp
And then copy and modify the following: Add a command struct like this (but changed for the command you want to implement) to ccCommandLineCommands.h
The action you will want to call is located here:
ccEntityAction::convertTextureToColor
This is a super easy function to call just pass the commandline Mesh group to it
Here is one example command to examine to understand the requirements, this converts Normals to Dip and Dip Dir, just copy the two functions changing names and relevant content
You'll need to create a command string, here is the Normals to dip dir
Code: Select all
constexpr char COMMAND_CONVERT_NORMALS_TO_DIP[] = "NORMALS_TO_DIP";
Code: Select all
constexpr char COMMAND_CONVERT_TEXTURE_TO_RGB[] = "TEXTURE_TO_RGB";
Here are the two main functions to modify:
Code: Select all
CommandConvertNormalsToDipAndDipDir::CommandConvertNormalsToDipAndDipDir()
: ccCommandLineInterface::Command(QObject::tr("Convert normals to dip and dip. dir."), COMMAND_CONVERT_NORMALS_TO_DIP)
{}
bool CommandConvertNormalsToDipAndDipDir::process(ccCommandLineInterface &cmd)
{
cmd.print(QObject::tr("[CONVERT NORMALS TO DIP/DIP DIR]"));
if (cmd.clouds().empty())
{
return cmd.error(QObject::tr("No input point cloud (be sure to open one with \"-%1 [cloud filename]\" before \"-%2\")").arg(COMMAND_OPEN, COMMAND_CONVERT_NORMALS_TO_DIP));
}
for (CLCloudDesc& thisCloudDesc : cmd.clouds())
{
ccPointCloud* cloud = thisCloudDesc.pc;
if (!cloud->hasNormals())
{
cmd.warning(QObject::tr("Cloud %1 has no normals").arg(cloud->getName()));
continue;
}
ccHObject::Container container;
container.push_back(cloud);
if (!ccEntityAction::convertNormalsTo(container, ccEntityAction::NORMAL_CONVERSION_DEST::DIP_DIR_SFS))
{
return cmd.error(QObject::tr("Failed to convert normals to dip and dip direction"));
}
if (cmd.autoSaveMode())
{
QString errorStr = cmd.exportEntity(thisCloudDesc, "_DIP_AND_DIP_DIR");
if (!errorStr.isEmpty())
{
return cmd.error(errorStr);
}
}
}
return true;
}
And then copy and modify the following:
Code: Select all
struct CommandConvertNormalsToDipAndDipDir : public ccCommandLineInterface::Command
{
CommandConvertNormalsToDipAndDipDir();
bool process(ccCommandLineInterface& cmd) override;
};