#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