New Dynamic Lights Script for XP...

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 69
RMRK Junior




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
« Last Edit: August 26, 2017, 05:54:10 PM by Heretic86 »
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!

**
Rep:
Level 70
RMRK Junior
it looks awesome give it to me

***
Rep:
Level 69
RMRK Junior
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 for:
Code: [Select]
// 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;
}

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!

***
Rep:
Level 69
RMRK Junior
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...

.
« Last Edit: August 25, 2016, 12:16:00 AM by Heretic86 »
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!

***
Rep:
Level 69
RMRK Junior
* 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
« Last Edit: August 21, 2016, 07:55:53 AM by Heretic86 »
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!