LCOV - code coverage report
Current view: top level - scenegraph - mpeg4_valuator.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 176 325 54.2 %
Date: 2021-04-29 23:48:07 Functions: 14 21 66.7 %

          Line data    Source code
       1             : /*
       2             :  *                      GPAC - Multimedia Framework C SDK
       3             :  *
       4             :  *                      Authors: Jean Le Feuvre
       5             :  *                      Copyright (c) Telecom ParisTech 2000-2019
       6             :  *                                      All rights reserved
       7             :  *
       8             :  *  This file is part of GPAC / Scene Graph sub-project
       9             :  *
      10             :  *  GPAC is free software; you can redistribute it and/or modify
      11             :  *  it under the terms of the GNU Lesser General Public License as published by
      12             :  *  the Free Software Foundation; either version 2, or (at your option)
      13             :  *  any later version.
      14             :  *
      15             :  *  GPAC is distributed in the hope that it will be useful,
      16             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             :  *  GNU Lesser General Public License for more details.
      19             :  *
      20             :  *  You should have received a copy of the GNU Lesser General Public
      21             :  *  License along with this library; see the file COPYING.  If not, write to
      22             :  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
      23             :  *
      24             :  */
      25             : 
      26             : 
      27             : #include <gpac/internal/scenegraph_dev.h>
      28             : /*MPEG4 tags (for internal nodes)*/
      29             : #include <gpac/nodes_mpeg4.h>
      30             : 
      31             : 
      32             : #ifndef GPAC_DISABLE_VRML
      33             : 
      34         734 : static void format_sftime_string(Fixed _val, char *str)
      35             : {
      36             :         u32 h, m, s;
      37             :         Bool neg = 0;
      38             :         Float val = FIX2FLT(_val);
      39         734 :         if (val<0) {
      40           1 :                 val = -val;
      41             :                 neg = 1;
      42             :         }
      43         734 :         h = (u32) (val/3600);
      44         734 :         m = (u32) (val/60) - h*60;
      45         734 :         s = (u32) (val) - h*3600 - m*60;
      46         734 :         sprintf(str, "%s%02d:%02d:%02d", neg ? "-" : "", h, m, s);
      47         734 : }
      48             : 
      49        2944 : static void valuator_get_output(M_Valuator *p, GenMFField *inMFField, u32 inType, Bool do_sum, u32 i, SFVec4f *output, u32 *num_out)
      50             : {
      51        2944 :         if (!inMFField) return;
      52             :         
      53         300 :         switch (inType) {
      54           0 :         case GF_SG_VRML_MFINT32:
      55             :         {
      56           0 :                 SFInt32 sfi = ((MFInt32 *)inMFField)->vals[i];
      57           0 :                 Fixed vi = INT2FIX(sfi);
      58           0 :                 output->x = gf_mulfix(p->Factor1, vi) + p->Offset1;
      59           0 :                 output->y = gf_mulfix(p->Factor2, vi) + p->Offset2;
      60           0 :                 output->z = gf_mulfix(p->Factor3, vi) + p->Offset3;
      61           0 :                 output->q = gf_mulfix(p->Factor4, vi) + p->Offset4;
      62             :         }
      63           0 :         break;
      64           0 :         case GF_SG_VRML_MFFLOAT:
      65             :         {
      66           0 :                 Fixed sff = ((MFFloat *)inMFField)->vals[i];
      67           0 :                 output->x = gf_mulfix(p->Factor1, sff) + p->Offset1;
      68           0 :                 output->y = gf_mulfix(p->Factor2, sff) + p->Offset2;
      69           0 :                 output->z = gf_mulfix(p->Factor3, sff) + p->Offset3;
      70           0 :                 output->q = gf_mulfix(p->Factor4, sff) + p->Offset4;
      71             :         }
      72           0 :         break;
      73           0 :         case GF_SG_VRML_MFCOLOR:
      74             :         {
      75           0 :                 SFColor sfc = ((MFColor *)inMFField)->vals[i];
      76           0 :                 output->x = gf_mulfix(p->Factor1, sfc.red) + p->Offset1;
      77           0 :                 output->y = gf_mulfix(p->Factor2, sfc.green) + p->Offset2;
      78           0 :                 output->z = gf_mulfix(p->Factor3, sfc.blue) + p->Offset3;
      79           0 :                 output->q = p->Offset4;
      80           0 :                 *num_out = 3;
      81             :         }
      82           0 :         break;
      83         300 :         case GF_SG_VRML_MFVEC2F:
      84             :         {
      85         300 :                 SFVec2f sfv = ((MFVec2f *)inMFField)->vals[i];
      86         300 :                 output->x = gf_mulfix(p->Factor1, sfv.x) + p->Offset1;
      87         300 :                 output->y = gf_mulfix(p->Factor2, sfv.y) + p->Offset2;
      88         300 :                 output->z = p->Offset3;
      89         300 :                 output->q = p->Offset4;
      90         300 :                 *num_out = 2;
      91             :         }
      92         300 :         break;
      93           0 :         case GF_SG_VRML_MFVEC3F:
      94             :         {
      95           0 :                 SFVec3f sfv = ((MFVec3f *)inMFField)->vals[i];
      96           0 :                 output->x = gf_mulfix(p->Factor1, sfv.x) + p->Offset1;
      97           0 :                 output->y = gf_mulfix(p->Factor2, sfv.y) + p->Offset2;
      98           0 :                 output->z = gf_mulfix(p->Factor3, sfv.z) + p->Offset3;
      99           0 :                 output->q = p->Offset4;
     100           0 :                 *num_out = 3;
     101             :         }
     102           0 :         break;
     103           0 :         case GF_SG_VRML_MFVEC4F:
     104             :         case GF_SG_VRML_MFROTATION:
     105             :         {
     106           0 :                 SFVec4f sfv = ((MFVec4f *)inMFField)->vals[i];
     107           0 :                 output->x = gf_mulfix(p->Factor1, sfv.x) + p->Offset1;
     108           0 :                 output->y = gf_mulfix(p->Factor2, sfv.y) + p->Offset2;
     109           0 :                 output->z = gf_mulfix(p->Factor3, sfv.z) + p->Offset3;
     110           0 :                 output->q = gf_mulfix(p->Factor4, sfv.q) + p->Offset4;
     111           0 :                 *num_out = 4;
     112             :         }
     113           0 :         break;
     114           0 :         case GF_SG_VRML_MFSTRING:
     115             :                 /*cf below*/
     116           0 :                 output->x = output->y = output->z = output->q = 0;
     117           0 :                 if (((MFString *)inMFField)->vals[i]) {
     118           0 :                         if (!stricmp(((MFString *)inMFField)->vals[i], "true")) {
     119           0 :                                 output->x = output->y = output->z = output->q = FIX_ONE;
     120           0 :                         } else if (!strstr(((MFString *)inMFField)->vals[i], ".")) {
     121           0 :                                 output->x = INT2FIX( atoi(((MFString *)inMFField)->vals[i]) );
     122           0 :                                 output->y = output->z = output->q = output->x;
     123             :                         } else {
     124           0 :                                 output->x = FLT2FIX( atof(((MFString *)inMFField)->vals[i]) );
     125           0 :                                 output->y = output->z = output->q = output->x;
     126             :                         }
     127             :                 }
     128             : 
     129           0 :                 output->x = gf_mulfix(p->Factor1, output->x) + p->Offset1;
     130           0 :                 output->y = gf_mulfix(p->Factor2, output->y) + p->Offset2;
     131           0 :                 output->z = gf_mulfix(p->Factor3, output->z) + p->Offset3;
     132           0 :                 output->q = gf_mulfix(p->Factor4, output->q) + p->Offset4;
     133           0 :                 break;
     134             : 
     135             :         }
     136         300 :         if (do_sum) {
     137           0 :                 output->x = output->x + output->y + output->z + output->q;
     138           0 :                 output->y = output->z = output->q = output->x;
     139             :         }
     140             : }
     141             : 
     142        3235 : static void SetValuatorOutput(M_Valuator *p, SFVec4f *inSFField, GenMFField *inMFField, u32 inType)
     143             : {
     144             :         char str[500];
     145             :         u32 i, j;
     146             :         GF_Route *r;
     147             :         SFVec4f output, sf_out;
     148        3235 :         MFVec4f *mf_output = (MFVec4f *)gf_node_get_private((GF_Node*)p);
     149             :         u32 count, num_out;
     150             :         Bool do_sum;
     151        3235 :         output.x = output.y = output.z = output.q = 0;
     152             :         sf_out.x = sf_out.y = sf_out.z = sf_out.q = 0;
     153        3625 :         if (!p->sgprivate->interact || !mf_output) return;
     154             : 
     155        2845 :         do_sum = p->Sum;
     156        2845 :         num_out = 1;
     157             : 
     158        2845 :         if (!inMFField) {
     159             :                 count = 1;
     160        2695 :                 output.x = gf_mulfix(p->Factor1, inSFField->x) + p->Offset1;
     161        2695 :                 output.y = gf_mulfix(p->Factor2, inSFField->y) + p->Offset2;
     162        2695 :                 output.z = gf_mulfix(p->Factor3, inSFField->z) + p->Offset3;
     163        2695 :                 output.q = gf_mulfix(p->Factor4, inSFField->q) + p->Offset4;
     164             : 
     165        2695 :                 if (do_sum) {
     166           0 :                         output.x = output.x + output.y + output.z + output.q;
     167           0 :                         output.y = output.z = output.q = output.x;
     168             :                         do_sum = 0;
     169             :                 }
     170             : 
     171        2695 :                 switch (inType) {
     172         101 :                 case GF_SG_VRML_SFVEC2F:
     173         101 :                         num_out = 2;
     174         101 :                         break;
     175         277 :                 case GF_SG_VRML_SFVEC3F:
     176             :                 case GF_SG_VRML_SFCOLOR:
     177         277 :                         num_out = 3;
     178         277 :                         break;
     179           0 :                 case GF_SG_VRML_SFVEC4F:
     180             :                 case GF_SG_VRML_SFROTATION:
     181           0 :                         num_out = 4;
     182           0 :                         break;
     183             :                 }
     184             :         } else {
     185         150 :                 count = inMFField->count;
     186             :         }
     187             : 
     188             :         /*allocate temp buffer and compute values*/
     189        2845 :         gf_sg_vrml_mf_alloc(mf_output, GF_SG_VRML_MFVEC4F, count);
     190        5840 :         for (i=0; i<count; i++) {
     191        2995 :                 if (inType) {
     192        2944 :                         valuator_get_output(p, inMFField, inType, do_sum, i, &output, &num_out);
     193        2944 :                         mf_output->vals[i] = output;
     194          51 :                 } else if (!i) {
     195          51 :                         mf_output->vals[0] = output;
     196             :                 }
     197        2995 :                 if (!i) sf_out = output;
     198             :         }
     199             : 
     200        2845 :         gf_sg_vrml_mf_alloc(&p->outMFColor, GF_SG_VRML_MFCOLOR, count);
     201        2845 :         gf_sg_vrml_mf_alloc(&p->outMFFloat, GF_SG_VRML_MFFLOAT, count);
     202        2845 :         gf_sg_vrml_mf_alloc(&p->outMFInt32, GF_SG_VRML_MFINT32, count);
     203        2845 :         gf_sg_vrml_mf_alloc(&p->outMFRotation, GF_SG_VRML_MFROTATION, count);
     204        2845 :         gf_sg_vrml_mf_alloc(&p->outMFString, GF_SG_VRML_MFSTRING, count);
     205        2845 :         gf_sg_vrml_mf_alloc(&p->outMFVec2f, GF_SG_VRML_MFVEC2F, count);
     206        2845 :         gf_sg_vrml_mf_alloc(&p->outMFVec3f, GF_SG_VRML_MFVEC3F, count);
     207             : 
     208             :         /*valuator is a special case, all routes are triggered*/
     209        2845 :         j=0;
     210        9338 :         while ((r = (GF_Route*)gf_list_enum(p->sgprivate->interact->routes, &j))) {
     211        3648 :                 if (r->FromNode != (GF_Node *)p) continue;
     212        3648 :                 if (!r->is_setup) gf_sg_route_setup(r);
     213        3648 :                 if (r->FromField.eventType != GF_SG_EVENT_OUT) continue;
     214             : 
     215             :                 /*TODO we could optimize more and check if the field has been set or not ...*/
     216        3641 :                 switch (r->FromField.fieldType) {
     217          37 :                 case GF_SG_VRML_SFBOOL:
     218          37 :                         p->outSFBool = (Bool) (sf_out.x ? 1 : 0);
     219          37 :                         break;
     220        1575 :                 case GF_SG_VRML_SFFLOAT:
     221        1575 :                         p->outSFFloat = sf_out.x;
     222        1575 :                         break;
     223         598 :                 case GF_SG_VRML_SFINT32:
     224         598 :                         p->outSFInt32 = FIX2INT(sf_out.x);
     225         598 :                         break;
     226          23 :                 case GF_SG_VRML_SFTIME:
     227          23 :                         p->outSFTime = (SFTime) FIX2FLT(sf_out.x);
     228          23 :                         break;
     229           0 :                 case GF_SG_VRML_SFROTATION:
     230           0 :                         p->outSFRotation.x = sf_out.x;
     231           0 :                         p->outSFRotation.y = sf_out.y;
     232           0 :                         p->outSFRotation.z = sf_out.z;
     233           0 :                         p->outSFRotation.q = sf_out.q;
     234           0 :                         break;
     235          36 :                 case GF_SG_VRML_SFCOLOR:
     236          36 :                         p->outSFColor.red = sf_out.x;
     237          36 :                         p->outSFColor.green = sf_out.y;
     238          36 :                         p->outSFColor.blue = sf_out.z;
     239          36 :                         break;
     240         237 :                 case GF_SG_VRML_SFVEC2F:
     241         237 :                         p->outSFVec2f.x = sf_out.x;
     242         237 :                         p->outSFVec2f.y = sf_out.y;
     243         237 :                         break;
     244           0 :                 case GF_SG_VRML_SFVEC3F:
     245           0 :                         p->outSFVec3f.x = sf_out.x;
     246           0 :                         p->outSFVec3f.y = sf_out.y;
     247           0 :                         p->outSFVec3f.z = sf_out.z;
     248           0 :                         break;
     249           0 :                 case GF_SG_VRML_SFSTRING:
     250           0 :                         if (num_out==1) {
     251           0 :                                 if (inType==GF_SG_VRML_SFTIME) {
     252           0 :                                         format_sftime_string(output.x, str);
     253             :                                 } else {
     254           0 :                                         sprintf(str, "%.6f", FIX2FLT(sf_out.x));
     255             :                                 }
     256           0 :                         } else if (num_out==2) {
     257           0 :                                 sprintf(str, "%.4f %.4f", FIX2FLT(sf_out.x), FIX2FLT(sf_out.y));
     258           0 :                         } else if (num_out==3) {
     259           0 :                                 sprintf(str, "%.3f %.3f %.3f", FIX2FLT(sf_out.x), FIX2FLT(sf_out.y), FIX2FLT(sf_out.z));
     260           0 :                         } else if (num_out==4) {
     261           0 :                                 sprintf(str, "%.2f %.2f %.2f %.2f", FIX2FLT(sf_out.x), FIX2FLT(sf_out.y), FIX2FLT(sf_out.z), FIX2FLT(sf_out.q));
     262             :                         }
     263           0 :                         if (p->outSFString.buffer ) gf_free(p->outSFString.buffer);
     264           0 :                         p->outSFString.buffer = gf_strdup(str);
     265           0 :                         break;
     266             : 
     267             : 
     268         150 :                 case GF_SG_VRML_MFFLOAT:
     269         150 :                         gf_sg_vrml_mf_alloc(&p->outMFFloat, GF_SG_VRML_MFFLOAT, count);
     270         450 :                         for (i=0; i<count; i++)
     271         300 :                                 p->outMFFloat.vals[i] = mf_output->vals[i].x;
     272             :                         break;
     273           0 :                 case GF_SG_VRML_MFINT32:
     274           0 :                         gf_sg_vrml_mf_alloc(&p->outMFInt32, GF_SG_VRML_MFINT32, count);
     275           0 :                         for (i=0; i<count; i++)
     276           0 :                                 p->outMFInt32.vals[i] = FIX2INT(mf_output->vals[i].x);
     277             :                         break;
     278           0 :                 case GF_SG_VRML_MFCOLOR:
     279           0 :                         gf_sg_vrml_mf_alloc(&p->outMFColor, GF_SG_VRML_MFCOLOR, count);
     280           0 :                         for (i=0; i<count; i++) {
     281           0 :                                 p->outMFColor.vals[i].red = mf_output->vals[i].x;
     282           0 :                                 p->outMFColor.vals[i].green = mf_output->vals[i].y;
     283           0 :                                 p->outMFColor.vals[i].blue = mf_output->vals[i].z;
     284             :                         }
     285             :                         break;
     286           0 :                 case GF_SG_VRML_MFVEC2F:
     287           0 :                         gf_sg_vrml_mf_alloc(&p->outMFVec2f, GF_SG_VRML_MFVEC2F, count);
     288           0 :                         for (i=0; i<count; i++) {
     289           0 :                                 p->outMFVec2f.vals[i].x = mf_output->vals[i].x;
     290           0 :                                 p->outMFVec2f.vals[i].y = mf_output->vals[i].y;
     291             :                         }
     292             :                         break;
     293           0 :                 case GF_SG_VRML_MFVEC3F:
     294           0 :                         gf_sg_vrml_mf_alloc(&p->outMFVec3f, GF_SG_VRML_MFVEC3F, count);
     295           0 :                         for (i=0; i<count; i++) {
     296           0 :                                 p->outMFVec3f.vals[i].x = mf_output->vals[i].x;
     297           0 :                                 p->outMFVec3f.vals[i].y = mf_output->vals[i].y;
     298           0 :                                 p->outMFVec3f.vals[i].z = mf_output->vals[i].z;
     299             :                         }
     300             :                         break;
     301           0 :                 case GF_SG_VRML_MFROTATION:
     302           0 :                         gf_sg_vrml_mf_alloc(&p->outMFRotation, GF_SG_VRML_MFROTATION, count);
     303           0 :                         for (i=0; i<count; i++) {
     304           0 :                                 p->outMFRotation.vals[i].x = mf_output->vals[i].x;
     305           0 :                                 p->outMFRotation.vals[i].y = mf_output->vals[i].y;
     306           0 :                                 p->outMFRotation.vals[i].z = mf_output->vals[i].z;
     307           0 :                                 p->outMFRotation.vals[i].q = mf_output->vals[i].q;
     308             :                         }
     309             :                         break;
     310         985 :                 case GF_SG_VRML_MFSTRING:
     311         985 :                         gf_sg_vrml_mf_alloc(&p->outMFString, GF_SG_VRML_MFSTRING, count);
     312         985 :                         gf_sg_vrml_mf_alloc(&p->outMFVec2f, GF_SG_VRML_MFVEC2F, count);
     313        1970 :                         for (i=0; i<count; i++) {
     314         985 :                                 if (num_out==1) {
     315         767 :                                         if (inType==GF_SG_VRML_SFTIME) {
     316         734 :                                                 format_sftime_string(mf_output->vals[i].x, str);
     317             :                                         } else {
     318          33 :                                                 sprintf(str, "%g", FIX2FLT(mf_output->vals[i].x));
     319             :                                         }
     320         218 :                                 } else if (num_out==2) {
     321           0 :                                         sprintf(str, "%g %g", FIX2FLT(mf_output->vals[i].x), FIX2FLT(mf_output->vals[i].y));
     322         218 :                                 } else if (num_out==3) {
     323         218 :                                         sprintf(str, "%g %g %g", FIX2FLT(mf_output->vals[i].x), FIX2FLT(mf_output->vals[i].y), FIX2FLT(mf_output->vals[i].z));
     324           0 :                                 } else if (num_out==4) {
     325           0 :                                         sprintf(str, "%g %g %g %g", FIX2FLT(mf_output->vals[i].x), FIX2FLT(mf_output->vals[i].y), FIX2FLT(mf_output->vals[i].z), FIX2FLT(mf_output->vals[i].q));
     326             :                                 }
     327         985 :                                 if (p->outMFString.vals[i]) gf_free(p->outMFString.vals[i]);
     328         985 :                                 p->outMFString.vals[i] = gf_strdup(str);
     329             :                         }
     330             :                         break;
     331             :                 }
     332        3641 :                 if (r->IS_route) {
     333          74 :                         gf_sg_route_activate(r);
     334             :                 } else {
     335        3567 :                         gf_sg_route_queue(p->sgprivate->scenegraph, r);
     336             :                 }
     337             :         }
     338             : }
     339             : 
     340             : 
     341             : /*
     342             : valuator spec (9.4.2.116.2)
     343             : "In the special case of a scalar input type (e.g. SFBool, SFInt32) that is cast to a vectorial output type (e.g.
     344             : SFVec2f), for all components i of output.i, input.i shall take the value of the scalar input type, after appropriate type
     345             : conversion"
     346             : */
     347             : 
     348          51 : static void Valuator_SetInSFBool(GF_Node *n, GF_Route *route)
     349             : {
     350             :         SFVec4f val;
     351             :         M_Valuator *_this = (M_Valuator *) n;
     352          51 :         val.x = val.y = val.z = val.q = _this->inSFBool ? FIX_ONE : 0;
     353          51 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFBOOL);
     354          51 : }
     355         687 : static void Valuator_SetInSFFloat(GF_Node *n, GF_Route *route)
     356             : {
     357             :         SFVec4f val;
     358             :         M_Valuator *_this = (M_Valuator *) n;
     359         687 :         val.x = val.y = val.z = val.q = _this->inSFFloat;
     360         687 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFFLOAT);
     361         687 : }
     362        1210 : static void Valuator_SetInSFInt32(GF_Node *n, GF_Route *route)
     363             : {
     364             :         SFVec4f val;
     365             :         M_Valuator *_this = (M_Valuator *) n;
     366        1210 :         val.x = val.y = val.z = val.q = INT2FIX(_this->inSFInt32);
     367        1210 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFINT32);
     368        1210 : }
     369         757 : static void Valuator_SetInSFTime(GF_Node *n, GF_Route *route)
     370             : {
     371             :         SFVec4f val;
     372             :         M_Valuator *_this = (M_Valuator *) n;
     373         757 :         val.x = val.y = val.z = val.q = FLT2FIX(_this->inSFTime);
     374         757 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFTIME);
     375         757 : }
     376          36 : static void Valuator_SetInSFColor(GF_Node *n, GF_Route *route)
     377             : {
     378             :         SFVec4f val;
     379             :         M_Valuator *_this = (M_Valuator *) n;
     380          36 :         val.x = _this->inSFColor.red;
     381          36 :         val.y = _this->inSFColor.green;
     382          36 :         val.z = _this->inSFColor.blue;
     383          36 :         val.q = 0;
     384          36 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFCOLOR);
     385          36 : }
     386         101 : static void Valuator_SetInSFVec2f(GF_Node *n, GF_Route *route)
     387             : {
     388             :         SFVec4f val;
     389             :         M_Valuator *_this = (M_Valuator *) n;
     390         101 :         val.x = _this->inSFVec2f.x;
     391         101 :         val.y = _this->inSFVec2f.y;
     392         101 :         val.z = val.q = 0;
     393         101 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFVEC2F);
     394         101 : }
     395         241 : static void Valuator_SetInSFVec3f(GF_Node *n, GF_Route *route)
     396             : {
     397             :         SFVec4f val;
     398             :         M_Valuator *_this = (M_Valuator *) n;
     399         241 :         val.x = _this->inSFVec3f.x;
     400         241 :         val.y = _this->inSFVec3f.y;
     401         241 :         val.z = _this->inSFVec3f.z;
     402         241 :         val.q = 0;
     403         241 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFVEC3F);
     404         241 : }
     405           0 : static void Valuator_SetInSFRotation(GF_Node *n, GF_Route *route)
     406             : {
     407             :         SFVec4f val;
     408           0 :         if (n) {
     409             :                 M_Valuator *_this = (M_Valuator *) n;
     410           0 :                 val = _this->inSFRotation;
     411           0 :                 SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFROTATION);
     412             :         }
     413           0 : }
     414             : 
     415             : /*
     416             : valuator spec (9.4.2.116.2)
     417             : Convert if the content of the string represents an int, float or
     418             : double value. Boolean string values 'true' and 'false' are
     419             : converted to 1.0 and 0.0 respectively. Any other string is converted to 0.0
     420             : */
     421           2 : static void Valuator_SetInSFString(GF_Node *n, GF_Route *route)
     422             : {
     423             :         SFVec4f val;
     424             :         M_Valuator *_this = (M_Valuator *) n;
     425             : 
     426           2 :         if (! _this->inSFString.buffer) return;
     427             : 
     428           2 :         if (!stricmp(_this->inSFString.buffer, "true")) {
     429           0 :                 val.x = val.y = val.z = val.q = FIX_ONE;
     430           2 :         } else if (!strstr(_this->inSFString.buffer, ".")) {
     431           2 :                 val.x = INT2FIX( atoi(_this->inSFString.buffer) );
     432           2 :                 val.y = val.z = val.q = val.x;
     433             :         } else {
     434           0 :                 val.x = FLT2FIX( atof(_this->inSFString.buffer) );
     435           0 :                 val.y = val.z = val.q = val.x;
     436             :         }
     437           2 :         SetValuatorOutput(_this, &val, NULL, GF_SG_VRML_SFSTRING);
     438             : }
     439             : 
     440           0 : static void Valuator_SetInMFColor(GF_Node *n, GF_Route *route)
     441             : {
     442           0 :         if (n) {
     443             :                 M_Valuator *_this = (M_Valuator *) n;
     444           0 :                 SetValuatorOutput(_this, NULL, (GenMFField *) &_this->inMFColor, GF_SG_VRML_MFCOLOR);
     445             :         }
     446           0 : }
     447             : 
     448           0 : static void Valuator_SetInMFFloat(GF_Node *n, GF_Route *route)
     449             : {
     450           0 :         if (n) {
     451             :                 M_Valuator *_this = (M_Valuator *) n;
     452           0 :                 SetValuatorOutput(_this, NULL, (GenMFField *) &_this->inMFFloat, GF_SG_VRML_MFFLOAT);
     453             :         }
     454           0 : }
     455           0 : static void Valuator_SetInMFInt32(GF_Node *n, GF_Route *route)
     456             : {
     457           0 :         if (n) {
     458             :                 M_Valuator *_this = (M_Valuator *) n;
     459           0 :                 SetValuatorOutput(_this, NULL, (GenMFField *) &_this->inMFInt32, GF_SG_VRML_MFINT32);
     460             :         }
     461           0 : }
     462         150 : static void Valuator_SetInMFVec2f(GF_Node *n, GF_Route *route)
     463             : {
     464             :         M_Valuator *_this = (M_Valuator *) n;
     465         150 :         SetValuatorOutput(_this, NULL, (GenMFField *) &_this->inMFVec2f, GF_SG_VRML_MFVEC2F);
     466         150 : }
     467           0 : static void Valuator_SetInMFVec3f(GF_Node *n, GF_Route *route)
     468             : {
     469           0 :         if (n) {
     470             :                 M_Valuator *_this = (M_Valuator *) n;
     471           0 :                 SetValuatorOutput(_this, NULL, (GenMFField *) &_this->inMFVec3f, GF_SG_VRML_MFVEC3F);
     472             :         }
     473           0 : }
     474           0 : static void Valuator_SetInMFRotation(GF_Node *n, GF_Route *route)
     475             : {
     476           0 :         if (n) {
     477             :                 M_Valuator *_this = (M_Valuator *) n;
     478           0 :                 SetValuatorOutput(_this, NULL, (GenMFField *) &_this->inMFRotation, GF_SG_VRML_MFROTATION);
     479             :         }
     480           0 : }
     481           0 : static void Valuator_SetInMFString(GF_Node *n, GF_Route *route)
     482             : {
     483           0 :         if (n) {
     484             :                 M_Valuator *_this = (M_Valuator *) n;
     485           0 :                 SetValuatorOutput(_this, NULL, (GenMFField *) &_this->inMFString, GF_SG_VRML_MFSTRING);
     486             :         }
     487           0 : }
     488             : 
     489             : 
     490       99914 : static void valuator_destroy(GF_Node *node, void *rs, Bool is_destroy)
     491             : {
     492       99914 :         if (is_destroy) {
     493        1551 :                 MFVec4f *stack = (MFVec4f *)gf_node_get_private(node);
     494        1551 :                 gf_sg_vrml_field_pointer_del(stack, GF_SG_VRML_MFROTATION);
     495             :         }
     496       99914 : }
     497             : 
     498        1551 : Bool InitValuator(M_Valuator *node)
     499             : {
     500        1551 :         MFVec4f *temp = gf_sg_vrml_field_pointer_new(GF_SG_VRML_MFROTATION);
     501        1551 :         if (!temp) return 1;
     502             : 
     503        1551 :         node->on_inSFTime = Valuator_SetInSFTime;
     504        1551 :         node->on_inSFBool = Valuator_SetInSFBool;
     505        1551 :         node->on_inSFColor = Valuator_SetInSFColor;
     506        1551 :         node->on_inSFInt32 = Valuator_SetInSFInt32;
     507        1551 :         node->on_inSFFloat = Valuator_SetInSFFloat;
     508        1551 :         node->on_inSFVec2f = Valuator_SetInSFVec2f;
     509        1551 :         node->on_inSFVec3f = Valuator_SetInSFVec3f;
     510        1551 :         node->on_inSFRotation = Valuator_SetInSFRotation;
     511        1551 :         node->on_inSFString = Valuator_SetInSFString;
     512        1551 :         node->on_inMFColor = Valuator_SetInMFColor;
     513        1551 :         node->on_inMFInt32 = Valuator_SetInMFInt32;
     514        1551 :         node->on_inMFFloat = Valuator_SetInMFFloat;
     515        1551 :         node->on_inMFVec2f = Valuator_SetInMFVec2f;
     516        1551 :         node->on_inMFVec3f = Valuator_SetInMFVec3f;
     517        1551 :         node->on_inMFRotation = Valuator_SetInMFRotation;
     518        1551 :         node->on_inMFString = Valuator_SetInMFString;
     519             : 
     520        1551 :         gf_node_set_private((GF_Node*)node, temp);
     521        1551 :         gf_node_set_callback_function((GF_Node*)node, valuator_destroy);
     522             : 
     523             : #ifdef GPAC_ENABLE_COVERAGE
     524             :         //we are a bit lazy here
     525        1551 :         if (gf_sys_is_cov_mode()) {
     526             :                 Valuator_SetInSFRotation(NULL, NULL);
     527             :                 Valuator_SetInMFColor(NULL, NULL);
     528             :                 Valuator_SetInMFFloat(NULL, NULL);
     529             :                 Valuator_SetInMFInt32(NULL, NULL);
     530             :                 Valuator_SetInMFVec3f(NULL, NULL);
     531             :                 Valuator_SetInMFRotation(NULL, NULL);
     532             :                 Valuator_SetInMFString(NULL, NULL);
     533             :         }
     534             : #endif
     535        1551 :         return 1;
     536             : }
     537             : 
     538             : 
     539             : #endif /*GPAC_DISABLE_VRML*/

Generated by: LCOV version 1.13