LevelLoader reads lights and cgMesh correctly.
This commit is contained in:
parent
1c71d7ef80
commit
6eb0a282c2
|
@ -231,7 +231,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
||||||
pointLight.Color = light->color;
|
pointLight.Color = light->color;
|
||||||
pointLight.Pos = light->position;
|
pointLight.Pos = light->position;
|
||||||
pointLight.Bright = light->intensity;
|
pointLight.Bright = light->intensity;
|
||||||
pointLight.Radius = light->raduis;
|
pointLight.Radius = light->radius;
|
||||||
|
|
||||||
C_Light *newLight = new C_Light( pointLight, objectID );
|
C_Light *newLight = new C_Light( pointLight, objectID );
|
||||||
|
|
||||||
|
|
|
@ -166,16 +166,17 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
|
|
||||||
case ObjectType_Light:
|
case ObjectType_Light:
|
||||||
{
|
{
|
||||||
LightType lightType;
|
//LightType lightType;
|
||||||
|
|
||||||
//Get Light type
|
//Get Light type
|
||||||
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
//ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
||||||
|
|
||||||
//We only support PointLight for now.
|
//We only support PointLight for now.
|
||||||
BasicLight* header = new BasicLight;
|
BasicLight* header = new BasicLight;
|
||||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
|
||||||
counter += sizeof(*header);
|
ParseLight(&buffer[counter], *header, counter);
|
||||||
objects.push_back(header);
|
objects.push_back(header);
|
||||||
|
|
||||||
/*switch(lightType)
|
/*switch(lightType)
|
||||||
{
|
{
|
||||||
case LightType_PointLight:
|
case LightType_PointLight:
|
||||||
|
@ -208,6 +209,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
}
|
}
|
||||||
break;*/
|
break;*/
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
//Couldn't find typeID. FAIL!!!!!!
|
//Couldn't find typeID. FAIL!!!!!!
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace GameLogic
|
||||||
CollisionGeometryType_Box,
|
CollisionGeometryType_Box,
|
||||||
CollisionGeometryType_Sphere,
|
CollisionGeometryType_Sphere,
|
||||||
CollisionGeometryType_Cylinder,
|
CollisionGeometryType_Cylinder,
|
||||||
|
CollisionGeometryType_CG_MESH,
|
||||||
|
|
||||||
CollisionGeometryType_Count,
|
CollisionGeometryType_Count,
|
||||||
CollisionGeometryType_Unknown = -1
|
CollisionGeometryType_Unknown = -1
|
||||||
|
@ -161,6 +162,11 @@ namespace GameLogic
|
||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BoundingVolumeCGMesh : public BoundingVolumeBase
|
||||||
|
{
|
||||||
|
wchar_t filename[128];
|
||||||
|
};
|
||||||
|
|
||||||
struct BoundingVolume
|
struct BoundingVolume
|
||||||
{
|
{
|
||||||
CollisionGeometryType geoType;
|
CollisionGeometryType geoType;
|
||||||
|
@ -169,9 +175,9 @@ namespace GameLogic
|
||||||
LevelLoaderInternal::BoundingVolumeBox box;
|
LevelLoaderInternal::BoundingVolumeBox box;
|
||||||
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
||||||
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
||||||
|
LevelLoaderInternal::BoundingVolumeCGMesh cgMesh;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LevelMetaData : public ObjectTypeHeader
|
struct LevelMetaData : public ObjectTypeHeader
|
||||||
|
@ -253,8 +259,10 @@ namespace GameLogic
|
||||||
LightType lightType; //Is not used right now
|
LightType lightType; //Is not used right now
|
||||||
float color[3];
|
float color[3];
|
||||||
float position[3];
|
float position[3];
|
||||||
float raduis;
|
float radius;
|
||||||
float intensity;
|
float intensity;
|
||||||
|
|
||||||
|
virtual ~BasicLight(){}
|
||||||
};
|
};
|
||||||
/* We only support pointlight right now.
|
/* We only support pointlight right now.
|
||||||
struct PointLight : public BasicLight
|
struct PointLight : public BasicLight
|
||||||
|
|
|
@ -20,6 +20,32 @@ namespace GameLogic
|
||||||
memcpy(header, buffer, size);
|
memcpy(header, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ParseLight(char* buffer, BasicLight& header, int& size)
|
||||||
|
{
|
||||||
|
int start = 0;
|
||||||
|
memcpy(&header.typeID, &buffer[start], 40);
|
||||||
|
start += 40;
|
||||||
|
/*
|
||||||
|
memcpy(&header.lightType, &buffer[start], 4);
|
||||||
|
start += 4;
|
||||||
|
|
||||||
|
memcpy(&header.color, &buffer[start], 12);
|
||||||
|
start += 12;
|
||||||
|
|
||||||
|
memcpy(&header.position, &buffer[start], 12);
|
||||||
|
start += 12;
|
||||||
|
|
||||||
|
memcpy(&header.radius, &buffer[start], 4);
|
||||||
|
start += 4;
|
||||||
|
|
||||||
|
memcpy(&header.intensity, &buffer[start], 4);
|
||||||
|
start += 4;*/
|
||||||
|
|
||||||
|
size += start;
|
||||||
|
|
||||||
|
//memcpy(&header, buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
void ParseObject(char* buffer, ObjectHeader& header, int& size, bool loadCgf)
|
void ParseObject(char* buffer, ObjectHeader& header, int& size, bool loadCgf)
|
||||||
{
|
{
|
||||||
char tempName[128];
|
char tempName[128];
|
||||||
|
@ -173,6 +199,22 @@ namespace GameLogic
|
||||||
start += sizeof(volume.cylinder);
|
start += sizeof(volume.cylinder);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CollisionGeometryType_CG_MESH:
|
||||||
|
{
|
||||||
|
memcpy(&volume.cgMesh, &buf[start], sizeof(float)*12);
|
||||||
|
start += sizeof(float)*12;
|
||||||
|
memcpy(&tempSize, &buf[start], sizeof(tempSize));
|
||||||
|
start += 4;
|
||||||
|
memcpy(&tempName, &buf[start], tempSize);
|
||||||
|
tempName[tempSize] = '\0';
|
||||||
|
|
||||||
|
//convert from char[] to wchar_t[]
|
||||||
|
mbstowcs_s(NULL, volume.cgMesh.filename, tempSize+1, tempName, _TRUNCATE);
|
||||||
|
|
||||||
|
start += tempSize;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace GameLogic
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void ParseObject(char* buffer, void *header, int size);
|
void ParseObject(char* buffer, void *header, int size);
|
||||||
|
void ParseLight(char* buffer, BasicLight& header, int& size);
|
||||||
void ParseObject(char* buffer, ObjectHeader& header, int& size , bool loadCgf);
|
void ParseObject(char* buffer, ObjectHeader& header, int& size , bool loadCgf);
|
||||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
||||||
void ParseBoundingVolume(char* buffer, LevelLoaderInternal::BoundingVolume& volume, int &size);
|
void ParseBoundingVolume(char* buffer, LevelLoaderInternal::BoundingVolume& volume, int &size);
|
||||||
|
|
Loading…
Reference in New Issue