Extra Lights for ZGE

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

Post Reply
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Extra Lights for ZGE

Post by StevenM »

Just a small external library to add some more OGL Light functionality to ZGE.

Made it for personal use, but just wanted to share it :wink:. I haven't tested the get property functions yet - let me know if there are problems.

for the get functions - since I can't return an array -
use 0 to get x, use 1 to get y, 2 to get z...for example

float Light_X=GetLightPos(4,0); returns the X position of glLight4
float SpecCol = GetSpecCol(2, 1) returns the spec green value of glLight2


zip file includes the .dll and sample project.

You can add and position up to 8 lights, turn them off or on.
Also included some functions to set specular/diffuse/ambient properties to both materials and lights.

the mode property in the set mat functions :
0=front, 1=front and back,2=back

ZExternal Library Function Script:

/*

Code: Select all

/*
LightNum and ID refer to an integer that identifies a light.
The max number of LightSwitch is 8.  This value should be between
0-7, but the function accepts any positive or negative integer.
Anything >7 = 7, <0 = 0.

Steps for creating a Light :

LightSwitch(1,1);   This Enables GLlight1

SetLightPosition(1,0,20,10,0);  This positions GLlight1 @ {x,y,z,w}={0,20,10,0}

SetDiffuseLight (1,1,0,0,1);  This sets the GLlight1 RGBA color  to red.

SetAmbientLight (1,.2,0,0,1); This seta a value that
                              brightens surface unaffected
                              by direct light.  Should be kept
                              fairly low, but higher value can create
                              a pseudo self illumination effect.

SetSpecularLight (1,1,1,1,1)  Sets the color of the HotSpot to white.  This ony shows up
                              if you define specular value and shininess for the
                              material.
*/

//Turn a light off or on.
void LightSwitch(int LightNum,int Lswitch){}

//Set the position of the Light - note that W is usually 0
void SetLightPosition(int ID,float x,float y,float z,float w){}

//Set Light color properties
//It is importantant to set the light Diffuse color every time you create a light.
//Ambient and specular properties will not work if your material doesn't use these properties.
void SetDiffuseLight(int ID, float R,float G, float B, float A){}
void SetAmbientLight(int ID, float R,float G, float B, float A){}
void SetSpecularLight(int ID, float R,float G, float B, float A){}

//Use these to easily set Material Properties, set value prior to Use material in a Zexpression
void SetMatDiffuse(int mode, float R,float G, float B, float A){}
void SetMatAmbient(int mode, float R,float G, float B, float A){}
void SetMatSpecular(int mode, float R,float G, float B, float A){}
void SetMatShininess(int mode,float v){}
void SetMatEmission(int mode, float R,float G, float B, float A){}

//These are here as a way to get info about Lights in your scene.
float GetLightPos(int ID, int xywz){}
float GetDifCol(int ID, int colorID){}
float GetAmbCol(int ID, int colorID){}
float GetSpecCol(int ID, int colorID){}
float GetSpotDir(int ID, int xyw){}
float GetSpotCut(int ID){}
float GetSpotExp(int ID){}

//This can be very useful - returns 0 if light is off, 1 if light is on
int LightIsOn(int Id){}

/* Experimental = Added spotlight functions here try if you like
I was hopeing to be able to produce some attenuated lighting, but
I really don't know hot to calculate/set the right values here.
*/
void SetSpotDir(int ID, float x, float y, float z){}
void SetSpotCut(int ID, float angle){}
void SetSpotExp(int ID, float exponent){}
void SetQuadAtt(int ID, float v){}
void SetLinAtt(int ID, float v){}
void SetConstAtt(int ID, float v){}

Attachments
ZGELightDLL3.zip
(155.39 KiB) Downloaded 961 times
Last edited by StevenM on Wed Dec 07, 2011 7:15 pm, edited 2 times in total.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

This is really cool! I can only seem to get lights 0 and 1 to work though. Could be my gpu?

I am amazed at how many different looks you can get from a few parameters. I think we should have had these settings build into the material component, or a material2 component perhaps,. thanks for sharing it.
iterationGAMES.com
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

I can only seem to get lights 0 and 1 to work though.
Yes - sorry about that...

Thanks for letting me know - I'll upload a new DLL in a bit - It was a typo that caused it. Must of happened, after I updated it yesterday.

Edit: Uploaded a new dll, I modified the example project to use GlLight5 - Let me know if you find any other issues.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

thanks for the update,. all of the lights are working now.

Just messing around with three lights in this little test. wiggle the mouse to move a light and tweak a color.

Loving the hard tech. metallic looks that are easy to get with these light settings.
Attachments
SilverGold.zip
.exe test.
(30.1 KiB) Downloaded 970 times
iterationGAMES.com
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

Just messing around with three lights in this little test.
Thats a nice demo - thanks! I'm going to experiment with it later today. Using lights in ZGE is so easy - along with the bullet library, new beta visualizer,and the new scripting Ville added - I'm in heaven...it's going to be fun.

I'm really glad to see that it handles well with 3 lights and all those objects too. I wasn't really sure about performance issues.
User avatar
Lupo
Posts: 76
Joined: Wed Sep 09, 2009 6:21 pm
Location: Montevideo, Uruguay

Post by Lupo »

Hi Steven,

Thanks for this, a while ago I was looking for something similar. Great work!

Regards.
Close, but not there yet.
Post Reply