Guest JRowe_1 Posted December 2, 2006 Posted December 2, 2006 Ok, I'm totally new to this aspect of Autoit, and indeed, programming. I have some questions about how to get started using the irrlicht engine... it comes as a precompiled dll, and I want to grab it right off the downloads page, open it with autoit, and attempt to display something. How would I go about translating the API into dllCall functions for autoit? I believe this is called a "wrapper" , when you define functions in a language that are designed to simulate functions in another language or system? Heh, sorry for the noob questions... is there an easy to understand methodology for creating wrappers for autoit syntax for any given dll? I'd love to be able to run a few simple functions in Irrlicht and snd the controls to Autoit, so I could use a mouse to rotate a 3D object, or something of that nature.
PaulIA Posted December 2, 2006 Posted December 2, 2006 Do you have any of the documentation that shows the API calls for the DLL? If so, post one here and I'll show you how to convert it to something you can use in AutoIt. Auto3Lib: A library of over 1200 functions for AutoIt
Guest JRowe_1 Posted December 2, 2006 Posted December 2, 2006 (edited) Okie... I think this may not be what you need, or it could be. I'm terribly new to this and not certain of the terminology, so bear with me...(Thanks for helping!)I'm making an assumption that the API calls used in creating the sample "hello world" app are what's needed here, so without further ado:CODE #include <irrlicht.h> using namespace irr; int main() { // start up the engine IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D8, core::dimension2d<s32>(640,480)); video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* scenemgr = device->getSceneManager(); device->setWindowCaption(L"Hello World!"); // load and show quake2 .md2 model scene::ISceneNode* node = scenemgr->addAnimatedMeshSceneNode( scenemgr->getMesh("quake2model.md2")); // if everything worked, add a texture and disable lighting if (node) { node->setMaterialTexture(0, driver->getTexture("texture.bmp")); node->setMaterialFlag(video::EMF_LIGHTING, false); } // add a first person shooter style user controlled camera scenemgr->addCameraSceneNodeFPS(); // draw everything while(device->run() && driver) { driver->beginScene(true, true, video::SColor(255,0,0,255)); scenemgr->drawAll(); driver->endScene(); } // delete device device->drop(); return 0; }That's the hello world app. Again, I'm assuming that if you recreate the function calls with Autoit by using dllCall, it will work. IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D8, core::dimension2d<s32>(640,480));IrrlichtDevice seems to be an API Call, as you put it, so http://irrlicht.sourceforge.net/docu/class...cht_device.htmlThere's the class reference.Are my assumptions way off here, or is dllCall usable in this way? Edited December 2, 2006 by JRowe_1
PaulIA Posted December 2, 2006 Posted December 2, 2006 I downloaded the SDK and took a look at the API. Trust me, you don't want to start learning programming or AutoIt with this puppy. It's huge! It would take me months to code the API for this thing. Auto3Lib: A library of over 1200 functions for AutoIt
Guest JRowe_1 Posted December 2, 2006 Posted December 2, 2006 Gah Ok, so would the new plugin sdk by jon be a solution?
Guest JRowe_1 Posted December 2, 2006 Posted December 2, 2006 E.G. use the irrlicht engine to create functions that I want, then create hooks(?) for Autoit to use?
Guest JRowe_1 Posted December 2, 2006 Posted December 2, 2006 (edited) Or, I find a wrapper for another Basic syntax like language, figure out how it works, and rewrite the c++ for the wrapper, and figure it out from there.I figure a FreeBasic wrapper shouldnt be that hard to convert over to Autoit, since the syntaxes are somewhat simpler, and both languages are easy to understand.I hope. Gah, this should be fun.Ok... so, from what I understand thus far (which is limited, as you can see...)Plugins can be written for Autoit in FreeBasic. FreeBasic has a wrapper for Irrlicht, located at http://www.frankdodd.screaming.net/IrrlichtWrapper.zip .I can write code in FreeBasic that uses the Irrlicht engine, and use that code as a plugin for Autoit.It's probably a horribly inefficient method and bad programming practice, but I don't care, all I want is a window that displays a 3D box, that lets me rotate the box, or something similarly simple. Written in Autoit.lol, yet another crazy noob idea. sigh. Edited December 2, 2006 by JRowe_1
piccaso Posted December 2, 2006 Posted December 2, 2006 if you really write that plugin your noob times are over CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Guest JRowe_1 Posted December 2, 2006 Posted December 2, 2006 Yeah, this is nuts. Now I'm seeing that I'll have to write a wrapper for the Irrlicht wrapper in freebasic, which is probably twice as much work as it should be. However, the Irrlicht wrapper looks like it might be easily converted, so I will see if that can be done. This looks to be a long ass night Apparently Irrlicht can be run successfully with only 100 of the functions "wrapped", so I'll see where I can get.
Guest JRowe_1 Posted December 2, 2006 Posted December 2, 2006 Ok, so now I see that the wrapper this guy came up with is apparently directly usable by Autoit. At least thats what the comments indicate to me. // // Irrlicht Wrapper for Imperative Languages // Frank Dodd (2006) // // This wrapper DLL encapsulates a sub-set of the features of the powerful // Irrlicht 3D Graphics Engine exposing the Object Oriented architecture and // providing a functional 3D SDK for languages that are not object oriented. // // This source was created with the help of the great examples in the Irrlicht // SDK and the excellent Irrlicht documentation. This software was developed // using the GCC compiler and Code::Blocks IDE // CODEvoid * DLL_EXPORT IrrGetMesh( char *cptrFile ) { /* load a mesh and add it to the scene */ IAnimatedMesh* mesh = smgr->getMesh( cptrFile ); return (void *)mesh; } /* ---------------------------------------------------------------------------- create a mesh from an array of verticies, an array of incidies to those verticies that connect them to form triangles and finally texture co-ordinates to map the verticies against a texture plane */ void * DLL_EXPORT IrrCreateMesh( char *cptrMeshName, int iVertexCount, IRR_VERT *vVertices, int iIndicesCount, unsigned short *usIndices ) { int iLoop; /* get the mesh cache for the scene */ IMeshCache *mcache = smgr->getMeshCache(); SMeshBuffer *smeshbuffer = new SMeshBuffer; SMesh *smesh = new SMesh; SAnimatedMesh * sanimmesh = new SAnimatedMesh; // add all of the verts printf( "Adding %d verts\n", iVertexCount ); smeshbuffer->Vertices.set_used(iVertexCount); for ( iLoop = 0; iLoop < iVertexCount; iLoop++ ) { smeshbuffer->Vertices[iLoop].Pos.set( vVertices[iLoop].x, vVertices[iLoop].y, vVertices[iLoop].z ); smeshbuffer->Vertices[iLoop].Normal.set( vVertices[iLoop].normal_x, vVertices[iLoop].normal_y, vVertices[iLoop].normal_z ); smeshbuffer->Vertices[iLoop].Color.color = vVertices[iLoop].vcolor; smeshbuffer->Vertices[iLoop].TCoords.set( vVertices[iLoop].texture_x, vVertices[iLoop].texture_y ); } // add all of the indices printf( "Adding %d indicies\n", iIndicesCount ); smeshbuffer->Indices.set_used(iIndicesCount); for ( iLoop = 0; iLoop < iIndicesCount; iLoop++ ) { smeshbuffer->Indices[iLoop] = usIndices[iLoop]; } // assemble the mesh objects smesh->addMeshBuffer( smeshbuffer ); sanimmesh->addMesh( smesh ); mcache->addMesh( cptrMeshName, sanimmesh ); // recalculate the bounding box around the object for clipping purposes sanimmesh->recalculateBoundingBox(); return (void *)sanimmesh; } /* ---------------------------------------------------------------------------- remove a loaded mesh from the scene cache useful if you are dealing with large numbers of meshes that you dont want cached in memory at the same time (for example when swapping between BSP maps for levels */ void DLL_EXPORT IrrRemoveMesh( IAnimatedMesh* mesh ) { /* get the mesh cache for the scene */ IMeshCache *mcache = smgr->getMeshCache(); /* remove the selected mesh */ mcache->removeMesh( mesh ); } /* //////////////////////////////////////////////////////////////////////////// SCENE MESH MANIPULATION */ /* ---------------------------------------------------------------------------- get the number of indicies in the mesh buffer */ int DLL_EXPORT IrrGetMeshIndexCount( IAnimatedMesh* mesh, int iFrame ) { return mesh->getMesh(iFrame)->getMeshBuffer(0)->getIndexCount(); } /* ---------------------------------------------------------------------------- copy the indicies of a mesh into the supplied buffer, the caller must ensure that the buffer is big enough to store the data */ void DLL_EXPORT IrrGetMeshIndices( IAnimatedMesh* mesh, int iFrame, unsigned short *indicies ) { int iLoop; int iIndexCount = mesh->getMesh(iFrame)->getMeshBuffer(0)->getIndexCount(); unsigned short *us = mesh->getMesh(iFrame)->getMeshBuffer(0)->getIndices(); for ( iLoop = 0; iLoop < iIndexCount; iLoop++ ) { indicies[iLoop] = us[iLoop]; } } /* ---------------------------------------------------------------------------- copy the indicies in the supplied buffer into the mesh , the caller must ensure that the buffer is big enough to supply all of the data */ void DLL_EXPORT IrrSetMeshIndices( IAnimatedMesh* mesh, int iFrame, unsigned short *indicies ) { int iLoop; int iIndexCount = mesh->getMesh(iFrame)->getMeshBuffer(0)->getIndexCount(); unsigned short *us = mesh->getMesh(iFrame)->getMeshBuffer(0)->getIndices(); for ( iLoop = 0; iLoop < iIndexCount; iLoop++ ) { us[iLoop] = indicies[iLoop]; } } /* ---------------------------------------------------------------------------- get the number of vertices in the mesh buffer */ int DLL_EXPORT IrrGetMeshVertexCount( IAnimatedMesh* mesh, int iFrame ) { return mesh->getMesh(iFrame)->getMeshBuffer(0)->getVertexCount(); } /* ---------------------------------------------------------------------------- copy the vertices of a mesh into the supplied buffer, the caller must ensure that the buffer is big enough to store the data */ int DLL_EXPORT IrrGetMeshVertices( IAnimatedMesh* mesh, int iFrame, IRR_VERT *verts ) { int iLoop; S3DVertex *s3d_verts; S3DVertex2TCoords *texture_verts; S3DVertexTangents *tangent_verts; IMeshBuffer *mb = mesh->getMesh(iFrame)->getMeshBuffer(0); int iVertexCount = mb->getVertexCount(); switch ( mb->getVertexType()) { case EVT_STANDARD: // Standard vertex type used by the Irrlicht engine, video::S3DVertex s3d_verts = (S3DVertex *)mb->getVertices(); for ( iLoop = 0; iLoop < iVertexCount; iLoop++ ) { verts[iLoop].x = s3d_verts[iLoop].Pos.X; verts[iLoop].y = s3d_verts[iLoop].Pos.Y; verts[iLoop].z = s3d_verts[iLoop].Pos.Z; verts[iLoop].normal_x = s3d_verts[iLoop].Normal.X; verts[iLoop].normal_y = s3d_verts[iLoop].Normal.Y; verts[iLoop].normal_z = s3d_verts[iLoop].Normal.Z; verts[iLoop].vcolor = s3d_verts[iLoop].Color.color; verts[iLoop].texture_x = s3d_verts[iLoop].TCoords.X; verts[iLoop].texture_y = s3d_verts[iLoop].TCoords.Y; } break; case EVT_2TCOORDS: /* Vertex with two texture coordinates, video::S3DVertex2TCoords. Usually used for geometry with lightmaps or other special materials. */ texture_verts = (S3DVertex2TCoords *)mb->getVertices(); for ( iLoop = 0; iLoop < iVertexCount; iLoop++ ) { verts[iLoop].x = texture_verts[iLoop].Pos.X; verts[iLoop].y = texture_verts[iLoop].Pos.Y; verts[iLoop].z = texture_verts[iLoop].Pos.Z; verts[iLoop].normal_x = texture_verts[iLoop].Normal.X; verts[iLoop].normal_y = texture_verts[iLoop].Normal.Y; verts[iLoop].normal_z = texture_verts[iLoop].Normal.Z; verts[iLoop].vcolor = texture_verts[iLoop].Color.color; verts[iLoop].texture_x = texture_verts[iLoop].TCoords.X; verts[iLoop].texture_y = texture_verts[iLoop].TCoords.Y; } break; case EVT_TANGENTS: /* Vertex with a tangent and binormal vector, video::S3DVertexTangents. Usually used for tangent space normal mapping. */ tangent_verts = (S3DVertexTangents *)mb->getVertices(); for ( iLoop = 0; iLoop < iVertexCount; iLoop++ ) { verts[iLoop].x = tangent_verts[iLoop].Pos.X; verts[iLoop].y = tangent_verts[iLoop].Pos.Y; verts[iLoop].z = tangent_verts[iLoop].Pos.Z; verts[iLoop].normal_x = tangent_verts[iLoop].Normal.X; verts[iLoop].normal_y = tangent_verts[iLoop].Normal.Y; verts[iLoop].normal_z = tangent_verts[iLoop].Normal.Z; verts[iLoop].vcolor = tangent_verts[iLoop].Color.color; verts[iLoop].texture_x = tangent_verts[iLoop].TCoords.X; verts[iLoop].texture_y = tangent_verts[iLoop].TCoords.Y; } break; } } /* ---------------------------------------------------------------------------- copy the vertices in the supplied buffer into the mesh , the caller must ensure that the buffer is big enough to supply all of the data */ int DLL_EXPORT IrrSetMeshVertices( IAnimatedMesh* mesh, int iFrame, IRR_VERT *verts ) { int iLoop; S3DVertex *s3d_verts; S3DVertex2TCoords *texture_verts; S3DVertexTangents *tangent_verts; IMeshBuffer *mb = mesh->getMesh(iFrame)->getMeshBuffer(0); int iVertexCount = mb->getVertexCount(); switch ( mb->getVertexType()) { case EVT_STANDARD: // Standard vertex type used by the Irrlicht engine, video::S3DVertex s3d_verts = (S3DVertex *)mb->getVertices(); for ( iLoop = 0; iLoop < iVertexCount; iLoop++ ) { s3d_verts[iLoop].Pos.X = verts[iLoop].x; s3d_verts[iLoop].Pos.Y = verts[iLoop].y; s3d_verts[iLoop].Pos.Z = verts[iLoop].z; s3d_verts[iLoop].Normal.X = verts[iLoop].normal_x; s3d_verts[iLoop].Normal.Y = verts[iLoop].normal_y; s3d_verts[iLoop].Normal.Z = verts[iLoop].normal_z; s3d_verts[iLoop].Color.color = verts[iLoop].vcolor; s3d_verts[iLoop].TCoords.X = verts[iLoop].texture_x; s3d_verts[iLoop].TCoords.Y = verts[iLoop].texture_y; } break; case EVT_2TCOORDS: /* Vertex with two texture coordinates, video::S3DVertex2TCoords. Usually used for geometry with lightmaps or other special materials. */ texture_verts = (S3DVertex2TCoords *)mb->getVertices(); for ( iLoop = 0; iLoop < iVertexCount; iLoop++ ) { texture_verts[iLoop].Pos.X = verts[iLoop].x; texture_verts[iLoop].Pos.Y = verts[iLoop].y; texture_verts[iLoop].Pos.Z = verts[iLoop].z; texture_verts[iLoop].Normal.X = verts[iLoop].normal_x; texture_verts[iLoop].Normal.Y = verts[iLoop].normal_y; texture_verts[iLoop].Normal.Z = verts[iLoop].normal_z; texture_verts[iLoop].Color.color = verts[iLoop].vcolor; texture_verts[iLoop].TCoords.X = verts[iLoop].texture_x; texture_verts[iLoop].TCoords.Y = verts[iLoop].texture_y; } break; case EVT_TANGENTS: /* Vertex with a tangent and binormal vector, video::S3DVertexTangents. Usually used for tangent space normal mapping. */ tangent_verts = (S3DVertexTangents *)mb->getVertices(); for ( iLoop = 0; iLoop < iVertexCount; iLoop++ ) { tangent_verts[iLoop].Pos.X = verts[iLoop].x; tangent_verts[iLoop].Pos.Y = verts[iLoop].y; tangent_verts[iLoop].Pos.Z = verts[iLoop].z; tangent_verts[iLoop].Normal.X = verts[iLoop].normal_x; tangent_verts[iLoop].Normal.Y = verts[iLoop].normal_y; tangent_verts[iLoop].Normal.Z = verts[iLoop].normal_z; tangent_verts[iLoop].Color.color = verts[iLoop].vcolor; tangent_verts[iLoop].TCoords.X = verts[iLoop].texture_x; tangent_verts[iLoop].TCoords.Y = verts[iLoop].texture_y; } break; } // now that the geometry has been altered recalculate the bounding box smgr->getMeshManipulator()->recalculateBoundingBox( mesh->getMesh(iFrame)->getMeshBuffer(0)); } /* //////////////////////////////////////////////////////////////////////////// SCENE NODE CREATION */ /* ---------------------------------------------------------------------------- add a loaded mesh to the irrlicht scene manager */ void * DLL_EXPORT IrrAddMeshToScene ( IAnimatedMesh* mesh ) { IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); return (void *)node; } /* ---------------------------------------------------------------------------- add the supplied mesh object to the scene as an octtree node */ void * DLL_EXPORT IrrAddMeshToSceneAsOcttree( void *vptrMesh ) { // add the mesh to the scene as an octtree return (void *)smgr->addOctTreeSceneNode((IAnimatedMesh*)vptrMesh); } /* ---------------------------------------------------------------------------- adds a billboard to the scene this is a flat 3D textured sprite */ void * DLL_EXPORT IrrAddBillBoardToScene( float sizex, float sizey, float x, float y, float z ) { return (void *)smgr->addBillboardSceneNode( NULL, dimension2d<f32>( sizex, sizey ), vector3df(x, y, z ) ); } /* ---------------------------------------------------------------------------- add a particle system to the irrlicht scene manager */ void * DLL_EXPORT IrrAddParticleSystemToScene ( bool defaultemitter ) { return (void *)smgr->addParticleSystemSceneNode(defaultemitter); } /* ---------------------------------------------------------------------------- add a skybox to the irrlicht scene manager based on six pictures */ void * DLL_EXPORT IrrAddSkyBoxToScene ( ITexture *texture_up, ITexture *texture_down, ITexture *texture_left, ITexture *texture_right, ITexture *texture_front, ITexture *texture_back ) { return (void *)smgr->addSkyBoxSceneNode( texture_up, texture_down, texture_left, texture_right, texture_front, texture_back ); } /* ---------------------------------------------------------------------------- adds a test node to the scene, the node is a simple cube */ void * DLL_EXPORT IrrAddTestSceneNode( void ) { return (void *)smgr->addTestSceneNode(); } /* //////////////////////////////////////////////////////////////////////////// SCENE EFFECTS */ /* ---------------------------------------------------------------------------- set the color of shadows in the scene */ void DLL_EXPORT IrrSetShadowColor( int alpha, int R, int G, int B ) { // set shadow color smgr->setShadowColor(video::SColor(alpha,R,G,); } /* ---------------------------------------------------------------------------- set the scene fog */ void DLL_EXPORT IrrSetFog( int R, int G, int B, bool fogtype, float start, float end, float density ) { driver->setFog( SColor(0, R, G, , fogtype, start, end, density ); } /* //////////////////////////////////////////////////////////////////////////// all of the above functions are declared as C functions and are exposed without any mangled names */ } Does that look like it's useable by autoit, using those functions through DllCall? The code above is the c++ source code for the wrapper. We may have something here
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now