Beispiel #1
0
 public Fog()
 {
     color = new float4();
 }
Beispiel #2
0
        public List<Entity> GetEntities(BsonDocument bsonDoc)
        {
            var entities = new List<Entity>();
            BsonDocument entityElements = bsonDoc["assets"].AsBsonDocument;
            Entity anEntity = null;

            for (int i = 0; i < entityElements.Count(); i++)
            {
                BsonDocument entityAttributes = entityElements[i].AsBsonDocument;
                anEntity = new Entity();

                if (entityAttributes.Contains("objectName"))
                {
                    anEntity.ObjectName = entityAttributes["objectName"].AsString;
                }

                if (entityAttributes.Contains("asset_file"))
                {
                    anEntity.FilePath = entityAttributes["asset_file"].AsString;
                }

                if (entityAttributes.Contains("position_x") &&
                    entityAttributes.Contains("position_y") &&
                    entityAttributes.Contains("position_z"))
                {
                    anEntity.Position = new float3(float.Parse(entityAttributes["position_x"].AsString),
                        float.Parse(entityAttributes["position_y"].AsString),
                        float.Parse(entityAttributes["position_z"].AsString));
                }

                if (entityAttributes.Contains("rotation_x") &&
                    entityAttributes.Contains("rotation_y") &&
                    entityAttributes.Contains("rotation_z"))
                {
                    anEntity.Rotation = new float3(float.Parse(entityAttributes["rotation_x"].AsString),
                        float.Parse(entityAttributes["rotation_y"].AsString),
                        float.Parse(entityAttributes["rotation_z"].AsString));
                }

                if (entityAttributes.Contains("tag"))
                {
                    anEntity.Tag = entityAttributes["tag"].AsString;
                }

                if (entityAttributes.Contains(DbConstants.LevelFieldEntityLightmapIndex))
                {
                    anEntity.LightmapIndex = int.Parse(entityAttributes[DbConstants.LevelFieldEntityLightmapIndex].AsString);
                }
                else
                {
                    anEntity.LightmapTilingOffset = new float4(0f, 0f, 0f, 0f);
                }

                float4 lightmapTileOffset = new float4(0f, 0f, 0f, 0f);
                if (entityAttributes.Contains(DbConstants.LevelFieldEntityLightmapsTilingOffsetX))
                {
                    lightmapTileOffset.x = float.Parse(entityAttributes[DbConstants.LevelFieldEntityLightmapsTilingOffsetX].AsString);
                }

                if (entityAttributes.Contains(DbConstants.LevelFieldEntityLightmapsTilingOffsetY))
                {
                    lightmapTileOffset.y = float.Parse(entityAttributes[DbConstants.LevelFieldEntityLightmapsTilingOffsetY].AsString);
                }

                if (entityAttributes.Contains(DbConstants.LevelFieldEntityLightmapsTilingOffsetZ))
                {
                    lightmapTileOffset.z = float.Parse(entityAttributes[DbConstants.LevelFieldEntityLightmapsTilingOffsetZ].AsString);
                }

                if (entityAttributes.Contains(DbConstants.LevelFieldEntityLightmapsTilingOffsetW))
                {
                    lightmapTileOffset.w = float.Parse(entityAttributes[DbConstants.LevelFieldEntityLightmapsTilingOffsetW].AsString);
                }
                anEntity.LightmapTilingOffset = lightmapTileOffset;

                entities.Add(anEntity);
            }

            return entities;
        }