Jump to content

Au3Irrlicht 2.0


JRowe
 Share

Recommended Posts

currently...no I dont think it does...Will it? who can say. There are wrappers out there for it including one written by frank(The writer of the wrapper we are using), and indeed there are some others available. However at this moment no we do not have access to Irrklang but it would be a great addition after the wrapper for the irrlicht-wrapper is completed.

Link to comment
Share on other sites

Quick question about the whole thing... It's really intersting but does it includes irrKlang for sounds?

Thanks! ;)

Not only a quick - also a good question (wonder why not asked before) :)

But it's as fireryblaze said before - main thing is completing the UDF around the Irrlicht wrapper itself, and there are alternatives if you need sound: quick and dirty with au3 sound functions (ok, very poor), so of course better to use existing UDF's like bass (includes also 3D sound if I am not wrong).

Sound for au3Irr2 should especially mean also a buildin 3D soundnode attachable to the 3D scene - so simply wrapping Frank Dodd's (incomplete) IrrKlang dll would not be enough. And he is currently not planning to implement this into the wrapper dll himself ...

But as sound is also on the very top of my personal wishlist, I'll have a look what's possible. So maybe something for the 2.05, maybe not ;)

Link to comment
Share on other sites

I noticed a bug in the calltips or whatever they are called. _Irraddchildtoparent should go Child then parent, and it works when done in that order. However the calltips say Parent then child.

Hi fireryblaze, au3.User.Calltips.api "shipped" with 2.03 seems to be ok: _IrrAddChildToParent($h_ChildNode,$h_ParentNode), so maybe you need to update your local SciTE userCalltips?
Link to comment
Share on other sites

Hi again,

Found another trivial 2D texture function _IrrBlendTextures()

#include "au3Irrlicht2.au3"

;Constants for 2D Management Texture Blend, need adding to au3Irr2_Constants.au3
Global Const $BLEND_SCREEN = 0
Global Const $BLEND_ADD = 1
Global Const $BLEND_SUBTRACT = 2
Global Const $BLEND_MULTIPLY = 3
Global Const $BLEND_DIVIDE = 4

; Start Example
Global $hTextureDest, $hTextureSrc

_IrrStart()

$hTextureDest = _IrrGetTexture("./media/Diagonal.bmp")
$hTextureSrc = _IrrGetTexture("./media/cross.bmp")

_IrrBlendTextures($hTextureDest, $hTextureSrc, 0, 0, $BLEND_MULTIPLY)


While _IrrRunning() And Sleep(10)

    _IrrBeginScene(50, 50, 50)

    _IrrDraw2DImage($hTextureDest, 0, 0)

    _IrrEndScene()

WEnd

_IrrStop()
;End Example

; #FUNCTION# =============================================================================================================
; Name...........: _IrrBlendTextures
; Description ...: Blend the source texture into the destination texture to create a single texture.
; Syntax.........: _IrrBlendTextures($h_TextureDest, $h_TextureSrc, $i_Xoffset, $i_Yoffset, $i_Operation)
; Parameters ....: $h_TextureDest - Handle to the Destination irrlicht texture object.
;                  $h_TextureSrc - Handle to the Source irrlicht texture object.
;                  $i_Xoffset - X position where the Source texture will be blended into the Desination texture.
;                  $i_Yoffset - Y position where the Source texture will be blended into the Desination texture.
;                  $i_Operation - Can be one of the following:
;                  |$BLEND_SCREEN
;                  |$BLEND_ADD
;                  |$BLEND_SUBTRACT
;                  |$BLEND_MULTIPLY
;                  |$BLEND_BLEND_DIVIDE
; Return values .: Success - True
;                  Failure - False and set @error, check @extended to see what the error is.
;                  |@extended 0 then the @error is autoit failed the DllCall
;                  |@extended 1 Incompatible texture types
;                  |@extended 2 Unsupported texture format, must be 32bit
; Author ........:
; Modified.......:
; Remarks .......: Textures must be 32 bit format.
; Related .......: _IrrGetTexture, _IrrCreateTexture, _IrrDraw2DImage
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrBlendTextures($h_texturedest, $h_TextureSrc, $i_Xoffset, $i_Yoffset, $i_Operation)
    Local $aResult
    $aResult = DllCall($_irrDll, "int:cdecl", "IrrBlendTextures", "ptr", $h_texturedest, "ptr", $h_TextureSrc, "int", $i_Xoffset, "int", $i_Yoffset, "int", $i_Operation)
    If @error Then Return SetError(@error, 0, @error = 0)
    Return SetError($aResult[0], $aResult[0], $aResult[0] = 0)
EndFunc   ;==>_IrrBlendTextures

Cheers

Link to comment
Share on other sites

Hi again and yw,

I've done an edit on au3Irr2_2D.au3.

Changed all returns to Not rely on the Global var of $result.

It would be a good idea to get rid of the Global $result in the near future.

The returns from the functions should all still be the same apart from the error code returns may vary.

Also trimmed If Then Else Endif where applicable.

Only dif being the error code return may be 0, 1, 2, 3, 4

In most cases though anything other then 0 results in AutoIt hard crash anyways ;)

Most the Function headers I've tried to fill with info (even if it's not that great).

For Help file examples I've included some very basic examples for functions that had none as .au3.

eg:

_IrrGetScreenShot_2D_HelpExample.au3

_IrrSaveScreenShot_2D_HelpExample.au3

_IrrCreateTexture_2D_HelpExample.au3

I'm aware much better examples of use can be found in the Examples folder.

But this was just so the Help File had something for a user to quickly try.

Let me know if your not happy with the way I've done things.

I thought I'd better check before I go any further.

Edited by smashly
Link to comment
Share on other sites

Hi, nothing to do with anything, but I was playing with the AddBeamNode example, almost made a startfield out of it..lol

#include "..\au3Irrlicht2.au3"
Opt("MustDeclareVars", True)

Global $MD2Mesh ; irr_mesh
Global $MeshTexture ; irr_texture
Global $hSceneNode[100][4] ; irr_node(s)
Global $OurCamera ; irr_camera

_IrrStart($IRR_EDT_OPENGL, 800, 400, $IRR_BITS_PER_PIXEL_32, _
        $IRR_WINDOWED, $IRR_SHADOWS, $IRR_IGNORE_EVENTS, $IRR_VERTICAL_SYNC_ON)

_IrrSetWindowCaption("Example 109: 100 Beam nodes")
$MeshTexture = _IrrGetTexture("../media/beam.png")
For $i = 0 To UBound($hSceneNode, 1) - 1
    $hSceneNode[$i][0] = _IrrAddBeamSceneNode()
    _IrrSetNodeMaterialTexture($hSceneNode[$i][0], $MeshTexture, 0)
    _IrrSetNodeMaterialType($hSceneNode[$i][0], $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL)
    $hSceneNode[$i][1] = Random(-400, 9)
    $hSceneNode[$i][2] = Random(0, 1) * 100 - 50
    $hSceneNode[$i][3] = Random(0, 1) * 100 - 50
    _IrrSetBeamPosition($hSceneNode[$i][0], $hSceneNode[$i][1], $hSceneNode[$i][2], $hSceneNode[$i][3], $hSceneNode[$i][1] + 10, $hSceneNode[$i][2], $hSceneNode[$i][3])
    _IrrSetBeamSize($hSceneNode[$i][0], (Random(0, 1) + 0.01) * 4.0)
Next
$OurCamera = _IrrAddCamera(50, 0, 0, 0, 0, 0)

While _IrrRunning() And Sleep(10)
    _IrrBeginScene(0, 0, 0)
    _IrrDrawScene()
    _IrrEndScene()
    For $i = 0 To UBound($hSceneNode, 1) - 1
        $hSceneNode[$i][1] += Random(2, 10, 1)
        _IrrSetBeamPosition($hSceneNode[$i][0], $hSceneNode[$i][1], $hSceneNode[$i][2], $hSceneNode[$i][3], $hSceneNode[$i][1] + 10, $hSceneNode[$i][2], $hSceneNode[$i][3])
        If $hSceneNode[$i][1] > 10 Then
            $hSceneNode[$i][1] = -400
            $hSceneNode[$i][2] = Random(0, 1) * 100 - 50
            $hSceneNode[$i][3] = Random(0, 1) * 100 - 50
            _IrrSetBeamSize($hSceneNode[$i][0], (Random(0, 1) + 0.01) * 4.0)
        EndIf
    Next
    _IrrSetWindowCaption("Example 109: 100 Beam nodes - FPS: " & _IrrGetFPS())
WEnd

_IrrStop()
;) Edited by smashly
Link to comment
Share on other sites

Let me know if your not happy with the way I've done things.

Nothing to say against it ;)

Together with yours we'll have around 80 completely documented functions inside next help - a good base.

I have seen you have set some #NoDocFunctions# to #Functions#. So some words about their general intention:

Thanks to the big work of JRowe the UDF contains mostly all functions of the wrapper dll, but this was for the initial version of the UDF, so think he had no chance to also check correctness of all this functions.

So my decision was to include only those functions into the help that are "proven" - means all functions that I have seen working. Think the only way to assure a help that is a reliable reference: no matter if a function has complete description including example or only some syntax info - if it's in it's "good".

IMHO it would make the help less useful if we start to add also functions that may or may not work, do things not expected or simply need complete re-design to do anything ...

Of course I'll keep all your doc headers, just reset those to #nodoc# which had this tag before AND where no example is available. Maybe you have some time to do examples for them? It's the best way to check if functions not used in the "big" examples are ready for the help. And your examples are perfect for help: showing short and concise what it's about!

Not too relevant for 2D include, but definetly for other functions: Please have also an eye on parameter lists for added functions - Frank Dodd's original reference is not very accurate/up-to-date sometimes - descriptions of particle functions for example sometimes miss MOST of its parameters, sometimes descriptions are not correct ...

Lot of words - but think this general rule is the best to provide a help for au3Irr2 everybody can rely to: "if in, you can use it, if not but in the UDF, it MAY work but be aware: it's not "official" "

Hope you will continue to help completing the help with your good contributions, so we'll have much more "official" over the time;)

Link to comment
Share on other sites

Hi,

Yep I'll continue in my spare time to go through the includes and try for better info about functions.

I'll keep working on the 2D include in the meantime, for a more complete header info (based on what you've said) and where needed try to give an example.

I mainly stopped and posted what I had done to check whether to continue along the line I was going, hence only 3 little 2D help file examples.

As I said I'd also like to see the Returns not revolve around a Gloabal $return, try to make Global $return redundant in the near future.

I've already done the returns only (not changed No Doc header or completed info and examples), for au3Irr2_Scene.au3 and au3Irr2_System.au3, they no longer need the Global $result for return, can post those if you like.

As for the Beam Example I honestly wouldn't replace the original due to the original is easy to understand and will have user firing a laser beam from a gun, spaceship or whatever in there game in no time.

Where as my toyed with example will only add confusion, but with that said I will add commenting to what the beam mod I did in the near future.

Cheers

Link to comment
Share on other sites

Yep I'll continue in my spare time to go through the includes ...

... you are the best ;) There are also two not-converted examples around 2D I haven't converted yet (039 + 70), so if you like (if so, I can send you pre-converted files)?

Nothing against "cleaner" UDF by changing $results and returns - we'll just have to make sure not to disturb each other. So better if you wait some days and do this on coming 2.04.

And you are right - changing the original examples is a on the one hand-on the other hand-thing: sometimes not very "funky", but (mostly) perfect for their purpose; showing how to use features in general. So they stay as they are. Maybe we can set up an adcanced section for those nice little toys someday inside the project's wiki, we'll see ...

Link to comment
Share on other sites

Hi,

Are the 2 not converted files from IrrlichtWrapper SDK (39_Example_Texture_Blending.bas and 70_Example_Texture_and_Images.bas)?

If so I have them and I'll look into them shortly.

Get those done then you have an example for Lock and Unlock texture/image ;)

On another note, I sorta drifted into a non working incomplete function in "au3Irr2_Terrain.au3" while I was amending the Global $result returns.

Couldn't help myself and I ended up giving the function a poke with a stick and it came to life..lol

I've got the function returning without error, but the returns I have no idea how to test they are correct.

Since you seem quite adept with vectors and angles I'll leave it for you to have a look and evaluate.

The function is _IrrGetSphericalTerrainSurfacePosition()

I tested with 065_Example_Sphere_Terrain.au3 and seems it returns ok

; #NO_DOC_FUNCTION# =============================================================================================================
; Name...........: _IrrGetSphericalTerrainSurfacePosition
; Description ...: Get the surface position of a logical point on the terrain.
; Syntax.........: _IrrGetSphericalTerrainSurfacePosition($h_Terrain, $i_Face, $f_LogicalX, $f_LogicalZ)
; Parameters ....: $h_Terrain - Handle to a Spherical Terrain object as returned by _IrrAddSphericalTerrain function
;                  $i_Face - Integer value of a Face to calculate for.
;                  $f_LogicalX - Float value for Logical X position.
;                  $f_LogicalZ - Float value for Logical Z position.
; Return values .: Success - 1D Array with the returned values
;                  |$Array[0] = X float value
;                  |$Array[1] = Y float value
;                  |$Array[2] = Z float value
;                  Failure - False and set @error 1
; Author ........: [todo]
; Modified.......:
; Remarks .......: You supply a face number and a logical X, Y position on that face and this call will return the height of that point on the terrain sphere.
;                  X, Y, Z is returned in a 1D Array.
;                  Note: By subtracting the center of the sphere from this co-ordinate and converting this vector to angles you can find the upward direction of the point on the surface.
; Related .......: _IrrAddSphericalTerrain
; Link ..........:
; Example .......: [todo: Yes, No]
; ===============================================================================================================================
Func _IrrGetSphericalTerrainSurfacePosition($h_Terrain, $i_Face, $f_LogicalX, $f_LogicalZ)
    Local $aResult, $aReturn[3]
    $aResult = DllCall($_irrDll, "none:cdecl", "IrrGetSphericalTerrainSurfacePosition", "ptr", $h_Terrain, "int", $i_Face, "float", $f_LogicalX, "float", $f_LogicalZ, "float*", 0, "float*", 0, "float*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 0, False)
    For $i = 0 To 2
        $aReturn[$i] = $aResult[$i + 5]
    Next
    Return SetError(0, 0, $aReturn)
EndFunc   ;==>_IrrGetSphericalTerrainSurfacePosition

;This was the function before I poked it with a stick.
;~ ; #NO_DOC_FUNCTION# =============================================================================================================
;~ ; Name...........: _IrrGetSphericalTerrainSurfacePosition
;~ ; Description ...: [todo]
;~ ; Syntax.........: _IrrGetSphericalTerrainSurfacePosition($h_Terrain, $i_Face, $f_LogicalX, $f_LogicalY, $f_LogicalZ)
;~ ; Parameters ....: [param1] - [explanation]
;~ ;                  |[moreTextForParam1]
;~ ;                  [param2] - [explanation]
;~ ; Return values .: [success] - [explanation]
;~ ;                  [failure] - [explanation]
;~ ;                  |[moreExplanationIndented]
;~ ; Author ........: [todo]
;~ ; Modified.......:
;~ ; Remarks .......: [todo]
;~ ; Related .......: [todo: functionName, functionName]
;~ ; Link ..........:
;~ ; Example .......: [todo: Yes, No]
;~ ; ===============================================================================================================================
;~ Func _IrrGetSphericalTerrainSurfacePosition($h_Terrain, $i_Face, $f_LogicalX, $f_LogicalY, $f_LogicalZ)
;~  Local $X = DllStructCreate("float")
;~  Local $Y = DllStructCreate("float")
;~  Local $Z = DllStructCreate("float")
;~  DllCall($_irrDll, "none:cdecl", "IrrGetSphericalTerrainSurfacePosition", "ptr", $h_Terrain, "int", $i_Face, "float", $f_LogicalX, "float", $f_LogicalY, "float", $f_LogicalZ, "float*", DllStructGetPtr($X), "float*", DllStructGetPtr($Y), "float*", DllStructGetPtr($Z))
;~  Local $result[3] = [DllStructGetData($X, 1), DllStructGetData($Y, 1), DllStructGetData($Z, 1)]
;~ EndFunc   ;==>_IrrGetSphericalTerrainSurfacePosition

Let me know cause there's another 2 of them that need poking with a stick.

Edited by smashly
Link to comment
Share on other sites

Hi,

Are the 2 not converted files from IrrlichtWrapper SDK (39_Example_Texture_Blending.bas and 70_Example_Texture_and_Images.bas)?

If so I have them and I'll look into them shortly.

Get those done then you have an example for Lock and Unlock texture/image ;)

Exactly - don't know if it's easy or need some tricky things (example are using pointers). But yes, when working those functions are "proven" :)

I'll have a look on the other things later (some "real" work to do before ;) )

Link to comment
Share on other sites

Hi,

Here's a working rough draft of 39_Example_Texture_Blending

#include "au3Irrlicht2.au3"

Opt("MustDeclareVars", 1)

;~ ;If your au3Irr2_Constants.au3 doesn't have these constants then enable them here
;~ Global Const $BLEND_SCREEN = 0
;~ Global Const $BLEND_ADD = 1
;~ Global Const $BLEND_SUBTRACT = 2
;~ Global Const $BLEND_MULTIPLY = 3
;~ Global Const $BLEND_BLEND_DIVIDE = 4

Global $hTextureA ;irr_texture
Global $hTextureB ;irr_texture
Global $hTextureC ;irr_texture
Global $hTextureD ;irr_texture
Global $pPixels ;ptr to pixels

Global $iTextureWidth = 128 ;Texture width
Global $iTextureHeight = 128 ;Texture height
Global $iPixelsAmount = $iTextureWidth * $iTextureHeight ; total ammount of pixels
Global $tPixels ;AutoIt DllStruct so we can edit our pixels

; Creating an Array of 4 Colors Red, Green, Blue, Black to use on one of our Created Textures
; The color format can be also be AARRGGBB eg: 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFF000000
; Either way seems to work
Global $aColor[4] = [16711680, 65280, 255, 0]
Global $iColorCount = 0

; Start the irrlicht interface
_IrrStart()

; Set the title of the display
_IrrSetWindowCaption("Example 39: Texture Blending")

; Create two new blank texture surface and load two pattern images from file
$hTextureA = _IrrCreateTexture("stripes", $iTextureWidth, $iTextureHeight, $ECF_A8R8G8B8)
$hTextureB = _IrrGetTexture("./media/Diagonal.bmp")
$hTextureC = _IrrGetTexture("./media/Cross.bmp")
$hTextureD = _IrrCreateTexture("merged", $iTextureWidth, $iTextureHeight, $ECF_A8R8G8B8)

; Get the pixels of one of the textures and write blocks of color into the image
$pPixels = _IrrLockTexture($hTextureA)

; We can access the locked pixels in this Dll struct
$tPixels = DllStructCreate("uint[" & $iPixelsAmount & "]", $pPixels)

; We go from the first pixel to the last pixel and set the colors as we go.
For $i = 1 To $iPixelsAmount

    ;We set each pixel in the $tPixels struct
    DllStructSetData($tPixels, 1, $aColor[$iColorCount], $i)

    ;Move to the next pixel in the $pPixels pointer
    $pPixels += 1

    ;We're creating 4 different colored horizontal stipes so when we hit 4096 (128 x 128 / 4 = 4096) we change the color.
    If Not Mod($i, $iPixelsAmount / 4) Then $iColorCount += 1
Next

;unlock $hTextureA now we have set the pixels to the color we want.
_IrrUnlockTexture($hTextureA)

; Pixel Struct no longer needed
$tPixels = 0

; Blend the two loaded textures onto the created surface
_IrrBlendTextures($hTextureD, $hTextureB, 0, 0, $BLEND_ADD)
_IrrBlendTextures($hTextureD, $hTextureC, 0, 0, $BLEND_SCREEN)

; while the scene is still running
While _IrrRunning()
    ; begin the scene, erasing the canvas to Yellow before rendering
    _IrrBeginScene(255, 255, 0)

    ; draw all of the images to the display
    _IrrDraw2DImage($hTextureA, 0, 0)
    _IrrDraw2DImage($hTextureB, $iTextureWidth, 0)
    _IrrDraw2DImage($hTextureC, 0, $iTextureHeight)
    _IrrDraw2DImage($hTextureD, $iTextureWidth, $iTextureHeight)

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

; Stop the irrlicht engine and release resources
_IrrStop()

Strange that the pixel struct seems to work with any struct data type as long as it's 32bit(4bytes)unsigned or signed ;)

So I used "uint" but not sure if I should use int, dword, ptr, ULONG ..etc

Any of them seem to work fine.

From the original .bas example I had to improvise on how to access the the pixel data from the pointer ..lol

Edited by smashly
Link to comment
Share on other sites

Really nice gfx stuff I must say with great examples.;)

Most of the examples probably not possible with GDI+...

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Hi,

And here's a rough working draft of 70_Example_Texture_and_Images

#include "au3Irrlicht2.au3"

Opt("MustDeclareVars", 1)

Global $hCreatedTexture ;irr_texture
Global $hCreatedImage ;irr_image
Global $hLoadedImage ;irr_image
Global $pPixelsDestination ; ptr
Global $pPixelsSource ;ptr to pixels
Global $tPixelsDestination ;AutoIt DllStruct so we can edit our destination pixels
Global $tPixelsSource ;AutoIt DllStruct so we can access our source pixels

Global $iTextureWidth = 256 ;Texture width
Global $iTextureHeight = 256 ;Texture height
Global $iPixelsAmount = $iTextureWidth * $iTextureHeight ; total ammount of pixels


; Start the irrlicht interface
_IrrStart()

; Set the title of the display
_IrrSetWindowCaption("Example 70: Copying between Textures and Images")

; Create two new blank texture surface and load two pattern images from file
$hLoadedImage = _IrrGetImage("./media/splatter.tga")
$hCreatedImage = _IrrCreateImage($iTextureWidth, $iTextureHeight, $ECF_A8R8G8B8)
$hCreatedTexture = _IrrCreateTexture("NewTexture", 256, 256, $ECF_A8R8G8B8)

; First copy the loaded image into the created image.
; Lock the two images gaining pointers that access their pixels.
$pPixelsSource = _IrrLockImage($hLoadedImage)
$pPixelsDestination = _IrrLockImage($hCreatedImage)

; We can access the locked pixels in these Dll structs
$tPixelsSource = DllStructCreate("uint[" & $iPixelsAmount & "]", $pPixelsSource)
$tPixelsDestination = DllStructCreate("uint[" & $iPixelsAmount & "]", $pPixelsDestination)

; copy the data between the two, in ECF_A8R8G8B8 format there are 4 bytes per
; pixel a byte for alpha red, green and blue our unsigned integer pointers can
; copy a pixel in one operation, in a 256 x 256 image there are 65,536 pixels
; so we repeat the operation that number of times copying all the pixels from
; one image to another
For $i = 1 To $iPixelsAmount

    ;Set each pixel in the $tPixelsDestination struct with the corresponding pixel from the $tPixelsSource struct
    DllStructSetData($tPixelsDestination, 1, DllStructGetData($tPixelsSource, 1, $i), $i)

    ;Move to the next pixel in the $pPixelsSource and $pPixelsDestination pointers
    $pPixelsSource += 1
    $pPixelsDestination += 1
Next

;unlock $hCreatedImage and $hLoadedImage now we have copied the pixels.
_IrrUnlockImage($hCreatedImage)
_IrrUnlockImage($hLoadedImage)

; Source and Desination Pixel Structs no longer needed
$tPixelsDestination = 0
$tPixelsSource = 0

; secondly copy the created image into the created texture
$pPixelsSource = _IrrLockImage($hCreatedImage)
$pPixelsDestination = _IrrLockTexture($hCreatedTexture)

;once again we create source and destination stuct for the final copy to the texture
$tPixelsSource = DllStructCreate("uint[" & $iPixelsAmount & "]", $pPixelsSource)
$tPixelsDestination = DllStructCreate("uint[" & $iPixelsAmount & "]", $pPixelsDestination)

For $i = 1 To $iPixelsAmount

    ;Set each pixel in the $tPixelsDestination struct with the corresponding pixel from the $tPixelsSource struct
    DllStructSetData($tPixelsDestination, 1, DllStructGetData($tPixelsSource, 1, $i), $i)

    ;Move to the next pixel in the $pPixelsSource and $pPixelsDestination pointers
    $pPixelsSource += 1
    $pPixelsDestination += 1
Next

; Unlock the $hCreatedTexture and $hCreatedImage.
_IrrUnlockTexture($hCreatedTexture)
_IrrUnlockImage($hCreatedImage)

; For the last time clear the no longer needed Pixel Structs
$tPixelsDestination = 0
$tPixelsSource = 0


; while the scene is still running
While _IrrRunning() And Sleep(10)
    ; begin the scene, erasing the canvas to Yellow before rendering
    _IrrBeginScene(255, 255, 0)

    ; draw the newly created texture to the display
    _IrrDraw2DImage($hCreatedTexture, 0, 0)

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

; Stop the irrlicht engine and release resources
_IrrStop()

Note if your using that modified version of au3Irr2_2D.au3 I posted then you'll need to correct the Return of IrrGetImage() function.

The final line in the function is Return SetError(0, 0, $aResult)

It should be Return SetError(0, 0, $aResult[0])

Cheers

PS: I know one thing you wouldn't want to be doing big textures this way at runtime of a script.. Autoit and big loops is damn slow..lol

Edited by smashly
Link to comment
Share on other sites

Hi,

Just some more completed and working functions for au3Irr2_Scene.au3

These are the 7 Billboard Group functions, modded the code from "103_Example_Billboard_Groups.bas" to use all the new functions ;)

#include "au3Irrlicht2.au3"

Opt("MustDeclareVars", 1)

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

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

; Global constants for setting the state of node visibility
Global Const $IRR_INVISIBLE = 0
Global Const $IRR_VISIBLE = 1

; Particle (Billboards) controls
Global $PARTICLE_COUNT = 5
Global $PARTICLE_LAYERS = 15
Global $SPACING = 75.0
Global $SCALE = 100.0
Global $CAMERA_SPEED = 0.1

; irrlicht objects
Global $hBillboardGroup ;irr_node
Global $hBillboardTexture ;irr_texture
Global $hSun ;irr_node
Global $hCamera ;irr_camera
Global $iTotalParticales = $PARTICLE_COUNT * $PARTICLE_LAYERS ; how many cloud billboards (Particles)
Global $aBillboard[$iTotalParticales + 1] ;array of handles to billboards (particles) in the billboard group
Global $hSkybox
Global $hMoon

; variables for setting up the billboard group
Global $fFactor, $fX, $fY, $fZ, $iSmall, $iBig
Global $currentTime


; Personal Note: I'm testing this on an old P4 3Ghz, w/ Intel 865 onboard graphics (that doesn't support much) in XP x86..
; $IRR_EDT_OPENGL sux on this old PC, low fps, random distant flickering textures, skybox seams have a big striped lines where they meet top an bottom... etc
; $IRR_EDT_DIRECT3D9 appears to reduce the random flickering textures and skybox seams displays nicely for me.

; start the irrlicht interface
_IrrStart($IRR_EDT_DIRECT3D9, 640, 480, $IRR_BITS_PER_PIXEL_32, _
        $IRR_WINDOWED, $IRR_SHADOWS, $IRR_IGNORE_EVENTS, $IRR_VERTICAL_SYNC_ON)

; add a skybox with a space theme to the scene as a backdrop
$hSkybox = _IrrAddSkyBoxToScene( _
        _IrrGetTexture("./media/starbox1.jpg"), _
        _IrrGetTexture("./media/starbox1.jpg"), _
        _IrrGetTexture("./media/starbox1.jpg"), _
        _IrrGetTexture("./media/starbox1.jpg"), _
        _IrrGetTexture("./media/starbox1.jpg"), _
        _IrrGetTexture("./media/starbox1.jpg"))

; Create a billboard representing the Sun
; load the texture resource for the billboard
$hBillboardTexture = _IrrGetTexture("./media/sun.tga")

; add the billboard to the scene
$hSun = _IrrAddBillBoardToScene(256.0, 256.0, 0.0, 0.0, 998.0)

; now we apply the loaded texture to the billboard using node material index 0
_IrrSetNodeMaterialTexture($hSun, $hBillboardTexture, 0)

; hide transparent areas
_IrrSetNodeMaterialFlag($hSun, $IRR_EMF_LIGHTING, $IRR_OFF)
_IrrSetNodeMaterialType($hSun, $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL)

; Create a billboard representing the Moon
; load the texture resource for the billboard
$hBillboardTexture = _IrrGetTexture("./media/moon.tga")

; add the billboard to the scene
$hMoon = _IrrAddBillBoardToScene(20.0, 20.0, 0.0, 0.0, 1200.0)

; now we apply the loaded texture to the billboard using node material index 0
_IrrSetNodeMaterialFlag($hMoon, $IRR_EMF_LIGHTING, $IRR_OFF)
_IrrSetNodeMaterialTexture($hMoon, $hBillboardTexture, 0)

; hide transparent areas
_IrrSetNodeMaterialType($hMoon, $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL_REF)

; make the moon orbit the sun
_IrrAddFlyCircleAnimator($hMoon, 0.0, 0.0, 1000.0, 800.0, 0.0001)

; load the texture resource for the billboard
$hBillboardTexture = _IrrGetTexture("./media/cloudtest.bmp")

; add a billboard group to the scene
$hBillboardGroup = _IrrAddBillBoardGroupToScene()

; add billboards to the billBoard group
For $j = 1 To $PARTICLE_LAYERS
    For $i = 1 To $PARTICLE_COUNT

        ; Generate a random co-ordinate in a cube
        $fX = Random(-5.0, 5.0)
        $fY = Random(-5.0, 5.0)
        $fZ = Random(-5.0, 5.0)

        ; normalise the co-ordinate. this scales the x,y,z so they are
        ; exactly a distance of 1 * SCALE from origin and when they are
        ; all the same distance they appear as points on a sphere
        $fFactor = 1 / Sqrt($fX * $fX + $fY * $fY + $fZ * $fZ)
        $fX *= $fFactor * $SPACING * $j
        $fY *= $fFactor * $SPACING * $j
        $fZ *= $fFactor * $SPACING * $j

        ; calculate a couple of color values
        $iSmall = (255 / $PARTICLE_LAYERS) * $j / 3
        $iBig = (255 / $PARTICLE_LAYERS) * $j

        ; the particle can be one of two colors to add some tone to the cloud
        Switch Mod($i, 2)
            Case 0 ;Change this to any number other then 0 or 1 (eg: 3) if you would like to see _IrrAddBillBoardByAxisToGroup clouds only.

                ; add a billboard to the group. the parameters are as follows: -
                ; The billboard group node
                ; the X,Y scale of the billboard
                ; X,Y,Z co-ordinates for the billboard
                ; a roll for the billboard that allows each billboard to be rotated
                ; A,R,G,B color values
                $aBillboard[($i + ($j - 1) * $PARTICLE_COUNT)] = _IrrAddBillBoardToGroup($hBillboardGroup, _
                        15.0 * $SCALE - 3.0 * $SCALE * $j, 15.0 * $SCALE - 3.0 * $SCALE * $j, _
                        $fX, $fY, $fZ, _
                        0.0, _
                        255, 255 - $iBig, 255, 255 - $iSmall)
            Case 1

                ; we are adding these By Axis (just to show the _IrrAddBillBoardByAxisToGroup function works);
                ; Same as above but with 3 more parameters X,Y,Z Axis of the billboard
                ; this billboard is slightly bigger and more yellow with Y axis set to 1.0
                $aBillboard[($i + ($j - 1) * $PARTICLE_COUNT)] = _IrrAddBillBoardByAxisToGroup($hBillboardGroup, _
                        20.0 * $SCALE - 3.0 * $SCALE * $j, 20.0 * $SCALE - 3.0 * $SCALE * $j, _
                        $fX, $fY, $fZ, _
                        0.0, _
                        255, 255 - $iSmall, 255, 255 - $iBig, _
                        0.0, 1.0, 0.0)
        EndSwitch
    Next
Next

; just move the particles forward so we can have a good look at them
_IrrSetNodePosition($hBillboardGroup, 0.0, 0.0, 1000.0)

; this can be used to apply a graduated shading to billboards color.
_IrrBillBoardGroupShadows($hBillboardGroup, 1, 0, 0, 1.0, 0.2)

; apply the loaded texture to the billboard group using node material index 0
_IrrSetNodeMaterialTexture($hBillboardGroup, $hBillboardTexture, 0)

; disabling lighting
_IrrSetNodeMaterialFlag($hBillboardGroup, $IRR_EMF_LIGHTING, $IRR_OFF)

; layer the colour upon what is already there (works well for clouds)
_IrrSetNodeMaterialType($hBillboardGroup, $IRR_EMT_TRANSPARENT_ADD_COLOR)

; add a first person perspective camera into the scene so we can move around
; the billboard and see how it reacts
$hCamera = _IrrAddFPSCamera($IRR_NO_OBJECT, 100.0, $CAMERA_SPEED)
_IrrSetCameraClipDistance($hCamera, 128000)

; hide the mouse pointer
_IrrHideMouse()

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

    ; removing 1 billboard from the billboard group every second
    If TimerDiff($currentTime) >= 1000 And $iTotalParticales > 0 Then
        _IrrRemoveBillBoardFromGroup($hBillboardGroup, $aBillboard[$iTotalParticales])
        $iTotalParticales -= 1
        $currentTime = TimerInit()

        ; This forces the billboard group to update their orientation, in this example it's not really needed.
        ; It's only here show that it works without error.
        ; It would be more beneficial to use when you have a camera that is movining around in a scene.
        ; Force Update would make the billboards point to the camera once more.
        _IrrBillBoardForceUpdate($hBillboardGroup)
    EndIf

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

    ; Change the title to show how many Cloud billboards and the frame rate
    _IrrSetWindowCaption("Example 103: Billboard groups - Clouds: " & _IrrGetBillBoardGroupCount($hBillboardGroup) & " - FPS: " & _IrrGetFPS())

    ; we are drawing in two passes first the sun, moon and sky
    _IrrSetNodeVisibility($hBillboardGroup, $IRR_INVISIBLE)
    _IrrSetNodeVisibility($hSun, $IRR_VISIBLE)
    _IrrSetNodeVisibility($hMoon, $IRR_VISIBLE)
    _IrrSetNodeVisibility($hSkybox, $IRR_VISIBLE)

    ; draw the scene
    _IrrDrawScene()

    ; on the second pass we are just drawing the clouds. by doing this we
    ; ensure that if billboards get in front of the clouds origin but are
    ; still IN the clouds they are still covered by cloud
    _IrrSetNodeVisibility($hBillboardGroup, $IRR_VISIBLE)
    _IrrSetNodeVisibility($hSun, $IRR_VISIBLE)
    _IrrSetNodeVisibility($hMoon, $IRR_VISIBLE)
    _IrrSetNodeVisibility($hSkybox, $IRR_VISIBLE)

    ; draw the scene
    _IrrDrawScene()

    ; end drawing the scene and render it
    _IrrEndScene()

WEnd

; Stop the irrlicht engine and release resources
_IrrStop()


;----> New Group Billboard functions to add to au3Irr2_Scene.au3 ... w00t :D

; #FUNCTION# =============================================================================================================
; Name...........: _IrrAddBillBoardGroupToScene
; Description ...: Adds a billboard group to the scene.
; Syntax.........: _IrrAddBillBoardGroupToScene()
; Parameters ....: None.
; Return values .: Success - Handle to an irr node object.
;                  Failure - False and @error 1
; Author ........:
; Modified.......:
; Remarks .......: This is a special object that can have billboard like objects added and removed from it and rendered in a very quick an efficient manner.
;                  They are all treated as a single object rather than as many individual nodes. This is particuallarly useful for custom particle effects.
; Related .......: _IrrAddBillBoardToGroup, _IrrRemoveBillBoardFromGroup, _IrrAddBillBoardByAxisToGroup, _IrrGetBillBoardGroupCount, IrrBillBoardGroupShadows, , _IrrBillBoardForceUpdate
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrAddBillBoardGroupToScene()
    ; In the wrapper reference docs this function doesn't have any params.
    ; Looking at the source of the wrapper, I can see this function call takes 5 paramaters..
    ; When you see what the function call is doing, it doesn't actually use the parameters at all.
    ; I still pass the 5 params as 0 so the function will proceed without error
    Local $aResult
    $aResult = DllCall($_irrDll, "ptr:cdecl", "IrrAddBillBoardGroupToScene", "float", 0, "float", 0, "float", 0, "float", 0, "float", 0)
    If @error Or Not $aResult[0] Then Return SetError(1, 0, False)
    Return SetError(0, 0, $aResult[0])
EndFunc   ;==>_IrrAddBillBoardGroupToScene


; #FUNCTION# =============================================================================================================
; Name...........: _IrrAddBillBoardToGroup
; Description ...: Adds a billboard to a billboard group. There are a number of properties that are used to specify the billboard
; Syntax.........: _IrrAddBillBoardToGroup($h_BillboardGroup, $f_XSize, $f_YSize, $f_XPos, $f_YPos, $f_ZPos, $f_Roll, $u_Alpha, $u_Red , $u_Green, $u_Blue)
; Parameters ....: $h_BillboardGroup - Handle to the Billboard Group as returned by _IrrAddBillBoardGroupToScene
;                  $f_XSize - Width of the billboard
;                  $f_YSize - Height of the billboard
;                  $f_XPos - X position of the billboard
;                  $f_YPos - Y position of the billboard
;                  $f_ZPos - Z position of the billboard
;                  $f_Roll - Specifies the number of degrees that the billboard is spun around its center
;                  $u_Alpha - Alpha color used for the billboard 0 - 255
;                  $u_Red - Red color used for the billboard 0 - 255
;                  $u_Green - Green color used for the billboard 0 - 255
;                  $u_Blue - Blue color used for the billboard 0 - 255
; Return values .: Success - Handle to the billbord scene node address in the billbord group
;                  Failure - False and @error 1
; Author ........:
; Modified.......:
; Remarks .......: None
; Related .......: _IrrAddBillBoardGroupToScene, _IrrRemoveBillBoardFromGroup, _IrrGetBillBoardGroupCount, _IrrAddBillBoardByAxisToGroup, _IrrBillBoardForceUpdate
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrAddBillBoardToGroup($h_BillboardGroup, $f_XSize, $f_YSize, $f_XPos, $f_YPos, $f_ZPos, $f_Roll, $u_Alpha, $u_Red, $u_Green, $u_Blue)
    Local $aResult
    $aResult = DllCall($_irrDll, "ptr:cdecl", "IrrAddBillBoardToGroup", "ptr", $h_BillboardGroup, "float", $f_XSize, "float", $f_YSize, "float", $f_XPos, "float", $f_YPos, "float", $f_ZPos, _
            "float", $f_Roll, "uint", $u_Alpha, "uint", $u_Red, "uint", $u_Green, "uint", $u_Blue)
    If @error Or Not $aResult[0] Then Return SetError(1, 0, False)
    Return SetError(0, 0, $aResult[0])
EndFunc   ;==>_IrrAddBillBoardToGroup

; #FUNCTION# =============================================================================================================
; Name...........: _IrrAddBillBoardByAxisToGroup
; Description ...: Adds a billboard to a billboard group that is fixed to a particular axis.
; Syntax.........: _IrrAddBillBoardByAxisToGroup($h_BillboardGroup, $f_XSize, $f_YSize, $f_XPos, $f_YPos, $f_ZPos, $f_Roll, $u_Alpha, $u_Red , $u_Green, $u_Blue, $f_XAxis, $f_YAxis, $f_ZAxis)
; Parameters ....: $h_BillboardGroup - Handle to the Billboard Group as returned by _IrrAddBillBoardGroupToScene
;                  $f_XSize - Width of the billboard
;                  $f_YSize - Height of the billboard
;                  $f_XPos - X position of the billboard
;                  $f_YPos - Y position of the billboard
;                  $f_ZPos - Z position of the billboard
;                  $f_Roll - Specifies the number of degrees that the billboard is spun around its center
;                  $u_Alpha - Alpha color used for the billboard 0 - 255
;                  $u_Red - Red color used for the billboard 0 - 255
;                  $u_Green - Green color used for the billboard 0 - 255
;                  $u_Blue - Blue color used for the billboard 0 - 255
;                  $f_XAxis - X direction around which the billboard is spun to face the camera.
;                  $f_YAxis - Y direction around which the billboard is spun to face the camera.
;                  $f_ZAxis - Z direction around which the billboard is spun to face the camera
; Return values .: Success - Handle to the billbord scene node address in the billbord group
;                  Failure - False and @error 1
; Author ........:
; Modified.......:
; Remarks .......: These billboards are particularly useful for things like grass..There are a number of properties that are used to specify the billboard.
; Related .......: _IrrAddBillBoardGroupToScene, _IrrRemoveBillBoardFromGroup, _IrrGetBillBoardGroupCount, _IrrBillBoardForceUpdate
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrAddBillBoardByAxisToGroup($h_BillboardGroup, $f_XSize, $f_YSize, $f_XPos, $f_YPos, $f_ZPos, $f_Roll, $u_Alpha, $u_Red, $u_Green, $u_Blue, $f_XAxis, $f_YAxis, $f_ZAxis)
    Local $aResult
    $aResult = DllCall($_irrDll, "ptr:cdecl", "IrrAddBillBoardByAxisToGroup", "ptr", $h_BillboardGroup, _
            "float", $f_XSize, "float", $f_YSize, _
            "float", $f_XPos, "float", $f_YPos, "float", $f_ZPos, "float", $f_Roll, _
            "uint", $u_Alpha, "uint", $u_Red, "uint", $u_Green, "uint", $u_Blue, _
            "float", $f_XAxis, "float", $f_YAxis, "float", $f_ZAxis)
    If @error Or Not $aResult[0] Then Return SetError(1, 0, False)
    Return SetError(0, 0, $aResult[0])
EndFunc   ;==>_IrrAddBillBoardByAxisToGroup


; #FUNCTION# =============================================================================================================
; Name...........: _IrrRemoveBillBoardFromGroup
; Description ...: Removes the specified billboard from the billboard group.
; Syntax.........: _IrrRemoveBillBoardFromGroup($h_BillboardGroup, $h_BillboardGroupSceneNode)
; Parameters ....: $h_BillboardGroup - Handle to the Billboard Group as returned by _IrrAddBillBoardGroupToScene
;                  $h_BillboardGroupSceneNode - Handle to the billbord scene node address in the billbord group as returned by _IrrAddBillBoardToGroup
; Return values .: Success - True
;                  Failure - False
; Author ........:
; Modified.......:
; Remarks .......:
; Related .......: _IrrAddBillBoardGroupToScene, _IrrAddBillBoardToGroup
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrRemoveBillBoardFromGroup($h_BillboardGroup, $h_BillboardGroupSceneNode)
    DllCall($_irrDll, "none:cdecl", "IrrRemoveBillBoardFromGroup", "ptr", $h_BillboardGroup, "ptr", $h_BillboardGroupSceneNode)
    Return SetError(@error, 0, @error = 0)
EndFunc   ;==>_IrrRemoveBillBoardFromGroup


; #FUNCTION# =============================================================================================================
; Name...........: _IrrBillBoardGroupShadows
; Description ...: Applies lighting to the billboards in a cluster of billboards.
; Syntax.........: _IrrBillBoardGroupShadows($h_BillboardGroup, $f_X, $f_Y, $f_Z, $f_Intensity, $f_Ambient)
; Parameters ....: $h_BillboardGroup - Handle to the Billboard Group as returned by _IrrAddBillBoardGroupToScene
;                  $f_X - X direction from which the light is arriving.
;                  $f_Y - Y direction from which the light is arriving.
;                  $f_Z - Z direction from which the light is arriving.
;                  $f_Intensity - Strength of the light
;                  $f_Ambient - Strength of ambient light in the billboard group
; Return values .: Success - True
;                  Failure - False
; Author ........:
; Modified.......:
; Remarks .......: This can be used for example to shade the particles in a group of billboards representing a cloud.
; Related .......: _IrrAddBillBoardGroupToScene, _IrrAddBillBoardToGroup
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrBillBoardGroupShadows($h_BillboardGroup, $f_X, $f_Y, $f_Z, $f_Intensity, $f_Ambient)
    DllCall($_irrDll, "none:cdecl", "IrrBillBoardGroupShadows", "ptr", $h_BillboardGroup, "float", $f_X, "float", $f_Y, "float", $f_Z, "float", $f_Intensity, "float", $f_Ambient)
    Return SetError(@error, 0, @error = 0)
EndFunc   ;==>_IrrBillBoardGroupShadows


; #FUNCTION# =============================================================================================================
; Name...........: _IrrGetBillBoardGroupCount
; Description ...: Get the number of billboards in the billboard group.
; Syntax.........: _IrrGetBillBoardGroupCount($h_BillboardGroup)
; Parameters ....: $h_BillboardGroup - Handle to the Billboard Group as returned by _IrrAddBillBoardGroupToScene
; Return values .: Success - The number of billboards in the billboard group
;                  Failure - False and @error 1
; Author ........:
; Modified.......:
; Remarks .......:
; Related .......: _IrrAddBillBoardGroupToScene, _IrrAddBillBoardToGroup, _IrrRemoveBillBoardFromGroup
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrGetBillBoardGroupCount($h_BillboardGroup)
    Local $aResult
    $aResult = DllCall($_irrDll, "int:cdecl", "IrrGetBillBoardGroupCount", "ptr", $h_BillboardGroup)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 0, False)
    Return SetError(0, 0, $aResult[0])
EndFunc   ;==>_IrrGetBillBoardGroupCount

; #FUNCTION# =============================================================================================================
; Name...........: _IrrBillBoardForceUpdate
; Description ...: Force the billboard group update the scene. (see remarks for further explanation)
; Syntax.........: _IrrBillBoardForceUpdate($h_BillboardGroup)
; Parameters ....: $h_BillboardGroup - Handle to the Billboard Group as returned by _IrrAddBillBoardGroupToScene
; Return values .: Success - True
;                  Failure - False
; Author ........:
; Modified.......:
; Remarks .......: Unlike regular billboards the billboard group does not always update the orientation of the billboards every frame.
;                  If you are a long distance away from the billboard group the camera needs to travel a significant distance before the
;                  angle has changed enough to warrent an update of all of the billboards verticies to make them point to the camera once more.
;                  You may want to force a refresh at some point with this call.
; Related .......: _IrrAddBillBoardGroupToScene, _IrrAddBillBoardToGroup, _IrrAddBillBoardByAxisToGroup, _IrrRemoveBillBoardFromGroup
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _IrrBillBoardForceUpdate($h_BillboardGroup)
    DllCall($_irrDll, "none:cdecl", "IrrBillBoardForceUpdate", "ptr", $h_BillboardGroup)
    Return SetError(@error, 0, @error = 0)
EndFunc   ;==>_IrrBillBoardForceUpdate

Cheers

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

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...