NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
RenderModuleMaterialsSystem.cpp
Go to the documentation of this file.
00001 
00012 #include "RenderModule.h"
00013 
00014 // Standard Includes
00015 #include <string>
00016 #include <deque>
00017 
00018 // Library Includes
00019 
00020 // Local Includes
00021 #include "../sharedbase/EventLogger.h"
00022 #include "../sharedbase/Envelope.h"
00023 
00024 #include "material/MaterialsSystemInterface.h"
00025 
00026 #include "Messages.h"
00027 
00028 // Typedefs and structs
00029 
00030 // Constants
00031 
00032 // Class Mathods
00033 namespace GraphicsCore {
00034   /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00035   bool RenderModule::CreateMaterial(EnvelopeSPTR incomingEnvelope, MaterialsSystemInterface* object) const {
00036     const static unsigned int MATERIAL_MESSAGE_STRIDE = 2;
00037     
00038     int index = incomingEnvelope->GetCount();
00039     
00040     // If there's a material's list, it should at least have some members!
00041     if (index >= MATERIAL_MESSAGE_STRIDE) {
00042       unsigned int material_index;
00043       EnvelopeSPTR material_spec;
00044       
00045       bool status = true;
00046       
00047       while ((index -= MATERIAL_MESSAGE_STRIDE) >= 0 && status) {
00048         material_index = incomingEnvelope->GetDataUInt(        index + 0);
00049         material_spec  = incomingEnvelope->GetDataEnvelopeSPTR(index + 1);
00050         
00051         status = object->InsertMaterial(material_index, material_spec);
00052       }
00053       
00054       return status;
00055     }
00056     
00057     LOG(LOG_PRIORITY::INFO, "Attempted creation of a materials list without a material!");
00058     
00059     return false;
00060   }
00061 }