Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: CreateLight  (Read 229 times)
StakFallT
Community Member
*
Posts: 127


« on: September 29, 2008, 05:49:58 PM »

How come CreateLight won't return back a light index in my project?
Here's my light creation code:

Relevant object variables
Code:
SunLight: Array[1..MaxSunLights] of TV_LIGHT;
    SunLightIndexesUsed: Array[1..MaxSunLights] of Integer;
    TVSunLightIndexes: Array[1..MaxSunLights] of Integer;
    SunLightNames: Array[1..MaxSunLights] of String;

LightEngine: TVLightEngine;

Actual code
Code:
LightEngine := CoTVLightEngine.Create;

MainRenderWindow.SunLightNames[1] := 'SunLight';
    MainRenderWindow.SunLightIndexesUsed[1] := 1;   //Container-Index 1 is being used
    MainRenderWindow.SunLight[1].Position.X := 1024;
    MainRenderWindow.SunLight[1].Position.Y := 512;
    MainRenderWindow.SunLight[1].Position.Z := 1024;

    MainRenderWindow.SunLight[1].Direction.X := 0;
    MainRenderWindow.SunLight[1].Direction.Y := 0;
    MainRenderWindow.SunLight[1].Direction.Z := 0;

    MainRenderWindow.SunLight[1].Attenuation.X := 0;
    MainRenderWindow.SunLight[1].Attenuation.Y := 0;
    MainRenderWindow.SunLight[1].Attenuation.Z := 0;

    MainRenderWindow.SunLight[1].Ambient.R := 190 / 255;
    MainRenderWindow.SunLight[1].Ambient.G := 130 / 255;
    MainRenderWindow.SunLight[1].Ambient.B := 0;
    MainRenderWindow.SunLight[1].Ambient.A := 1;

    MainRenderWindow.SunLight[1].Diffuse.R := 190 / 255;
    MainRenderWindow.SunLight[1].Diffuse.G := 130 / 255;
    MainRenderWindow.SunLight[1].Diffuse.B := 0;
    MainRenderWindow.SunLight[1].Diffuse.A := 1;

    MainRenderWindow.SunLight[1].Specular.R := 190 / 255;
    MainRenderWindow.SunLight[1].Specular.G := 130 / 255;
    MainRenderWindow.SunLight[1].Specular.B := 0;
    MainRenderWindow.SunLight[1].Specular.A := 1 / 255;

    MainRenderWindow.SunLight[1].Range := 10000;
    MainRenderWindow.SunLight[1].Phi := 0;
    MainRenderWindow.SunLight[1].Theta := 0;
    MainRenderWindow.SunLight[1].fFallOff := 0;

    MainRenderWindow.SunLight[1].bManaged := 1;

    MainRenderWindow.TVSunLightIndexes[1] := MainRenderWindow.LightEngine.CreateLight(MainRenderWindow.SunLight[1], MainRenderWindow.SunLightNames[1]);

    MainRenderWindow.LightEngine.SetLightProperties(MainRenderWindow.TVSunLightIndexes[1], true, true, true);

MainRenderWindow.TVSunLightIndexes[1] always is 0, meaning CreateLight isn't returning a value, and when I look at the debug file, it never mentioned any problems... Any one with any leads I can try to check? I've been looking through my code, and it seems pretty straight-forward but I can't figure out where the cause of the problem is. Is there something that can throw off CreateLight from returning values? If my lightengine object wasn't initialized I would have gotten an "Access Violation" error, and even then I double checked that and the tooltip does show the lightengine object as a pointer. Any help would be greatly appreciated, thanks in advance!

-- StakFallT
Logged
Toaster
Community Member
*
Posts: 147


WWW
« Reply #1 on: September 29, 2008, 06:52:42 PM »

Dont use createlight.. Tongue

Instead use:

Code:

TVLights.CreateDirectionalLight(stuff);
or
TVLights.CreatePointLight(Stuff);
or
TVLights.CreateSpotLight(stuff);

-Toaster
Logged

Visit my site at: Unknown Abstraction
StakFallT
Community Member
*
Posts: 127


« Reply #2 on: September 29, 2008, 07:31:21 PM »

Here's the really odd thing, in another area of my project I used create light and it worked ok. I had TVDirLight, PointLight, and SpotLight arrays of TVLightEngine. I figured adding a SunLight variable (as TVLightEngine) would push some internal TV variable counter to over 3 (3 being suspected as being important relating to 3 different types of lights), but that didn't fix it (Bringing it down to a single LightEngine).

Now I did kinda thought I had thought the cause might have been because of like you said, the  need to use CreateDirectionalLight and I kind've remember it still returning 0. However, I just now tried it again just to make sure and be thorough, and unfortunately it still returns 0.

-- StakFallT
Logged
TecnoBacon
Customers
Community Member
*****
Posts: 235


WWW
« Reply #3 on: September 30, 2008, 05:16:38 PM »

You are not having nightmares, this is how it works at the moment:
you can have 1 light that will actually be accesible to you at all times, ussually used as your direct lighting.

I have been trapping the calls to set light characteristics in my editor and found that you must use getindex to have the real index (not ID) from TV. This index does not insure that the light is actually active so if it is not then a memory exc is thrown.
Our work around had been to set the color then catch the exception then set the light params.
This does not work since last update and have no info on what our ability to set lights without shaders will end up being.
Logged

www.TecnoBacon.com - the other side of the Bacon family! 3D Development, Music and more.
StakFallT
Community Member
*
Posts: 127


« Reply #4 on: September 30, 2008, 06:03:24 PM »

First, THANKS for the info!  Second, wow man that's involved as far as workarounds go, definitely my sympathy to ya :/  So if I understand you correctly, what you're saying is: this is an (I hate to use the term but...) internal design flaw of TV? I'm guessing it'll get fixed at some point? Guess you wouldn't know the answer to that though as per what you said about "[you don't know what your result will wind up being]". Just, I'd hate to think the direction we're supposed to go would be trapping exception just to set parameters upon the exception occuring... Though I do recall reading something once about the backend of the kernel of windows. Supposedly the kernel works that way -- Protection Faults occur all the time or something and the kernel's behavior expects them to occur and has problems when they don't or something odd like that.. Still... seems like a backwards way for anything, whether it be TV or the kernel or anything else, for it's normal operational parameters to work off "bad".

-- StakFallT
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks