Example #1
0
bool OpenStringDestination(
  Environment *theEnv,
  const char *name,
  char *str,
  size_t maximumPosition)
  {
   struct stringRouter *newStringRouter;
   char *theName;

   if (FindStringRouter(theEnv,name) != NULL) return false;

   newStringRouter = get_struct(theEnv,stringRouter);
   theName = (char *) gm1(theEnv,strlen(name) + 1);
   genstrcpy(theName,name);
   newStringRouter->name = theName;
   newStringRouter->readString = NULL;
   newStringRouter->writeString = str;
   newStringRouter->currentPosition = 0;
   newStringRouter->readWriteType = WRITE_STRING;
   newStringRouter->maximumPosition = maximumPosition;
   newStringRouter->next = StringRouterData(theEnv)->ListOfStringRouters;
   StringRouterData(theEnv)->ListOfStringRouters = newStringRouter;

   return true;
  }
Example #2
0
static void mix_columns(uint8_t *state)
{
	int i;
	uint8_t cpy[4];

	for (i = 0; i < 4; i++) {
		cpy[0] = state[0 * 4 + i];
		cpy[1] = state[1 * 4 + i];
		cpy[2] = state[2 * 4 + i];
		cpy[3] = state[3 * 4 + i];
		state[i] = gm2(cpy[0]) ^ gm1(cpy[3]) ^ gm1(cpy[2]) ^ gm3(cpy[1]);
		state[4+i] = gm2(cpy[1]) ^ gm1(cpy[0]) ^ gm1(cpy[3]) ^ gm3(cpy[2]);
		state[8+i] = gm2(cpy[2]) ^ gm1(cpy[1]) ^ gm1(cpy[0]) ^ gm3(cpy[3]);
		state[12+i] = gm2(cpy[3]) ^ gm1(cpy[2]) ^ gm1(cpy[1]) ^ gm3(cpy[0]);
	}
}
Example #3
0
bool OpenStringBuilderDestination(
  Environment *theEnv,
  const char *name,
  StringBuilder *theSB)
  {
   StringBuilderRouter *newStringRouter;
   char *theName;

   if (FindStringBuilderRouter(theEnv,name) != NULL) return false;

   newStringRouter = get_struct(theEnv,stringBuilderRouter);
   theName = (char *) gm1(theEnv,strlen(name) + 1);
   genstrcpy(theName,name);
   newStringRouter->name = theName;
   newStringRouter->SBR = theSB;
   newStringRouter->next = StringRouterData(theEnv)->ListOfStringBuilderRouters;
   StringRouterData(theEnv)->ListOfStringBuilderRouters = newStringRouter;

   return true;
  }
Example #4
0
globle int OpenStringDestination(
  void *theEnv,
  char *name,
  char *str,
  size_t maximumPosition)
  {
   struct stringRouter *newStringRouter;

   if (FindStringRouter(theEnv,name) != NULL) return(0);

   newStringRouter = get_struct(theEnv,stringRouter);
   newStringRouter->name = (char *) gm1(theEnv,(int) strlen(name) + 1);
   genstrcpy(newStringRouter->name,name);
   newStringRouter->str = str;
   newStringRouter->currentPosition = 0;
   newStringRouter->readWriteType = WRITE_STRING;
   newStringRouter->maximumPosition = maximumPosition;
   newStringRouter->next = StringRouterData(theEnv)->ListOfStringRouters;
   StringRouterData(theEnv)->ListOfStringRouters = newStringRouter;

   return(1);
  }
Example #5
0
static int CreateReadStringSource(
  void *theEnv,
  char *name,
  char *str,
  size_t currentPosition,
  size_t maximumPosition)
  {
   struct stringRouter *newStringRouter;

   if (FindStringRouter(theEnv,name) != NULL) return(0);

   newStringRouter = get_struct(theEnv,stringRouter);
   newStringRouter->name = (char *) gm1(theEnv,strlen(name) + 1);
   genstrcpy(newStringRouter->name,name);
   newStringRouter->str = str;
   newStringRouter->currentPosition = currentPosition;
   newStringRouter->readWriteType = READ_STRING;
   newStringRouter->maximumPosition = maximumPosition;
   newStringRouter->next = StringRouterData(theEnv)->ListOfStringRouters;
   StringRouterData(theEnv)->ListOfStringRouters = newStringRouter;

   return(1);
  }
Example #6
0
static void StrOrSymCatFunction(
  void *theEnv,
  DATA_OBJECT_PTR returnValue,
  unsigned short returnType)
  {
   DATA_OBJECT theArg;
   int numArgs, i, total, j;
   char *theString;
   SYMBOL_HN **arrayOfStrings;
   SYMBOL_HN *hashPtr;
   char *functionName;

   /*============================================*/
   /* Determine the calling function name.       */
   /* Store the null string or the symbol nil as */
   /* the return value in the event of an error. */
   /*============================================*/

   SetpType(returnValue,returnType);
   if (returnType == STRING)
     {
      functionName = "str-cat";
      SetpValue(returnValue,(void *) EnvAddSymbol(theEnv,""));
     }
   else
     {
      functionName = "sym-cat";
      SetpValue(returnValue,(void *) EnvAddSymbol(theEnv,"nil"));
     }

   /*===============================================*/
   /* Determine the number of arguments as create a */
   /* string array which is large enough to store   */
   /* the string representation of each argument.   */
   /*===============================================*/

   numArgs = EnvRtnArgCount(theEnv);
   arrayOfStrings = (SYMBOL_HN **) gm1(theEnv,(int) sizeof(SYMBOL_HN *) * numArgs);
   for (i = 0; i < numArgs; i++)
     { arrayOfStrings[i] = NULL; }

   /*=============================================*/
   /* Evaluate each argument and store its string */
   /* representation in the string array.         */
   /*=============================================*/

   total = 1;
   for (i = 1 ; i <= numArgs ; i++)
     {
      EnvRtnUnknown(theEnv,i,&theArg);

      switch(GetType(theArg))
        {
         case STRING:
#if OBJECT_SYSTEM
         case INSTANCE_NAME:
#endif
         case SYMBOL:
           hashPtr = (SYMBOL_HN *) GetValue(theArg);
           arrayOfStrings[i-1] = hashPtr;
           IncrementSymbolCount(hashPtr);
           break;

         case FLOAT:
           hashPtr = (SYMBOL_HN *) EnvAddSymbol(theEnv,FloatToString(theEnv,ValueToDouble(GetValue(theArg))));
           arrayOfStrings[i-1] = hashPtr;
           IncrementSymbolCount(hashPtr);
           break;

         case INTEGER:
           hashPtr = (SYMBOL_HN *) EnvAddSymbol(theEnv,LongIntegerToString(theEnv,ValueToLong(GetValue(theArg))));
           arrayOfStrings[i-1] = hashPtr;
           IncrementSymbolCount(hashPtr);
           break;

         default:
           ExpectedTypeError1(theEnv,functionName,i,"string, instance name, symbol, float, or integer");
           SetEvaluationError(theEnv,TRUE);
           break;
        }

      if (EvaluationData(theEnv)->EvaluationError)
        {
         for (i = 0; i < numArgs; i++)
           {
            if (arrayOfStrings[i] != NULL)
              { DecrementSymbolCount(theEnv,arrayOfStrings[i]); }
           }

         rm(theEnv,arrayOfStrings,sizeof(SYMBOL_HN *) * numArgs);
         return;
        }

      total += (int) strlen(ValueToString(arrayOfStrings[i - 1]));
     }

   /*=========================================================*/
   /* Allocate the memory to store the concatenated string or */
   /* symbol, then copy the values in the string array to the */
   /* memory just allocated.                                  */
   /*=========================================================*/

   theString = (char *) gm2(theEnv,(sizeof(char) * total));

   j = 0;
   for (i = 0 ; i < numArgs ; i++)
     {
      sprintf(&theString[j],"%s",ValueToString(arrayOfStrings[i]));
      j += (int) strlen(ValueToString(arrayOfStrings[i]));
     }

   /*=========================================*/
   /* Return the concatenated value and clean */
   /* up the temporary memory used.           */
   /*=========================================*/

   SetpValue(returnValue,(void *) EnvAddSymbol(theEnv,theString));
   rm(theEnv,theString,sizeof(char) * total);

   for (i = 0; i < numArgs; i++)
     {
      if (arrayOfStrings[i] != NULL)
        { DecrementSymbolCount(theEnv,arrayOfStrings[i]); }
     }

   rm(theEnv,arrayOfStrings,sizeof(SYMBOL_HN *) * numArgs);
  }
	void Drawer::OnInit(Graph::Scene & scene)
	{
		scene.SetAmbientLight(Math::Color(0.2f, 0.2f, 0.2f, 1.f));

		Graph::PointLightProperties * pl1 = &scene.GetPointLights()[0];
		pl1->worldPosition = Math::Vector4f(-50, 50, 150, 0); 
		pl1->color = Math::Color(0.98f, 0.8f, 0.0f, 500);
		pl1->attenuation = {1, 0.0025f, 0.00065f, 0};


		Graph::PointLightProperties * pl2 = &scene.GetPointLights()[1];
		pl2->worldPosition = Math::Vector4f(50, 50, 150, 0);
		pl2->color = Math::Color(1.f, 0.f, 0.f, 200);
		pl2->attenuation = { 1, 0.0015f, 0.00065f, 0 };

		Graph::PointLightProperties * pl3 = &scene.GetPointLights()[2];
		pl3->worldPosition = Math::Vector4f(-50, -50, 150, 0);
		pl3->color = Math::Color(0.f, 0.f, 1.f, 300);
		pl3->attenuation = { 1, 0.0025f, 0.00065f, 0 };

		scene.SetActivePointLights(3);

        std::unique_ptr<Graph::Geometry> gm1(new Graph::Geometry);

		gm1->SetPrimitiveTopology(Graph::PrimitiveTopology::TriangleList);

		gm1->addVertex(Math::Vertex(Math::Vector3f(-40, 40, 0), Math::Color(1.f, 0.f, 0.f, 1.f), Math::Vector3f(0, 0, -1), {0,0}));
		gm1->addVertex(Math::Vertex(Math::Vector3f(40, -40, 0), Math::Color(0.f, 1.f, 0.f, 1.f), Math::Vector3f(0, 0, -1), {1,1}));
		gm1->addVertex(Math::Vertex(Math::Vector3f(-40, -40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1), {0,1}));
		gm1->addVertex(Math::Vertex(Math::Vector3f(40, 40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1), {1,0}));

		std::unique_ptr<Resources::Texture2d> texture = std::make_unique<Resources::Texture2d>();
		texture->SetFilename("WoodDiffuseTest.dds");

		gm1->SetDiffuseTexture(std::move(texture));
		
		gm1->SetShaderSet(Resources::Shaders::SHADERS_IDX::BLINN_PHONG_TEXTURE);

        //Using vs 2012
        const int size = 6;
        const int indices[] = {
            0,1,2, //front
            3,1,0, 
        };

        std::vector<int> indicesVecor;

        indicesVecor.assign(indices, indices + size);

		gm1->setIndices(indicesVecor);

        gm1->translate(Math::Vector3f(-40, 0, 200));

        gm1->scale(Math::Vector3f(0.8f, 0.8f, 0.8f));

		gm1->rotate(Math::Vector3f(0, -30, 0));

		geometry = scene.AddGeometry(std::move(gm1));


		
		std::unique_ptr<Graph::Geometry> gm2(new Graph::Geometry);

		gm2->SetPrimitiveTopology(Graph::PrimitiveTopology::TriangleList);

		gm2->addVertex(Math::Vertex(Math::Vector3f(-40, 40, 0), Math::Color(1.f, 0.f, 0.f, 1.f), Math::Vector3f(0, 0, -1), { 0, 0 }));
		gm2->addVertex(Math::Vertex(Math::Vector3f(40, -40, 0), Math::Color(0.f, 1.f, 0.f, 1.f), Math::Vector3f(0, 0, -1), { 1, 1 }));
		gm2->addVertex(Math::Vertex(Math::Vector3f(-40, -40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1), { 0, 1 }));
		gm2->addVertex(Math::Vertex(Math::Vector3f(40, 40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1), { 1, 0 }));

		gm2->setIndices(indicesVecor);

		gm2->translate(Math::Vector3f(40, 0, 200));

		gm2->scale(Math::Vector3f(0.8f, 0.8f, 0.8f));

		gm2->rotate(Math::Vector3f(0, 40, 0));

		std::unique_ptr<Resources::Texture2d> diffuseTextureGm2 = std::make_unique<Resources::Texture2d>();
		diffuseTextureGm2->SetFilename("MetalPaintedDiffuse.dds");

		gm2->SetShaderSet(Resources::Shaders::SHADERS_IDX::BLINN_PHONG_TEXTURE);

		gm2->SetDiffuseTexture(std::move(diffuseTextureGm2));

		scene.AddGeometry(std::move(gm2));
		

		/*

		std::unique_ptr<Graph::Geometry> gm3(new Graph::Geometry);

		gm3->SetPrimitiveTopology(Graph::PrimitiveTopology::TriangleList);

		gm3->addVertex(Math::Vertex(Math::Vector3f(-40, 40, 0), Math::Color(1.f, 0.f, 0.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm3->addVertex(Math::Vertex(Math::Vector3f(40, -40, 0), Math::Color(0.f, 1.f, 0.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm3->addVertex(Math::Vertex(Math::Vector3f(-40, -40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm3->addVertex(Math::Vertex(Math::Vector3f(40, 40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1)));
		
		gm3->setIndices(indicesVecor);
		
		gm3->translate(Math::Vector3f(0, 0, 200));
		
		gm3->scale(Math::Vector3f(0.5f, 0.5f, 0.5f));
		
		gm3->rotate(Math::Vector3f(0, 0, 0));

		scene.AddGeometry(std::move(gm3));


		std::unique_ptr<Graph::Geometry> gm4(new Graph::Geometry);

		gm4->SetPrimitiveTopology(Graph::PrimitiveTopology::TriangleList);

		gm4->addVertex(Math::Vertex(Math::Vector3f(-40, 40, 0), Math::Color(1.f, 0.f, 0.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm4->addVertex(Math::Vertex(Math::Vector3f(40, -40, 0), Math::Color(0.f, 1.f, 0.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm4->addVertex(Math::Vertex(Math::Vector3f(-40, -40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm4->addVertex(Math::Vertex(Math::Vector3f(40, 40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1)));

		gm4->setIndices(indicesVecor);

		gm4->translate(Math::Vector3f(50, 0, 200));

		gm4->scale(Math::Vector3f(0.5f, 0.5f, 0.5f));

		gm4->rotate(Math::Vector3f(0, 0, 0));


		scene.AddGeometry(std::move(gm4));
		*/

		
		/*std::unique_ptr<Graph::Geometry> gm5(new Graph::Geometry);

		gm5->SetPrimitiveTopology(Graph::PrimitiveTopology::TriangleList);

		gm5->addVertex(Math::Vertex(Math::Vector3f(-40, 40, 0), Math::Color(1.f, 0.f, 0.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm5->addVertex(Math::Vertex(Math::Vector3f(40, -40, 0), Math::Color(0.f, 1.f, 0.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm5->addVertex(Math::Vertex(Math::Vector3f(-40, -40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1)));
		gm5->addVertex(Math::Vertex(Math::Vector3f(40, 40, 0), Math::Color(0.f, 0.f, 1.f, 1.f), Math::Vector3f(0, 0, -1)));

		gm5->setIndices(indicesVecor);

		gm5->translate(Math::Vector3f(pl1->worldPosition.x, pl1->worldPosition.y, pl1->worldPosition.z));

		gm5->scale(Math::Vector3f(0.1f, 0.1f, 0.1f));

		geometry = scene.AddGeometry(std::move(gm5));*/
		

	}