Jump to content
The Dark Mod Forums

mohij

Member
  • Posts

    244
  • Joined

  • Last visited

Posts posted by mohij

  1. Not all the time, since the key is different sometimes (I think).

    Different problem: it is not allowed to include from the plugins dir, right?

    But when modifying getBinding to accept MapExpressions I need to modify the base class IGLTextureManager too. But to do that I would need to include the .h file from the plugins dir.

     

    Edit: btw. getBinding has 3 different ways to be called on my local copy:

    TexturePtr getBinding(MapExpressionPtr mapExp, const std::string& textureKey = NULL);
    TexturePtr getBinding(const std::string& filename);

  2. Small status report.

    Yesterday evening and this evening I spent on fixing compiler errors...

    atm I'm stuck on GLTexturemanager.cpp. I changed getBinding() to accept an Image& instead of a TextureConstructor. Problem is that empty Images need to be possible. And I didn't consider that non existant MapExpressions can't produce Images (not even empty ones ;-). So I guess I will have to rewrite the getBinding() to accept a MapExpression instead of an Image. Hopefully it will work afterwards.

  3. If I understand right, the textures need to be identified with a definite string. I have no idea what string should be used to identify a MapExpression, since a MapExpression can be build up of more than one token. Any ideas?

     

    Edit: an idea I had is that every map expression also has a function

    std::string getName();

    which constructs it's name from the previous ones and adds it's own part to it. No idea if that would be ok.

  4. greebo: I didn't try to compile it when I posted the links, but since then I'm on fixing compile errors, got quite a lot. Now it compiles. And I also changed some typedefs. About the p in

    return shared_ptr<IMapExpression> p(new MakeAlphaExpression (token));

    the boost documentation says it's saver.

     

    OrbWeaver: so I'll try to change The ShaderTemplate.

     

    edit: I uploaded the new versions

    MapExpression.cpp

    MapExpression.h

  5. class IMapExpression {
    	   Image result; /* will hold the image on first call of getImage(), further calls to getImage will simply return result */
       public:
    	   static boost::shared_ptr<IMapExpression> createForToken(parser::DefTokeniser& token);
    	   virtual Image& getImage() = 0;
       };

     

    Last question: Is this interface fine now (before I start to change everything to work with this one)?

  6. Bypassing the TextureConstructor class would mean returning directly an image object?

     

    Just out of curiosity, would I have had to implement my own version of the textureConstructor class? I only found two implementations that both load from filename.

     

    Is the TextureConstructor class still needed when MapExpressions directly produce image classes?

     

    When the TextureConstructor is only needed for the MapExpressions (that's what it looks like atm), then I would probably remove it.

  7. So here is my current progress:

    MapExpressionnew.cpp

    MapExpressionnew.h

     

    I just looked at the surrounding files and I think I will have to change some other files too to make them work with the new interface, right? Then this should be done first, so I can test the code I write.

     

     

    Should the processed images be saved at all (or just created every time the Shadersystem requests one) and if yes, where?

    In the Constructor: all MapExpressions would be evaluated, independent of their usage

    getImage could also be defined in the base class

    in getImage: either the MapExpression is recreated everytime it is asked for, or saved (either in the class or pushed to the texture manager)

     

    I think in getImage would be better. Different from the files above, I think it would be better to save the results instead of the arguments.

    Edit: I changed MapExpressionnew.h to reflect this.

  8. Well, what I have since now is:

     

    Base class:

     class IMapExpression {
       public:
    	   static boost::shared_ptr<IMapExpression> createForToken(parser::DefTokeniser& tok);
    	   virtual TextureConstructor& getImage() = 0;
       };

     

    specific Map Expressions then look this way:

    class HeightMapExpression : IMapExpression {
    	   shared_ptr<IMapExpression> argOne;
    	   float argTwo;
       public:
    	   HeightMapExpression (parser::DefTokeniser& tok);
    	   TextureConstructor& getImage();
       };

     

    implementation for createForToken:

    boost::shared_ptr<IMapExpression> IMapExpression::createForToken(parser::DefTokeniser& tok) {
    
    	 // Switch on the first keyword, to determine what kind of expression this
    	 // is.
    	 std::string token = boost::algorithm::to_lower_copy(token.nextToken());
    
    	 if (token == "heightmap") {
    		 return shared_ptr<IMapExpression> p(new HeightMapExpression (tok));
    	 }
    	 else if (token == "addnormals") {
    		 return shared_ptr<IMapExpression> p(new AddNormalsExpression (tok));
    	 } ...

     

    I'm not entirely sure where the images should be saved, inside the structures? Also not sure when they should be processed. Either when creating the class or when getImage is called. So, comments please :rolleyes:

×
×
  • Create New...