Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Lightmap DLL  (Read 11365 times)

0 Members and 1 Guest are viewing this topic.

falcomus

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 9
    • View Profile
Lightmap DLL
« on: October 27, 2012, 10:10:32 PM »


Demo Screen:

http://www.youtube.com/watch?v=3Pgd-T_Cdyo&feature=youtu.be


_____________________________________________________________________________________________________________________________________
- Create a empty bmp, same size like your scene bmp.
- Fill it completely with color "white"
- The areas, where the actor stands in the shadow, you can paint on your lightmap in a darker gray
- If the actor for example stands in front of a fire-place, you can paint this area in the lightmap red (Easiest way to use 2 layers, Photoshop, .NET Paint etc.)
_____________________________________________________________________________________________________________________________________


Embed the dll and call the function "GetRGB" in Game_loop.script.

Example:


external "C:\LMDLL.dll" int GetRGB(string fName, int x, int y, int buflen, string buf);




// infinite loop of game_loop.script
while(true)
{

   //Don't call func every pixel movement

   if ( (actor.X % 5 == 0) || (actor.Y % 5 == 0) )
   {

      //Call the dll function and receive the lightmap-color values (RGB) at actors coordinates
 
     GetRGB ("C:\LM.bmp", actor.X,actor.Y, str.Capacity,str);

      //Split the result value in an array (RGB-values, I did not know how to send the 3 int values back from DLL, so I used a string)

      arr = str.Split(";");

     //Change actors color corresponding to lightmap
     actor.AlphaColor = MakeRGBA(ToInt(arr[0]),ToInt(arr[1]),ToInt(arr[2]),255);

  }

You can use gradients (black to white or lightgray) in lightmap, while the actor is walking in scene his color and brightness is changing :-)


P.S: Array and string I declared in base.inc

arr = new Array();
str = new String(100);

---------------------------------------------------------------------------------------------------------------

Because I have no webspace I can't put a link to the dll and example bmp.
If somebody likes to have the dll I'll send it to you via email


SOURCE OF DLL
=============

library LMDLL;

uses

  Windows, SysUtils, Dialogs, Graphics, Classes;

{$R *.res}


function GetRGB(fName: string; x, y: integer; buflen: integer; buf: PChar): integer; stdcall;

var
  aBmp:   TBitmap;
  iColor: Longint;
  r,g,b:  integer;
begin

  try

    aBmp := TBitmap.Create;
    aBmp.LoadFromFile(fName);

    iColor := ColorToRGB(aBmp.Canvas.Pixels[x,y]);

  finally
    aBmp.Free;
  end;

  r := GetRValue(iColor);
  b := GetBValue(iColor);
  g := GetGValue(iColor);

  StrLCopy(buf, PChar(IntToStr(r) + ';' + IntToStr(g) + ';' + IntToStr(b)), buflen);

  result := 0;

end;

exports GetRGB;

begin
end.




« Last Edit: October 28, 2012, 04:58:58 PM by falcomus »
Logged
Everything was better in the good old days, even the future ...

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Lightmap DLL
« Reply #1 on: October 29, 2012, 12:27:41 AM »

Cool ! Can you post a link to download this?
Logged

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Lightmap DLL
« Reply #2 on: December 11, 2012, 08:51:08 PM »

nice! work only 2d actor?
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

shuin

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 51
    • View Profile
Re: Lightmap DLL
« Reply #3 on: December 13, 2012, 01:59:47 PM »

I haven't used WME in a while, but watching that video, isn't it the same as the engine's decoration regions?
Logged
Untitled project status: production

lof

  • Lurker
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 19
  • A Leap Of Fate
    • View Profile
Re: Lightmap DLL
« Reply #4 on: December 13, 2012, 03:31:03 PM »

i am guessing it is, but i get why he made this plugin, if you need to make a bunch of scenes with different lightmaps, this tool can come in handy.
no need to make regions, locate them, shape them, select color, just make an extra colored layer of the floor while designing the scene.
cheers  ::beer
Logged

falcomus

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 9
    • View Profile
Re: Lightmap DLL
« Reply #5 on: March 21, 2013, 11:15:38 PM »

Right, lof

To each scene you just have to make a lightmap. If you change to another scene, the corresponding Lightmap is used automatically.

Normally you define a region and when actor enters this region you can specify a color.

With the lightmap the actor changes color continuously (gradient) as he walks around.



The following code manages this


//Infinite loop
while(true)
{

  //examine not every pixel movement of actor
  if (loop_counter > 40)
  {
     
     //Build the path to the lightmap according to the current scene
     filename = Directory.CurrentDirectory +  "\Lightmaps\" + Scene.Name + "_LM.bmp";
     
     //Get actors color corresponding to lightmap
   if (GetActorColor(filename, actor.X,actor.Y, strRGB.Capacity,strRGB) == 0)
   {
           
           //split to result in an array
      arrRGB = strRGB.Split(";");
         
          //set the actors alpha-color with values from lightmap
     actor.AlphaColor = MakeRGBA(ToInt(arrRGB[0]),ToInt(arrRGB[1]),ToInt(arrRGB[2]),255);

   }
   loop_counter = 0;
  }
  else loop_counter = loop_counter + 1;
   
Logged
Everything was better in the good old days, even the future ...

AndyT

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 14
    • View Profile
Re: Lightmap DLL
« Reply #6 on: June 30, 2014, 11:10:22 AM »

I know this is a bit old topic, but i´d love to try this, is it possible to upload the .dll file somewhere or even some demo project? And if maybe the creator is no longer active in this forum, does anybody else uses this? Thanks
Logged
 

Page created in 0.022 seconds with 24 queries.