Jump to content

Help - Turning the lights on!


Recommended Posts

Hi guys!

Recently i started on moddeling and im working on a version of the Altair Lander and Orion Spacecraft. Yes, i know that there's wonderfull mods with those, but i wanted something more stockalike and updated (for me, BobCat's the king and his versions is the best, but outdated and need some work to fit with the new versions and look on game).

 

Said that, i started my own project but i dont know how to make the texture and action to change the windows color "turning the lights on" like other parts on game... Didnt found any tutorial either...

 

1CxmreT.png

BAOcNGo.png

mVdr1Zm.png


Can anyone give me some tips?

Thank you!

Gabu

Link to comment
Share on other sites

Is this your own model? or rather do you have access to the model you are building this with. I ask because the current 'lights on' for some stock parts is done by a sort of 'hacky' method. Usually you would have the windows manually animated, similar to the video tutorial @MeCripp posted but with the 'point light/spot light' element.

The key thing is to change the _EmissiveColor properties which creates the appearance of light without actually generating light. Think of it this way, when you turn the floodlight on its changes from a grey to a white/yellow and spills a beam/circle/spot of light over the desired area (this is generating light) when you turn on the lander can lights, the glass changes from blue to white/yellow but doesn't actually cast light outward anywhere. This is a good thing because unity can only handle so many light sources at once before it starts 'dropping' them.

As an example here is the MK1CrewCabin lights part of it's config:

MODULE
	{
		name = ModuleAnimateGeneric
		animationName = Mk1Lights
		actionGUIName = Toggle Lights
		startEventGUIName = Lights On
		endEventGUIName = Lights Off
	}

Now some of the stock older parts never got this emissive animation when they were originally made so Squad got clever and made a workaround. The changes the window elements of there part's model (and a few other objects within the model here and there) from the normal Shader to one of their KSP Emissive Shaders. This meant that using ModuleColorchanger they could change the _EmissiveColor properties for that part.
Its a bit brutish though and the code below will force all the emissive elements on that part to go whichever colour you have determined in the config (adjusting the redCurve, greenCurve and blueCurve will give different colours). The draw back to this approach is that if you play with @Snark's  indicator lights there are additional implications (better explained at the bottom of this config here: IndicatorLights mk1 Lander Can config).

MODULE
     {
         name = ModuleColorChanger
         shaderProperty = _EmissiveColor
         animRate = 0.4
         animState = true
         useRate = true
         toggleInEditor = true
         toggleInFlight = true
         unfocusedRange = 5
         toggleName = Toggle Lights
         eventOnName = Lights On
         eventOffName = Lights Off
         toggleAction = True
         defaultActionGroup = Lights
         redCurve
         {
             key = 0 1
             key = 1 0
         }
         greenCurve
         {
             key = 0 1
             key = 1 0
         }
         blueCurve
         {
             key = 0 0
             key = 1 0
         }
         alphaCurve
         {
             key = 0 1
         }
     } 

 

Link to comment
Share on other sites

17 hours ago, Gabu said:

dont know how to make the texture and action to change the windows color "turning the lights on" like other parts on game...

I'd recommend ModuleColorChanger.  It's really simple and easy to use, and you can (mostly) copy the necessary config from existing stock KSP parts.  Detailed discussion below:

ModuleColorChanger, which KSP introduced with 1.2, makes it pretty easy to have functional cabin lights on your model.  It's what Squad used for all the "older" crew parts that they added cabin lights to in 1.2.

The one "gotcha" to be aware of is that if you use it in the simple "default" way, without specifying which meshes on your model it should include or exclude, it will grab control of the emissive color of all the meshes on the part, which will not only stop mods like IndicatorLights from working, but will also screw up the thermal overlay display that shows up with F11 (your part will show up as simply black, without the thermal highlight).  You can see that bug on the stock parts in KSP-- they missed a spot.  :wink:

Thankfully, that foible's easy to work around, as long as your cabin windows are a separate mesh (or meshes) from the main body of the part.  That's because the ModuleColorChanger has a couple of fields you can set to control which meshes are or aren't included.  For example, you can see this in the Mk1 lander can config for IndicatorLights, which @steedcrugeon points out above:  in my ModuleManager patch, I add an excludedRenderer line so it won't try to control the mesh that my mod tacks on to the part.

If you're making your own part, I'd suggest using includedRenderer instead, since it's "friendlier".  Here's how ModuleColorChanger works:

  • If you don't specify any included or excluded renderers, then it will control all meshes on the part, which is bad (will stop the thermal overlay from working, can interfere with other mods).
  • If you specify excludedRenderer, it will control everything except what you specify.
  • If you specify includedRenderer, it will control only the ones you specify.  (You can include more than one.)

So what I'd recommend that you do is, set up your model so that your cabin windows (that you want to light up) are a separate mesh or meshes from the rest of the model, and make sure that they're made of a material that has an _EmissiveColor on it (e.g. they use some form of emissive renderer).  Then, in your .cfg file for your model, specify a ModuleColorChanger.  You can just copy it verbatim from the ModuleColorChanger that Squad uses for its various parts like the Mk1 lander can, if you'd like it to have the same look-and-feel.  Then, add the necessary entry or entries for includedRenderer, and provide just the window meshes there.

That way, the ModuleColorChanger will only try to control your windows, and will leave the rest of your part alone-- which means it will have a properly functioning thermal overlay via F11, and also means that it will play nice with IndicatorLights if you or anyone else authors a patch to add indicators to it.  :)

 

Link to comment
Share on other sites

Thank you all by repsonse!!! Sorry to get so much time to reply, the only time I have to mod its on weekends!

Today Ill try the tips and ill let you all know the progress!! Thank you again guys!!

On 31/07/2017 at 2:42 PM, MeCripp said:

 Most of the parts look like SSTU mod 

 

I LOVE SSTU!! Some day ill get on that level of modding! If I have time, i hope so! :)

Edited by Gabu
Link to comment
Share on other sites

On 7/31/2017 at 11:50 AM, Snark said:
Spoiler

 

I'd recommend ModuleColorChanger.  It's really simple and easy to use, and you can (mostly) copy the necessary config from existing stock KSP parts.  Detailed discussion below:

ModuleColorChanger, which KSP introduced with 1.2, makes it pretty easy to have functional cabin lights on your model.  It's what Squad used for all the "older" crew parts that they added cabin lights to in 1.2.

The one "gotcha" to be aware of is that if you use it in the simple "default" way, without specifying which meshes on your model it should include or exclude, it will grab control of the emissive color of all the meshes on the part, which will not only stop mods like IndicatorLights from working, but will also screw up the thermal overlay display that shows up with F11 (your part will show up as simply black, without the thermal highlight).  You can see that bug on the stock parts in KSP-- they missed a spot.  :wink:

Thankfully, that foible's easy to work around, as long as your cabin windows are a separate mesh (or meshes) from the main body of the part.  That's because the ModuleColorChanger has a couple of fields you can set to control which meshes are or aren't included.  For example, you can see this in the Mk1 lander can config for IndicatorLights, which @steedcrugeon points out above:  in my ModuleManager patch, I add an excludedRenderer line so it won't try to control the mesh that my mod tacks on to the part.

If you're making your own part, I'd suggest using includedRenderer instead, since it's "friendlier".  Here's how ModuleColorChanger works:

  • If you don't specify any included or excluded renderers, then it will control all meshes on the part, which is bad (will stop the thermal overlay from working, can interfere with other mods).
  • If you specify excludedRenderer, it will control everything except what you specify.
  • If you specify includedRenderer, it will control only the ones you specify.  (You can include more than one.)

So what I'd recommend that you do is, set up your model so that your cabin windows (that you want to light up) are a separate mesh or meshes from the rest of the model, and make sure that they're made of a material that has an _EmissiveColor on it (e.g. they use some form of emissive renderer).  Then, in your .cfg file for your model, specify a ModuleColorChanger.  You can just copy it verbatim from the ModuleColorChanger that Squad uses for its various parts like the Mk1 lander can, if you'd like it to have the same look-and-feel.  Then, add the necessary entry or entries for includedRenderer, and provide just the window meshes there.

That way, the ModuleColorChanger will only try to control your windows, and will leave the rest of your part alone-- which means it will have a properly functioning thermal overlay via F11, and also means that it will play nice with IndicatorLights if you or anyone else authors a patch to add indicators to it.  :)


 

 

I never knew about that, seems interesting, and I may use it for my own command pods!

Link to comment
Share on other sites

Guys, first i would like to thank you all by support!

Houston we have the lights rdy to roll! :)

I tried the 1st metode, but the animation didnt work as I expected. So, i tried the second way from master @Snark and thats it! I still have some work to do on the release and to read the rules for sharing it here, but soon i expect to share this work!

Thank you all again!!!!

hXVeUu2.png

3B92O1v.png

SGa2V96.png

2pNWIiS.png

FBGGX6g.png

WpnLAZi.png

nQlBpVW.png

zCPhe0C.png

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...