35#include <libFreeWRL.h>
37#include "../vrml_parser/Structs.h"
38#include "../main/headers.h"
39#include "../opengl/Frustum.h"
40#include "../opengl/Material.h"
41#include "../opengl/OpenGL_Utils.h"
42#include "../opengl/Textures.h"
43#include "Component_ProgrammableShaders.h"
44#include "Component_Shape.h"
45#include "RenderFuncs.h"
46#include "LinearAlgebra.h"
62 struct X3D_Node * this_textureTransform;
74static void *Component_Shape_constructor(){
79void Component_Shape_init(
struct tComponent_Shape *t){
82 t->prv = Component_Shape_constructor();
84 ppComponent_Shape p = (ppComponent_Shape)t->prv;
86 p->isBackMaterial = 0;
90void fwl_set_modulation(
int modulation){
91 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
92 p->modulation = modulation;
94int fwl_get_modulation(){
95 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
100 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
102 return &p->appearanceProperties;
106static int hasUserDefinedShader(
struct X3D_Node *node) {
107#define NO_SHADER 99999
108 unsigned int rv = NO_SHADER;
110 if (node==NULL)
return 0;
114 if (node->_nodeType == NODE_Appearance) {
119 if (ap && ap->shaders.n != 0) {
123 if (ap->shaders.n > 1) {
124 ConsoleMessage (
"warning, Appearance->shaders has more than 1 node, using only first one");
131 if (cps->_nodeType == NODE_ComposedShader) {
136 if (cps->_retrievedURLData) {
137 if (cps->_shaderUserNumber == -1) cps->_shaderUserNumber = getNextFreeUserDefinedShaderSlot();
138 rv = cps->_shaderUserNumber;
140 }
else if (cps->_nodeType == NODE_PackagedShader) {
142 if (X3D_PACKAGEDSHADER(cps)->_retrievedURLData) {
143 if (X3D_PACKAGEDSHADER(cps)->_shaderUserNumber == -1)
144 X3D_PACKAGEDSHADER(cps)->_shaderUserNumber = getNextFreeUserDefinedShaderSlot();
145 rv = X3D_PACKAGEDSHADER(cps)->_shaderUserNumber;
147 }
else if (cps->_nodeType == NODE_ProgramShader) {
149 if (X3D_PROGRAMSHADER(cps)->_retrievedURLData) {
150 if (X3D_PROGRAMSHADER(cps)->_shaderUserNumber == -1)
151 X3D_PROGRAMSHADER(cps)->_shaderUserNumber = getNextFreeUserDefinedShaderSlot();
153 rv = X3D_PROGRAMSHADER(cps)->_shaderUserNumber;
156 ConsoleMessage (
"shader field of Appearance is a %s, ignoring",stringNodeType(cps->_nodeType));
166 if (rv == NO_SHADER) rv = 0;
177 POSSIBLE_PROTO_EXPANSION(
struct X3D_Appearance *, X3D_NODE(appearance),tmpN)
178 if(tmpN && tmpN->texture)
179 if(tmpN->texture->_nodeType == NODE_GeneratedCubeMapTexture) ret = TRUE;
183void setUserShaderNode(
struct X3D_Node *me) {
184 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
185 p->userShaderNode = me;
188struct X3D_Node *getThis_textureTransform(){
189 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
190 return p->this_textureTransform;
192void clear_bound_textures();
193void push_isBackMaterial(){
194 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
195 p->isBackMaterial += 1;
197void pop_isBackMaterial(){
198 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
199 p->isBackMaterial -= 1;
201int get_isBackMaterial(){
202 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
203 return p->isBackMaterial;
208 ttglobal tg = gglobal();
209 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
216 PRINT_GL_ERROR_IF_ANY(
"child_Appearance start");
218 RENDER_MATERIAL_SUBNODES(node->material);
219 if(node->material && node->material->_nodeType == NODE_TwoSidedMaterial)
220 getAppearanceProperties()->twosided = TRUE;
221 else if(node->backMaterial){
222 push_isBackMaterial();
223 getAppearanceProperties()->twosided = TRUE;
224 RENDER_MATERIAL_SUBNODES(node->backMaterial);
225 pop_isBackMaterial();
231 if (node->fillProperties) {
232 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->fillProperties,tmpN);
237 if (node->lineProperties) {
238 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->lineProperties,tmpN);
241 if (node->pointProperties) {
242 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->pointProperties,tmpN);
245 if (node->textureTransform) {
246 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
248 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node*, node->textureTransform, p->this_textureTransform);
254 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
261 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->texture,tmpN);
262 tg->RenderFuncs.texturenode = (
void*)tmpN;
265 if (!node->material) {
267 mat->fw_FrontMaterial.type = MAT_UNLIT;
272 if (node->shaders.n !=0) {
274 int foundGoodShader = FALSE;
276 for (count=0; count<node->shaders.n; count++) {
277 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->shaders.p[count], tmpN);
281 if (foundGoodShader) {
284 SET_SHADER_SELECTED_FALSE(tmpN);
287 SET_FOUND_GOOD_SHADER(tmpN);
288 DEBUG_SHADER(
"running shader (%s) %d of %d\n",
289 stringNodeType(X3D_NODE(tmpN)->_nodeType),count, node->shaders.n);
297 if (node->effects.n !=0) {
300 prep_sibAffectors(X3D_NODE(node),&node->effects);
322 PRINT_GL_ERROR_IF_ANY(
"child_Appearance end");
330 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
338 if(get_isBackMaterial()){
339 memcpy (&p->appearanceProperties.fw_BackMaterial, node->_material, sizeof (
struct fw_MaterialParameters));
341 memcpy (&p->appearanceProperties.fw_FrontMaterial, node->_material, sizeof (
struct fw_MaterialParameters));
360 node->ambientIntensity = fclamp(node->ambientIntensity,0.0f,1.0f);
361 node->shininess = fclamp(node->shininess,0.0f,1.0f);
362 node->occlusionStrength = fclamp(node->occlusionStrength, 0.0f, 1.0f);
363 node->normalScale = fclamp(node->normalScale, 1.0f, 1.e9f);
364 node->transparency = fclamp(node->transparency,0.0f,1.0f);
365 fvecclamp3f(node->diffuseColor.c,0.0f,1.0f);
366 fvecclamp3f(node->emissiveColor.c,0.0f,1.0f);
367 fvecclamp3f(node->specularColor.c,0.0f,1.0f);
369 if(!node->_material){
371 register_node_gc(node,node->_material);
376 vecset3f(q->baseColor,1.0f,1.0f,1.0f);
377 veccopy3f(q->diffuse,node->diffuseColor.c);
378 veccopy3f(q->emissive,node->emissiveColor.c);
379 veccopy3f(q->specular,node->specularColor.c);
380 q->ambient = node->ambientIntensity;
381 q->shininess = node->shininess;
384 q->transparency = node->transparency;
385 q->occlusion = node->occlusionStrength;
387 q->normalScale = node->normalScale;
388 q->type = MAT_REGULAR;
393 tnodes = q->textures;
394 memset(tnodes,0,7*
sizeof(
void *));
395 if(node->normalTexture)
397 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->normalTexture,tnodes[0]);
398 if (tnodes[0]) q->map[0] = node->normalTextureMapping ? node->normalTextureMapping->strptr : NULL;
400 if(node->emissiveTexture)
402 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->emissiveTexture,tnodes[1]);
403 if (tnodes[1]) q->map[1] = node->emissiveTextureMapping ? node->emissiveTextureMapping->strptr : NULL;
405 if(node->occlusionTexture)
407 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->occlusionTexture,tnodes[2]);
408 if (tnodes[2]) q->map[2] = node->occlusionTextureMapping ? node->occlusionTextureMapping->strptr : NULL;
410 if(node->diffuseTexture)
412 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->diffuseTexture,tnodes[3]);
413 if (tnodes[3]) q->map[3] = node->diffuseTextureMapping ? node->diffuseTextureMapping->strptr : NULL;
415 if(node->shininessTexture)
417 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->shininessTexture,tnodes[4]);
418 if (tnodes[4]) q->map[4] = node->shininessTextureMapping ? node->shininessTextureMapping->strptr : NULL;
420 if(node->specularTexture)
422 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->specularTexture,tnodes[5]);
423 if (tnodes[5]) q->map[5] = node->specularTextureMapping ? node->specularTextureMapping->strptr : NULL;
425 if (node->ambientTexture)
427 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node*, node->ambientTexture, tnodes[6]);
428 if (tnodes[6]) q->map[6] = node->ambientTextureMapping ? node->ambientTextureMapping->strptr : NULL;
439 for(
int i=0;i<7;i++){
441 q->tstart[i] = q->nt;
443 if(tnodes[i]->_nodeType == NODE_MultiTexture) {
445 q->tcount[i] = mt->texture.n;
446 q->nt += mt->texture.n;
457void clear_materialparameters_per_draw_counts() {
463 for (
int iuse = 0; iuse < 7; iuse++) {
464 mat->fw_FrontMaterial.tstart[iuse] = 0;
465 mat->fw_FrontMaterial.tcount[iuse] = 0;
466 mat->fw_BackMaterial.tstart[iuse] = 0;
467 mat->fw_BackMaterial.tcount[iuse] = 0;
469 mat->fw_FrontMaterial.nt = 0;
470 mat->fw_BackMaterial.nt = 0;
473#define CHECK_COLOUR_FIELD(aaa) \
475 struct X3D_##aaa *me = (struct X3D_##aaa *)realNode; \
476 if (me->color == NULL) return NOTHING; \
477 else return COLOUR_MATERIAL_SHADER; \
480#define CHECK_FOGCOORD_FIELD(aaa) \
482 struct X3D_##aaa *me = (struct X3D_##aaa *)realNode; \
483 if (me->fogCoord == NULL) return NOTHING; \
484 else return HAVE_FOG_COORDS; \
492static bool getIfLinePoints(
struct X3D_Node *realNode) {
493 if (realNode == NULL)
return false;
494 switch (realNode->_nodeType) {
495 case NODE_IndexedLineSet:
498 case NODE_Polyline2D:
499 case NODE_Polypoint2D:
510 int *fieldOffsetsPtr = NULL;
513 if (realGeomNode == NULL)
return tc;
515 fieldOffsetsPtr = (
int *)NODE_OFFSETS[realGeomNode->_nodeType];
517 while (*fieldOffsetsPtr != -1) {
518 if (*fieldOffsetsPtr == FIELDNAMES_texCoord) {
520 memcpy(&tc,offsetPointer_deref(
void*, realGeomNode,*(fieldOffsetsPtr+1)),
sizeof(
struct X3D_Node *));
523 fieldOffsetsPtr += FIELDOFFSET_LENGTH;
528static int getShapeTextureCoordGen(
struct X3D_Node *realNode) {
530 tc = getGeomTexCoordField(realNode);
532 if (tc->_nodeType == NODE_TextureCoordinateGenerator)
return HAVE_TEXTURECOORDINATEGENERATOR;
539static int getShapeColourShader (
struct X3D_Node *myGeom) {
542 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *,myGeom,realNode);
544 if (realNode == NULL)
return NOTHING;
549 switch (realNode->_nodeType) {
550 CHECK_COLOUR_FIELD(IndexedFaceSet);
551 CHECK_COLOUR_FIELD(IndexedLineSet);
552 CHECK_COLOUR_FIELD(IndexedTriangleFanSet);
553 CHECK_COLOUR_FIELD(IndexedTriangleSet);
554 CHECK_COLOUR_FIELD(IndexedTriangleStripSet);
555 CHECK_COLOUR_FIELD(LineSet);
556 CHECK_COLOUR_FIELD(PointSet);
557 CHECK_COLOUR_FIELD(TriangleFanSet);
558 CHECK_COLOUR_FIELD(TriangleStripSet);
559 CHECK_COLOUR_FIELD(TriangleSet);
560 CHECK_COLOUR_FIELD(ElevationGrid);
561 CHECK_COLOUR_FIELD(GeoElevationGrid);
562 CHECK_COLOUR_FIELD(QuadSet);
563 CHECK_COLOUR_FIELD(IndexedQuadSet);
570static int getShapeFogShader (
struct X3D_Node *myGeom) {
573 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *,myGeom,realNode);
575 if (realNode == NULL)
return NOTHING;
580 switch (realNode->_nodeType) {
581 CHECK_FOGCOORD_FIELD(IndexedFaceSet);
582 CHECK_FOGCOORD_FIELD(IndexedLineSet);
583 CHECK_FOGCOORD_FIELD(IndexedTriangleFanSet);
584 CHECK_FOGCOORD_FIELD(IndexedTriangleSet);
585 CHECK_FOGCOORD_FIELD(IndexedTriangleStripSet);
586 CHECK_FOGCOORD_FIELD(LineSet);
587 CHECK_FOGCOORD_FIELD(PointSet);
588 CHECK_FOGCOORD_FIELD(TriangleFanSet);
589 CHECK_FOGCOORD_FIELD(TriangleStripSet);
590 CHECK_FOGCOORD_FIELD(TriangleSet);
591 CHECK_FOGCOORD_FIELD(ElevationGrid);
593 CHECK_FOGCOORD_FIELD(QuadSet);
594 CHECK_FOGCOORD_FIELD(IndexedQuadSet);
600void compile_material_if_required(
struct X3D_Node *node){
601 COMPILE_IF_REQUIRED(node);
604static long long getAppearanceShader (
struct X3D_Node *myApp) {
606 struct X3D_Node *realMaterialNode, *realBackMaterialNode;
609 long long retval = NOTHING;
612 if (myApp == NULL)
return retval;
614 POSSIBLE_PROTO_EXPANSION(
struct X3D_Appearance *, myApp,realAppearanceNode);
615 if (!realAppearanceNode || realAppearanceNode->_nodeType != NODE_Appearance)
return retval;
618 realMaterialNode = realBackMaterialNode = NULL;
619 if (realAppearanceNode->backMaterial != NULL) {
620 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, realAppearanceNode->backMaterial,realBackMaterialNode);
622 if (realAppearanceNode->material != NULL) {
623 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, realAppearanceNode->material,realMaterialNode);
625 if(realMaterialNode || realBackMaterialNode) {
628 int material, texture, multitex, twosided, physical, unlit;
629 material = texture = multitex = twosided = physical = unlit = FALSE;
632 if(realMaterialNode){
633 compile_material_if_required(realMaterialNode);
634 switch(realMaterialNode->_nodeType){
642 case NODE_PhysicalMaterial:
649 case NODE_UnlitMaterial:
656 case NODE_TwoSidedMaterial:
669 if(realBackMaterialNode){
670 compile_material_if_required(realBackMaterialNode);
671 switch(realBackMaterialNode->_nodeType){
679 case NODE_PhysicalMaterial:
686 case NODE_UnlitMaterial:
693 case NODE_TwoSidedMaterial:
707 if(p->nt) texture = TRUE;
708 if(p->mt) multitex = TRUE;
712 if(q->nt) texture = TRUE;
713 if(q->mt) multitex = TRUE;
716 if(twosided) retval |= TWO_MATERIAL_APPEARANCE_SHADER;
717 if(material) retval |= MATERIAL_APPEARANCE_SHADER;
718 if(physical) retval |= PHYSICAL_MATERIAL_APPEARANCE_SHADER;
719 if(unlit) retval |= UNLIT_MATERIAL_APPEARANCE_SHADER;
721 if(texture) retval |= ONE_TEX_APPEARANCE_SHADER;
722 if(multitex) retval |= MULTI_TEX_APPEARANCE_SHADER;
724 if(realBackMaterialNode || realMaterialNode->_nodeType == NODE_TwoSidedMaterial ) {
725 retval |= TWO_MATERIAL_APPEARANCE_SHADER;
727 if (realMaterialNode->_nodeType == NODE_Material || (realBackMaterialNode && realBackMaterialNode->_nodeType == NODE_Material)) {
728 retval |= MATERIAL_APPEARANCE_SHADER;
730 if (realMaterialNode->_nodeType == NODE_PhysicalMaterial || (realBackMaterialNode && realBackMaterialNode->_nodeType == NODE_PhysicalMaterial)) {
731 retval |= PHYSICAL_MATERIAL_APPEARANCE_SHADER;
733 if (realMaterialNode->_nodeType == NODE_UnlitMaterial || (realBackMaterialNode && realBackMaterialNode->_nodeType == NODE_UnlitMaterial)) {
734 retval |= UNLIT_MATERIAL_APPEARANCE_SHADER;
746 if (realAppearanceNode->fillProperties != NULL) {
748 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, realAppearanceNode->fillProperties,fp);
750 if (fp->_nodeType != NODE_FillProperties) {
751 ConsoleMessage(
"getAppearanceShader, fillProperties has a node type of %s",stringNodeType(fp->_nodeType));
754 if (X3D_FILLPROPERTIES(fp)->_enabled)
755 retval |= FILL_PROPERTIES_SHADER;
760 if (realAppearanceNode->lineProperties != NULL) {
762 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, realAppearanceNode->lineProperties,lp);
764 if (lp->_nodeType != NODE_LineProperties) {
765 ConsoleMessage(
"getAppearanceShader, lineProperties has a node type of %s",stringNodeType(lp->_nodeType));
768 if (X3D_LINEPROPERTIES(lp)->applied){
769 if(X3D_LINEPROPERTIES(lp)->linetype > 1)
770 retval |= LINE_PROPERTIES_SHADER;
776 if (realAppearanceNode->pointProperties != NULL) {
778 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, realAppearanceNode->pointProperties,pp);
780 if (pp->_nodeType != NODE_PointProperties) {
781 ConsoleMessage(
"getAppearanceShader, pointProperties has a node type of %s",stringNodeType(pp->_nodeType));
783 if(X3D_POINTPROPERTIES(pp)->_pointMethod > 0)
784 retval |= POINT_PROPERTIES_SHADER;
789 if (realAppearanceNode->texture != NULL) {
793 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, realAppearanceNode->texture,tex);
795 if ((tex->_nodeType == NODE_ImageTexture) ||
796 (tex->_nodeType == NODE_MovieTexture) ||
797 (tex->_nodeType == NODE_PixelTexture) ){
798 retval |= ONE_TEX_APPEARANCE_SHADER;
799 }
else if( (tex->_nodeType == NODE_PixelTexture3D) ||
800 (tex->_nodeType == NODE_ComposedTexture3D) ||
801 (tex->_nodeType == NODE_ImageTexture3D) ) {
802 retval |= ONE_TEX_APPEARANCE_SHADER;
803 retval |= TEX3D_SHADER;
804 if(tex->_nodeType == NODE_ComposedTexture3D)
805 retval |= TEX3D_LAYER_SHADER;
806 }
else if (tex->_nodeType == NODE_MultiTexture) {
807 retval |= MULTI_TEX_APPEARANCE_SHADER;
810 for (
int i = 0; i < mt->texture.n; i++) {
811 struct X3D_Node *stex = mt->texture.p[i];
812 if ((stex->_nodeType == NODE_PixelTexture3D) ||
813 (stex->_nodeType == NODE_ComposedTexture3D) ||
814 (stex->_nodeType == NODE_ImageTexture3D)) {
815 retval |= TEX3D_SHADER;
816 if (stex->_nodeType == NODE_ComposedTexture3D)
817 retval |= TEX3D_LAYER_SHADER;
819 if ((stex->_nodeType == NODE_ComposedCubeMapTexture) ||
820 (stex->_nodeType == NODE_ImageCubeMapTexture) ||
821 (stex->_nodeType == NODE_GeneratedCubeMapTexture)) {
822 retval |= HAVE_CUBEMAP_TEXTURE;
825 }
else if ((tex->_nodeType == NODE_ComposedCubeMapTexture) ||
826 (tex->_nodeType == NODE_ImageCubeMapTexture) ||
827 (tex->_nodeType == NODE_GeneratedCubeMapTexture)) {
828 retval |= HAVE_CUBEMAP_TEXTURE;
830 ConsoleMessage (
"getAppearanceShader, texture field %s not supported yet\n",
831 stringNodeType(tex->_nodeType));
837 printf (
"getAppearanceShader, returning %x\n",retval);
882 algor = node->hatchStyle; filled = node->filled; hatched = node->hatched;
885 me->filledBool = filled;
886 me->hatchedBool = hatched;
887 me->hatchAlgo = algor;
888 me->hatchColour[0]=node->hatchColor.c[0]; me->hatchColour[1]=node->hatchColor.c[1]; me->hatchColour[2] = node->hatchColor.c[2];
889 me->hatchColour[3] = 1.0;
892void printBitsB(
size_t const size,
void const *
const ptr);
928 {10.0f,12.0f,2.0f,12.0f},
935 {16.0f,10.0f,2.0f,9.0f,2.0f,9.0f},
970 {8.0f,4.0f,4.0f,4.0f},
991 {24.0f,3.0f,6.0f,3.0f,6.0f,3.0f},
997 14,
"break line - style 1",1,
1000 {{ 0.00f,0.0f},{ 9.60f,-1.44f},{12.80f,-1.28f},{14.72f,-2.40f},{19.20f,-1.76f},{24.32f,1.28f},{28.80f,2.24f},{36.96f,1.60f},{42.40f,2.24f},{48.00f,1.12f},{51.20f,-1.92f},{55.36f,-0.96f},{62.40f,1.28f},{76.80f,1.12f},{82.88f,-1.60f},{85.92f,-0.64f},{97.44f,4.32f},{101.12f,4.96f},{108.80f,1.12f},{112.16f,1.12f},{120.00f,0.00f},{125.12f,2.72f},{128.0f,0.0f}},
1004 15,
"break line - style 2",1,
1007 {{0.f,0.f},{20.f,0.f},{24.f,4.f},{32.f,-4.f},{36.f,0.f},},
1011 16,
"fallback for user style 16",1,
1022float make_linetype_atlas_row(
float *dash,
int ndash,
vec2 *zig,
int nzig,
1023 float *uv_row,
float *tse_row){
1024 float period = 0.0f;
1025 for(
int j=0;j<ndash;j++)
1030 float curr_start = 0.0f;
1031 float curr_end = dash[0];
1034 for(
int j=0;j<(int)(period+.5);j++){
1037 curr_start = curr_end;
1039 curr_end = curr_start + dash[idash];
1041 int gap = idash % 2 != 0 ? TRUE: FALSE;
1044 uu = u_ - curr_start < (curr_end - u_) ? curr_start : curr_end;
1050 uv_row[j*2+1] = 0.0f;
1051 tse_row[j*3] = gap ? 0 : 2;
1052 tse_row[j*3+1] = curr_start;
1053 tse_row[j*3+2] = curr_end;
1056 for(
int k=1;k<nzig;k++){
1059 if(d0.u <= u_ && u_ < d1.u){
1061 zigv = (u_ - d0.u)/(d1.u - d0.u) * (d1.v - d0.v) + d0.v;
1064 uv_row[j*2+1] = zigv;
1069static float *linetype_atlas_uv = NULL;
1070static float *linetype_atlas_tse = NULL;
1093 int nlinetypes = 20;
1094 linetype_atlas_uv = MALLOCV(128*
sizeof(
float)*2*nlinetypes);
1095 linetype_atlas_tse = MALLOCV(128*
sizeof(
float)*3*nlinetypes);
1096 memset(linetype_atlas_uv,0,128*
sizeof(
float)*2*nlinetypes);
1097 memset(linetype_atlas_tse,0,128*
sizeof(
float)*3*nlinetypes);
1098 for(
int i=0;i<16;i++){
1099 float * uv_row = &linetype_atlas_uv[128*2*i];
1100 float * tse_row = &linetype_atlas_tse[128*3*i];
1101 struct lineinfo *lt = &linetypes[i];
1103 int ndash = lt->ndash;
1104 float *dash = lt->dash;
1105 int nzig = lt->nzig;
1107 lt->period = make_linetype_atlas_row(dash,ndash,zig,nzig,uv_row,tse_row);
1112 float atlas_uv[256];
1113 float atlas_tse[384];
1117 if(linetype_atlas_uv){
1118 if(me->linetype == 16 && node->__style16){
1120 me->linetype_uv = &s16->atlas_uv[0];
1121 me->linetype_tse = &s16->atlas_tse[0];
1123 int irow = me->linetype-1;
1124 me->linetype_uv = &linetype_atlas_uv[irow*2*128];
1125 me->linetype_tse = &linetype_atlas_tse[irow*3*128];
1127 int start_style, end_style;
1128 start_style = node->__styleStart;
1129 end_style = node->__styleEnd;
1130 switch(me->linetype){
1131 case 6: end_style = 1;
break;
1132 case 7: end_style = 2;
break;
1133 case 8: start_style = 1;
1134 end_style = 1;
break;
1138 me->linestrip_start_style = start_style;
1139 me->linestrip_end_style = end_style;
1145 int start_style, end_style;
1146 start_style = end_style = 0;
1147 if(!strcmp(node->styleStart->strptr,
"ARROW")) start_style = 1;
1148 if(!strcmp(node->styleStart->strptr,
"DOT")) start_style = 2;
1149 if(!strcmp(node->styleEnd->strptr,
"ARROW")) end_style = 1;
1150 if(!strcmp(node->styleEnd->strptr,
"DOT")) end_style = 2;
1151 node->__styleStart = start_style;
1152 node->__styleEnd = end_style;
1153 if(node->type16dashes.n || node->type16wiggles.n){
1154 if(node->__style16 == NULL){
1155 node->__style16 = MALLOCV(
sizeof(
struct style16));
1156 memset(node->__style16,0,
sizeof(
struct style16));
1158 struct style16* s16 = node->__style16;
1159 int ndash = node->type16dashes.n;
1160 float *dash = node->type16dashes.p;
1161 float *uv_row = s16->atlas_uv;
1162 float *tse_row = s16->atlas_tse;
1163 int nzig = node->type16wiggles.n;
1164 vec2 *zig = (
vec2 *)node->type16wiggles.p;
1165 s16->period = make_linetype_atlas_row(dash,ndash,zig,nzig,uv_row,tse_row);
1169int get_GLSL_max_version();
1223 if (node->applied) {
1225 int linetype_capable_shader = get_GLSL_max_version() >= 130;
1227 if (node->linewidthScaleFactor > 1.0 || !linetype_capable_shader) {
1229 me= getAppearanceProperties();
1230 me->pointSize = node->linewidthScaleFactor ? node->linewidthScaleFactor : 1.0f;
1232 glLineWidth(me->pointSize);
1234 if(node->linetype > 1 && linetype_capable_shader){
1236 me= getAppearanceProperties();
1238 me->linetype = node->linetype;
1241 if(linetype_atlas_uv == NULL){
1242 make_linetype_atlas(me);
1244 if(linetype_atlas_uv){
1245 send_linetype_atlas_to_shader(node,me);
1247 me->lineperiod = linetypes[node->linetype - 1].period;
1248 me->linewidth = node->linewidthScaleFactor;
1249 me->pointSize = 10.0f;
1250 glLineWidth(me->pointSize);
1255PP_COLORMODE_NONE = 0,
1256PP_COLORMODE_POINT = 1,
1257PP_COLORMODE_TEXTURE = 2,
1258PP_COLORMODE_BOTH = 3,
1259} pointproperties_colormodes;
1274 update_node(X3D_NODE(node));
1276 node->_colormode = PP_COLORMODE_BOTH;
1282 float *attenuation = node->_attenuation.c;
1286 attenuation[0] = node->attenuation.n > 0 ? attenuation[0] = node->attenuation.p[0] : 1.0f;
1287 attenuation[1] = node->attenuation.n > 1 ? attenuation[1] = node->attenuation.p[1] : 0.0f;
1288 attenuation[2] = node->attenuation.n > 0 ? attenuation[2] = node->attenuation.p[2] : 0.0f;
1291 int SCREENSCALE = APPROX(node->_attenuation.c[0],1.0f) && APPROX(node->_attenuation.c[1],0.0f) && APPROX(node->_attenuation.c[2],0.0f) ? TRUE : FALSE;
1292 SCREENSCALE = SCREENSCALE && APPROX(node->pointSizeMinValue,node->pointSizeMaxValue);
1294 int OBJECTSCALE = APPROX(node->_attenuation.c[0],0.0f) && APPROX(node->_attenuation.c[1],1.0f) && APPROX(node->_attenuation.c[2],0.0f) ? TRUE : FALSE;
1295 OBJECTSCALE = OBJECTSCALE && APPROX(node->pointSizeMinValue,0.0F) && node->pointSizeScaleFactor && node->pointSizeMaxValue > 10.0f*node->pointSizeScaleFactor;
1296 node->_pointMethod = SCREENSCALE ? PM_SCREEN : OBJECTSCALE ? PM_OBJECT : PM_FANCY;
1307 me= getAppearanceProperties();
1308 me->pointSize = node->pointSizeScaleFactor > 0.0f ? node->pointSizeScaleFactor : 1.0f;
1310 veccopy3f(me->pointsizeAttenuation,node->_attenuation.c);
1311 me->pointColorMode = node->_colormode;
1312 me->pointsizeRange[0] = node->pointSizeMinValue;
1313 me->pointsizeRange[1] = node->pointSizeMaxValue;
1314 me->pointMethod = node->_pointMethod;
1318int getImageChannelCountFromTTI(
struct X3D_Node *appearanceNode ){
1320 int channels, imgalpha, haveTexture;
1325 POSSIBLE_PROTO_EXPANSION(
struct X3D_Appearance*,appearanceNode,appearance);
1329 if(appearance->texture){
1334 if(appearance->texture->_nodeType == NODE_MultiTexture ||
1335 appearance->texture->_nodeType == NODE_ComposedTexture3D ){
1338 switch(appearance->texture->_nodeType){
1339 case NODE_MultiTexture: mtex = &((
struct X3D_MultiTexture*)appearance->texture)->texture;
break;
1340 case NODE_ComposedTexture3D: mtex = &((
struct X3D_ComposedTexture3D*)appearance->texture)->texture;
break;
1345 for(k=0;k<mtex->n;k++){
1346 textureTableIndexStruct_s *tti = getTableTableFromTextureNode(mtex->p[k]);
1352 channels = max(channels,tti->channels);
1353 imgalpha = max(tti->hasAlpha,imgalpha);
1360 textureTableIndexStruct_s *tti = getTableTableFromTextureNode(appearance->texture);
1366 channels = tti->channels;
1367 imgalpha = tti->hasAlpha;
1374 channels = haveTexture ? channels : 0;
1381 mat->shininess = .2f;
1382 vecset3f(mat->diffuse,1.0f,1.0f,1.0f);
1383 vecset3f(mat->baseColor,1.0f,1.0f,1.0f);
1384 mat->occlusion = 1.0f;
1385 mat->normalScale = 1.0f;
1386 vecset3f(mat->emissive, 1.0f, .8f, 1.0f);
1387 mat->type = MAT_NONE;
1389void initialize_front_and_back_material_params(){
1390 ppComponent_Shape p;
1391 ttglobal tg = gglobal();
1392 p = (ppComponent_Shape)tg->Component_Shape.prv;
1394 initialize_fw_MaterialParameters(&p->appearanceProperties.fw_FrontMaterial);
1395 initialize_fw_MaterialParameters(&p->appearanceProperties.fw_BackMaterial);
1397void initialize_non_material_appearance_parameters() {
1399 memset(getAppearanceProperties(), 0,
sizeof(
struct matpropstruct));
1405void update_effect_uniforms();
1407void textureTransform_start();
1409void reallyDrawOnce();
1410void sendProjectorInfo();
1411static struct X3D_Shape* wrap_shape = NULL;
1412void push_shape(
struct X3D_Shape* node) {
1421void* peek_humanoid_skinCoord();
1423void sendSkinningInfo();
1424void clearSkinningInfo();
1425void PRINT_GL_ERROR(GLenum _global_gl_err);
1427int peek_group_visible();
1428void child_Shape (
struct X3D_Shape *node) {
1433 ppComponent_Shape p;
1434 ttglobal tg = gglobal();
1442 if(!(node->geometry)) {
return; }
1444 if((renderstate()->render_collision) || (renderstate()->render_sensitive) || (renderstate()->render_other) || (renderstate()->render_depth)) {
1446 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *,node->geometry,tmpNG);
1447 if (renderstate()->render_depth) {
1448 if (node->castShadow) {
1449 PRINT_GL_ERROR_IF_ANY(
"child_shape depth start");
1450 s_shader_capabilities_t* scap;
1453 shader_requirements.depth = TRUE;
1454 scap = getMyShaders(shader_requirements);
1455 enableGlobalShader(scap);
1456 sendMatriciesToShader(scap);
1458 if (peek_group_visible()) {
1463 finishedWithGlobalShader();
1465 PRINT_GL_ERROR_IF_ANY(
"child_shape depth end");
1473 if ((renderstate()->render_cube) && hasGeneratedCubeMapTexture((
struct X3D_Appearance*)node->appearance))
1476 p = (ppComponent_Shape)tg->Component_Shape.prv;
1477 PRINT_GL_ERROR_IF_ANY(
"child_shape START");
1481 tg->RenderFuncs.last_texture_type = NOTEXTURE;
1482 tg->RenderFuncs.shapenode = node;
1485 initialize_non_material_appearance_parameters();
1486 initialize_front_and_back_material_params();
1489 prep_BBox((
struct BBoxFields*)&node->bboxCenter);
1492 if (renderstate()->render_blend == (node->_renderFlags & VF_Blend)) {
1494 s_shader_capabilities_t *scap;
1498 PRINT_GL_ERROR_IF_ANY(
"child_shape before render_material_subnodes");
1501 RENDER_MATERIAL_SUBNODES(node->appearance);
1506 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->geometry,tmpNG);
1510 shader_requirements.base = node->_shaderflags_base;
1512 void* hsc = peek_humanoid_skinCoord();
1513 int do_skinning = FALSE;
1517 if (pr && (pr->itype == 1 || pr->itype == 2)) {
1518 void* coordnode = pr->coordinate_node;
1519 if(pr->itype == 1) {
1521 coordnode = lr->coordinate_node;
1523 if (coordnode && coordnode == hsc) {
1524 shader_requirements.base |= SKINNING_SHADER;
1527 if(hr->bo_dindex) shader_requirements.base |= DISPLACER_SHADER;
1532 shader_requirements.effects = node->_shaderflags_effects;
1533 shader_requirements.usershaders = node->_shaderflags_usershaders;
1534 isUserShader = shader_requirements.usershaders ? TRUE : FALSE;
1554 int channels,modulation,scenefile_specversion;
1565 channels = getImageChannelCountFromTTI(node->appearance);
1568 scenefile_specversion = X3D_PROTO(node->_executionContext)->__specversion;
1571 switch(fwl_get_modulation()){
1574 modulation = scenefile_specversion >= 400 ? TRUE : FALSE;
1577 modulation = FALSE;
break;
1579 modulation = TRUE;
break;
1583 if(modulation == TRUE){
1584 shader_requirements.base |= MODULATE_TEXTURE;
1586 if(!channels || (channels == 1 || channels == 3))
1587 shader_requirements.base |= MODULATE_ALPHA;
1588 if(channels && (channels == 1 || channels == 2) )
1589 shader_requirements.base |= MODULATE_COLOR;
1595 shader_requirements.base |= getShaderFlags().base;
1596 shader_requirements.effects |= getShaderFlags().effects;
1601 scap = getMyShaders(shader_requirements);
1602 enableGlobalShader(scap);
1604 PRINT_GL_ERROR_IF_ANY(
"AFTER getMyShaders");
1607 if (tmpNG && tmpNG->_intern && tmpNG->_intern->itype == 2) {
1609 if (tmppr->tcoordtype == NODE_TextureCoordinateGenerator) {
1610 getAppearanceProperties()->texCoordGeneratorType = tmppr->texgentype;
1616 if(isUserShader && p->userShaderNode){
1620 switch (p->userShaderNode->_nodeType) {
1621 case NODE_ComposedShader:
1622 if (X3D_COMPOSEDSHADER(p->userShaderNode)->isValid) {
1623 if (!X3D_COMPOSEDSHADER(p->userShaderNode)->_initialized) {
1624 PRINT_GL_ERROR_IF_ANY(
"BEFORE send fields");
1625 sendInitialFieldsToShader(p->userShaderNode);
1626 PRINT_GL_ERROR_IF_ANY(
"AFTER send fields");
1630 case NODE_ProgramShader:
1631 if (X3D_PROGRAMSHADER(p->userShaderNode)->isValid) {
1632 if (!X3D_PROGRAMSHADER(p->userShaderNode)->_initialized) {
1633 sendInitialFieldsToShader(p->userShaderNode);
1638 case NODE_PackagedShader:
1639 if (X3D_PACKAGEDSHADER(p->userShaderNode)->isValid) {
1640 if (!X3D_PACKAGEDSHADER(p->userShaderNode)->_initialized) {
1641 sendInitialFieldsToShader(p->userShaderNode);
1649 if(shader_requirements.effects){
1650 update_effect_uniforms();
1654 #ifdef SHAPEOCCLUSION
1673 clear_textureUnit_used();
1675 clear_material_samplers();
1677 clear_materialparameters_per_draw_counts();
1679 textureTransform_start();
1680 sendProjectorInfo();
1685 if (do_skinning) sendSkinningInfo();
1695 if(peek_group_visible()){
1696 PRINT_GL_ERROR_IF_ANY(
"child_shape before reallyDrawOnce");
1700 static int err_count = 0;
1701 if (err_count < 10) {
1703 GLenum _global_gl_err = glGetError();
1704 while (_global_gl_err != GL_NONE && err_count < 10) {
1705 PRINT_GL_ERROR(_global_gl_err);
1706 printf(
" here: %s (%s:%d)\n",
"child_shape after reallyDrawOnce",
"Component_Shape", __LINE__);
1707 _global_gl_err = glGetError();
1715 if (do_skinning) clearSkinningInfo();
1716 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
1717 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
1718 textureTransform_end();
1720 #ifdef SHAPEOCCLUSION
1725 if(node->appearance){
1727 POSSIBLE_PROTO_EXPANSION(
struct X3D_Appearance *,node->appearance,tmpA);
1729 fin_sibAffectors(X3D_NODE(tmpA),&tmpA->effects);
1737 finishedWithGlobalShader();
1740 p->userShaderNode = NULL;
1741 tg->RenderFuncs.shapenode = NULL;
1746 if (p->this_textureTransform) {
1747 p->this_textureTransform = NULL;
1748 FW_GL_MATRIX_MODE(GL_TEXTURE);
1749 FW_GL_LOAD_IDENTITY();
1750 FW_GL_MATRIX_MODE(GL_MODELVIEW);
1755 float gl_linewidth = tg->Mainloop.gl_linewidth;
1756 glLineWidth(gl_linewidth);
1757 p->appearanceProperties.pointSize = gl_linewidth;
1767 PRINT_GL_ERROR_IF_ANY(
"child_shape END");
1771void compile_Shape (
struct X3D_Shape *node) {
1772 long long whichAppearanceShader = 0;
1773 long long whichShapeColorShader = 0;
1774 long long whichShapeFogShader = 0;
1775 bool isUnlitGeometry =
false;
1776 int hasTextureCoordinateGenerator = 0;
1777 long long whichUnlitGeometry = 0;
1781 int userDefinedShader = 0;
1788 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->geometry,tmpG);
1789 whichShapeColorShader = getShapeColourShader(tmpG);
1790 whichShapeFogShader = getShapeFogShader(tmpG);
1792 isUnlitGeometry = getIfLinePoints(tmpG);
1793 hasTextureCoordinateGenerator = getShapeTextureCoordGen(tmpG);
1795 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->appearance,tmpN);
1799 userDefinedShader = hasUserDefinedShader(tmpN);
1804 whichUnlitGeometry = HAVE_LINEPOINTS_COLOR;
1805 whichAppearanceShader = getAppearanceShader(tmpN);
1809 node->_shaderflags_base = (whichShapeColorShader | whichShapeFogShader | whichAppearanceShader |
1810 hasTextureCoordinateGenerator | whichUnlitGeometry );
1811 node->_shaderflags_usershaders = userDefinedShader;
1812 node->_shaderflags_effects = 0;
1818 if (node->_shaderflags_base == NOTHING)
1819 node->_shaderflags_base = NO_APPEARANCE_SHADER;
1829void wrap_Shape(
struct X3D_Node* node) {
1832 if (!shape) shape = createNewX3DNode(NODE_Shape);
1833 shape->_executionContext = node->_executionContext;
1834 if (!appearance) appearance = createNewX3DNode(NODE_Appearance);
1835 appearance->_executionContext = node->_executionContext;
1836 if (!material) material = createNewX3DNode(NODE_Material);
1837 material->_executionContext = node->_executionContext;
1838 shape->appearance = X3D_NODE(appearance);
1839 appearance->material = X3D_NODE(material);
1840 vecset3f(material->diffuseColor.c, .5f, .5f, .5f);
1841 shape->geometry = node;
1842 render_node(X3D_NODE(shape));
1850 node->ambientIntensity = fclamp(node->ambientIntensity,0.0f,1.0f);
1851 node->shininess = fclamp(node->shininess,0.0f,1.0f);
1852 node->transparency = fclamp(node->transparency,0.0f,1.0f);
1853 fvecclamp3f(node->diffuseColor.c,0.0f,1.0f);
1854 fvecclamp3f(node->emissiveColor.c,0.0f,1.0f);
1855 fvecclamp3f(node->specularColor.c,0.0f,1.0f);
1857 if(!node->_material){
1859 register_node_gc(node,node->_material);
1863 vecset3f(q->baseColor,1.0f,1.0f,1.0f);
1864 veccopy3f(q->diffuse,node->diffuseColor.c);
1865 veccopy3f(q->emissive,node->emissiveColor.c);
1866 veccopy3f(q->specular,node->specularColor.c);
1867 q->ambient = node->ambientIntensity;
1868 q->shininess = node->shininess;
1869 q->transparency = node->transparency;
1870 q->type = MAT_REGULAR;
1873 if (node->separateBackColor) {
1874 node->backAmbientIntensity = fclamp(node->backAmbientIntensity,0.0f,1.0f);
1875 node->backShininess = fclamp(node->backShininess,0.0f,1.0f);
1876 node->backTransparency = fclamp(node->backTransparency,0.0f,1.0f);
1877 fvecclamp3f(node->backDiffuseColor.c,0.0f,1.0f);
1878 fvecclamp3f(node->backEmissiveColor.c,0.0f,1.0f);
1879 fvecclamp3f(node->backSpecularColor.c,0.0f,1.0f);
1881 if(!node->_backMaterial){
1883 register_node_gc(node,node->_backMaterial);
1887 vecset3f(q->baseColor,1.0f,1.0f,1.0f);
1888 veccopy3f(q->diffuse,node->backDiffuseColor.c);
1889 veccopy3f(q->emissive,node->backEmissiveColor.c);
1890 veccopy3f(q->specular,node->backSpecularColor.c);
1891 q->ambient = node->backAmbientIntensity;
1892 q->shininess = node->backShininess;
1893 q->transparency = node->backTransparency;
1894 q->type = MAT_REGULAR;
1898 if(!node->_backMaterial){
1900 register_node_gc(node,node->_backMaterial);
1912 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
1914 memcpy (&p->appearanceProperties.fw_FrontMaterial, node->_material, sizeof (
struct fw_MaterialParameters));
1915 memcpy (&p->appearanceProperties.fw_BackMaterial, node->_backMaterial, sizeof (
struct fw_MaterialParameters));
1924 node->transparency = fclamp(node->transparency,0.0f,1.0f);
1925 fvecclamp3f(node->emissiveColor.c,0.0f,1.0f);
1926 node->normalScale = fclamp(node->normalScale, 1.0f, 1.e9f);
1927 if(!node->_material){
1929 register_node_gc(node,node->_material);
1934 vecset3f(q->baseColor,1.0f,1.0f,1.0f);
1935 vecset3f(q->diffuse,1.0f,1.0f,1.0f);
1936 veccopy3f(q->emissive,node->emissiveColor.c);
1937 q->transparency = node->transparency;
1938 q->normalScale = node->normalScale;
1939 q->type = MAT_UNLIT;
1943 tnodes = q->textures;
1944 memset(tnodes,0,7*
sizeof(
void *));
1945 if(node->normalTexture)
1947 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->normalTexture,tnodes[0]);
1948 if (tnodes[0]) q->map[0] = node->normalTextureMapping ? node->normalTextureMapping->strptr : NULL;
1950 if(node->emissiveTexture)
1952 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->emissiveTexture,tnodes[1]);
1953 if (tnodes[1]) q->map[1] = node->emissiveTextureMapping ? node->emissiveTextureMapping->strptr : NULL;
1963 for(
int i=0;i<7;i++){
1965 q->tstart[i] = q->nt;
1967 if(tnodes[i]->_nodeType == NODE_MultiTexture) {
1969 q->tcount[i] = mt->texture.n;
1970 q->nt += mt->texture.n;
1984 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
1986 if(get_isBackMaterial()){
1987 memcpy (&p->appearanceProperties.fw_BackMaterial, node->_material, sizeof (
struct fw_MaterialParameters));
1989 memcpy (&p->appearanceProperties.fw_FrontMaterial, node->_material, sizeof (
struct fw_MaterialParameters));
2052 node->roughness = fclamp(node->roughness,0.0f,1.0f);
2053 node->metallic = fclamp(node->metallic,0.0f,1.0f);
2054 node->transparency = fclamp(node->transparency,0.0f,1.0f);
2055 node->occlusionStrength = fclamp(node->occlusionStrength, 0.0f, 1.0f);
2056 node->normalScale = fclamp(node->normalScale, 1.0f, 1.e9f);
2057 fvecclamp3f(node->baseColor.c,0.0f,1.0f);
2058 fvecclamp3f(node->emissiveColor.c,0.0f,1.0f);
2060 if(!node->_material){
2062 register_node_gc(node,node->_material);
2067 vecset3f(q->diffuse,1.0f,1.0f,1.0f);
2068 veccopy3f(q->baseColor,node->baseColor.c);
2069 veccopy3f(q->emissive,node->emissiveColor.c);
2070 q->metallic = node->metallic;
2071 q->roughness = node->roughness;
2072 q->transparency = node->transparency;
2073 q->occlusion = node->occlusionStrength;
2074 q->normalScale = node->normalScale;
2075 q->type = MAT_PHYSICAL;
2080 tnodes = q->textures;
2081 memset(tnodes,0,7*
sizeof(
void *));
2082 if(node->normalTexture)
2084 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->normalTexture,tnodes[0]);
2085 if (tnodes[0]) q->map[0] = node->normalTextureMapping ? node->normalTextureMapping->strptr : NULL;
2088 if(node->emissiveTexture)
2090 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->emissiveTexture,tnodes[1]);
2091 if (tnodes[1]) q->map[1] = node->emissiveTextureMapping ? node->emissiveTextureMapping->strptr : NULL;
2094 if(node->occlusionTexture)
2096 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->occlusionTexture,tnodes[2]);
2097 if (tnodes[2]) q->map[2] = node->occlusionTextureMapping ? node->occlusionTextureMapping->strptr : NULL;
2100 if(node->baseTexture)
2102 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->baseTexture,tnodes[3]);
2103 if (tnodes[3]) q->map[3] = node->baseTextureMapping ? node->baseTextureMapping->strptr : NULL;
2106 if(node->metallicRoughnessTexture)
2108 POSSIBLE_PROTO_EXPANSION(
struct X3D_Node *, node->metallicRoughnessTexture,tnodes[4]);
2109 if (tnodes[4]) q->map[4] = node->metallicRoughnessTextureMapping ? node->metallicRoughnessTextureMapping->strptr : NULL;
2119 for(
int i=0;i<7;i++){
2121 q->tstart[i] = q->nt;
2123 if(tnodes[i]->_nodeType == NODE_MultiTexture) {
2125 q->tcount[i] = mt->texture.n;
2126 q->nt += mt->texture.n;
2142 ppComponent_Shape p = (ppComponent_Shape)gglobal()->Component_Shape.prv;
2144 if(get_isBackMaterial()){
2145 memcpy (&p->appearanceProperties.fw_BackMaterial, node->_material, sizeof (
struct fw_MaterialParameters));
2147 memcpy (&p->appearanceProperties.fw_FrontMaterial, node->_material, sizeof (
struct fw_MaterialParameters));