Animating textures/exporting from Blender

Tips and discussion about scenery creation for RailWorks.

Re: Animating textures/exporting from Blender

Unread postby PapaXpress » Sun Mar 30, 2014 2:20 am

The seasonal textures have nothing to do with node names. In fact the texture file you use with the model should not know about them (ie use no suffix). It is a mechanism handled purely within the game engine.

I am still thinking about the day/night problem. One idea I had was to place the night time nodes without the _fx_night under a parent node which did use _fx_night.

Kinda like:

Code: Select all
- 1_1000_ParentNight_fx_night
  |
  - Frame_1
  |
  - Frame_2
  |
  - etc...
Image
"Just post some random unrelated text. We have members here who can help you with that." ~ Chacal
"When all else fails, read the instructions... if that doesn't work either, try following them." ~ Old Prof
Image
The Grade Crossing - Atlanta North Project - Virtual Rail Creations
User avatar
PapaXpress
 
Posts: 5147
Joined: Sat Oct 23, 2010 10:30 pm
Location: that "other" timezone

Re: Animating textures/exporting from Blender

Unread postby mrennie » Sun Mar 30, 2014 6:01 am

Dan, I don't really follow why you want to use the seasonal textures to change the time at which the day and night textured nodes show up ... I must be missing something. What dogrokket described about adjusting the time span in the script, after using the syscall to find out the current season (and then hardcoding into the script the corresponding times for dawn and dusk) is exactly what I meant when I mentioned the syscall. To me it seems easier to use the script, that way you don't have to add extra texture files.

By the way, I don't think it matters much if the nightime mode is on for a few hours after dawn - in real life I often see street lights still lit when it's daytime (the software, or maybe it's hardware/firmware) controlling the lights must get it wrong too. It's probably not even worth bothering about the seasons.
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Re: Animating textures/exporting from Blender

Unread postby PapaXpress » Sun Mar 30, 2014 2:53 pm

Since Dog was getting into seasons I wanted to introduce him to a new element of modeling available to him. I understand that it does not effect the day/night nodes.
Image
"Just post some random unrelated text. We have members here who can help you with that." ~ Chacal
"When all else fails, read the instructions... if that doesn't work either, try following them." ~ Old Prof
Image
The Grade Crossing - Atlanta North Project - Virtual Rail Creations
User avatar
PapaXpress
 
Posts: 5147
Joined: Sat Oct 23, 2010 10:30 pm
Location: that "other" timezone

Re: Animating textures/exporting from Blender

Unread postby mrennie » Sun Mar 30, 2014 4:34 pm

PapaXpress wrote:Since Dog was getting into seasons I wanted to introduce him to a new element of modeling available to him. I understand that it does not effect the day/night nodes.


Ah, my bad

!!**sorry**!!
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Re: Animating textures/exporting from Blender

Unread postby PapaXpress » Sun Mar 30, 2014 9:10 pm

No problem. Its good that you are keeping me in check. This lack of sleep is doing all sorts of nuttyness to my head.
Image
"Just post some random unrelated text. We have members here who can help you with that." ~ Chacal
"When all else fails, read the instructions... if that doesn't work either, try following them." ~ Old Prof
Image
The Grade Crossing - Atlanta North Project - Virtual Rail Creations
User avatar
PapaXpress
 
Posts: 5147
Joined: Sat Oct 23, 2010 10:30 pm
Location: that "other" timezone

Re: Animating textures/exporting from Blender

Unread postby mrennie » Sun Mar 30, 2014 9:42 pm

PapaXpress wrote:No problem. Its good that you are keeping me in check. This lack of sleep is doing all sorts of nuttyness to my head.


Hehe, tell me about it ... it's coming up to 5am here and I'm still awake *!lol!* .
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Re: Animating textures/exporting from Blender

Unread postby dogrokket » Tue Apr 01, 2014 11:47 pm

Here's what the dog has brought home~ Season times are figured out, but the season syscall seems to default to winter, no matter what the season is set to in the scenario !**conf**!
Code: Select all
           --Script storage area (above dashed line):--
           
          -- local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")-- from Mrennie
           --add test andis on wed 3/26
        --       -- start of temporary testing code
        --if SecondsAfterMidnight == nil then
        --Call( "*:ActivateNode", "Node_2_fx_night", 1 );
        --else
        ---- end of temporary testing code
        --           if SecondsAfterMidnight >= 3600 * 5.5 and SecondsAfterMidnight < 3600 * 21 then   
        --              gNextTime = 3600 * 21         -- do something again at 9 p.m.
        --           end
        ---- start of temporary testing code
        --end
        ---- end of temporary testing code

        --- replace this:           local currTime = Call("*:GetSimulationTime", 0);
        --- with this:          local currTime = SysCall ("ScenarioManager:GetTimeOfDay")
        ---------------------------------------------------------------------------------------------------------------------------------------------------------------------   
            -- set globals

            -- assumes the first frame is named Node_0
            --   however it appears we need to work backwards??
            gNextNode = 9;

            -- the maximum number of nodes, remember we are 0 based
            --   so if there are ten nodes then the last node
            --   would be Node_9
            MAX_NODES = 10;

            -- number of seconds to wait till showing the next frame
            INTERVAL_SEC = 2;

            -- use this to determine if the interval has passed
            gNextTime = 0.0;

            -- initialize, always needed
            function Initialise()
                  Call( "BeginUpdate" )

            local Season = SysCall ("ScenarioManager:GetSeason") -- defining the variables morning and evening by what season is
                  if Season ==  0 then      -- Spring = 0
                     morning = 8.25
                     evening = 19
                  elseif Season == 1 then   -- summer = 1
                     morning = 5.5
                     evening = 21
                  elseif Season == 2 then   -- autumn/fall = 2
                     morning = 6.75
                     evening = 19.75
                  else               -- winter = 3
                     morning = 9.25
                     evening = 17
             
              end
             
              earlystopping = 5.5      -- hack to stop a bit before the daytime version appears
             
              local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")
                    if SecondsAfterMidnight >= 3600 * morning - earlystopping and SecondsAfterMidnight < 3600 * evening then --meaning daytime
                       gNextTime = 3600 * evening         -- do something again at night.
                    end
            end

            -- update, always needed
            function Update( time )   
               SetNode( );
            end

            -- this is where all the heavy lifting is done
            function SetNode()
              -- first get the time, then find out if the interval has passed (test for 0)
              -- local currTime = Call("*:GetSimulationTime", 0);swapped out for below code
              local currTime = SysCall ("ScenarioManager:GetTimeOfDay")
               
              -- there is a trick here because this function is called several times
              --   per second, not on the second, so we need to build a semaphore to
              --   guard it from cycling though all the frames within the span of
              --   one second
              if (currTime > gNextTime) then
                local index = 0;       
                   
                while (index < MAX_NODES) do     
                  -- if the frame is equal to the index then turn it on
                  if (index == gNextNode) then
                    Call( "*:ActivateNode", "Node_" .. index .. "_fx_night",  1 );
                  else -- turn the frame off
                    Call( "*:ActivateNode", "Node_" .. index .. "_fx_night",  0 );
                  end
                  index = index + 1;   
                end
               

                --set the semaphore
                gNextTime = currTime + INTERVAL_SEC;
                -- if we cycled through all the frames then reset to the first frame
                --  remember that we seem to need to flip through the frames backwards
                if (gNextNode ~= 0) then
                   gNextNode = gNextNode - 1;
                else
                  -- ADDED from AndiS
                  -- here we know we are at gNextNode 0, and we consider stopping
                   local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")
                                 if SecondsAfterMidnight >= 3600 * morning - earlystopping and SecondsAfterMidnight < 3600 * evening then -- changed 12? to evening   
                   -- turn it off at 0530 a.m. or whatever the season commands
                         gNextTime = 3600 * evening         -- do something again at 9 p.m. or so (see what happens)(doesn't work if removed)
                   --ADD to turn off
                --  Call( "*:ActivateNode", "Node_1_fx_night", 0 );  (not needed)
                    Call( "*:ActivateNode", "Node_0_fx_night", 0 );
                   
                   end
                 
                   
                   gNextNode = MAX_NODES - 1;
                end
               
               
                -- set the semaphore (was originally here; moved up AndiS)
                -- gNextTime = currTime + INTERVAL_SEC;
               end
           
               
            end

What do the code miesters say???
Down another rabbit hole we go....
User avatar
dogrokket
 
Posts: 176
Joined: Wed May 08, 2013 2:18 pm

Re: Animating textures/exporting from Blender

Unread postby mrennie » Wed Apr 02, 2014 9:24 am

dogrokket wrote:Here's what the dog has brought home~ Season times are figured out, but the season syscall seems to default to winter, no matter what the season is set to in the scenario !**conf**!
Code: Select all
           --Script storage area (above dashed line):--
           
          -- local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")-- from Mrennie
           --add test andis on wed 3/26
        --       -- start of temporary testing code
        --if SecondsAfterMidnight == nil then
        --Call( "*:ActivateNode", "Node_2_fx_night", 1 );
        --else
        ---- end of temporary testing code
        --           if SecondsAfterMidnight >= 3600 * 5.5 and SecondsAfterMidnight < 3600 * 21 then   
        --              gNextTime = 3600 * 21         -- do something again at 9 p.m.
        --           end
        ---- start of temporary testing code
        --end
        ---- end of temporary testing code

        --- replace this:           local currTime = Call("*:GetSimulationTime", 0);
        --- with this:          local currTime = SysCall ("ScenarioManager:GetTimeOfDay")
        ---------------------------------------------------------------------------------------------------------------------------------------------------------------------   
            -- set globals

            -- assumes the first frame is named Node_0
            --   however it appears we need to work backwards??
            gNextNode = 9;

            -- the maximum number of nodes, remember we are 0 based
            --   so if there are ten nodes then the last node
            --   would be Node_9
            MAX_NODES = 10;

            -- number of seconds to wait till showing the next frame
            INTERVAL_SEC = 2;

            -- use this to determine if the interval has passed
            gNextTime = 0.0;

            -- initialize, always needed
            function Initialise()
                  Call( "BeginUpdate" )

            local Season = SysCall ("ScenarioManager:GetSeason") -- defining the variables morning and evening by what season is
                  if Season ==  0 then      -- Spring = 0
                     morning = 8.25
                     evening = 19
                  elseif Season == 1 then   -- summer = 1
                     morning = 5.5
                     evening = 21
                  elseif Season == 2 then   -- autumn/fall = 2
                     morning = 6.75
                     evening = 19.75
                  else               -- winter = 3
                     morning = 9.25
                     evening = 17
             
              end
             
              earlystopping = 5.5      -- hack to stop a bit before the daytime version appears
             
              local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")
                    if SecondsAfterMidnight >= 3600 * morning - earlystopping and SecondsAfterMidnight < 3600 * evening then --meaning daytime
                       gNextTime = 3600 * evening         -- do something again at night.
                    end
            end

            -- update, always needed
            function Update( time )   
               SetNode( );
            end

            -- this is where all the heavy lifting is done
            function SetNode()
              -- first get the time, then find out if the interval has passed (test for 0)
              -- local currTime = Call("*:GetSimulationTime", 0);swapped out for below code
              local currTime = SysCall ("ScenarioManager:GetTimeOfDay")
               
              -- there is a trick here because this function is called several times
              --   per second, not on the second, so we need to build a semaphore to
              --   guard it from cycling though all the frames within the span of
              --   one second
              if (currTime > gNextTime) then
                local index = 0;       
                   
                while (index < MAX_NODES) do     
                  -- if the frame is equal to the index then turn it on
                  if (index == gNextNode) then
                    Call( "*:ActivateNode", "Node_" .. index .. "_fx_night",  1 );
                  else -- turn the frame off
                    Call( "*:ActivateNode", "Node_" .. index .. "_fx_night",  0 );
                  end
                  index = index + 1;   
                end
               

                --set the semaphore
                gNextTime = currTime + INTERVAL_SEC;
                -- if we cycled through all the frames then reset to the first frame
                --  remember that we seem to need to flip through the frames backwards
                if (gNextNode ~= 0) then
                   gNextNode = gNextNode - 1;
                else
                  -- ADDED from AndiS
                  -- here we know we are at gNextNode 0, and we consider stopping
                   local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")
                                 if SecondsAfterMidnight >= 3600 * morning - earlystopping and SecondsAfterMidnight < 3600 * evening then -- changed 12? to evening   
                   -- turn it off at 0530 a.m. or whatever the season commands
                         gNextTime = 3600 * evening         -- do something again at 9 p.m. or so (see what happens)(doesn't work if removed)
                   --ADD to turn off
                --  Call( "*:ActivateNode", "Node_1_fx_night", 0 );  (not needed)
                    Call( "*:ActivateNode", "Node_0_fx_night", 0 );
                   
                   end
                 
                   
                   gNextNode = MAX_NODES - 1;
                end
               
               
                -- set the semaphore (was originally here; moved up AndiS)
                -- gNextTime = currTime + INTERVAL_SEC;
               end
           
               
            end

What do the code miesters say???


I need to use the season myself (to initialise the track conditions for the FEF-3), so I'll try it out later, with the debugger, and see what I can come up with.
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Re: Animating textures/exporting from Blender

Unread postby dogrokket » Wed Apr 02, 2014 10:40 am

mrennie wrote:
dogrokket wrote:Here's what the dog has brought home~ Season times are figured out, but the season syscall seems to default to winter, no matter what the season is set to in the scenario !**conf**!

What do the code miesters say???


I need to use the season myself (to initialise the track conditions for the FEF-3), so I'll try it out later, with the debugger, and see what I can come up with.


It's fixed Mike! !*brav*! We had to use a boolean flag to get the script to update after initial load. Apparently, the game did not know what season it was in the scenario, before it started running the script. (That's probably not a completely accurate description, but here is the final code below:
Code: Select all
            --  This script will run a series of nodes as an animation.  It is designed to conform to the standard Time of Day Blue Print;
                      --stopping and starting the cycling of the nodes to
                      --  conform with seasonal changes of day and night. Thanks to AndiS, PapaXpress and mrennie for their input!

            ---------------------------------------------------------------------------------------------------------------------------------------------------------------------   
                -- set globals

                -- assumes the first frame is named Node_0
                --   however it appears we need to work backwards??
                gNextNode = 9;

                -- the maximum number of nodes, remember we are 0 based
                --   so if there are ten nodes then the last node
                --   would be Node_9
                MAX_NODES = 10;

                -- number of seconds to wait till showing the next frame
                INTERVAL_SEC = 2;

                -- use this to determine if the interval has passed
                gNextTime = 0.0;

                -- initialize, always needed
                function Initialise()
                      Call( "BeginUpdate" )
                      firstUpdate = true -- added to delay update (bolean flag)
                end

                -- update, always needed
                function Update( time )   
                   if firstUpdate then
                      firstUpdate = false
                      local Season = SysCall ("ScenarioManager:GetSeason") -- defining the variables morning and evening by what season is
                      if Season ==  0 then      -- Spring = 0
                         morning = 8.25
                         evening = 18.75
                      elseif Season == 1 then   -- summer = 1
                         morning = 5.5
                         evening = 21
                      elseif Season == 2 then   -- autumn/fall = 2
                         morning = 6.75
                         evening = 19.75
                      else               -- winter = 3
                         morning = 9.25
                         evening = 17
                        end
                 
                    earlystopping = 5.5      -- hack to stop a bit before the daytime version appears
                   
                    local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")
                     if SecondsAfterMidnight >= 3600 * morning - earlystopping and SecondsAfterMidnight < 3600 * evening then --meaning daytime
                        gNextTime = 3600 * evening         -- do something again at night.
                     end
                 end
                 SetNode( );
                end

                -- this is where all the heavy lifting is done
                function SetNode()
                  -- first get the time, then find out if the interval has passed (test for 0)
                  -- local currTime = Call("*:GetSimulationTime", 0);swapped out for below code
                  local currTime = SysCall ("ScenarioManager:GetTimeOfDay")
                   
                  -- there is a trick here because this function is called several times
                  --   per second, not on the second, so we need to build a semaphore to
                  --   guard it from cycling though all the frames within the span of
                  --   one second
                  if (currTime > gNextTime) then
                    local index = 0;       
                       
                    while (index < MAX_NODES) do     
                      -- if the frame is equal to the index then turn it on
                      if (index == gNextNode) then
                        Call( "*:ActivateNode", "Node_" .. index .. "_fx_night",  1 );
                      else -- turn the frame off
                        Call( "*:ActivateNode", "Node_" .. index .. "_fx_night",  0 );
                      end
                      index = index + 1;   
                    end
                   

                    --set the semaphore
                    gNextTime = currTime + INTERVAL_SEC;
                    -- if we cycled through all the frames then reset to the first frame
                    --  remember that we seem to need to flip through the frames backwards
                    if (gNextNode ~= 0) then
                       gNextNode = gNextNode - 1;
                    else
                     
                      -- here we know we are at gNextNode 0, and we consider stopping
                       local SecondsAfterMidnight= SysCall ("ScenarioManager:GetTimeOfDay")
                                     if SecondsAfterMidnight >= 3600 * morning - earlystopping and SecondsAfterMidnight < 3600 * evening then -- changed 12? to evening   
                       -- turn it off at 0530 a.m. or whatever the season commands
                             gNextTime = 3600 * evening         -- do something again at 9 p.m. or so (see what happens)(doesn't work if removed)
                       --ADD to turn off
                    --  Call( "*:ActivateNode", "Node_1_fx_night", 0 );  (not needed)
                        Call( "*:ActivateNode", "Node_0_fx_night", 0 );
                       
                       end
                     
                       
                       gNextNode = MAX_NODES - 1;
                    end
                   
                   
                   
                   end
               
                   
                end

Well done gents! kudos to Mike, Papa and AndiS for your input. I would not have been able to navigate through this maze without your help. !*salute*!
Down another rabbit hole we go....
User avatar
dogrokket
 
Posts: 176
Joined: Wed May 08, 2013 2:18 pm

Re: Animating textures/exporting from Blender

Unread postby mrennie » Wed Apr 02, 2014 10:45 am

dogrokket wrote:We had to use a boolean flag to get the script to update after initial load. Apparently, the game did not know what season it was in the scenario, before it started running the script.


I was just about to say that *!lol!* The Initialise script gets called along with lots of other initialisations, before the scenario starts to run, so I often find that I have to do certain things in the first call to Update rather than in the Initialise function.

Anyway, glad you got it working !!*ok*!!
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Previous

Return to Scenery Design

Who is online

Users browsing this forum: PetalBot and 5 guests

cron