katsu
January 18th, 2008, 13:34
Dear RS users,
#I'm sorry for my poor English.
I use RealityServer2.1 Developer Edition.
According to the documentation "MetaSL_spec.pdf, p-7",
we are able to implement specific functions using C++ language,
and these functions are called 'native functions'.
Also, these seem to be good for compatibility between Level2 and Level3.
So, I would like to try 'native functions' implementation.
The following are my expectation:
----------------------------------------------------
1. create .cpp file (named nf_test.cpp) which includes "metasl.h".
2. In nf_test.cpp, code a function like a following:
Scalar io_test(String filename) {
FILE* fp = fopen(filename.c_str(), "rb");
float value;
fread(&value, sizeof(float), 1, fp);
fclose(fp);
return value;
}
3. compile and link nf_test.cpp, and export .dll file like a mental ray shader.
4. call this function 'io_test' by using the keyword *native* in a Level2 MetaSL shader:
input:
String data_file;
//snip...
Scalar data_value;
data_value = native io_test(data_file);
----------------------------------------------------
I'm wondering if my expectation is right or not...
I would be happy if there are sample codes
for the implementation of 'native functions' like a 'nf_test.cpp'
and the calling them in a Level2 MetaSL shader.
Also, a Level3 MetaSL shader seems to have the ability of accessing to all the features of C++.
I shall be happy if there are sample codes for this as well.
Best regards,
--katsu
#I'm sorry for my poor English.
I use RealityServer2.1 Developer Edition.
According to the documentation "MetaSL_spec.pdf, p-7",
we are able to implement specific functions using C++ language,
and these functions are called 'native functions'.
Also, these seem to be good for compatibility between Level2 and Level3.
So, I would like to try 'native functions' implementation.
The following are my expectation:
----------------------------------------------------
1. create .cpp file (named nf_test.cpp) which includes "metasl.h".
2. In nf_test.cpp, code a function like a following:
Scalar io_test(String filename) {
FILE* fp = fopen(filename.c_str(), "rb");
float value;
fread(&value, sizeof(float), 1, fp);
fclose(fp);
return value;
}
3. compile and link nf_test.cpp, and export .dll file like a mental ray shader.
4. call this function 'io_test' by using the keyword *native* in a Level2 MetaSL shader:
input:
String data_file;
//snip...
Scalar data_value;
data_value = native io_test(data_file);
----------------------------------------------------
I'm wondering if my expectation is right or not...
I would be happy if there are sample codes
for the implementation of 'native functions' like a 'nf_test.cpp'
and the calling them in a Level2 MetaSL shader.
Also, a Level3 MetaSL shader seems to have the ability of accessing to all the features of C++.
I shall be happy if there are sample codes for this as well.
Best regards,
--katsu