Board index FlightGear Development Effects and shaders

Dynamic replacing texture on object

An exciting "new" option in FlightGear, that includes reflections, lightmaps, the particle system etc.. A lot is yet to be discovered/implemented!

Dynamic replacing texture on object

Postby kuifje09 » Thu Oct 27, 2011 1:29 pm

I am looking for a way to exchange a texture on an object. Found some articles but no one gave me the right answer.
One looked promising about changing a sound dynamicly but I lost the address and can't find it nomore.
In this article I found an example, but that does not do the job?
[url]
http://www.gnu-darwin.org/www001/src/po ... l#material
[/url]

My code :
[EDIT] Code removed because it was too ugly [/EDIT]

So, anytime I push a button, MidMain is altered to another value, or just from 1 _ 2 _ 1 _ and so on. When I change the map.png and then change the value MidMain to 2, this altered map should be shown/reloaded.

But the value of MidMain can change to anything but no change in texture.
The png loaded by default from the model.ac file will stay on top. Changes are not seen or not triggerd by this code.
What do I wrong ?
[edit] In other words, I want a variable texture on an object, how would I do that [/edit]
Last edited by kuifje09 on Thu Oct 27, 2011 2:56 pm, edited 1 time in total.
kuifje09
 
Posts: 596
Joined: Tue May 17, 2011 9:51 pm

Re: Dynamic replacing texture on object

Postby Gijs » Thu Oct 27, 2011 1:48 pm

Code: Select all
  <texture-prop>Aircraft/.../Mid/map.png</texture-prop>

This isn't a property, so it should be <texture> instead...

Code: Select all
   <model>
      <name>Panels6</name>
      ...
      <map2>
       <texture>Aircraft/.../Mid/map.png</texture>
      </map2>
   </model>

What is this supposed to do?
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9549
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Dynamic replacing texture on object

Postby kuifje09 » Thu Oct 27, 2011 2:32 pm

Maybe I don't have the concept clear in mind, but..
I can change the value of a property by pushing a button, thats simple.
So I change the value of a string representing the name of a texture, it is changed in the property tree.
But the animation bound to that property does not load that file, but holds on to the first loaded.

So it all about :
Code: Select all
<animation>
  <type>material</type>
  <object-name>HalfMap2</object-name>
  <texture-prop>sim/model/map2/texture</texture-prop>
</animation>


And the name of the texture, which is a filename, is set somewhere else. But it does not listen to my command.
kuifje09
 
Posts: 596
Joined: Tue May 17, 2011 9:51 pm

Re: Dynamic replacing texture on object

Postby Gijs » Thu Oct 27, 2011 2:36 pm

Right, that's a different piece of code than you showed up there ^ ;)

Did you try:
Code: Select all
<animation>
  <type>material</type>
  <object-name>HalfMap2</object-name>
  <property-base>sim/model/map2</property-base>
  <texture-prop>texture</texture-prop>
</animation>

And check the console for any errors (so you're sure you goth the paths right).
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9549
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Dynamic replacing texture on object

Postby kuifje09 » Thu Oct 27, 2011 2:46 pm

Ah, thats funny, now I have an ugly "double" path in the property tree.

sim/model/map2/sim/model/map2 and the property itself is ""(none)


And the first piece of code was complete wrong, I did not understand what happened in the example...
Indeed it should be just about changing a property in the property tree....


Edit :

code changed to :
Code: Select all
<animation>
  <type>material</type>
  <object-name>HalfMap2</object-name>
<property-base>sim/model/map2</property-base>
  <texture-prop>texture</texture-prop>
</animation>


Property is corect changed in the tree now, but the animation does not work.
To be a little more precise: I change the name of the texture in the tree but the animation is not triggered and the image on the object is not replaced/changed.
kuifje09
 
Posts: 596
Joined: Tue May 17, 2011 9:51 pm

Re: Dynamic replacing texture on object

Postby kuifje09 » Sat Oct 29, 2011 2:38 pm

Has no-one any further hints ? I realy cant get it to work.

I tried also the texture replacement code from :
http://wiki.flightgear.org/Howto:_Illuminate_faces#Changing_texture_if_illuminated

Nothing works but I am shure it sould be possible. I just dont see my fault.

This is the last thing I tried:
Code: Select all
<animation>
  <type>material</type>
  <object-name>HalfMap2</object-name>
  <texture>sim/model/map2/texture</texture>
</animation>


HalfMap2 is a square piece object with a moving map on it, the map should be replaced sometimes.
sim/model/map2/texture does contain the map(name) to be displayed as texture on the HalfMap2 object.
kuifje09
 
Posts: 596
Joined: Tue May 17, 2011 9:51 pm

Re: Dynamic replacing texture on object

Postby kuifje09 » Wed Nov 02, 2011 10:19 pm

Oops, 4786 enthousiasts and no answer?

Please, you could help me so much with that.
kuifje09
 
Posts: 596
Joined: Tue May 17, 2011 9:51 pm


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 2 guests