13 #include "vrmlAppearance.h" 15 #include "deg_2_rad.h" 18 VRMLAppearance(
const VrmlNode *appearance) {
19 _has_material =
false;
21 _color.set(1.0f, 1.0f, 1.0f, 1.0f);
22 _has_tex_transform =
false;
24 if (appearance != NULL) {
25 const VrmlNode *material = appearance->get_value(
"material")._sfnode._p;
26 if (material != NULL) {
28 const double *c = material->get_value(
"diffuseColor")._sfvec;
29 _transparency = material->get_value(
"transparency")._sffloat;
30 _color.set(c[0], c[1], c[2], 1.0 - _transparency);
33 const VrmlNode *tex_transform = appearance->get_value(
"textureTransform")._sfnode._p;
34 if (tex_transform != NULL) {
35 if (strcmp(tex_transform->_type->getName(),
"TextureTransform") == 0) {
36 _has_tex_transform =
true;
37 const double *c = tex_transform->get_value(
"center")._sfvec;
38 _tex_center.set(c[0], c[1]);
39 _tex_rotation = tex_transform->get_value(
"rotation")._sffloat;
40 const double *s = tex_transform->get_value(
"scale")._sfvec;
41 _tex_scale.set(s[0], s[1]);
42 const double *t = tex_transform->get_value(
"translation")._sfvec;
43 _tex_translation.set(t[0], t[1]);
47 const VrmlNode *texture = appearance->get_value(
"texture")._sfnode._p;
48 if (texture != NULL) {
49 if (strcmp(texture->_type->getName(),
"ImageTexture") == 0) {
50 MFArray *url = texture->get_value(
"url")._mf;
52 const char *filename = (*url->begin())._sfstring;
55 if (_has_tex_transform) {
56 _tex->add_translate2d(-_tex_center);
57 _tex->add_scale2d(_tex_scale);
58 _tex->add_rotate2d(rad_2_deg(_tex_rotation));
59 _tex->add_translate2d(_tex_center);
60 _tex->add_translate2d(_tex_translation);
Defines a texture map that may be applied to geometry.