Jump to content

Au3Irrlicht 2.0


JRowe
 Share

Recommended Posts

Edit, now it's onto 104_LOD functions and example... weee

smashly, you are killing me - haven't finished my first breakfast coffee yet, and you are giving additional work ;)

OK, joke - I check your postings and upload 2.04 later this day.

Link to comment
Share on other sites

Hi,

Shake the led out boy, don't make come over there and poke you with my stick to bring you back to life. ;)

Nah just joking, enjoy your coffee and chill for a bit.

I've almost got the LOD functions and example done, works well so far..

Just working out the CallBack part of LOD function (callback not really needed but an example using the callback with LOD would be nice if possible.)

I need to do the Header info for the functions, tidy the LOD example and then I'll post it.

Cheers

Link to comment
Share on other sites

Second coffee - it's getting better ...

maybe you can also have a look on another thing(?): not sure but I think alpha channel is not really working (e.g. example 107, but also other functions using this). Hope I simply missunderstand its usage, but afraid it's a general problem within the Irrlicht.dll. Also freeBasic example 107 (and others) does not do anything different when changing alpha values ...

BTW: what is your code base - 2.03 or the dev version directly from the Project Page's subversion?

Link to comment
Share on other sites

Hi,

I'm using the includes from dev version (mine are a little different due to changing the Global $result in most the includes, not all yet).

I'm using the rest of the files from v2.03.

The Alpha in 107 example from 2.03 using dev includes is working for me fine.

If I change the value of Alpha it still works fine and it appears to be doing what it's spose to from the brief tests I just did.

Well I've worked out the CallBack for LOD and using it in 104_LOD_Example, now it's time to tidy it all up and post it..w00t.

BBS with some more functions and 104 example.

Cheers

Link to comment
Share on other sites

I'm using the includes from dev version (mine are a little different due to changing the Global $result in most the includes, not all yet).

I'm using the rest of the files from v2.03.

Perfect - we should add you to the committer list, so you can work on the dev sources directly (seems you work trustable enough ;) ) I want to set up the repository's structure in a better way next time so it would be more transparent when comitting is done from severals.

BTW: (hello jRowe: )Hope you find some time to give me owner rights for the Project page as promised loooooooong ago :)

The Alpha in 107 example from 2.03 using dev includes is working for me fine.

Yep, seems the problem is simply my outdated every-day-laptop - works also fine on my "good PC" ...
Link to comment
Share on other sites

Hi again,

We now have LOD Manager working ;)

3 new functions and example

#include "au3Irrlicht2.au3"

Opt("MustDeclareVars", 1)

HotKeySet("{ESC}", "_exit")

Func _exit()
    _IrrStop()
    Exit
EndFunc   ;==>_exit

; Play with these 3 variables to see things different ;)
Global $USE_LOD = 1 ; Use LOD = 1, Don't Use LOD = 0
Global $iNodeType = 1 ; Set what type of nodes to create; 1 = Mesh Nodes, 2 = Billboard Nodes, 3 = Billboard Group scene nodes (needs Billboard group functions I posted earlier)
Global $ROWS_AND_COLUMNS = 20 ; Change this to control how many objects are added to the scene

Global $hLOD1Mesh ;irr_mesh
Global $hLOD2Mesh ;irr_mesh
Global $hMeshTextureA ;irr_texture
Global $hMeshTextureB ;irr_texture
Global $hParticleTexture ;irr_texture
Global $hMaterial ;irr_material
Global $hOurCamera ;irr_camera
Global $iAmountNodes = $ROWS_AND_COLUMNS * $ROWS_AND_COLUMNS ; how many nodes we are starting with.
Global $aSceneNodes[$iAmountNodes] ;irr_node array of scene node handles
Global $iNodes = $iAmountNodes ;integer
Global $k = 0 ;using this in our loop when creating nodes
Global $hLODManager, $hCallBack ; handle to the LODManager , Handle to CallBack function

; We'll register a CallBack function so that the LOD Manager can let us know when nodes are changing
; In this case we're using the callback to let us know how many nodes are are visible which we'll write to the window title.
$hCallBack = DllCallbackRegister("_NodeChangeCallback", "int:cdecl", "uint;ptr")

;This is our callback function
Func _NodeChangeCallback($u_Visible, $h_Node)
    If $u_Visible And $iNodes < $iAmountNodes Then
        $iNodes += 1
    Else
        If $iAmountNodes Then $iNodes -= 1
    EndIf
EndFunc   ;==>_NodeChangeCallback

;Free the callback function when autoit exits.
OnAutoItExitRegister("_FreeCallBack")

Func _FreeCallBack()
    DllCallbackFree($hCallBack)
    $hCallBack = 0
EndFunc   ;==>_FreeCallBack


; start the irrlicht interface
_IrrStart($IRR_EDT_DIRECT3D9, 512, 512, $IRR_BITS_PER_PIXEL_32, _
        $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_IGNORE_EVENTS)

; load the meshes used for level of detail on this object
$hLOD1Mesh = _IrrGetMesh("./media/cylinderY.obj")
$hLOD2Mesh = _IrrGetMesh("./media/cylinderYLow.obj")

; scale the two meshes to a size appropriate for our scene
_IrrScaleMesh($hLOD1Mesh, 8.0)
_IrrScaleMesh($hLOD2Mesh, 8.0)

; for a fair test make sure that the both meshes are hardware accellerated
_IrrSetMeshHardwareAccelerated($hLOD1Mesh)
_IrrSetMeshHardwareAccelerated($hLOD2Mesh)

; load texture resources for texturing the scene nodes
$hMeshTextureA = _IrrGetTexture("./media/Cross.bmp")
$hMeshTextureB = _IrrGetTexture("./media/Diagonal.bmp")
$hParticleTexture = _IrrGetTexture("./media/cloud4.png")

; Add a big grid of nodes to demonstrate level of detail
For $i = -($ROWS_AND_COLUMNS / 2) To ($ROWS_AND_COLUMNS / 2) - 1
    For $j = -($ROWS_AND_COLUMNS / 2) To ($ROWS_AND_COLUMNS / 2) - 1
        Switch $iNodeType
            Case 1 ; Mesh Nodes
                $aSceneNodes[$k] = _IrrAddMeshToScene($hLOD1Mesh)
                _IrrSetNodePosition($aSceneNodes[$k], $i * 40.0, 0.0, $j * 40.0)

                If Not Mod($i + Mod($j, 2), 2) Then
                    _IrrSetNodeMaterialTexture($aSceneNodes[$k], $hMeshTextureA, 0)
                Else
                    _IrrSetNodeMaterialTexture($aSceneNodes[$k], $hMeshTextureB, 0)
                EndIf

            Case 2 ;Billboard Nodes
                $aSceneNodes[$k] = _IrrAddBillBoardToScene(20.0, 20.0, $i * 40.0, 0.0, $j * 40.0)
                _IrrSetNodeMaterialTexture($aSceneNodes[$k], $hParticleTexture, 0)
                _IrrSetNodeMaterialType($aSceneNodes[$k], $IRR_EMT_TRANSPARENT_ADD_COLOR)

            Case 3 ;Billboard Group scene nodes
                $aSceneNodes[$k] = _IrrAddBillBoardGroupToScene()
                For $l = 1 To 5
                    _IrrAddBillBoardToGroup($aSceneNodes[$k], $l * 4.0, $l * 4.0, Random(-2.5, 5.0), Random(-2.5, 5.0), Random(-2.5, 5.0), 0, 255, 255, 255, 255)
                Next
                _IrrSetNodePosition($aSceneNodes[$k], $i * 40.0, 0.0, $j * 40.0)
                _IrrSetNodeMaterialTexture($aSceneNodes[$k], $hParticleTexture, 0)
                _IrrSetNodeMaterialType($aSceneNodes[$k], $IRR_EMT_TRANSPARENT_ADD_COLOR)
        EndSwitch
        _IrrSetNodeMaterialFlag($aSceneNodes[$k], $IRR_EMF_LIGHTING, $IRR_ON)
        $hMaterial = _IrrGetMaterial($aSceneNodes[$k], 0)
        _IrrMaterialVertexColorAffects($hMaterial, $ECM_NONE)
        _IrrMaterialSetAmbientColor($hMaterial, 255, 255, 255, 255)
        _IrrMaterialSetDiffuseColor($hMaterial, 255, 255, 255, 255)
        $k += 1
    Next
Next

; add a LOD Manager, this takes 3 parameters
; the first is the number of 1/4 seconds over which a node is faded in or out
; in this example it is 2 so they will fade in and out in about a 500ms
; the second parameter is whether alpha is used when objects are faded, some
; materials need it some dont you will have to experiment with this
; the last parameter is a callback function that is called whenever a node is
; made invisible or visible if you dont want this feature leave the parameter out.
$hLODManager = _IrrAddLODManager(2, $IRR_ON, DllCallbackGetPtr($hCallBack))

; The material map tells the LOD system which material you want to use to fade
; a node out for a particular material type. by default every node uses
; IRR_EMT_TRANSPARENT_VERTEX_ALPHA for fading but you can change this on a per
; material basis so here instead of using IRR_EMT_TRANSPARENT_VERTEX_ALPHA the
; material type IRR_EMT_TRANSPARENT_ADD_COLOR uses itself when fading again this
; needs experimentation to find what works best for your scene
_IrrSetLODMaterialMap($hLODManager, $IRR_EMT_TRANSPARENT_ADD_COLOR, $IRR_EMT_TRANSPARENT_ADD_COLOR)

; add the first level of detail from 0 outwards this uses a high resoloution mesh
_IrrAddLODMesh($hLODManager, 0.0, $hLOD1Mesh)

; add a lower levl of detail from 300.0 outwards, this is more in the distance
; so the mesh is swapped for a low detail mesh
_IrrAddLODMesh($hLODManager, 300.0, $hLOD2Mesh)

; fade objects out from 600.0 outwards, when an object is over 600.0 units away
; it will fade out of the scene smoothly
_IrrAddLODMesh($hLODManager, 600.0, $IRR_NO_OBJECT)

; disable lighting on the manager
_IrrSetNodeMaterialFlag($hLODManager, $IRR_EMF_LIGHTING, $IRR_OFF)

; add all of the nodes to the LOD Manager if $USE_LOD variable <> 0
If $USE_LOD Then
    $i = 0
    While $i < $k
        _IrrAddChildToParent($aSceneNodes[$i], $hLODManager)
        $i += 1
    WEnd
EndIf

; add a camera into the scene
$hOurCamera = _IrrAddFPSCamera($IRR_NO_OBJECT, 100.0, 0.05)
_IrrSetNodePosition($hOurCamera, 0, $ROWS_AND_COLUMNS * 4, $ROWS_AND_COLUMNS * 2)
_IrrSetCameraTarget($hOurCamera, 0, 50, 0)
_IrrSetCameraClipDistance($hOurCamera, 2500.0)

; set the ambient light level across the entire scene
_IrrSetAmbientLight(1, 1, 1)

; hide the mouse pointer
_IrrHideMouse()

; add some text to let people know the fps camera keys.
_IrrAddStaticText("ARROW KEYS TO MOVE AROUND", 8, 8, 200, 20, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)

; while the irrlicht environment is still running
While _IrrRunning() And Sleep(10)

    ; begin the scene, erasing the canvas with sky-blue before rendering
    _IrrBeginScene(255, 255, 0)

    ; display number of visible nodes (LOD callback function is setting the $iNodes value) and the framerate.
    _IrrSetWindowCaption("104 Example LOD - Visable Nodes: " & $iNodes & " - FPS: " & _IrrGetFPS())

    ;;To display the static text
    _IrrDrawGUI()


    ; draw the scene
    _IrrDrawScene()

    ; end drawing the scene and render it
    _IrrEndScene()
WEnd

; Stop the irrlicht engine and release resources
_IrrStop()


;---> 3 New LOD functions for au3Irr2_Scene.au3 ...w00t

; #FUNCTION# =============================================================================================================
; Name...........: _IrrAddLODManager
; Description ...: Adds a level of detail manager to the scene.
; Syntax.........: _IrrAddLODManager($u_FadeScale, $u_UseAlpha[, $p_Callback = 0])
; Parameters ....: $u_FadeScale - Number of 1/4 seconds that the node takes to fade out or in. 4 units equals 1 second.
;                  $u_UseAlpha - Specifies whether or not the Alpha color of the object is faded too.
;                  $p_Callback - [Optional] Register a callback function that is called whenever a node is made invisible or visible.
;                  |This allows you to stop processing hidden nodes.
; Return values .: Success - Handle to the LOD Manager node
;                  Failure - False and @error 1
; Author ........:
; Modified.......:
; Remarks .......: The primary use for this node is to add other scene nodes to it as children and have their level of detail controlled automatically.
;                  If those nodes are made from loaded meshs different meshes containing different amounts of detail can be displayed at different distances.
;                  The other function of the LOD manager is to fade nodes in an out at a specific distance so they gradually fade rather than disappear abruptly.
;                  This is achieved by applying a distance without supplying a mesh.
; Related .......: _IrrAddLODMesh, _IrrSetLODMaterialMap
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrAddLODManager($u_FadeScale, $u_UseAlpha, $p_Callback = 0)
    Local $aResult
    $aResult = DllCall($_irrDll, "ptr:cdecl", "IrrAddLODManager", "uint", $u_FadeScale, "uint", $u_UseAlpha, "ptr", $p_Callback)
    If @error Or Not $aResult[0] Then Return SetError(1, 0, False)
    Return SetError(0, 0, $aResult[0])
EndFunc   ;==>_IrrAddLODManager


; #FUNCTION# =============================================================================================================
; Name...........: _IrrAddLODMesh
; Description ...: Set the distance at which a particular mesh is to be applied to child mesh nodes.
; Syntax.........: _IrrAddLODMesh($h_LODManager, $f_Distance, $h_Mesh)
; Parameters ....: $h_LODManager - Handle to the LOD Manager node.
;                  $f_Distance - Distance at which this effect will be applied.
;                  $h_Mesh - Handle to an irr mesh object
; Return values .: Success - True
;                  Failure - False
; Author ........:
; Modified.......:
; Remarks .......: If no mesh is supplied it specifies the distance at which the node should be faded in an out.
; Related .......: _IrrAddLODManager, _IrrSetLODMaterialMap
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrAddLODMesh($h_LODManager, $f_Distance, $h_Mesh)
    DllCall($_irrDll, "none:cdecl", "IrrAddLODMesh", "ptr", $h_LODManager, "float", $f_Distance, "ptr", $h_Mesh)
    Return SetError(@error, 0, @error = 0)
EndFunc   ;==>_IrrAddLODMesh


; #FUNCTION# =============================================================================================================
; Name...........: _IrrSetLODMaterialMap
; Description ...: Specifies which material is used to apply the fade effect for another material type.
; Syntax.........: _IrrSetLODMaterialMap($h_LODManager, $i_SourceType, $i_TargetType)
; Parameters ....: $h_LODManager - Handle to the LOD Manager node.
;                  $u_SourceType - The irr material type your node uses
;                  $u_TargetType - The material type used for the fade effect.
; Return values .: Success - True
;                  Failure - False
; Author ........:
; Modified.......:
; Remarks .......: How this is used will depend on the effect that you want to achieve.
;                  By default fading is applied with the $IRR_EMT_TRANSPARENT_VERTEX_ALPHA material.
; Related .......: _IrrAddLODManager, _IrrAddLODMesh
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrSetLODMaterialMap($h_LODManager, $i_SourceType, $i_TargetType)
    DllCall($_irrDll, "none:cdecl", "IrrSetLODMaterialMap", "uint_ptr", $h_LODManager, "uint", $i_SourceType, "uint", $i_TargetType)
    Return SetError(@error, 0, @error = 0)
EndFunc   ;==>_IrrSetLODMaterialMap

Cheers

Edited by smashly
Link to comment
Share on other sites

Hi Smashly, source is updated on the project page; hope I have all your things inside. Did not check too deeply since you seem to know what you are doing ;) Think final release should wait some days - better to check if everything is alright and I want also complete some things inside the help.

BTW: nice try to say "Example: Yes" for LOD + Billboard functions - but nothing posted for \internal_tools\buildHelp\examples :) Anyway, new BIG examples are really nice, thanks a lot for your contributions (until now ...)

BTW2: See credits page inside updated help, could not resist ...

Link to comment
Share on other sites

Hi linus,

Source is coming along nicely, just been checking it out ;)

Your doing well at getting all my scrap bits and pieces into the help file and includes.

Not to mention all the other functions you've been working on and integrating.

LMAO at Help file Credits. (Mental note to self, post after Sundays)

I've got a 13 lightened helpfile examples for you to add to \internal_tools\buildHelp\examples.

Some are just duplicates of each other eg;

Unlock/Lock

LOD

Couldn't see any point in trying to write individual examples with some things.

Some functions are just to hard to make into small examples :)

Have look and see if they suit.

I'm still going through the includes trying to get headers done and getting rid of that Global $return.

But I keep getting side tracked as I'm going along. lol

Cheers

Edited by smashly
Link to comment
Share on other sites

Hi again,

9 more little help file examples

I've also added my au3Irr2_Scene.au3.

It's still not finished, quite a lot of function header info needs to be done.

And needs many more examples for the help file.

But it's still a WIP and it's a little more complete then the current Dev version.

I posted it mainly because of the example help functions have their function header info complete(ish).

Also the Global $result isn't needed for it either ;)

Cheers

Edited by smashly
Link to comment
Share on other sites

Hi Smashly, wounderful, you keep on beautifying - I will take myself an evening this week to include your new additions and to finish mine (just some help + test for the already added vertices functions of example 15).

Couldn't see any point in trying to write individual examples with some things.

Some functions are just to hard to make into small examples :)

Yep, especially more adcanced functions are hard to break down, and a lot can use same small examples. It's just to follow the VERY helpful concept of the au3 help: "needing a function not used for years?, get it's usage again with one look" into a self-working example as short as possible.

LMAO at Help file Credits. (Mental note to self, post after Sundays)

... some call it sick sense of humour ;) If you like it I'll keep it, or make it "serious" again ... And DON'T stop posting on Sundays - it's personal risk to check mails before coffee ... and moreover, coming 2.04 wouldn't be what it will be without your "sinful Sunday postings" ;)

BTW: As I know you are working from the dev sources I'll keep them now regularly up-to-date. And if you like: set up a dev branch in the repository together with some write rights for you (when I can ...); would be easier to work in synchro than now ...

@JRowe: ... or you do this if there are any problems with changing current rights?

Link to comment
Share on other sites

Hi linus,

Yep to write rights when or if possible, it'd save me cluttering this thread with long winded autoit code tags and zip files..lol

PS. ignore my help file example/header info for 3dLine, didn't see you had already done it till after I posted it.. doh ..(yours was better of coarse ;) )

Well back to copy/paste/create/improvise, rinse, lather and repeat again :)

Cheers

Link to comment
Share on other sites

Hmm, I was attempting to convert my old project to the new format and was attempting to try and figure out how to create a windowed sceen in a gui (used to be CreateDeviceOnWindow or some such thing)

I decided to haver a look at the examples to see if any of them came close and ran the demo launcher...

Apparently someone forgot to wrap the paths in single quotes as I was running from C:\Program Files\Terisi\au3Irrlicht2

and I kept recieving the error

Line 0 (File "C:\Program"): Error: Error opening the file.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Hmm, I was attempting to convert my old project to the new format and was attempting to try and figure out how to create a windowed sceen in a gui (used to be CreateDeviceOnWindow or some such thing)

I decided to haver a look at the examples to see if any of them came close and ran the demo launcher...

Apparently someone forgot to wrap the paths in single quotes as I was running from C:\Program Files\Terisi\au3Irrlicht2

1) Think the "someone" was me :) Thanks for info, will be fixed in next release.

2) If you mean to render the Irrlicht scene directly into another window: I am afraid this is not possible with the used wrapper dll (if I am wrong and you find a solution; you are the hero of the day ...) - but got some time ago info from JRowe that he wants to look for something like this.

3) Nice that you are switching to au3Irr2. If you have something working would be nice to see it (I know some are working with this UDF, but seems most prefer silence ... Much more motivating to provide an UDF when you know & see that it's used ;) )

Link to comment
Share on other sites

I might have to do a mix of the original and the new for the 2 different parts of my project. The first part is the character creation that needs the window in a gui for display of the 3d model, however I did see many normal gui functions included in this wrapper so I may look into that instead.

That would mean a complete rewrite of the character creation, but may be better in the long run.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

That would mean a complete rewrite of the character creation, but may be better in the long run.

If you want to work with a "living" UDF - yes! Besides, thanks to the guys from the Irrlicht wrapper dll, au3Irr2 provides more features than the one from aPercy (also he did a really impressing piece of work by writing a wrapping dll from scratch).
Link to comment
Share on other sites

The only thing I see missing from the GUI management section that I used in my program is the GUICtrlCreateSlider. Maybe it's still hidden in there somewhere? if not I may be able to come up with some sort of work-around.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

The only thing I see missing from the GUI management section that I used in my program is the GUICtrlCreateSlider. Maybe it's still hidden in there somewhere? if not I may be able to come up with some sort of work-around.

Nope, no function with this name in the wrapper. But maybe you can use _IrrAddScrollBar? Edited by linus
Link to comment
Share on other sites

Well back to copy/paste/create/improvise, rinse, lather and repeat again :)

... still welcome ;) Your changes until now are inside the sources. At least I hope so, managing it this way is like pain in the a$@ ... Please have also a look on scene.au3 if merging moving fixing adding was finally ok.

BTW: what the heck is "While _IrrRunning() And Sleep(10)" - Sleep does not return anything?

Edited by linus
Link to comment
Share on other sites

Hi linus,

Looking good so far and well done, I'll use the updated dev scene.au3 to work on now ;)

I'm thinking I may as well remove the Global $return from all the other now day dev includes without changing anything else (to much ;) )and post them.

So if you've got any includes that need updating on the dev, then update them asap.

au3Irr2_Animation.au3 I'm now removing Global $result and will post it shortly.

I'll work my way through the includes alphabetically just removing Global $result.

I think you can move _IrrSetFlareScale() from #NO_DOC_FUNCTION# to #Current# since the example and function appear to work fine from what I've tested.

BTW: what the heck is "While _IrrRunning() And Sleep(10)" - Sleep does not return anything?

Haha, it's just my dodgy way of sleep.. :)

Sleep(10) doesn't need to return anything, it's like While Not 0 or While 1,

0 or 1 don't return anything they just are or are not..

Sleep(10) will always Sleep for 10ms even when used as a bool for a While statement.

I just got tired of Irr While loop chewing 50% cpu power just to sit an object on screen in a simple non mission critical example hence using a sleep.

Cheers

Edited by smashly
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...