Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Resources and Tools => Topic started by: Garthog on August 04, 2011, 12:57:21 am

Title: [C++] LightAdder
Post by: Garthog on August 04, 2011, 12:57:21 am
It's a tool which is used to add lights to M2. As a screen talk much than writing :

(http://img37.imageshack.us/img37/1932/wowscrnshot080111002123.jpg)

Download : Windows (http://filebeam.com/4260f6152f7ba1aeeb462c155c1f82b6) / Source (http://pastebin.com/rmszTtHF) / OSX (http://cl.ly/312j2g0X0S2t3t0q0A41) / Linux (http://cl.ly/2B173o3M0o1o3V0Y2X0H)

How to use : Drag a M2 file on the LightAdder, and then follow the menu. It's still a work in progress, so some things don't work, like deletion.

Create light : AR = Ambiant Red | AG = Ambiant Green | AB = Ambiant Blue | AI = Ambiant Intensity
DR, DG, DB, DI ( Same thing as ambiant ).

Modify : ID => Number of the light with the i command on the menu ( start from 0 )
And the rest work as intended. Be careful some things are integers, others are float ( eg : 1.24 ).

Author : Me, and help from Schlumpf / Tigurius / pxr.dk !

Thanks ! Don't hesitate to post me some improvements !
Title: Re: [C++] LightAdder
Post by: Vel on August 04, 2011, 01:17:11 am
Woah, realy nice.
---
It would be cool if you made the lighting editor (light.dbc and others light dbc ...).
1) loads a 3 DBC in editor
2) change in the program colortime etc
3) save the changes (which apply to all loaded into the DBC editor)
..?
Title: Re: [C++] LightAdder
Post by: Garthog on August 04, 2011, 01:43:36 am
It's different as it mess with dbc. I never touched to dbc. I could make something with the CSV generated by DBCUtil, but not by this. Someone of my team did something like that to make some dark night everywhere. When he's back i'll post it. ( in Pascal )
Title: Re: [C++] LightAdder
Post by: Vel on August 04, 2011, 02:03:54 am
Quote from: "Garthog"
It's different as it mess with dbc. I never touched to dbc. I could make something with the CSV generated by DBCUtil, but not by this. Someone of my team did something like that to make some dark night everywhere. When he's back i'll post it. ( in Pascal )
it is only in the old MES (tbc), and very very poorly compatible with wotlk.

(I have at least failed to make tbc MES work with wotlk dbc)
Title: Re: [C++] LightAdder
Post by: Garthog on August 04, 2011, 02:55:48 am
DBCUtil works perfectly to get csv from dbc files, and it's pretty simple to change. Then you get your dbc back with dbcutil too.
Title: Re: [C++] LightAdder
Post by: schlumpf on August 04, 2011, 08:15:29 am
OSX: http://cl.ly/312j2g0X0S2t3t0q0A41 (http://cl.ly/312j2g0X0S2t3t0q0A41" onclick="window.open(this.href);return false;)
Linux: http://cl.ly/2B173o3M0o1o3V0Y2X0H (http://cl.ly/2B173o3M0o1o3V0Y2X0H" onclick="window.open(this.href);return false;)

light.cpp:183: warning: converting to non-pointer type ‘char’ from NULL

You may want to end couting with a new line.
You may want not to keep the application open by tricks but should end the application as soon as its over. (waiting for a key press, that trick is.)
You may want to use two or three whitespaces instead of tabs.
Global variables are bad. Use a class if you need some semi global state and add functions needing the globals as methods.
using namespace is evil. Do full name qualification instead.
std::endl does not only "n" or "rn" but also flushes the buffer. Better do that only when really needing the text to be printed _now_ and use "n" instead.
const char null = NULL; might be nice for you coming from a null background, but better get used to NULL. Also, NULL is a void* so converting it into a const char might not be a good idea. Or that const char was supposed to be a const char*.
For the sake of performance, better write into an allocated buffer in memory first, then when you're done, write that to disk. Disk access still is slow. This also enables you to do writes easier. *(float*)&buffer[address] = 0.0f; is easier than calling a function to modify the file. And is more save than reinterpret_casting that float to a char*.
Title: Re: [C++] LightAdder
Post by: Tigurius on August 04, 2011, 09:00:16 am
Quote from: "schlumpf"
You may want to use two or three whitespaces instead of tabs.
Well the benefit of tabs is, that everyone who reads the code can make his editor show the indentation the way he likes.  That's why on my university the tab-indentation is preferred.
Title: Re: [C++] LightAdder
Post by: Steff on August 04, 2011, 12:25:38 pm
I want to add DBC light stuff to noggit some day. Tahts why the lights are displayed in the mapview (m).
You should be able then to select the lights in the mapview and change the parameters. Noggit updates then the view direct and save the dbc changes. You will also be able to add new lights.

So the plan :)

And very nice tool. Another point everyone can do.
Title: Re: [C++] LightAdder
Post by: schlumpf on August 04, 2011, 12:46:13 pm
Quote from: "Tigurius"
Quote from: "schlumpf"
You may want to use two or three whitespaces instead of tabs.
Well the benefit of tabs is, that everyone who reads the code can make his editor show the indentation the way he likes.  That's why on my university the tab-indentation is preferred.
This is correct, while n the other hand, people tend to align more than the beginning of lines like in his code, the variables in structures. With different tab width, that will fuck up the formatting for others.
Title: Re: [C++] LightAdder
Post by: Putte08 on March 22, 2012, 09:22:13 pm
Gotta try this out. Looks awesome.
Title: Re: [C++] LightAdder
Post by: PainSavior on October 23, 2013, 02:20:07 am
Could you share a download for the M2 file, just to use as a guideline.
Title: Re: [C++] LightAdder
Post by: Feel on February 23, 2014, 04:28:01 am
"Could you share a download for the M2 file, just to use as a guideline."


Up, I'm also interested ^^
Title: Re: [C++] LightAdder
Post by: tehrob on March 19, 2014, 05:44:17 pm
would be great if someone could write down here, how to use this tool :)
Title: Re: [C++] LightAdder
Post by: natrist on March 20, 2014, 02:54:39 pm
I have noticed that the lighting disappears if you get the camera away from the light source.
Is this caused by a bug in your application or the game client itself?
Title: Re: [C++] LightAdder
Post by: schlumpf on March 20, 2014, 04:05:02 pm
Quote from: "natrist"
I have noticed that the lighting disappears if you get the camera away from the light source.
Is this caused by a bug in your application or the game client itself?
It is a bug in the application: In the m2 header, there is a bounding box used to determine if the client needs to draw it. This is also used to determine if light sources from that model are used. When adding the light, the box needs to be extended to contain the maximum range of the light. If you don't, you can only see the light as long as at least a pixel of the bounding box is visible.
Title: Re: [C++] LightAdder
Post by: tehrob on March 20, 2014, 06:00:28 pm
Quote from: "schlumpf"
Quote from: "natrist"
I have noticed that the lighting disappears if you get the camera away from the light source.
Is this caused by a bug in your application or the game client itself?
It is a bug in the application: In the m2 header, there is a bounding box used to determine if the client needs to draw it. This is also used to determine if light sources from that model are used. When adding the light, the box needs to be extended to contain the maximum range of the light. If you don't, you can only see the light as long as at least a pixel of the bounding box is visible.

and how it is possible to extend this bounding box?
Title: Re: [C++] LightAdder
Post by: schlumpf on March 20, 2014, 06:30:07 pm
Quote from: "tehrob"
Quote from: "schlumpf"
Quote from: "natrist"
I have noticed that the lighting disappears if you get the camera away from the light source.
Is this caused by a bug in your application or the game client itself?
It is a bug in the application: In the m2 header, there is a bounding box used to determine if the client needs to draw it. This is also used to determine if light sources from that model are used. When adding the light, the box needs to be extended to contain the maximum range of the light. If you don't, you can only see the light as long as at least a pixel of the bounding box is visible.

and how it is possible to extend this bounding box?
http://www.pxr.dk/wowdev/wiki/index.php ... tLK#Header (http://www.pxr.dk/wowdev/wiki/index.php?title=M2/WotLK#Header" onclick="window.open(this.href);return false;)
Bounding boxes are at 0x0A0. Not sure which one is relevant, just update both. The first one should be the right one, though.
Title: Re: [C++] LightAdder
Post by: Heliocratic on April 09, 2014, 08:23:24 am
I'm going to try this out and tell you if I used/implemented everything right. I was bummed out when I got Milly's darker nights to find out torches don't actually produce light on their own. Now I have the power to change that, thanks.
Title: Re: [C++] LightAdder
Post by: Vortalex on March 06, 2015, 04:52:56 am
For someone like me who knows absolutely nothing about emitters, knowing what values do what, and what size my values should be, is confusing.

Has anyone got a tool with a helpful interface that can do this? Or if maybe someone could make a picture that details what controls what, and what the outcome looks like?

I'm sorry but this is just too confusing for me.
Title: Re: [C++] LightAdder
Post by: PhilipTNG on March 07, 2015, 10:52:03 pm
Quote from: "Vortalex"
if maybe someone could make a picture that details what controls what, and what the outcome looks like?

So.... you know, there's that search box Up there.  Use it sometime. :)  The stuff you can find is pretty amazing. Generally if you're thinking about something and you're pretty late in the game, it's possible that others have already discussed and gossiped about it, using that search box can lead to a lot of helpful hints from those of the past.  :D  :(  ;)  :)
Title: Re: [C++] LightAdder
Post by: Vortalex on March 10, 2015, 12:27:10 am
Quote from: "PhilipTNG"
So.... you know, there's that search box Up there.  Use it sometime. :)

Gee.. thanks. I hadn't thought of that before, ya know? If you search lightadder yourself tyou can see there has been 1 other discussion about it, and it didn't answer my questions about what the values meant.

Schlumpf gave a brief mention of what it meant, but to some of us that know absolutely nothing about how models work, it's very confusing.
Title: Re: [C++] LightAdder
Post by: Vortalex on March 11, 2015, 04:28:03 am
Quote from: "schlumpf"
http://www.pxr.dk/wowdev/wiki/index.php?title=M2/WotLK#Header
Bounding boxes are at 0x0A0. Not sure which one is relevant, just update both. The first one should be the right one, though.

Um, is there a specific application I should be using to edit an m2s header? I've looked around in 010 Editor and couldn't seem to find anything. I also looked around on the forums and saw that you gave this same answer to a lot of people, but never mentioned how to edit the header.
Title: Re: [C++] LightAdder
Post by: schlumpf on March 11, 2015, 11:47:56 am
010 editor or any hex editor would be the correct tool. care to elaborate on "couldn't seem to find anything"? if there was nothing at that offset, the file would be seriously broken.
Title: Re: [C++] LightAdder
Post by: Vortalex on March 12, 2015, 07:07:55 pm
Quote from: "schlumpf"
care to elaborate on "couldn't seem to find anything"?

I ran a search for VertexBox using 010 Editor, and couldn't find it located anywhere. The wiki says it's located at 0x0A0 but I couldn't find that anywhere either. I'm probably doing it wrong, but that's exactly what I'm saying... I don't know how to mess with models, so saying it's located at 0x0A0 tells me absolutely nothing.

I did however add the model to GameObjectDisplayInfo.dbc and tried editing the vertices columns, but when I spawned it in-game it made no difference. It acted as if I hadn't edited the vertices at all. So, I'm really not sure that the vertices are responsible for the issue where lights disappear when you turn your camera away from the model. Either that, or the client just looks to the actual models for vertices and skips over the columns in the GameObjectDisplayInfo.
Title: Re: [C++] LightAdder
Post by: schlumpf on March 12, 2015, 09:13:02 pm
http://www.ownedcore.com/forums/world-o ... iting.html (http://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-model-editing/wow-me-tools-guides/60300-basic-introduction-structure-of-wows-files-hexediting.html" onclick="window.open(this.href);return false;)

http://www.flexhex.com/docs/howtos/hex-editing.phtml (http://www.flexhex.com/docs/howtos/hex-editing.phtml" onclick="window.open(this.href);return false;)
Title: Re: [C++] LightAdder
Post by: Vortalex on March 17, 2015, 03:17:38 am
I can't get the RBG to work correctly. Every color I add always turns out white. Anyone know what could be causing that to happen?
Title: Re: [C++] LightAdder
Post by: schlumpf on March 17, 2015, 01:36:10 pm
It likely is 0-1, not 0-255.
Title: Re: [C++] LightAdder
Post by: Vortalex on March 17, 2015, 04:35:20 pm
Quote from: "schlumpf"
It likely is 0-1, not 0-255.

Yeah, I figured that out, but even still the colors were all white. Here is some info I grabbed from a torch that gave off light:

---TORCH:
type 1, bone 1,
ARGB 1 1 1
AI 0
DRBG 0.466667 1 1
DI 3

In-game, this torch turned out orangish-yellowish, so I used this same info for some other models, and they all turned out white instead.
Title: Re: [C++] LightAdder
Post by: Magnus on April 04, 2015, 08:56:17 pm
Have tried that tool und it gives a nice effect.

Unfortunately you have heavy faults of light reflection on floor (whole chunks) and buildings.

Depending of your POV the whole floor of a chunk (cell) get massive darker. The same with buildings. So you have a flickering effect when you are moving.

Don't know if it's possible to reduce this effect by setting other values.

(BTW: I use serverside spawned lamps. In this case I do not have the bounding box bug. At least I can't see it.)

Edit:
Ok, it seems that you shouldn't have more than 1 light emitter per cell (or too close). Than it looks pretty cool.
Title: Re: [C++] LightAdder
Post by: jorgequintt on May 11, 2016, 09:24:06 pm
For the newbies like me who are just starting with this, here are a few things I learned these days playing with the values inside struct Light with the 101 editor:

(http://i.imgur.com/lL2jH5N.jpg)

This float inside Struct Light  > ABlock_f diffuseambient > SubAnimBlock_f Substruct is the size of the light. Change it to make it bigger/smaller. Default value is 3

(http://i.imgur.com/aBdZMmf.jpg)

These 3 values change the light color. 1st is red, 2nd green and 3rd blue. If you want your light to be only white you should set them all at 1.

If you have a problem with the light appearing where it shouldn't/not appearing at all, try changing this value to 0:

(http://i.imgur.com/ODgoCT2.jpg)

I guess that's all, I'm currently trying to figure how to stop that flickering thing with the lights when they aren't in your field of vision but I've made little progress. I managed to reduce the problem a bit by changing the VertexBoxMin and VertexBoxMax to x10 their default value, but they still appear/dissapear. I about to surrender and just make the lights smaller so is not noticeable :lol:
Title: Re: [C++] LightAdder
Post by: Steff on May 11, 2016, 09:50:48 pm
Would be nice if you could write a tutorial if you get it working.
Tahnks for your feedback.
Title: Re: [C++] LightAdder
Post by: jorgequintt on December 07, 2016, 12:10:54 am
Could someone re-upload this tool please? The link is dead and I lost my old HD. I would really appreciate it!  :(

EDIT: Found it http://www.mediafire.com/file/05q8q9ims ... tadder.rar (http://www.mediafire.com/file/05q8q9imshx2kxv/lightadder.rar" onclick="window.open(this.href);return false;)
Title: Re: [C++] LightAdder
Post by: Bardh on July 18, 2017, 12:08:25 am
The link for the windows-version of the tool isn't working, could someone please re-upload it? Thanks
Title: Re: [C++] LightAdder
Post by: Mjollna on November 26, 2017, 08:53:20 pm
*years later*
Very useful tool, thank you !

I reupload the source as an attachment to this post, since the pastebin link will surely die someday.
I unfortunately don't have any Windows OS to provide a binary for this platform.