Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Au3Irrlicht 2.0


  • Please log in to reply
439 replies to this topic

#1 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 03 May 2010 - 06:48 AM

A.Percy built the first Au3Irrlicht by writing an AutoIt plugin wrapper around the object oriented 3D library called Irrlicht. He quickly encountered difficulties in handling arrays and other structures from the AutoIt side of things, which restricted the flexibility of the library. Since then, I've been looking for a solution that would allow us to utilize all the functionality of Irrlicht, without the restrictions imposed by plugins.

This is the result. Since 2006, Frank Dodd of the Freebasic community has been writing an Irrlicht wrapper for imperative languages. It started similar to Au3Irrlicht, but has one advantage - instead of plugin functions, we can use DllCall. That translates into unrestricted access of Irrlicht for AutoIt. There are 299 functions, and for the last several weeks I've been wrapping each with a DllCall for use by AutoIt.

Features Overview:
  • Mesh/Node: General Animation (bone based and mesh morphing), child/parent tree manipulation, Special animator types (circle, spline, flystraight)
  • Scene: Node management, Octtree, collision optimization, Save/Load using IrrEdit
  • 2D: Billboards, Sprites, RenderToTexture
  • Terrain: Tiled Terrain manager (paging terrains), Spherical Terrains, configurable LoD and zone manager
  • Environmental effects: Fog, Grass, Wind, Gravity, Water, Clouds, Skyboxes and Skydomes
  • Special Effects: Particles, Emitters, Mesh Emitters, Lens Flare, Advanced shaders, Dynamic lights and shadows
  • GUI: Image, EditBox, ListBox, Window, Text, IrrFonts
As of this release, 291 are wrapped. I will be recommending and/or implementing the unique functionality created by A.Percy for the IrrlichtWrapper.

Huge Thanks to A.Percy and all the rest who've made this possible! They've done amazing work, and I'm glad to have been able to use their work and experience to make this wrapper. This definitely exemplifies the idea of standing on the shoulders of giants. Thanks guys!

Download the code and examples here: http://code.google.com/p/au3irrlicht2/downloads/list
Let me know if you want to contribute and I will assign you as a contributor to the code project. Much thanks to Linus for his contributions and drive!

Edited by JRowe, 30 July 2010 - 04:38 AM.








#2 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 03 May 2010 - 06:55 AM

Add these examples to the same directory as the dlls and include.
Spaced at top and bottom so you can copy directly (don't have to use the popup if you don't want to.)

Hello World:
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc _IrrStart($IRR_EDT_OPENGL, 600, 600, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_IGNORE_EVENTS, $IRR_VERTICAL_SYNC_ON) _IrrSetWindowCaption("Example 01: Hello World") _IrrAddStaticText("Hello World", 40, 10, 200, 26, $IRR_GUI_BORDER, $IRR_GUI_NO_WRAP, 0) While _IrrRunning()     _IrrBeginScene(200,200,200)     _IrrDrawGUI()     _IrrEndScene() Wend


2D Images:
AutoIt         
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc $screen_width = 400 $screen_height = 200 _IrrStart($IRR_EDT_OPENGL, $screen_width, $screen_height, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_IGNORE_EVENTS) _IrrSetWindowCaption("Example 02: 2D Images") $IrrlichtLogo = _IrrGetTexture( "./media/irrlichtlogo.bmp" ) $FreeBasicLogo = _IrrGetTexture( "./media/freebasiclogo.bmp" ) $FBIDELogo = _IrrGetTexture( "./media/fbidelogo.bmp" ) $CodeBlocksLogo = _IrrGetTexture( "./media/codeblockslogo.bmp" ) $WrapperLogo = _IrrGetTexture( "./media/wrapperby.tga" ) _IrrColorKeyTexture($FreeBasicLogo, 255, 255, 255 ) WHILE _IrrRunning()     _IrrBeginScene( 255,255,0 )     _IrrDraw2DImage($IrrlichtLogo, 4, 4)     _IrrDraw2DImageElement($FreeBasicLogo, $screen_width-64, 4, 0, 0, 60, 31, $IRR_USE_ALPHA)     _IrrDraw2DImageElement($FBIDELogo, 4, $screen_height-36, 0, 0, 128, 32, $IRR_IGNORE_ALPHA)     _IrrDraw2DImageElement($WrapperLogo,($screen_width-110)/2, $screen_height-36, 0, 0, 100, 32, $IRR_USE_ALPHA)     _IrrDraw2DImageElement($CodeBlocksLogo, $screen_width-114, $screen_height-36, 0,0,110,32, $IRR_IGNORE_ALPHA )     _IrrEndScene() WEND


Irrlicht Bitmap Fonts:
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc _IrrStart($IRR_EDT_SOFTWARE, 400, 200, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_IGNORE_EVENTS) _IrrSetWindowCaption( "Example 03: Bitmap Fonts" ) $BitmapFont = _IrrGetFont("./media/bitmapfont.bmp") WHILE _IrrRunning()     _IrrBeginScene( 0,0,0 )     _Irr2DFontDraw($BitmapFont, "SIMPLE MONOCHROME FONT", 120, 80, 250, 96)     _IrrEndScene() WEND


3D Models - Meshes and Nodes:
AutoIt         
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc _IrrStart($IRR_EDT_OPENGL, 400, 200, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_SHADOWS, $IRR_IGNORE_EVENTS) _IrrSetWindowCaption("Example 04: 3D Models - Meshes and Nodes") _IrrAddStaticText("Zumlin model by Rowan 'Sumaleth' Crawford", 4, 0, 200, 16, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP) $MD2Mesh = _IrrGetMesh("./media/zumlin.md2") $MeshTexture = _IrrGetTexture("./media/zumlin.pcx") $SceneNode = _IrrAddMeshToScene($MD2Mesh) _IrrSetNodeMaterialTexture($SceneNode, $MeshTexture, 0) _IrrSetNodeMaterialFlag($SceneNode, $IRR_EMF_LIGHTING, $IRR_OFF) _IrrPlayNodeMD2Animation($SceneNode, $IRR_EMAT_STAND) $OurCamera = _IrrAddCamera(50, 0, 0, 0, 0, 0) WHILE _IrrRunning()     _IrrBeginScene(240, 255, 255)     _IrrDrawScene()     _IrrDrawGUI()     _IrrEndScene() WEND


BSP Map and Zip archive:
AutoIt         
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc _IrrStart($IRR_EDT_OPENGL, 800, 400, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_IGNORE_EVENTS) _IrrSetWindowCaption("Example 05: BSP Map") _IrrAddZipFile("./media/map-20kdm2.pk3", $IRR_IGNORE_CASE, $IRR_IGNORE_PATHS) $BSPMesh = _IrrGetMesh("20kdm2.bsp") $BSPNode = _IrrAddMeshToSceneAsOcttree($BSPMesh) $Camera = _IrrAddFPSCamera() $CameraNode = $Camera _IrrSetNodePosition($CameraNode, 1750, 149, 1369) _IrrSetNodeRotation($CameraNode, 4, -461.63, 0) _IrrHideMouse() WHILE _IrrRunning()     _IrrBeginScene(240, 255, 255)     _IrrDrawScene()     _IrrEndScene() WEND


Billboard nodes:
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc _IrrStart($IRR_EDT_OPENGL, 400, 200, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_SHADOWS, $IRR_IGNORE_EVENTS) _IrrSetWindowCaption("Example 06: Billboards") $BillboardTexture = _IrrGetTexture("./media/freebasiclogo_big.jpg") $Billboard = _IrrAddBillBoardToScene(200.0, 102, 0.0, 0.0, 100.0) _IrrSetNodeMaterialTexture($Billboard, $BillboardTexture, 0) _IrrSetNodeMaterialFlag($Billboard, $IRR_EMF_LIGHTING, $IRR_OFF) $Camera = _IrrAddFPSCamera() ;_IrrHideMouse() WHILE _IrrRunning()     _IrrBeginScene(240, 255, 255)     _IrrDrawScene()     _IrrEndScene() WEND


Particle system:
AutoIt         
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc _IrrStart($IRR_EDT_OPENGL, 200, 200, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_IGNORE_EVENTS) _IrrSetWindowCaption("Example 07: Particle Systems") $TestNode = _IrrAddTestSceneNode() $SmokeParticles = _IrrAddParticleSystemToScene($IRR_NO_EMITTER) $SmokeEmitter = ___CreateParticleEmitter(-7, 0, -7, 7, 1, 7, 0, 0.04, 0, 80, 100, 255, 255, 255, 255, 255, 255, 800, 2000, 15.0, 15.0, 15.0, 15.0, 15) _IrrAddParticleEmitter($SmokeParticles, $SmokeEmitter) _IrrAddFadeOutParticleAffector($SmokeParticles, 2000, 16, 8, 0) _IrrAddGravityParticleAffector($SmokeParticles, 0.05, 0.05, 0.0) _IrrAddParticleAttractionAffector($SmokeParticles, 10.0, 0.0, 0.0, 20.0, $IRR_REPEL) ;_IrrAddRotationAffector($SmokeParticles, 0.0, -120.0, 0.0, 0.0, 0.0, 0.0) $ParticleTexture = _IrrGetTexture("./media/ParticleGrey.bmp") _IrrSetNodeMaterialTexture($SmokeParticles, $ParticleTexture, 0) _IrrSetNodeMaterialFlag($SmokeParticles, $IRR_EMF_LIGHTING, $IRR_OFF) _IrrSetNodeMaterialType($SmokeParticles, $IRR_EMT_TRANSPARENT_VERTEX_ALPHA) $Camera = _IrrAddCamera(100, 40, 0, 0, 40, 0) WHILE _IrrRunning()     _IrrBeginScene(0, 0, 0)     _IrrDrawScene()     _IrrEndScene() WEND

Edited by JRowe, 05 May 2010 - 01:39 PM.


#3 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 03 May 2010 - 12:34 PM

Wow! Great job getting everything together into one package. I will definately want to explore this a bit more.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#4 corgano

corgano

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 844 posts

Posted 03 May 2010 - 05:52 PM

Just by chance, do you think this would support sketchup 3d models?
0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

#5 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 03 May 2010 - 06:08 PM

Irrlicht supports the following mesh types:

Animated objects:

  • B3D files (.b3d, r, skeleton)
  • Microsoft DirectX (.x, r) (binary & text, skeleton)
  • Milkshape (.ms3d, r, skeleton)
  • Quake 3 models (.md3, r, morph)
  • Quake 2 models (.md2, r, morph)
Static objects:

  • Irrlicht scenes (.irr, r/w)
  • Irrlicht static meshes (.irrmesh, r/w)
  • 3D Studio meshes (.3ds, r)
  • Alias Wavefront Maya (.obj, r/w)
  • Lightwave Objects (.lwo, r)
  • COLLADA 1.4 (.xml, .dae, r/w)
  • OGRE meshes (.mesh, r)
  • My3DTools 3 (.my3D, r)
  • Pulsar LMTools (.lmts, r)
  • Quake 3 levels (.bsp, r)
  • DeleD (.dmf, r)
  • FSRad oct (.oct, r)
  • Cartography shop 4 (.csm, r)
  • STL 3D files (.stl, r/w)
  • PLY 3D files (.ply, r/w)



Just by chance, do you think this would support sketchup 3d models?


Sketchup exports to the .dae collada format, so yes. :idea:

#6 corgano

corgano

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 844 posts

Posted 03 May 2010 - 06:28 PM

SWEET

Sketchup(pro) can export into .3ds, .dae, and .obj. I may just need to write a plugin to run a sketchup model form sketchup, so you can walk around like you would in a game......

<off topic> If anyone knows of a way to convert .skp files to any of those formats, please pm me</off topic>

I can't wait to start using this. i was excited when the last irrlicht udf came out, and thought it had been discontinued,,,,
0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

#7 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 6,243 posts

Posted 03 May 2010 - 06:58 PM

JRowe, could you explain the logic of your _IrrCreateMesh() function?
I can't find a sensible connection with what IrrlichtWrapper.dll (source) requires and what you're trying.
It looks that you need to pass arrays (if you want them) ByRef.
your $VerticesStruct is wrong. And $IndicesStruct is wrong too.

What am I missing? :idea:

          ......       ......
        .:oOOOOo:.   .:oOOOOo:.
      .:oOO:'':Oo:. .:oO:'':OOo:.
     .:oO:      'Oo:oO'      :Oo:.
     :oO:         'o'   
      :Oo:
     :oO:                     :Oo:
     ':oO:     OT9AO0IEDrk   :Oo:'
      ':oO:                 :Oo:'
        ':oO.             .Oo:'
          ':oO
.         .Oo:'
            ':oO.     .Oo:'
              ':oO. .Oo:'
                'oO:Oo'
                  'o' :kiss:



 

.
eMyvnE


#8 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 03 May 2010 - 07:11 PM

I was trying to pass two Struct arrays constructed from arrays passed to the function - I need to figure out what the relationship between the two arrays is. I know that the Vertices array is a 2D array containing a list of of x,y,z points, and the indices array somehow represents groups of 3 points.

I think I'd just copied from another function and filled in pseudo-values to try to get a grasp of how things would come together. I believe the correct struct would consist of something like this:

    $arrayOfVerticesStruct = DllStructCreate("ptr[" & $vSize & "])"         For $i = 1 To $vSize         $VerticesListEntry = DllStructCreate("float;float;float")         DllStructSetData($VerticesListEntry, 1, $a_Vertices[$i - 1][0])         DllStructSetData($VerticesListEntry, 2, $a_Vertices[$i - 1][1])         DllStructSetData($VerticesListEntry, 3, $a_Vertices[$i - 1][2])         $VerticesListEntryPtr = DllStructGetPtr($VerticesListEntry)         DllStructSetData($arrayOfVerticesStruct, $i, $VerticesListEntryPtr)     Next


A struct array of pointers to 3 valued structs filled in from an AutoIt array representing the vertices, or individual points of mesh.

From there, I need to figure out the relationship of the vertices to the indices, which is what's sticking in my craw, so to speak.

Edited by JRowe, 03 May 2010 - 07:12 PM.


#9 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 6,243 posts

Posted 03 May 2010 - 07:29 PM

You should write an example script that uses _IrrCreateMesh(). It doesn't matter that it wouldn't work at this stage. Just for others who might help you to actually get your ideas.
Btw, $VerticesStruct should be derived from this:
typedef struct tag_IRR_VERT {     float x;                // The x position of the vertex     float y;                // The y position of the vertex     float z;                // The z position of the vertex     float normal_x;         // The x normal of the vertex     float normal_y;         // The y normal of the vertex     float normal_z;         // The z normal of the vertex     unsigned int vcolor;     // The 32bit ARGB color of the vertex     float texture_x;        // the x co-ordinate of the vertex on the texture (0 to 1)     float texture_y;        // the y co-ordinate of the vertex on the texture (0 to 1) } IRR_VERT;
So, you are missing elements.

          ......       ......
        .:oOOOOo:.   .:oOOOOo:.
      .:oOO:'':Oo:. .:oO:'':OOo:.
     .:oO:      'Oo:oO'      :Oo:.
     :oO:         'o'   
      :Oo:
     :oO:                     :Oo:
     ':oO:     OT9AO0IEDrk   :Oo:'
      ':oO:                 :Oo:'
        ':oO.             .Oo:'
          ':oO
.         .Oo:'
            ':oO.     .Oo:'
              ':oO. .Oo:'
                'oO:Oo'
                  'o' :kiss:



 

.
eMyvnE


#10 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 03 May 2010 - 07:41 PM

The docs are a bit scattered on some things.

You must supply a list of vertices of type IRR_VECT

IrrVect is just a struct with 3 floats, so what i put together should be correct. I'm going to go through and rewrite the docs for AutoIt, since there are a few misleading things throughout.

Anyway, I'll put together a demo script sometime tonight - after I figure out how the function is supposed to work, too - I don't know how IrrCreateMesh is supposed to work right now.

Down at the very end of the UDF, I have 3 helper funcs that create the structs. One of them is the one you found:
Func ___CreateVertex($f_X, $f_Y, $f_Z, $f_NormalX, $f_NormalY, $f_NormalZ, $i_ARGB, $f_TextureX, $f_TextureY)     Local $VertexStruct = DllStructCreate("float;float;float;float;float;float;int;float;float")     DllStructSetData($VertexStruct, 1, $f_X)     DllStructSetData($VertexStruct, 2, $f_Y)     DllStructSetData($VertexStruct, 3, $f_Z)     DllStructSetData($VertexStruct, 4, $f_NormalX)     DllStructSetData($VertexStruct, 5, $f_NormalY)     DllStructSetData($VertexStruct, 6, $f_NormalZ)     DllStructSetData($VertexStruct, 7, $i_ARGB)     DllStructSetData($VertexStruct, 8, $f_TextureX)     DllStructSetData($VertexStruct, 9, $f_TextureY)     Return $VertexStruct EndFunc ;==>___CreateVertex


There's probably a lot of work left for some of these functions, but I think I got the major milestones taken care of.

Edited by JRowe, 03 May 2010 - 07:42 PM.


#11 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 05 May 2010 - 01:42 PM

I added the first 7 demos and the updated wrapper. This is Au3Irrlicht 2.0.1

I've added the enumerations to the top of the include. They're definitely not all there, but as I go through rewriting the demos, I'll keep adding - others are free to chip in, as well, most of it's easy work. :idea:

Note: The Particle system demo doesn't work. There are completely undocumented functions used in the demos, which I am working on listing and fixing. My free time lately has disappeared, so I've only been doing bits and pieces here and there. Feel free to experiment, and post the fixes if you get things working!

#12 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 6,243 posts

Posted 05 May 2010 - 02:02 PM

I added the first 7 demos and the updated wrapper. This is Au3Irrlicht 2.0.1

I've added the enumerations to the top of the include. They're definitely not all there, but as I go through rewriting the demos, I'll keep adding - others are free to chip in, as well, most of it's easy work. :idea:

Note: The Particle system demo doesn't work. There are completely undocumented functions used in the demos, which I am working on listing and fixing. My free time lately has disappeared, so I've only been doing bits and pieces here and there. Feel free to experiment, and post the fixes if you get things working!

You need to ask the author of the wrapper to recompile the dlls so that there wouldn't be MSVCblah.dll dependencies. Otherwise not many people would be able to run your examples.

Edited by trancexx, 05 May 2010 - 02:02 PM.

          ......       ......
        .:oOOOOo:.   .:oOOOOo:.
      .:oOO:'':Oo:. .:oO:'':OOo:.
     .:oO:      'Oo:oO'      :Oo:.
     :oO:         'o'   
      :Oo:
     :oO:                     :Oo:
     ':oO:     OT9AO0IEDrk   :Oo:'
      ':oO:                 :Oo:'
        ':oO.             .Oo:'
          ':oO
.         .Oo:'
            ':oO.     .Oo:'
              ':oO. .Oo:'
                'oO:Oo'
                  'o' :kiss:



 

.
eMyvnE


#13 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 05 May 2010 - 02:12 PM

I think that's what this is for. The documentation is outdated in some things, and since I don't see "IrrlichtWrapper_gcc.dll", I'm going to assume that IrrlichtWrapper.dll can use both the ms and gcc version?

Overview
IrrlichtWrapper is supplied with three sets of files. MSVC versions, GCC versions and Linux Versions. The default version of the files are those compiled with MSVC, these provide support for OpenGL, Direct X 8, Direct X 9 and software rendering. The GCC and Linux versions support both OpenGL and Software rendering.

GCC Compiler
To use the GCC DLLs you need to rename the supplied files: -

1. Rename Irrlicht.dll to Irrlicht_ms.dll
2. Rename IrrlichtWrapper.dll to IrrlichtWrapper_ms.dll
3. Rename Irrlicht_gcc.dll to Irrlicht.dll
4. Rename IrrlichtWrapper_gcc.dll to IrrlichtWrapper.dll


If I'm wrong, I'll definitely try to get a fix from the author.
update: The instructions didn't work for me. I'll notify the author. I'll also package it accordingly once things are worked out.

Edited by JRowe, 05 May 2010 - 02:33 PM.


#14 bogQ

bogQ

    For me, it’s simple - it’s a way of life.

  • Active Members
  • PipPipPipPipPipPip
  • 1,847 posts

Posted 05 May 2010 - 05:47 PM

Why not for now to re-rar and reupload his package until fix? or add it to au3Irrlicht2.zip
msvcr71.dll

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project

Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 


#15 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 05 May 2010 - 06:23 PM

This is a working example for _IrrCreateMesh (no error-checking at all):
AutoIt         
#include "au3Irrlicht2.au3" HotKeySet("{ESC}", "_exit") Func _exit() _IrrStop() Exit EndFunc Global Const $tagIRR_VERT = "float x; " & _ ;                // The x position of the vertex     "float y; " & _ ;                // The y position of the vertex     "float z; " & _ ;                // The z position of the vertex     "float normal_x; " & _ ;         // The x normal of the vertex     "float normal_y; " & _ ;         // The y normal of the vertex     "float normal_z; " & _ ;         // The z normal of the vertex     "uint vcolor; " & _ ;     // The 32bit ARGB color of the vertex     "float texture_x; " & _ ;        // the x co-ordinate of the vertex on the texture (0 to 1)     "float texture_y; " ;        // the y co-ordinate of the vertex on the texture (0 to 1) _IrrStart($IRR_EDT_OPENGL, 400, 400, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_SHADOWS, $IRR_IGNORE_EVENTS) _IrrSetWindowCaption("Example 15: Create a custom mesh") $tVertexArray = _VertexArrayCreate(5) _VertexArraySet($tVertexArray, 0, "x", -10) _VertexArraySet($tVertexArray, 0, "y", 0) _VertexArraySet($tVertexArray, 0, "z", -10) _VertexArraySet($tVertexArray, 1, "x", -10) _VertexArraySet($tVertexArray, 1, "y", 0) _VertexArraySet($tVertexArray, 1, "z", 10) _VertexArraySet($tVertexArray, 2, "x", 10) _VertexArraySet($tVertexArray, 2, "y", 0) _VertexArraySet($tVertexArray, 2, "z", 10) _VertexArraySet($tVertexArray, 3, "x", 10) _VertexArraySet($tVertexArray, 3, "y", 0) _VertexArraySet($tVertexArray, 3, "z", -10) _VertexArraySet($tVertexArray, 4, "x", 0) _VertexArraySet($tVertexArray, 4, "y", 20) _VertexArraySet($tVertexArray, 4, "z", 0) _VertexArraySet($tVertexArray, 0, "texture_x", 0) _VertexArraySet($tVertexArray, 0, "texture_y", 0) _VertexArraySet($tVertexArray, 1, "texture_x", 0) _VertexArraySet($tVertexArray, 1, "texture_y", 1) _VertexArraySet($tVertexArray, 2, "texture_x", 1) _VertexArraySet($tVertexArray, 2, "texture_y", 1) _VertexArraySet($tVertexArray, 3, "texture_x", 1) _VertexArraySet($tVertexArray, 3, "texture_y", 0) _VertexArraySet($tVertexArray, 4, "texture_x", 0.5) _VertexArraySet($tVertexArray, 4, "texture_y", 0.5) _VertexArraySet($tVertexArray, 0, "vcolor", 0x00FFFFFF) _VertexArraySet($tVertexArray, 1, "vcolor", 0x00FFFFFF) _VertexArraySet($tVertexArray, 2, "vcolor", 0x00FFFFFF) _VertexArraySet($tVertexArray, 3, "vcolor", 0x00FFFFFF) _VertexArraySet($tVertexArray, 4, "vcolor", 0x00FFFFFF) $tIndices = DllStructCreate("ushort[18]") DllStructSetData($tIndices, 1, 0, 1) DllStructSetData($tIndices, 1, 1, 2) DllStructSetData($tIndices, 1, 4, 3) DllStructSetData($tIndices, 1, 1, 4) DllStructSetData($tIndices, 1, 2, 5) DllStructSetData($tIndices, 1, 4, 6) DllStructSetData($tIndices, 1, 2, 7) DllStructSetData($tIndices, 1, 3, 8) DllStructSetData($tIndices, 1, 4, 9) DllStructSetData($tIndices, 1, 3, 10) DllStructSetData($tIndices, 1, 0, 11) DllStructSetData($tIndices, 1, 4, 12) DllStructSetData($tIndices, 1, 2, 13) DllStructSetData($tIndices, 1, 1, 14) DllStructSetData($tIndices, 1, 0, 15) DllStructSetData($tIndices, 1, 0, 16) DllStructSetData($tIndices, 1, 3, 17) DllStructSetData($tIndices, 1, 2, 18) $hMesh = DllCall($_irrDll, "ptr:cdecl", "IrrCreateMesh", "str", "TestMesh", "int", 5, "ptr", DllStructGetPtr($tVertexArray), "int", 18, "ptr", DllStructGetPtr($tIndices)) $hMesh = $hMesh[0] $MeshTexture = _IrrGetTexture( "./media/texture.jpg" ) $SceneNode = _IrrAddMeshToScene( $hMesh ) _IrrSetNodeMaterialTexture( $SceneNode, $MeshTexture, 0 ) _IrrSetNodeMaterialFlag( $SceneNode, $IRR_EMF_LIGHTING, $IRR_OFF ) $OurCamera = _IrrAddFPSCamera() _IrrSetNodePosition( $OurCamera, 30,50,25) _IrrSetCameraTarget($OurCamera, 0,0,0) WHILE _IrrRunning()     _IrrBeginScene(240, 255, 255)     _IrrDrawScene()     _IrrEndScene() WEND Func _VertexArrayCreate($iCount)     Local Static $iSize = DllStructGetSize(DllStructCreate($tagIRR_VERT, 1))     Return DllStructCreate("byte[" & $iSize * $iCount & "]") EndFunc Func _VertexArraySet(ByRef $tVertexArray, $iVertex, $vMember, $vData)     Local Static $iSize = DllStructGetSize(DllStructCreate($tagIRR_VERT, 1))     DllStructSetData(DllStructCreate($tagIRR_VERT, DllStructGetPtr($tVertexArray) + $iSize*$iVertex), $vMember, $vData) EndFunc

PS: You should add If @error Then Return Seterror(1,0,0) after each DLLCall.

Edited by ProgAndy, 05 May 2010 - 06:24 PM.

*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#16 shadowhacker

shadowhacker

    Seeker

  • Active Members
  • 11 posts

Posted 06 May 2010 - 02:20 PM

First of all i must say i waited for this for a long time and finally it's here. Thank you JRowe your doing a great job.
Now i have a question about the GUI. I tried to use the function _IrrAddWindow("Simple window", 50, 50, 100, 50, "IRR_GUI_MODAL", "") but nothing appears when i run the application. And about the last argument, i read in the Reference Manual from the IrrWrapper from freebasic that the last argument can be skipped if there is no parent for that window, but i can't skip it. And about the 6th argument. Is it right, i took it from the same Reference Manual from freebasic.
Posted Image

#17 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 06 May 2010 - 02:59 PM

If you skip the argument, you don't include anything. Adding "" will bork it. The _IrrAddWindow function may also need to be modified to set 0 as the default.

Replace the _IrrAddWindow function with this:

Func _IrrAddWindow($s_Title, $i_TopX, $i_TopY, $i_BottomX, $i_BottomY, $i_Modal, $h_Parent = 0)     $result = DllCall($_irrDll, "ptr:cdecl", "IrrAddWindow", "str", $s_Title, "int", $i_TopX, "int", $i_TopY, "int", $i_BottomX, "int", $i_BottomY, "int", $i_Modal, "ptr", $h_Parent)     Return $result[0] EndFunc ;==>_IrrAddWindow


Then call it with this:
_IrrAddWindow("Simple window", 50, 50, 100, 50, $IRR_GUI_MODAL)


I'll change that in the next release (probably saturday.)

Edited by JRowe, 06 May 2010 - 03:54 PM.


#18 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 06 May 2010 - 03:53 PM

I think "IRR_GUI_MODAL" is wrong. It should be $IRR_GUI_MODAL :idea:
*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#19 JRowe

JRowe

    Chasing the white rabbits

  • Active Members
  • PipPipPipPipPipPip
  • 1,765 posts

Posted 06 May 2010 - 03:56 PM

:idea:
Thanks ProgAndy , lol.Fixed it.

#20 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 6,243 posts

Posted 06 May 2010 - 05:47 PM

Hi Jrowe,

I'm very exited but my attempt is solded by an error...

always the same :
C:\Program Files\AutoIt3\Include\au3Irrlicht2.au3 (1427) : ==> Subscript used with non-Array variable.:
Return $result[0]
Return $result^ ERROR

all your demo is solded by this message :idea:

Dlls are 32bit. That means you have to run 32bit AutoIt when using them.


edit:
It's not very nice to delete posts the way you did. Then I have to do what I did now.

Edited by trancexx, 06 May 2010 - 07:16 PM.

          ......       ......
        .:oOOOOo:.   .:oOOOOo:.
      .:oOO:'':Oo:. .:oO:'':OOo:.
     .:oO:      'Oo:oO'      :Oo:.
     :oO:         'o'   
      :Oo:
     :oO:                     :Oo:
     ':oO:     OT9AO0IEDrk   :Oo:'
      ':oO:                 :Oo:'
        ':oO.             .Oo:'
          ':oO
.         .Oo:'
            ':oO.     .Oo:'
              ':oO. .Oo:'
                'oO:Oo'
                  'o' :kiss:



 

.
eMyvnE





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users