Jump to content
Sign in to follow this  
Guest reddwarf

Making a DLL (switching of textures) - LaurentC?

Recommended Posts

Guest reddwarf

Hi everybody,I have an idea for a DLL that might be kind of cool, but I'm pretty new to the DLL consept of Fly!2. I have studied all available source-code for DLL, but have not found anything similar with what I'm trying to do.Basically, I have a model (not an aircraft) that I want to change texture of (based on some input), and was wondering how that might be accomplished. To me it seems like this is kind of a similar problem solved by LaurentC with his multiple aircraft night-lighting system.So Laurent, or anybody else, if you could either drop me a private message or post your comments to my problem here, I would appreciate it.Cheers,Geir StrandStavanger, Norway

Share this post


Link to post
Share on other sites
Guest danieletona

And the possibility to add lights:for the lighthouses, for the high tension, etc.Dan

Share this post


Link to post
Share on other sites
Guest laurentC

Hi all,Well ... it seems to be something like I have done with night textures, except that I used specifically a SDK API for "night textures" ... but the same can be done with "normal textures".I suppose the input is not "distance" because it would be too easy, eh, eh !You should notice anyway that the model manegement is somehow bugged : always a model need to be mounted and you can't simply stop rendering a version (norm, simple etc) ... or you need a decoy model (a point or a transparent sheet).You should use : ===================================================================in a DLLPrepare callbackAPIGetNamedModel (for a easier model management)APILoadModel (to actually load the model and all the different versions of it)===================================================================Then in the DLLTimeSlice callback put your input management and swap between models according your input with theAPISelectModel===================================================================I haven't found a way to get lights except for aircraft models, desolate ! If someone got it ...Cheers,laurentC

Share this post


Link to post
Share on other sites
Guest reddwarf

Hi LaurentC,Acutally, yes, the input is distance (and something else also). What I'm trying to accomplish is to create a model that may be placed in the scenery by using the scenery editor. I then need to have a DLL that will change the textures on that model depending on distance to user aircraft and other info.If I understand you correctly, I need to make one model for each texture I have. Is this correct? I then dynamically need to create files in the data directory that contains information about the other objects (like in your smoke example). When everything is finished, I need to destroy all objects (but do I remove the files?).BTW, What does the APIGetNamedModel call do? It's not documented anywhere in the sdk documentation, mind you that is actually from Fly!, but still ....Could you either give us a small example on how you use the APIGetNamedModel and APILoadModel/SelectModel?In advance thanks,Geir

Share this post


Link to post
Share on other sites
Guest laurentC

Hi Geir,Well, if you want to change texture according to distance or pixel rendering you can take advantage of the self built parameters :From a Richard post ....normxxx.SMFNotice the 'norm' tag ? This model is being setup as the normal model for the object. But tag is only one variety that can be used. There are others :modelTag(4char)modelNamepixelHeight (in Y pixels)You would use in place of . With this variety you establish a Y height of when this model should be swapped to.This test takes place in screen space. So if you set 100' as the pixel height, this model would be swapped to once it occupies 100 pixels of screen space.You would have multiple entries that would swap based on the pixel height to give LOD.This method works well particularly for very large objects like bridges ......modelTagmodelNameminDistmaxDistWith this variety you're setting a min/max distance that this model should be used for (from the camera eye). You can establish multiple models using multiple tags, each giving a different distance range...This version works well with buildings or structures that occupy a fairly small space ......End Richard Post.Now :I've made a dll for customized windsockets (simvol site) ... you should find some idea from the code attached to this post (VC6).Excuse me for the junk parts ... I'm not a neat code writer ![NB : If you ever use this code in your dll, I just ask you to post also the whole code in order to give it to the community ; thanks]Last : SFlyObjectRef flyObject;// We take a scenery object ...APIGetNamedObject(scene_model_name, &flyObject);// We load a 'simp' model and we attach it to our scene_modelAPILOadModel(&flyObject, model_filename, 'simp');//Then callingAPISelectModel(&flyObject, 'norm')orAPISelectModel(&flyObject, 'simp')We can toggle between each model.Cheers,laurent

Share this post


Link to post
Share on other sites
Guest reddwarf

Hi again Laurent,And thanks for your code. I've studied it intensively, but I might be a little bit dump so excuse me for asking more silly questions.First of all, I think the APIGetNamedObject, APILoadModel and APISelectModel might be the right route for me, but your code didn't use that at all, so I'm still uncertain about the APIGetNamedObject. Do you have some more documentation about this that I might get my hands on?Basically what I want to do is to make a docking system. The few airports here in Norway that has bridges also has docking system, telling the pilot when to stop. What my DLL will do is basically check if a docking model has been placed, and then check distance between this and the aircraft. If it's closer than a certain distance, then I would like to change the texture/model based on distance (and direction). It will also be different for different aircrafts (shouldn't be a problem if I'm able to do the rest).I could extend the idea so that I read additional tags to be able to customize distance and other stuff, but right now I'm struggling with the model concept. If I understand you correctly, I will be able (with APILoadModel) to load multiple models with different IDs, and then switch between them using the APISelectModel?Any additional help would be appreciated. In advance thanks, // Geir Strand // Stavanger, Norway // //

Share this post


Link to post
Share on other sites
Guest laurentC

Hi Geir,What I was thinkig of was to place a docking system (like a windsocket) in a point through a scenery file (as I did with windsockets) then change the model (and thus the texture) according to the distance from the user aircraft (I used many windsocket models to simulate the movement but only one pole : the changes were related to wind strenght and its direction but you can relate that to any value, doesn't it ?)Now, using the very same code you can replace windsocket by docking system and go through the models with different textures, testing distance in place of wind direction.Unfortunally I haven't any documentation other than the one I gave you about the GetNamedObject ... but it works as I described ... I used it with the towed gliders to have handlers.Cheers,laurent

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...