void ASpotLight::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { Super::PostEditChangeProperty(PropertyChangedEvent); if(ArrowComponent) { ArrowComponent->ArrowColor = GetLightColor(); } }
void ASpotLight::PostLoad() { Super::PostLoad(); if (GetLightComponent()->Mobility == EComponentMobility::Static) { GetLightComponent()->LightFunctionMaterial = NULL; } #if WITH_EDITORONLY_DATA if(ArrowComponent) { ArrowComponent->ArrowColor = GetLightColor(); } #endif }
ASpotLight::ASpotLight(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass<USpotLightComponent>(TEXT("LightComponent0"))) { // Structure to hold one-time initialization struct FConstructorStatics { FName ID_Lighting; FText NAME_Lighting; FConstructorStatics() : ID_Lighting(TEXT("Lighting")) , NAME_Lighting(NSLOCTEXT( "SpriteCategory", "Lighting", "Lighting" )) { } }; static FConstructorStatics ConstructorStatics; SpotLightComponent = CastChecked<USpotLightComponent>(GetLightComponent()); SpotLightComponent->Mobility = EComponentMobility::Stationary; SpotLightComponent->RelativeRotation = FRotator(-90, 0, 0); SpotLightComponent->UpdateComponentToWorld(); RootComponent = SpotLightComponent; #if WITH_EDITORONLY_DATA ArrowComponent = ObjectInitializer.CreateEditorOnlyDefaultSubobject<UArrowComponent>(this, TEXT("ArrowComponent0")); if (ArrowComponent) { ArrowComponent->ArrowColor = GetLightColor(); ArrowComponent->bTreatAsASprite = true; ArrowComponent->SpriteInfo.Category = ConstructorStatics.ID_Lighting; ArrowComponent->SpriteInfo.DisplayName = ConstructorStatics.NAME_Lighting; ArrowComponent->AttachParent = SpotLightComponent; ArrowComponent->bLightAttachment = true; ArrowComponent->bIsScreenSizeScaled = true; } #endif // WITH_EDITORONLY_DATA }
int InitLightData (void) { short segNum, sideNum; short sideVerts [4]; int bIsLight; short tMapNum; tLightMap tempLight; //temporary place to put light data. double sideRad; double baseRange = LightMapRange (); //first step find all the lights in the level. By iterating through every surface in the level. if (!(numLightMaps = CountLights ())) return 0; if (!(lightData = D2_ALLOC (sizeof (tLightMap) * numLightMaps))) return numLightMaps = 0; if (!(lightMaps = (tOglTexture *) D2_ALLOC (MAX_SEGMENTS * 6 * sizeof (*lightMaps)))) { D2_FREE (lightData); return numLightMaps = 0; } memset (lightMaps, 0, sizeof (*lightMaps) * MAX_SEGMENTS * 6); memset (lightData, 0, sizeof (tLightMap) * numLightMaps); numLightMaps = 0; for (segNum = 0; segNum <= gameData.segs.nLastSegment; segNum++) { for (sideNum = 0; sideNum < 6; sideNum++) { //check for point lights #if TEXTURE_CHECK if ((gameData.segs.segments [segNum].children [sideNum] >= 0) && !IS_WALL (WallNumI (segNum, sideNum))) continue; //skip open sides #endif bIsLight = 0; sideRad = 0; tMapNum = gameData.segs.segments [segNum].sides [sideNum].nOvlTex; if (GetLightColor (tMapNum, &tempLight)) { bIsLight = 1; //if (IsBigLight (tMapNum)) sideRad = SideRad (segNum, sideNum); } //then look at the base - will override an overlaying lightopTex. tMapNum = gameData.segs.segments [segNum].sides [sideNum].nBaseTex; if (GetLightColor (tMapNum, &tempLight)) { bIsLight = 1; //if (IsBigLight (tMapNum)) sideRad = SideRad (segNum, sideNum); } if (gameStates.app.bD2XLevel && gameData.render.color.lights [segNum * 6 + sideNum].index) { bIsLight = 1; tempLight.color [0] = (GLfloat) gameData.render.color.lights [segNum * 6 + sideNum].color.red; tempLight.color [1] = (GLfloat) gameData.render.color.lights [segNum * 6 + sideNum].color.green; tempLight.color [2] = (GLfloat) gameData.render.color.lights [segNum * 6 + sideNum].color.blue; tempLight.range = baseRange; } //Process found light. if (bIsLight) { #ifdef _DEBUG if (!sideFlags [segNum * 6 + sideNum]) continue; #endif tempLight.range += sideRad; //find where it is in the level. GetSideVerts (sideVerts, segNum, sideNum); //this is just temporary need to find actual lights on surfaces VmVecAvg4 ( &lightData [numLightMaps].pos, gameData.segs.vertices + sideVerts [0], gameData.segs.vertices + sideVerts [2], gameData.segs.vertices + sideVerts [3], gameData.segs.vertices + sideVerts [1]); #if 1 memcpy (&lightData [numLightMaps].color, &tempLight.color, sizeof (tempLight.color)); #else lightData [numLightMaps].color [0] = tempLight.color [0]; lightData [numLightMaps].color [1] = tempLight.color [1]; lightData [numLightMaps].color [2] = tempLight.color [2]; #endif lightData [numLightMaps].range = tempLight.range; lightData [numLightMaps].refside = segNum * 6 + sideNum; //find light direction, currently based on first 3 points of tSide, not always right. VmVecNormal ( &lightData [numLightMaps].dir, gameData.segs.vertices + sideVerts [0], gameData.segs.vertices + sideVerts [1], gameData.segs.vertices + sideVerts [2]); numLightMaps++; } } } return numLightMaps; }