Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Download Outerra Tech Demo. Unofficial Outerra Discord server, MicroProse Discord server for OWS.

Pages: [1] 2

Author Topic: illuminate outerra's villages by streetlamps..working !  (Read 15368 times)

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
illuminate outerra's villages by streetlamps..working !
« on: November 24, 2018, 04:14:01 pm »

Most recent updated version at the end of the topic !


It was a long time that I wanted to make the outerra night more bright installing some lights.
Thanks to aWac9 travels around the outerra world, remembering me how cool streetlights would be in outerra, i finally decided to actually make one.

Here it is ! :

https://www.dropbox.com/sh/na1c3r0kzwuh5gd/AADAd9bWSab7pbRv5WCRZuuXa?dl=0



It's a single streetlamp that can be switched on and off. By using the scenery editor you can place many of them wherever you like. The only drawback at the moment is that they need be switched on individually by moving near to each in outerra ufo mode and "entering" the lamp and then exit and go to the next. There may be some way to avoid this but I have not figured it out yet.







install by clicking on the "illumination.otx" file.

-------------

To use the lamp open the scenery editor inside outerra pressing the F7 key
under "assets" search for "illumination
"
drag and drop the lamp to the desired location in the scenery and manipulate in the usual way
as for placing buildings and other objects to orient and adjust the height. Levelling the terrain under the streetlamp helps to keep it stand more stably.

Close the scenery editor.

-------------

In "ufo mode" go near to a lamp that you have placed.


To switch on a lamp you need to go "inside" it.
This is because lamps are using the vehicle script and thus behave as vehicles except that they don't move.

To enter the lamp go near to the pole.
You will recognize that you have got inside as the pole shakes briefly.


the lamp will thus automatically have switched on

exit the lamp pressing the "enter" key as you do normally for exiting vehicles

you should see the lamp lit.

-------------

to switch the lamp off again:


enter the lamp once again

then press L

the lamp will switch off

eventually by pressing L again the lamp will switch on again if desired

exit the lamp pressing pressing the "enter" key.
« Last Edit: December 07, 2018, 08:34:05 am by fly77 »
Logged

HiFlyer

  • Hero Member
  • *****
  • Posts: 1788
  • newbie
Re: illuminate outerra's villages by streetlamps..working !
« Reply #1 on: November 25, 2018, 07:20:52 pm »

Looks Nice!
Logged
Spex: Intel Core i7 6700K @ 4.6GHz / 32.0GB G.SKILL TridentZ Series Dual-Channel Ram / ASUS STRIX GeForce GTX 1080 / Sound Blaster Z / Oculus Rift VR Headset / Klipsch® Promedia 2.1 Computer Speakers / ASUS ROG SWIFT PG279Q ‑ 27" IPS LED Monitor ‑ QHD / 2x Samsung SSD 850 EVO 500GB / Windows 10 Pro

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #2 on: November 26, 2018, 01:23:58 am »

Thanks. Here is a video showing more clearly how it looks and feels. It makes outerra nights more explorable and contributes a lot to the gaming possibilities. I think future updates should include procedural streetlights as well as traffic lights by default, unless it is computationally too intense to lighten up entire cities.

« Last Edit: November 26, 2018, 12:55:40 pm by fly77 »
Logged

patmarrnc

  • Full Member
  • ***
  • Posts: 136
Re: illuminate outerra's villages by streetlamps..working !
« Reply #3 on: November 27, 2018, 10:34:45 pm »

the things you are doing lately look AWESOME! I've been hoping for quite some time that somebody would create a free-standing light of some kind... all of my attempts generated JS errors (JS is a total mystery to me. If Andfly hadn't helped me out, I'd have never gotten anything working)


Thanks for sharing the fruits of your labors!  I hope to someday have time to study what you've done... but lately my attention is elsewhere.

edit: it would be cool to incorporate this idea into BOB425's traffic lights
« Last Edit: November 27, 2018, 10:38:57 pm by patmarrnc »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #4 on: November 27, 2018, 11:56:04 pm »

Thanks...in fact i have tried it and it already and works. Just need to finish tuning it and I will share. :)
« Last Edit: November 28, 2018, 02:36:25 am by fly77 »
Logged

patmarrnc

  • Full Member
  • ***
  • Posts: 136
Re: illuminate outerra's villages by streetlamps..working !
« Reply #5 on: November 28, 2018, 01:51:09 pm »

while you're at it... there is a lantern inside the log cabin I posted.  It was my plan to make it light up eventually, but I've been away from Outerra long enough now that I can't get my head back in the groove.
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #6 on: November 28, 2018, 04:08:12 pm »

Wow ! Very beautiful !  Sorry but I have had a look at all your models except this one. I looked at the "log cabin NEW" only but the "old" one is much better !
Its confirmed : using vehicle scripts to make lots of other stuff  is a very good idea ! I had to adjust some lines of code and the light position as it initially gave me error and the light was off position.
Here are my modifications to the code that made it work for me.

Code: [Select]
var myspotlight
var mypointlight
var light_switch = 0
var col = {x:0.99, y:0.99, z:0.99};
var fp
var vc_headlight = {x:0.7, y:0.7, z:1};


//---------------------------------------------------------------------------------------
function init_chassis(){

fp = {color:vc_headlight, size:0.1, angle:40, edge:0.08, fadeout:0.005, range:400 };

myspotlight = this.add_point_light({x:-1.8, y:-0.55, z:3.5} ,  fp);

//var fp = {size:0.165, angle:70, edge:0.2, fadeout:0.05, range:70 };
   
//myspotlight=this.add_spot_light({x:0.0,y:1.83982, z: 0} , {y:1}, fp);


//mypointlight=this.add_point_light({x:0.0,y:1.0,z:0.}, {color:col,  angle:10, size:1, edge:1, range:0.1, intensity:100, fadeout:0.1});


// L key toggles light on and off

this.register_event("car/lights/passing", light_action);
}


function light_action(){

    if(light_switch ==0){
       light_switch =1;
       this.light(myspotlight,1);
    }else{
       light_switch =0;
       this.light(myspotlight,0);
    }
}

//---------------------------------------------------------------------------------
function init_vehicle()
{
this.geom = this.get_geomob(0);

}

The only problem that I have - unfortunately serious  ;) - is that as soon as I enter the house starts floating in the air !!
I think the reason is that as the stair extends below the bottom of the base of the house the collision box by default is set to the bottom of the stairs and therefore the house actually floats in the air. I would be very glad if you could solve that very easily by adding a suitable collision box to the original mesh (blender ? ) file. By the way if you do it it would be even more nice to have collision boxes on walls and floor..or at least on floor and on stair so that my character can walk inside and have a rest in the bed !  :)  Would be a great addition to a collection of houses that can be "entered" by animated characters. If you have no time and agree I can do it and post it giving the due credits to you.
« Last Edit: November 28, 2018, 06:20:49 pm by fly77 »
Logged

andfly

  • Sr. Member
  • ****
  • Posts: 347
Re: illuminate outerra's villages by streetlamps..working !
« Reply #7 on: December 03, 2018, 08:22:26 am »

I have followed with much interest the construction and the evolution of your recent works and I congratulate again for the tenacity and the enthusiasm.
Maybe you could have a little suggestion …

Among the methods that can be used on all objects subjected to "vehicle_physics" (and therefore all the models defined as "vehicles") there is a very interesting one for lighting management.
https://github.com/Outerra/anteworld/blob/master/include/ot/vehicle_physics.h
This is the solar_time (time, sun_coef) method applicable directly to the model with the instruction:

var v = this.solar_time ()

The returned variables are:
v.time       time at vehicle location, in miliseconds
v.sun_coef    sun position relative to horizon: 0 sun at horizon, 1 sun at zenith, -1 sun at anti-zenith

Knowing the time and, better still, the solar lighting, it should be easy to insert a few more lines in the script associated with your models to make the lamps automatically turn on at nightfall and also to dose the intensity of the lighting proportionally ...

I hope I was helpful.  :D
Logged
I do not know the English language. I use Google Translate. I hope it's all understandable.

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #8 on: December 03, 2018, 09:52:21 am »

Hi andfly. Thank you for your appreciation and for the interesting information. Indeed as it stands the lighting during dark nights seems to be disproportionate and i was thinking  to correct that using that command just i didn' understand what is returned by it. Also I was not able to change light intensity once set in init chassis by trying to change the lighting parameters set in init chassis. Any help is appreciated !!
Turning lights on and off automatically will be cool ! Will do it for sure if I manage. Thank you.
« Last Edit: December 03, 2018, 10:32:06 am by fly77 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #9 on: December 03, 2018, 11:03:51 am »

OK I found it ! To modify the light range (and therefore intensity) and color we need to use the   light_color command

//Set light color/intensity
   
void light_color( uint id, const float4& color, float range = 0 );

works !  Just need figure out how to apply it to my lamps.

If anybody knows how to do it differently please post !  Having more than one solution is always good.


« Last Edit: December 03, 2018, 12:43:57 pm by fly77 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #10 on: December 07, 2018, 08:33:06 am »

Following the suggestion of andfly I incorporated  automatic light intensity switching on and off at dawn and dusk.
Also I added automatic light intensity regulation at dawn and dusk depending on the cloud coverage and rain intensity.

You still need to switch on initially the streetlights one by one, as explained above, but afterwards their behaviour is regulated automatically.

Download from here:

https://www.dropbox.com/sh/nb5bbq582xnwj9w/AABAt1JFZLhcZA4XBf_O1bSea?dl=0



Here is a demonstrative video


« Last Edit: December 07, 2018, 08:46:06 am by fly77 »
Logged

aWac9

  • Hero Member
  • *****
  • Posts: 2601
  • newbie
Re: illuminate outerra's villages by streetlamps..working !
« Reply #11 on: December 07, 2018, 06:09:57 pm »

As always, a great contribution. I have the feeling that the solution for automatic and autonomous lighting is not far away, just like the blades of the mill when we add it to outerra.
Thank you.

Either way the lighting looks great.



« Last Edit: December 07, 2018, 06:49:20 pm by aWac9 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #12 on: December 08, 2018, 02:18:54 am »

you are an artist !  :)

At the moment it seems impractical to place more that 100 lights in outerra as the framerate drops considerably even with the simplest version of light where one vehicles controls  100 lights together - of course placed automatically in a simple pattern (or maybe randomly) - and then does nothing in the update frame function.

Code: [Select]


var light_z = 7.1;        // corresponds to lantern height
var white ;
var white_range = 1000;



function init_chassis(){
 
  white =  Create2DArray(10,10);     
    var i,j;
    for ( i=0;i<10;i++){
      for (j=0; j<10;j++){     
         white[i][j] = this.add_point_light({ x: 2.45 + j*50, y: i*50, z: light_z }, { color: { x: 0.6, y: 0.6, z: 1 }, size: 0.25, angle: 48, edge: 0.01, intensity: 0, range: white_range, fadeout: 0.0 }); 
      }     
    }
   
     return {mass:100000, com:{ x:0, y:0, z:-1000}};
}


function init_vehicle() {

this.geom = this.get_geomob(0);

  this.set_fps_camera_pos({x:0,y:0,z:3});
 
  var i,j;
    for ( i=0;i<10;i++){
    for (j=0; j<10;j++){                 
     this.light(white[i][j], 1);
     }
  } 
}


function Create2DArray(rows,columns) {
   var x = new Array(rows);
   for (var i = 0; i < rows; i++) {
       x[i] = new Array(columns);
   }
   return x;
}


function update_frame(dt, engine, brake, steering){
 
 
}

« Last Edit: December 08, 2018, 04:32:49 am by fly77 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #13 on: December 13, 2018, 03:15:33 pm »

First trial of streetlamps made with "emissive textures" instead of pointlights.

Pros:
They switch on automatically by night alltogther.
No action needed by the user !!
As many as desired can be placed without any noticeable impact on framerate.

Cons:
they don't illuminate the terrain nor any object
it appears there is a limited range within which emissive textures are displayed - apparently depending on the size of the emissive object. Unfortunately for a few 10 cm large object this range is relatively small...100 -200 m or similar. So still can't enjoy a whole city illuminated yet.

Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: illuminate outerra's villages by streetlamps..working !
« Reply #14 on: December 29, 2018, 06:03:51 am »

As streetlamps based on vehicle scripts -while looking very cool - have also some disadvantages (need to be switched on individually by the user, placing too many lamps in a small area kills the framerate) I decided that it might be worth to share some "emissive texture" based streetlamps that automatically switch on in the dark and do not have any noticeable effect on framerate.

Download the emissive texture based streetlamp from here:

https://www.dropbox.com/sh/4z8ceyr2fqfzk5s/AABTK5WAoNgsLUbgBg0gdsnUa?dl=0

As emissive lights actually do not illuminate the road it is best to place in a addition to emmissive
streetlamps also some "vehicle script based" streetlamps downloadable from above to illuminate the road at least in some places.
Also adding some emissive "runway lights" (download from my runway post) along streets can give nice effects.

In this way a lot of streetlamps can be placed still illuminating sufficiently the road for nice driving in the night.


Here is a demonstrative video







https://www.dropbox.com/preview/outerra%20my%20mods/emissive-streetlamps/screen_1546087329.jpg?role=personal

Instructions

Install by clicking on self-installing

"illumination-emissive.otx" file

To use it open scenery editor F7

under assets search for "illumination-emissive"

place where you like and adjust rotation and/or hight as needed.

Enjoy !

« Last Edit: December 29, 2018, 10:10:19 am by fly77 »
Logged
Pages: [1] 2