Animating textures/exporting from Blender

Tips and discussion about scenery creation for RailWorks.

Re: Animating textures/exporting from Blender

Unread postby dogrokket » Fri Mar 07, 2014 10:51 am

PapaXpress wrote:Dog, don't muddy the waters bu throwing in engine scripts. Scenary objects don't have controls.
Gotchya... au contraire, it does show how to write a simple script and plug it into the blueprint editor. I didn't know how to do that. Now I do.
Down another rabbit hole we go....
User avatar
dogrokket
 
Posts: 176
Joined: Wed May 08, 2013 2:18 pm

Script exports fine, yet no animation

Unread postby dogrokket » Thu Mar 20, 2014 1:37 pm

PapaX,
I reconfigured my igs file to match the script, where I have ten nodes, named Frame_0 through Frame_9(these are 10 textured planes, layered on top of each other). I even renamed the associated texture/ace files to match (I don't know if that matters). specifically, the nodes are named 1_1000_Frame_1_fx_night, etc... because I only want these nodes at night. There is also a day texture. When I export it and fire it up, the day texture looks great, but when I switch over to night time running, I only have the last frame (Frame_9) showing. No animation. I tinkered around with the time to show each frame, changing it from 10 SEC to 30 SEC to see what would happen, but nothing. It seems like the script isn't 'hooking in' to the igs file. I'm stuck.

I would greatly appreciate some insight, if anyone has the time.
Here's the script again, below:
Code: Select all
    -- set globals

    -- assumes the first frame is named Frame_0
    gNextFrame = 0;

    -- the maximum number of frames, remember we are 0 based
    --   so if there are ten frames then the last frame
    --   would be Frame_9
    MAX_FRAMES = 10;

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


    -- initialize, always needed
    function Initialise()
       SetFrame( 0 );
    end

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

    -- this is where all the heavy lifting is done
    function SetFrame( currTime )
       -- loop through each frame every three seconds
       --   if the current time is 0 then we are initializing the model
       if (math.mod(math.floor(currTime), INTERVAL_SEC) == 0 or currTime == 0) then
          local index = 0;
          while (index < MAX_FRAMES) do
             -- if the frame is equal to the index then turn it on
             if (index == gNextFrame) then
                Call( "*:ActivateNode", "Frame_" .. index,  1 );
             else -- turn the frame off
                Call( "*:ActivateNode", "Frame_" .. index,  0 );
             end   
             index = index + 1;
          end

          -- if we cycled through all the frames then reset to the first frame   
          if (gNextFrame < MAX_FRAMES) then
             gNextFrame = gNextFrame + 1;
          else
             gNextFrame = 0;
          end
       end
    end
Down another rabbit hole we go....
User avatar
dogrokket
 
Posts: 176
Joined: Wed May 08, 2013 2:18 pm

Re: Script exports fine, yet no animation

Unread postby mrennie » Thu Mar 20, 2014 2:28 pm

dogrokket wrote:PapaX,
I reconfigured my igs file to match the script, where I have ten nodes, named Frame_0 through Frame_9(these are 10 textured planes, layered on top of each other). I even renamed the associated texture/ace files to match (I don't know if that matters). specifically, the nodes are named 1_1000_Frame_1_fx_night, etc... because I only want these nodes at night. There is also a day texture. When I export it and fire it up, the day texture looks great, but when I switch over to night time running, I only have the last frame (Frame_9) showing. No animation. I tinkered around with the time to show each frame, changing it from 10 SEC to 30 SEC to see what would happen, but nothing. It seems like the script isn't 'hooking in' to the igs file. I'm stuck.

I would greatly appreciate some insight, if anyone has the time.
Here's the script again, below:
Code: Select all
    -- set globals

    -- assumes the first frame is named Frame_0
    gNextFrame = 0;

    -- the maximum number of frames, remember we are 0 based
    --   so if there are ten frames then the last frame
    --   would be Frame_9
    MAX_FRAMES = 10;

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


    -- initialize, always needed
    function Initialise()
       SetFrame( 0 );
    end

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

    -- this is where all the heavy lifting is done
    function SetFrame( currTime )
       -- loop through each frame every three seconds
       --   if the current time is 0 then we are initializing the model
       if (math.mod(math.floor(currTime), INTERVAL_SEC) == 0 or currTime == 0) then
          local index = 0;
          while (index < MAX_FRAMES) do
             -- if the frame is equal to the index then turn it on
             if (index == gNextFrame) then
                Call( "*:ActivateNode", "Frame_" .. index,  1 );
             else -- turn the frame off
                Call( "*:ActivateNode", "Frame_" .. index,  0 );
             end   
             index = index + 1;
          end

          -- if we cycled through all the frames then reset to the first frame   
          if (gNextFrame < MAX_FRAMES) then
             gNextFrame = gNextFrame + 1;
          else
             gNextFrame = 0;
          end
       end
    end


You said your nodes are called 1_1000_Frame_1_fx_night, etc., but in the script, it's activating nodes called Frame_1, etc. Shouldn't you be including the full node names in the script, so that the LUA interpreter knows that you mean the night nodes? You can have the day and night nodes activated at the same time, and the naming and time of day will then determine which one is actually displayed.
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Re: Animating textures/exporting from Blender

Unread postby PapaXpress » Thu Mar 20, 2014 2:41 pm

I am at work right now so I can't look up how I did my day and night nodes in the hierarchy. You should not need to use the suffix in the LUA. Like the LOD prefix it is a special moniker which the game engine reads and splits out.

I'll see if I can get you a better answer tonight.
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: Script exports fine, yet no animation

Unread postby dogrokket » Thu Mar 20, 2014 5:35 pm

mrennie wrote:You said your nodes are called 1_1000_Frame_1_fx_night, etc., but in the script, it's activating nodes called Frame_1, etc. Shouldn't you be including the full node names in the script, so that the LUA interpreter knows that you mean the night nodes? You can have the day and night nodes activated at the same time, and the naming and time of day will then determine which one is actually displayed.


Hi Mike,
Thanks for responding, this LUA thing is brand new to me, and I'm looking at these like a dog watching TV. There is only 1 day texture, and that's not animated, since the neon sign only lights up at night. I'm not sure that calling the nodes by their full name in the script would make it work, because I stripped down my blender file to nothing but the 10 'slides' with no _fx_night suffix, and it still didn't grab hold. Of course, each frame still had the 1_1000_ prefix, because the blender exporter would stick something on there anyway. Maybe I should dig out a traffic light script and look at it???
Down another rabbit hole we go....
User avatar
dogrokket
 
Posts: 176
Joined: Wed May 08, 2013 2:18 pm

Re: Script exports fine, yet no animation

Unread postby mrennie » Thu Mar 20, 2014 6:06 pm

dogrokket wrote:
Hi Mike,
Thanks for responding, this LUA thing is brand new to me, and I'm looking at these like a dog watching TV. There is only 1 day texture, and that's not animated, since the neon sign only lights up at night. I'm not sure that calling the nodes by their full name in the script would make it work, because I stripped down my blender file to nothing but the 10 'slides' with no _fx_night suffix, and it still didn't grab hold. Of course, each frame still had the 1_1000_ prefix, because the blender exporter would stick something on there anyway. Maybe I should dig out a traffic light script and look at it???



Something I noticed just now is that your SetFrame function is declared after it's used by Initialise and Update. I can't remember now if that matters, but I always put functions further up (nearer to the top of the file) than the first place where they're called (an old habit from writing code in Ada). You could try that and see if it makes a difference.
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Re: Animating textures/exporting from Blender

Unread postby PapaXpress » Thu Mar 20, 2014 6:43 pm

You are thinking of a C shortcut of writing the function above main() so you don't need to prototype them. In LUA this is not the case. What is nice (at least to me) is that if you decompile the out file you can see where the calls are being referenced.
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 Chacal » Thu Mar 20, 2014 10:25 pm

Can you decompile the out file without a debug compile?
So far I haven't been able to.
Over the hill and gathering speed
Chacal
Site Admin
 
Posts: 6477
Joined: Tue Jul 05, 2011 1:11 pm
Location: Quebec, Canada

Re: Animating textures/exporting from Blender

Unread postby PapaXpress » Thu Mar 20, 2014 10:53 pm

Yes, but its practically unreadable. Reminds me of assembly language.
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 PapaXpress » Thu Mar 20, 2014 11:58 pm

OK, so I might be wrong about the group (node) naming. I craked open a model I did for RCAP and saw this:

Code: Select all
   <TransformName>
      <e d:type="cDeltaString">ChannelizerDrum</e>
      <e d:type="cDeltaString">Reflectors_fx_night</e>
      <e d:type="cDeltaString">Drum</e>
      <e d:type="cDeltaString">Reflectors_fx_day</e>
      <e d:type="cDeltaString">Backs</e>
   </TransformName>


So lets change how we are concatinating the node name in our code:

Where we have this:
Call( "*:ActivateNode", "Frame_" .. index, 0 );

Lets try this:
Call( "*:ActivateNode", "Frame_" .. index .. "_fx_day", 0 );

and add one more line just under it:
Call( "*:ActivateNode", "Frame_" .. index .. "_fx_night", 0 );

Thus...
Code: Select all
    -- set globals

    -- assumes the first frame is named Frame_0
    gNextFrame = 0;

    -- the maximum number of frames, remember we are 0 based
    --   so if there are ten frames then the last frame
    --   would be Frame_9
    MAX_FRAMES = 10;

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


    -- initialize, always needed
    function Initialise()
       SetFrame( 0 );
    end

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

    -- this is where all the heavy lifting is done
    function SetFrame( currTime )
       -- loop through each frame every three seconds
       --   if the current time is 0 then we are initializing the model
       if (math.mod(math.floor(currTime), INTERVAL_SEC) == 0 or currTime == 0) then
          local index = 0;
          while (index < MAX_FRAMES) do
             -- if the frame is equal to the index then turn it on
             if (index == gNextFrame) then
                Call( "*:ActivateNode", "Frame_" .. index .. "_fx_day",  1 );
                Call( "*:ActivateNode", "Frame_" .. index .. "_fx_night",  1 );
             else -- turn the frame off
                Call( "*:ActivateNode", "Frame_" .. index .. "_fx_day",  0 );
                Call( "*:ActivateNode", "Frame_" .. index .. "_fx_night",  0 );
             end   
             index = index + 1;
          end

          -- if we cycled through all the frames then reset to the first frame   
          if (gNextFrame < MAX_FRAMES) then
             gNextFrame = gNextFrame + 1;
          else
             gNextFrame = 0;
          end
       end
    end
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 dogrokket » Fri Mar 21, 2014 1:48 pm

Thanks for the update Papa! I ran the updated script and still nada.... !*don-know!* Having a helmet fire here. This is a stab in the dark but could what you listed earlier be of any use in this script?
Code: Select all
       <TransformName>
          <e d:type="cDeltaString">ChannelizerDrum</e>
          <e d:type="cDeltaString">Reflectors_fx_night</e>
          <e d:type="cDeltaString">Drum</e>
          <e d:type="cDeltaString">Reflectors_fx_day</e>
          <e d:type="cDeltaString">Backs</e>
       </TransformName>

I'm guessing that a node is not the same thing as a variable or a function, but does the above somehow 'initialize' those nodes in a script? I am starting to grasp the 'heavy lifting' section of your script, where 'local' is active in that if/else/end section and you are sequencing the nodes by upping the index by 1, and when the index reaches 10, it starts over. I also see where you use Call( "*:ActivateNode", etc) should grab "Frame_" .. , but it's just not doing it for some reason. Below is a scr shot of the object panel in blender, just for clarity, to show how these nodes are named:
BL.jpg

These nodes are all child objects of the support object, but I don't know if that matters to the script.
You do not have the required permissions to view the files attached to this post.
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 » Fri Mar 21, 2014 2:15 pm

dogrokket wrote:Thanks for the update Papa! I ran the updated script and still nada.... !*don-know!* Having a helmet fire here. This is a stab in the dark but could what you listed earlier be of any use in this script?
Code: Select all
       <TransformName>
          <e d:type="cDeltaString">ChannelizerDrum</e>
          <e d:type="cDeltaString">Reflectors_fx_night</e>
          <e d:type="cDeltaString">Drum</e>
          <e d:type="cDeltaString">Reflectors_fx_day</e>
          <e d:type="cDeltaString">Backs</e>
       </TransformName>

I'm guessing that a node is not the same thing as a variable or a function, but does the above somehow 'initialize' those nodes in a script? I am starting to grasp the 'heavy lifting' section of your script, where 'local' is active in that if/else/end section and you are sequencing the nodes by upping the index by 1, and when the index reaches 10, it starts over. I also see where you use Call( "*:ActivateNode", etc) should grab "Frame_" .. , but it's just not doing it for some reason. Below is a scr shot of the object panel in blender, just for clarity, to show how these nodes are named:
BL.jpg

These nodes are all child objects of the support object, but I don't know if that matters to the script.


The name you put in the call to ActivateNode has to be exactly the same as the node name in the model, otherwise it has no way to know what node you mean. The concatenated name is still missing the "1_1000_" at the beginning.

So instead of

Call( "*:ActivateNode", "Frame_" .. index .. "_fx_night", 0 );

you should put

Call( "*:ActivateNode", "1_1000_Frame_" .. index .. "_fx_night", 0 );

and likewise for when the last parameter is a 1 instead of 0.
User avatar
mrennie
 
Posts: 3214
Joined: Wed May 30, 2012 12:22 pm

Re: Animating textures/exporting from Blender

Unread postby PapaXpress » Fri Mar 21, 2014 3:50 pm

Mike, I don't think that is correct. The LOD prefix will get stripped out on export. The snippet I showed from my model had LODs, and as you can tell they are not in the node name.

More...
Dog, can you open the GEO file with RWTools and see what the node names are listed as? It could be that Blender is setting them to something else on export.
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 dogrokket » Fri Mar 21, 2014 3:54 pm

PapaXpress wrote:Mike, I don't think that is correct. The LOD prefix will get stripped out on export. The snippet I showed from my model had LODs, and as you can tell they are not in the node name.

More...
Dog, can you open the GEO file with RWTools and see what the node names are listed as? It could be that Blender is setting them to something else on export.


Yes Mike, I tried what you suggested and no changes. Papa, great suggestion. I have to run out for a bit, but I will look into the GEO file and try that!

Thanks!!!
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 dogrokket » Fri Mar 21, 2014 5:13 pm

Here's what I got Papa:
Code: Select all
<TransformName>
      <e d:type="cDeltaString">Support</e>
      <e d:type="cDeltaString">Frame_0_fx_night</e>
      <e d:type="cDeltaString">Frame_1_fx_night</e>
      <e d:type="cDeltaString">Frame_2_fx_night</e>
      <e d:type="cDeltaString">Frame_3_fx_night</e>
      <e d:type="cDeltaString">Frame_4_fx_night</e>
      <e d:type="cDeltaString">Frame_5_fx_night</e>
      <e d:type="cDeltaString">Frame_6_fx_night</e>
      <e d:type="cDeltaString">Frame_7_fx_night</e>
      <e d:type="cDeltaString">Frame_8_fx_night</e>
      <e d:type="cDeltaString">Frame_9_fx_night</e>
      <e d:type="cDeltaString">SignFront_fx_day</e>
   </TransformName>

Is that what you're talking about, or am I looking for something more code-like, like an <cHcSGNodeLODSelector d:id="32159824">?
BTW, SignFront_fx_day is not part of the animation.
Down another rabbit hole we go....
User avatar
dogrokket
 
Posts: 176
Joined: Wed May 08, 2013 2:18 pm

PreviousNext

Return to Scenery Design

Who is online

Users browsing this forum: No registered users and 1 guest