Revision: 45546
http://brlcad.svn.sourceforge.net/brlcad/?rev=45546&view=rev
Author: kunigami
Date: 2011-07-19 21:31:55 +0000 (Tue, 19 Jul 2011)
Log Message:
-----------
Added support for setting string parameters to OSL shaders
Modified Paths:
--------------
brlcad/trunk/src/liboptical/liboslrend.cpp
brlcad/trunk/src/liboptical/liboslrend.h
brlcad/trunk/src/liboptical/sh_osl.cpp
Modified: brlcad/trunk/src/liboptical/liboslrend.cpp
===================================================================
--- brlcad/trunk/src/liboptical/liboslrend.cpp 2011-07-19 20:52:39 UTC (rev
45545)
+++ brlcad/trunk/src/liboptical/liboslrend.cpp 2011-07-19 21:31:55 UTC (rev
45546)
@@ -68,6 +68,8 @@
shadingsys->Parameter(sh_info.fparam[i].first.c_str(),
TypeDesc::TypeFloat, &(sh_info.fparam[i].second));
for(size_t i = 0; i < sh_info.cparam.size(); i++)
shadingsys->Parameter(sh_info.cparam[i].first.c_str(),
TypeDesc::TypeColor, &(sh_info.cparam[i].second));
+ for(size_t i = 0; i < sh_info.sparam.size(); i++)
+ shadingsys->Parameter(sh_info.sparam[i].first.c_str(),
TypeDesc::TypeString, &(sh_info.sparam[i].second));
if(sh_info.layername == "")
shadingsys->Shader("surface", sh_info.shadername.c_str(), NULL);
Modified: brlcad/trunk/src/liboptical/liboslrend.h
===================================================================
--- brlcad/trunk/src/liboptical/liboslrend.h 2011-07-19 20:52:39 UTC (rev
45545)
+++ brlcad/trunk/src/liboptical/liboslrend.h 2011-07-19 21:31:55 UTC (rev
45546)
@@ -77,6 +77,7 @@
std::string layername; // Name of the layer (name of this partilar
instance)
std::vector< std::pair<std::string, float> > fparam;
std::vector< std::pair<std::string, Color3> > cparam;
+ std::vector< std::pair<std::string, std::string> > sparam;
};
/* Represents a parameter a shader */
struct ShaderParam {
Modified: brlcad/trunk/src/liboptical/sh_osl.cpp
===================================================================
--- brlcad/trunk/src/liboptical/sh_osl.cpp 2011-07-19 20:52:39 UTC (rev
45545)
+++ brlcad/trunk/src/liboptical/sh_osl.cpp 2011-07-19 21:31:55 UTC (rev
45546)
@@ -176,7 +176,6 @@
/* Name of the parameter */
std::string param_name = item;
-
/* Get the type of parameter being set */
item = strtok(NULL, "#");
if(item == NULL){
@@ -204,6 +203,20 @@
}
sh_info.cparam.push_back(std::make_pair(param_name,
color_value));
}
+ else if(strcmp(item, "string") == 0){
+ item = strtok(NULL, "#");
+ if(item == NULL){
+ fprintf(stderr, "[Error] Missing string\n");
+ return -1;
+ }
+ std::string string_value = item;
+ sh_info.sparam.push_back(std::make_pair(param_name,
string_value));
+ }
+ else {
+ /* FIXME: add support to TypeInt, TypePoint, TypeVector,
TypeNormal, TypeString parameters */
+ fprintf(stderr, "[Error] Unknown parameter type\n");
+ return -1;
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits