mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-22 09:40:46 +00:00
Read Blender lights directly through the KHR_lights_punctual glTF extension
This commit is contained in:
parent
d716661d90
commit
f8a5329ea8
2 changed files with 25 additions and 6 deletions
|
@ -3,7 +3,7 @@ bind "I" "toggle r_showSurfaceInfo"
|
|||
bind "N" "noclip"
|
||||
bind "M" "spawn moveable_macbethchart"
|
||||
|
||||
bind "F1" "toggle editLights"
|
||||
bind "F1" "editLights"
|
||||
bind "F2" "toggle r_showTris 1 2 0"
|
||||
bind "F3" "toggle r_forceAmbient 0.5 1.0 0"
|
||||
bind "F4" "toggle r_skipInteractions"
|
||||
|
|
|
@ -433,6 +433,8 @@ void ResolveLight( gltfData* data, idMapEntity* newEntity, gltfNode* node )
|
|||
|
||||
assert( light );
|
||||
|
||||
newEntity->epairs.Set( "classname", "light" );
|
||||
|
||||
//newEntity->epairs.SetMatrix( "rotation", mat3_default );
|
||||
newEntity->epairs.SetVector( "_color", light->color );
|
||||
|
||||
|
@ -450,8 +452,19 @@ void ResolveLight( gltfData* data, idMapEntity* newEntity, gltfNode* node )
|
|||
|
||||
case gltfExt_KHR_lights_punctual::Point:
|
||||
{
|
||||
newEntity->epairs.SetVector( "light_radius", idVec3( light->range ) );
|
||||
newEntity->epairs.Set( "texture", "lights/defaultpointlight" );
|
||||
float radius = 300;
|
||||
if( light->range != -1 )
|
||||
{
|
||||
radius = light->range;
|
||||
}
|
||||
|
||||
newEntity->epairs.SetVector( "light_radius", idVec3( radius ) );
|
||||
|
||||
idStr texture;
|
||||
if( !newEntity->epairs.GetString( "texture", "", texture ) )
|
||||
{
|
||||
newEntity->epairs.Set( "texture", "lights/biground1" );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -471,7 +484,12 @@ void ResolveLight( gltfData* data, idMapEntity* newEntity, gltfNode* node )
|
|||
newEntity->epairs.SetVector( "light_up", axis[2] * fov );
|
||||
newEntity->epairs.SetVector( "light_start", axis[0] * 16 );
|
||||
newEntity->epairs.SetVector( "light_end", axis[0] * ( light->range - 16 ) );
|
||||
newEntity->epairs.Set( "texture", "lights/spot01" );
|
||||
|
||||
idStr texture;
|
||||
if( !newEntity->epairs.GetString( "texture", "", texture ) )
|
||||
{
|
||||
newEntity->epairs.Set( "texture", "lights/spot01" );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -638,8 +656,9 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI
|
|||
idStr classnameStr = node->extras.strPairs.GetString( "classname" );
|
||||
bool skipInline = !node->extras.strPairs.GetBool( "inline", true );
|
||||
idDict epairs;
|
||||
// skip everything that is not an entity
|
||||
if( !classnameStr.IsEmpty() )
|
||||
|
||||
// skip everything that is not an entity except lights
|
||||
if( !classnameStr.IsEmpty() || node->extensions.KHR_lights_punctual )
|
||||
{
|
||||
idMapEntity* newEntity = new( TAG_IDLIB_GLTF ) idMapEntity();
|
||||
entities.Append( newEntity );
|
||||
|
|
Loading…
Reference in a new issue