RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

New Dynamic Lights Script for XP...

Started by Heretic86, May 21, 2016, 12:24:06 AM

0 Members and 1 Guest are viewing this topic.

Heretic86





New script I am working on.

Two things:
#1 - Any requested features?
#2 - Do you know of any other Dynamic Light Scripts I can take a look at?

What do you all think so far?

---

EDIT:  Oops!  I forgot to edit this post to put up a link to the FINISHED version of this script, complete with DEMO!

http://rmrk.net/index.php?topic=48400.0
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

swick


Heretic86

I will once its stable.

My c++ skills suck bowling balls thru stir straws and the script currently is very unstable.  This is the effect that will be produced in the long run once stable:



If there are any c++ folks here, care to take a look at the source code?
[spoiler]// KK20Rotate.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"

typedef union {
unsigned int pixel;
struct {
unsigned char blue;
unsigned char green;
unsigned char red;
unsigned char alpha;
};
} RGSSRGBA;

typedef struct {
DWORD flags;
DWORD klass;
void(*dmark) (void*);
void(*dfree) (void*);
BYTE *data; //B = 0, G = 1, R = 2, A = 3
} RGSSCOLOR;

typedef struct {
DWORD unk1;
DWORD unk2;
BITMAPINFOHEADER *infoheader;
RGSSRGBA *firstRow;
RGSSRGBA *lastRow;
} RGSSBMINFO;

typedef struct {
DWORD unk1;
DWORD unk2;
RGSSBMINFO *bminfo;
} BITMAPSTRUCT;

typedef struct {
DWORD flags;
DWORD klass;
void(*dmark) (void*);
void(*dfree) (void*);
BITMAPSTRUCT *bm;
} RGSSBITMAP;

extern "C" _declspec (dllexport) bool RotateRGSSBmp(long bmp, float * matrix)
{
RGSSBMINFO *bitmap = ((RGSSBITMAP*)(bmp << 1))->bm->bminfo;

long width, height;
RGSSRGBA *row;
RGSSRGBA *rowcopy;
long x, y;
float nx, ny;
float cx, cy;
unsigned char red, green, blue, alpha;

float transx, transy, transw;

if (!bitmap)
return false;
width = bitmap->infoheader->biWidth;
height = bitmap->infoheader->biHeight;
cx = (float)width / 2 + 0.0001;
cy = (float)height / 2 + 0.0001;

rowcopy = new RGSSRGBA[width*height];
row = bitmap->lastRow;
memcpy(rowcopy, row, width*height * 4);

RGSSRGBA *sourcepos;

for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
nx = x - cx;
ny = y - cy;

transx = (float)(matrix[0] * nx + matrix[1] * ny + matrix[2]);
transy = (float)(matrix[3] * nx + matrix[4] * ny + matrix[5]);
transw = (float)(matrix[6] * nx + matrix[7] * ny + matrix[8]);

// Dividing by zero is bad
if (transw == 0)
transw = (float)0.001;

transx = (transx + cx) / transw;
transy = (transy + cy) / transw;

if (transx < 0 || transx > width || transy < 0 || transy > height)
{
red = 0;
green = 0;
blue = 0;
alpha = 0;
}
else
{
sourcepos = rowcopy + (int)transx + ((int)transy * width);

red = sourcepos->red;
green = sourcepos->green;
blue = sourcepos->blue;
alpha = sourcepos->alpha;
}

row->red = red;
row->green = green;
row->blue = blue;
row->alpha = alpha;

row++;
}
}

delete[]rowcopy;

return true;
}
[/spoiler]

Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

Heretic86

#3
A couple of Screenshots showing off Pendulum Lights...





--- Edit ---

I put up a Prototype Demo for DOWNLOAD if anyone is interested in taking a look and offering suggestions or feedback during the development process...

PROTOTYPE DOWNLOAD
- Redacted, Obsolete -
http://rmrk.net/index.php?topic=48400.0 - Full Release Version

Feedback would be appreciated...

.
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

Heretic86

#4
* Modified *

Pre Release Version has been removed as it is now obsolete.  Full Version has been released with all Legal restrictions removed.  Available as a part of Heretic's Collection:

http://rmrk.net/index.php?topic=48400.0

And for my next magic trick, maybe I'll change my Avatar?  :P
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!