Exemple #1
0
RenderObjectPtr
Light::clone() const noexcept
{
	auto light = std::make_shared<Light>();
	light->setLightType(this->getLightType());
	light->setLightColor(this->getLightColor());
	light->setLightIntensity(this->getLightIntensity());
	light->setLightRange(this->getLightRange());
	light->setTransform(this->getTransform(), this->getTransformInverse());
	light->setBoundingBox(this->getBoundingBox());

	light->_spotInnerCone = _spotInnerCone;
	light->_spotOuterCone = _spotOuterCone;

	return light;
}
            void Opcode8107::_run() {
                Logger::debug("SCRIPT") << "[8107] [*] void obj_set_light_level(Object* object, int level, int radius)"
                                        << std::endl;
                auto object = _script->dataStack()->popObject();
                auto level = _script->dataStack()->popInteger();
                auto radius = _script->dataStack()->popInteger();
                if (level > 100 || level < 0) {
                    _warning("obj_set_light_level: level should be 0-100");
                    return;
                }
                if (radius > 8 || radius < 0) {
                    _warning("obj_set_light_level: radius should be 0-8");
                    return;
                }

                unsigned int light = 65536 / 100 * level;
                object->setLightIntensity(light);
                object->setLightRadius(radius);
            }
/* Option::load: load options from config file */
bool Option::load(const char *file)
{
   FILE *fp;
   char buf[OPTION_MAXBUFLEN];
   int len;
   char *p1;

   int ivec2[2];
   float fvec3[3];
   float fvec4[4];

   fp = MMDAgent_fopen(file, "r");
   if (fp == NULL)
      return false;

   while (fgets(buf, OPTION_MAXBUFLEN, fp)) {
      len = MMDAgent_strlen(buf);
      if(len <= 0) continue;
      p1 = &(buf[len - 1]);
      while (p1 >= &(buf[0]) && (*p1 == '\n' || *p1 == '\r' || *p1 == '\t' || *p1 == ' ')) {
         *p1 = L'\0';
         p1--;
      }
      p1 = &(buf[0]);
      if (*p1 == '#') continue;
      while (*p1 != L'=' && *p1 != L'\0') p1++;
      if (*p1 == L'\0') continue;
      *p1 = L'\0';
      p1++;

      /* overwrite option values */
      if(MMDAgent_strequal(buf, OPTION_USECARTOONRENDERING_STR)) {
         setUseCartoonRendering(MMDAgent_str2bool(p1));
      } else if(MMDAgent_strequal(buf, OPTION_USEMMDLIKECARTOON_STR)) {
         setUseMMDLikeCartoon(MMDAgent_str2bool(p1));
      } else if(MMDAgent_strequal(buf, OPTION_CARTOONEDGEWIDTH_STR)) {
         setCartoonEdgeWidth(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_CARTOONEDGESTEP_STR)) {
         setCartoonEdgeStep(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_CARTOONEDGESELECTEDCOLOR_STR)) {
         if(MMDAgent_str2fvec(p1, fvec4, 4))
            setCartoonEdgeSelectedColor(fvec4);
      } else if(MMDAgent_strequal(buf, OPTION_CAMERAROTATION_STR)) {
         if(MMDAgent_str2fvec(p1, fvec3, 3))
            setCameraRotation(fvec3);
      } else if(MMDAgent_strequal(buf, OPTION_CAMERATRANSITION_STR)) {
         if(MMDAgent_str2fvec(p1, fvec3, 3))
            setCameraTransition(fvec3);
      } else if(MMDAgent_strequal(buf, OPTION_CAMERADISTANCE_STR)) {
         setCameraDistance(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_CAMERAFOVY_STR)) {
         setCameraFovy(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_STAGESIZE_STR)) {
         if(MMDAgent_str2fvec(p1, fvec3, 3))
            setStageSize(fvec3);
      } else if(MMDAgent_strequal(buf, OPTION_SHOWFPS_STR)) {
         setShowFps(MMDAgent_str2bool(p1));
      } else if(MMDAgent_strequal(buf, OPTION_FPSPOSITION_STR)) {
         if(MMDAgent_str2fvec(p1, fvec3, 3))
            setFpsPosition(fvec3);
      } else if(MMDAgent_strequal(buf, OPTION_WINDOWSIZE_STR)) {
         if(MMDAgent_str2ivec(p1, ivec2, 2))
            setWindowSize(ivec2);
      } else if(MMDAgent_strequal(buf, OPTION_FULLSCREEN_STR)) {
         setFullScreen(MMDAgent_str2bool(p1));
      } else if(MMDAgent_strequal(buf, OPTION_LOGSIZE_STR)) {
         if(MMDAgent_str2ivec(p1, ivec2, 2))
            setLogSize(ivec2);
      } else if(MMDAgent_strequal(buf, OPTION_LOGPOSITION_STR)) {
         if(MMDAgent_str2fvec(p1, fvec3, 3))
            setLogPosition(fvec3);
      } else if(MMDAgent_strequal(buf, OPTION_LOGSCALE_STR)) {
         setLogScale(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_LIGHTDIRECTION_STR)) {
         if(MMDAgent_str2fvec(p1, fvec4, 4))
            setLightDirection(fvec4);
      } else if(MMDAgent_strequal(buf, OPTION_LIGHTINTENSITY_STR)) {
         setLightIntensity(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_LIGHTCOLOR_STR)) {
         if(MMDAgent_str2fvec(p1, fvec3, 3))
            setLightColor(fvec3);
      } else if(MMDAgent_strequal(buf, OPTION_CAMPUSCOLOR_STR)) {
         if(MMDAgent_str2fvec(p1, fvec3, 3))
            setCampusColor(fvec3);
      } else if(MMDAgent_strequal(buf, OPTION_MAXMULTISAMPLING_STR)) {
         setMaxMultiSampling(MMDAgent_str2int(p1));
      } else if(MMDAgent_strequal(buf, OPTION_MOTIONADJUSTTIME_STR)) {
         setMotionAdjustTime(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_LIPSYNCPRIORITY_STR)) {
         setLipsyncPriority(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_BULLETFPS_STR)) {
         setBulletFps(MMDAgent_str2int(p1));
      } else if(MMDAgent_strequal(buf, OPTION_GRAVITYFACTOR_STR)) {
         setGravityFactor(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_ROTATESTEP_STR)) {
         setRotateStep(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_TRANSLATESTEP_STR)) {
         setTranslateStep(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_DISTANCESTEP_STR)) {
         setDistanceStep(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_FOVYSTEP_STR)) {
         setFovyStep(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_USESHADOWMAPPING_STR)) {
         setUseShadowMapping(MMDAgent_str2bool(p1));
      } else if(MMDAgent_strequal(buf, OPTION_SHADOWMAPPINGTEXTURESIZE_STR)) {
         setShadowMappingTextureSize(MMDAgent_str2int(p1));
      } else if(MMDAgent_strequal(buf, OPTION_SHADOWMAPPINGSELFDENSITY_STR)) {
         setShadowMappingSelfDensity(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_SHADOWMAPPINGFLOORDENSITY_STR)) {
         setShadowMappingFloorDensity(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_SHADOWMAPPINGLIGHTFIRST_STR)) {
         setShadowMappingLightFirst(MMDAgent_str2bool(p1));
      } else if(MMDAgent_strequal(buf, OPTION_DISPLAYCOMMENTTIME_STR)) {
         setDisplayCommentTime(MMDAgent_str2float(p1));
      } else if(MMDAgent_strequal(buf, OPTION_MAXNUMMODEL_STR)) {
         setMaxNumModel(MMDAgent_str2int(p1));
      }
   }
   fclose(fp);

   return true;
}