19VRMLAppearance(
const VrmlNode *appearance) {
20 _has_material =
false;
22 _color.set(1.0f, 1.0f, 1.0f, 1.0f);
23 _has_tex_transform =
false;
25 if (appearance !=
nullptr) {
26 const VrmlNode *material = appearance->get_value(
"material")._sfnode._p;
27 if (material !=
nullptr) {
29 const double *c = material->get_value(
"diffuseColor")._sfvec;
30 _transparency = material->get_value(
"transparency")._sffloat;
31 _color.set(c[0], c[1], c[2], 1.0 - _transparency);
34 const VrmlNode *tex_transform = appearance->get_value(
"textureTransform")._sfnode._p;
35 if (tex_transform !=
nullptr) {
36 if (strcmp(tex_transform->_type->getName(),
"TextureTransform") == 0) {
37 _has_tex_transform =
true;
38 const double *c = tex_transform->get_value(
"center")._sfvec;
39 _tex_center.set(c[0], c[1]);
40 _tex_rotation = tex_transform->get_value(
"rotation")._sffloat;
41 const double *s = tex_transform->get_value(
"scale")._sfvec;
42 _tex_scale.set(s[0], s[1]);
43 const double *t = tex_transform->get_value(
"translation")._sfvec;
44 _tex_translation.set(t[0], t[1]);
48 const VrmlNode *texture = appearance->get_value(
"texture")._sfnode._p;
49 if (texture !=
nullptr) {
50 if (strcmp(texture->_type->getName(),
"ImageTexture") == 0) {
51 MFArray *url = texture->get_value(
"url")._mf;
53 const char *filename = (*url->begin())._sfstring;
56 if (_has_tex_transform) {
57 _tex->add_translate2d(-_tex_center);
58 _tex->add_scale2d(_tex_scale);
59 _tex->add_rotate2d(rad_2_deg(_tex_rotation));
60 _tex->add_translate2d(_tex_center);
61 _tex->add_translate2d(_tex_translation);
Defines a texture map that may be applied to geometry.
This is our own Panda specialization on the default STL vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.