PDA

View Full Version : Specular Light



Lionheart008
21-01-2009, 19:34
Hi all:)

Have a little question about 'Specular Light' (Ambient, Spotlight) and Entity Creations...


TBGL_EntityCreateSpecularLight(%sScene, %eSpecularLight)

does this one exists with tbgl entity language???

The light range, attenuation, ambient, diffuse, spotlight light does run also with entity system???

Didn't found any example for it, sorry... need it for a new project ;)

best regards, Lionheart

Petr Schreiber
21-01-2009, 20:09
Hi Frank,

entity system currently supports just diffuse and ambient color for light.
So you create light like usually, using TBGL_EntitySetColor (this is hybrid function for all entities) you set diffuse color of that light, and using TBGL_EntitySetAmbient you can set ambient color.

Light range (in meaning light is applied only in radius) can be done only via shaders, hardware lights work with the attenuation equation. That means light never reaches zero propagation, it just becomes weaker and weaker.

Spotlight is easy to do, when you look in help file, you can see you can specify which type of light you need - point, directional or spotlight. Spotlight can have specified angle and sort of attenuation factor called border fade.

So only thing not implemented now is attenuation and specular part of the light, will see what I can do ;)

Lionheart008
21-01-2009, 20:33
Hi Petr,


' -- Create point light
TBGL_EntityCreateLight(%sScene, %eLight)
TBGL_EntitySetColor(%sScene, %eLight, 50, 50, 255)
'-TBGL_EntitySetSpecular(%sScene, %eLight, 50, 50, 255)
TBGL_EntitySetAmbient(%sScene, %eLight, 250, 50, 255)
TBGL_EntitySetPos(%sScene, %eLight, 15, 10, 5)

this light examples exist if I have understood you well... without specular... it's ok... so I have tried it some hours before without success...

thank you for the info:)

I will build an reference tbgl example with primitives, movements and lights :) all things they are actual possible with tbgl features of thinbasic 1.7.5.0 :)

shadows will come at a later time, won't be able, so I am thinking (with stencil buffer perhaps...), isn't it???

ciao and servus, Lionheart

Petr Schreiber
21-01-2009, 20:42
:)

Yes, what you wrote will work perfectly.
For spotlights just:


TBGL_EntityCreateLight(%sScene, %eSpotLight, 0, %TBGL_LIGHTTYPE_SPOT)
TBGL_EntitySetCutoff(%sScene, %eSpotLight, 15) ' -- cut off angle
TBGL_EntitySetBorderfade(%sScene, %eSpotLight, 25) ' -- Softer edges of the circle produced


And the best of all - as spotlight is entity, you can attach it to model of car, so it moves with it automagically...

Lionheart008
22-01-2009, 17:54
:-)

hi petr, hi all...

shame upon me, but I have got some errors I cannot see the mistake :?

a) would like to "move" (turn, push, entity) the cylinder or box... but how can I do this with


If TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then TBGL_EntityPush(%sScene, %eBox, 0, 90/FrameRate, 0)

that it can run clearly as I wish??? know that hWnd and frameRate is missing to define...

b) have a double rendered picture... see not the problem here... perhaps I am blind ;)

c) would like to animate one object by button click with a step by time factor 10 or 100 and then stop it... somebody has an example for it???

that's all for the moment...

best regards, Lionheart
ps: have deleted the example for a well running script you can see below :-D

Petr Schreiber
22-01-2009, 20:00
Hi Lionheart,

I am too much under influence of school exam hell, so I will give you hints in form of test ;)

- In your RenderMyImage, where is TBGL_ClearFrame ( very related to b] ), where should you put it?
- hWnd is to TBGL window, as h??? to TBGL control ( very related to a] )
- FrameRate is defined in RenderMyImage as STATIC, how to make it visible from everywhere ( very related to a] ) ?

Hehe, I hope you can see the answers now, if not ... I will make normal reply

Lionheart008
22-01-2009, 20:35
hi petr :) hi all,

...solved it, as I am working again with 'thinair' and not with a pure texteditor... where I cannot see my mistakes ;) !!! must laugh

yes, I know my little problems... forgotten tbgl_clear frame and has to change my 'hWnd' (has nothing to do with my example) into '%sScene' tbgl language... brrr... my head is full of cold water... :-D

with up, down, right, left, page down, page up you can now move the box ! :)

everything is ok for me now...

bye, thanks for your hints, I need it to awake :-D, best wishes, Lionheart

edit: have fixed the current script at this place with a second sphere and with a little other push entity :)

Petr Schreiber
22-01-2009, 20:44
Hi Frank,

good job!

Just with that TBGL_GetWindowKeyState it is still formally wrong.

The correct answer to "hWnd is to TBGL window, as h??? to TBGL control ( very related to a] )" is:
"hWnd is to TBGL window, as hCtrl to TBGL control ( very related to a] )"

Thanks,
Petr

Lionheart008
22-01-2009, 21:32
Hi petr:)

good to know, doesn't try it before with tbgl entities and

If TBGL_GetWindowKeyState(hctrl, %VK_LEFT) Then TBGL_EntityTurn(%sScene, %eBox, 0, 90/FrameRate, 0)

thank you! :) fixed my script with 'hctrl'. So every day it's a good day when I can learn for minimum five cents ;) fixed the little problem with hctrl in my last post !

prosit :occasion:

Xavier Lionheart (X-Men Leadership)
often some humour here is missing at the board... :lol:

ps: it's possible to get more kinds of smileys???

ErosOlmi
22-01-2009, 21:38
ps: it's possible to get more kinds of smileys???


I will try to see what I can do.
In the meantime click on [more] link just right to basic smiles.
:occasion: :evil5: :violent: :escribe: :xyzw: :zzz: :eusaclap: :eusadance:

Lionheart008
26-01-2009, 15:25
hello dear thinbasic friends:)
dear eros, petr, hi all...

I have started a new tutorial this morning about the current light&primitives example :-)

beside that: how can I build into "articles" column pictures???

quite other question:

I am looking for a 'mouse over' function how can I move over a primitive in my scene and then I can get a message box "Hi I am a sphere"... ???
something like that...


case %WM_MOUSEMOVE

SetCapture hDlg

GetCursorPos pt
GetWindowRect hBtn_OK, rc

IF ptInRect(rc,pt.x,pt.y) THEN
control set text hDlg, %txt_Result, "Bingo" + msgbox(0,"Hello Rectangle",0)

ELSE
control set text hDlg, %txt_Result, ""
END IF

ReleaseCapture

found nothing for entity example or primitives (sphere, box, pyramid and so on)...

have all a nice day, bye, Lionheart

Petr Schreiber
26-01-2009, 15:30
Hi Frank,

few clues for your quest for the holy mouseover :):

Check what coordinates mouse points at TBGL_MouseGetPosX, TBGL_MouseGetPosY via TBGL_GetPixelInfo
Test whether x,y,z retrieved from TBGL_GetPixelInfo is or is not inside the sphere, which is defined by its position and radius



Petr

P.S. Just noticed "prosit" in your last post :D

Lionheart008
27-01-2009, 11:54
thank you Petr:-) ! :eusaclap:
good morning dear thinbasic/tbgl friends,

...more from the tbgl road :roll:

I have include new functions (my question about mouse over handling!) and the script expands but with a lot of useful infos about 'move mouse over' it (here: primitives) and entity system handling... I am learning every day who simple it can be if you know the right way :lol: to do it...

this one was very important and useful for me :


' -- Get 2D point on screen
Mouse.x = TBGL_MouseGetPosX
Mouse.y = TBGL_MouseGetPosY

' -- Get 3D point where mouse cursor is
TBGL_GetPixelInfo Mouse.x, Mouse.y, %TBGL_PINFO_XYZ, x,y,z

' -- Get where sphere is
TBGL_EntityGetPos(%sScene, %eSphere, sx, sy, sz)

the buttons are quite dummies, still doesn't run as I wish but give some infos ;)

some critics for the script are welcome :-)
more will come, I am sure... many thanks to mr. tbgl batman :occasion:
everybody who is interested in learning new stuff needs help or support, so you cannot learn new stuff and it does not make sense in my eyes, when thinbasic user don't ask and push their project here... ;)

best regards and wishes for thinbasic and the next release, Lionheart

PS: many thank to you eros, roberto (all who has helped!) for the new release 1.7.6.0 8) good work!!! After the release of thinbasic version 1.7.5.0 my lovely old machine worked very well with all scripts here !

Lionheart008
28-01-2009, 03:18
o.k: I have updated the script :escribe:

a) and deleted the fixed printBMPs infos of primitives because of disturbing the mouse over handling of the objects

b) have made a table with four table legs :) it wasn't so easy to place them in the right position... :roll:

c) the script is running as well as I wish, what a wonder ! :lol:

good night, see you later aligator, sleep now, lionheart

EDIT: I have added the better mouse over handling with script '2cc' :)

Petr Schreiber
28-01-2009, 10:34
Hi Frank,

good script!

Just one thing - what about better precision in tests ;)?
You test for floor which is cca 20x0.1x20 using query for sphere with radius 3.

This is why you get duplicated results - when I point at white table leg, it shows both "Welcome to the table leg" ( I like it :D ) but also "Huhu wonderful blue floor".

To get more precise details on use of TBGL_PointInside3D, just put cursor on this command in your source code, and hit F1.


Thanks,
Petr

Lionheart008
29-01-2009, 20:07
hi petr, hi all,

here is a better mouse over handling with closer access to the primitives :-)


To get more precise details on use of TBGL_PointInside3D, just put cursor on this command in your source code, and hit F1.


I have done it, thanks for the info with TBGL_PointInside3D... F1 often does give good advices I forget it regularly... ;)

best regards, Lionheart
ps: the new script '2cc' I have added in my last post :-)

Lionheart008
25-02-2009, 18:19
hi all:)

one more from the lighting/move primitives front: a little , but not unimportant update for my specular/lighting script:

a) have included a new LightIntensity feature for Light and a sphere object... It has taken some minutes to grap this feature and must laugh after build it... I am proud of it.... and I like and love tbgl:)

b) have done two versions of the script with "ambien" light and a "normal" light scene...

all work in progress...

all infos you can get by the infobox after starting the script...
btw: nobody knows how you (myself!) feel when you start a project and it's getting better and better and I have managed it nearly with own power, although that took a lot of time this afternoon ;)

bye, please test this version, critics are very welcome..

bye, best regards, Lionheart and my dental doctor is still living;)

ps: I sent the lighting&move script as *.tbasicx and would like to know what the hell we can do with this ending??? feature :D


pps: specular light tbgl feature will come with next thinbasic release 1.8.0.0??? ;)

Michael Clease
25-02-2009, 22:42
*.tbasicx Just means it been obfucated but it looks like you just renamed the files so they are not encryted.

Petr Schreiber
25-02-2009, 23:04
Frank,

thanks for the demos :) Manipulating light can greatly enhance look, I liked how "Beyond good and evil" used ambient lights to set nice mood.

In Lighting&Primitives_Move-3aa.tbasic, when I click on ThinBasic Box I get run time error on line 183 ( word DIALOG is redundant ).

To make ThinBasicX obfuscated file use Tools/Obfuscate.


Thanks,
Petr

ErosOlmi
26-02-2009, 08:29
Obfuscation: http://www.thinbasic.com/public/products/thinBasic/help/html/script_obfuscation.htm