Irrlicht Lime is a .NET wrapper for Irrlicht Engine
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
That is right, you cannot inherit from CameraSceneNode, there are only two classes which you can inherit from, its SceneNode and GUIElement (i mean classes initially inherited from ReferenceCounted; because all simple classes are inheritable). And believe me, this ability for inheritance was made with tricks which only make you think that you actually inherit stuff. If you learn better and try to use it on full, you will find issues, for example if you will add your own SceneNode to the scene manager and try to get the node back with smgr.GetSceneNodeFromID() you will get GUIElement object which is not YourCustomSceneNode (i mean type casting will fail, you will get null). This is because the inheritance for user is a fake, since you cannot inherit unmanaged type by a managed one.
This all doesn't mean that you cannot create your own camera, you can, but the approach will be a bit different - no inheritance, but making own class which will wrap camera usage and encapsulate its control. Particularly this way i have implemented in the most latest example for Lime which is only in trunk for now (will be in next release avail). But you can already look into it and get the point -- http://sourceforge.net/p/irrlichtlime/c ... ereCamera/ (SphereCamera.cs -- our custom camera; Program.cs -- usage of the camera). I'm pretty sure you can get all the source of the example and make it run in latest Lime version (1.3), the only thing about the example is that SpherePath.cs will not compile since it uses new class VertexPrimitive, which is only in trunk; you need to comment out all usage of SpherePath from Program class, then it should run just fine.
This all doesn't mean that you cannot create your own camera, you can, but the approach will be a bit different - no inheritance, but making own class which will wrap camera usage and encapsulate its control. Particularly this way i have implemented in the most latest example for Lime which is only in trunk for now (will be in next release avail). But you can already look into it and get the point -- http://sourceforge.net/p/irrlichtlime/c ... ereCamera/ (SphereCamera.cs -- our custom camera; Program.cs -- usage of the camera). I'm pretty sure you can get all the source of the example and make it run in latest Lime version (1.3), the only thing about the example is that SpherePath.cs will not compile since it uses new class VertexPrimitive, which is only in trunk; you need to comment out all usage of SpherePath from Program class, then it should run just fine.
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
Thanks for this great wrapper.
Is it possible to use Lime with SharDevelop? I have tried to use it but haven't gotten it to work yet. I have copied the Irrlicht.dll and IrrlichtLime.dll to my projects output folder, and I have added IrrlichLime.dll to projects references. I have also installed visual c++ 2010 redistributable (x86) just like Limes readme file suggests, but I still keep getting the file not found expection when I try to compile. I'm using SharDevelop version 4.3 and IrrlichtLime version 1.3. Does anyone know what is the problem? Has someone gotten Lime to work with SharpDevelop?
Thanks for the help and answers already in advance!
Is it possible to use Lime with SharDevelop? I have tried to use it but haven't gotten it to work yet. I have copied the Irrlicht.dll and IrrlichtLime.dll to my projects output folder, and I have added IrrlichLime.dll to projects references. I have also installed visual c++ 2010 redistributable (x86) just like Limes readme file suggests, but I still keep getting the file not found expection when I try to compile. I'm using SharDevelop version 4.3 and IrrlichtLime version 1.3. Does anyone know what is the problem? Has someone gotten Lime to work with SharpDevelop?
Thanks for the help and answers already in advance!
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
Yes.Is it possible to use Lime with SharDevelop?
Short answer
You need to copy Irrlicht.dll to your project's output directory.
Long answer
- start SharpDevelop 4.3
- New solution -> Windows Application -> Console Application, choose ".NET Framework 4.0 Client Profile"
- Select newly created project in the solution tree, then choose in main menu Project -> Add Reference -> .NET Assembly Browser -> Browse... -> locate debug build of IrrlichtLime.dll -> hit OK
- Now when you try to run app, you will get:
- Now all you need to do is to copy Irrlicht.dll (again, the Debug build) to the output folder of your project "\bin\Debug"Cannot intercept exception. Debugged program can not be continued and properties can not be evaluated.
System.IO.FileNotFoundException: Could not load file or assembly 'IrrlichtLime.dll' or one of its dependencies. The specified module could not be found.
Another way (which i use myself and recommend it), is to:
- add Irrlicht.dll to your project using Project -> Add -> Existing Item..., choose "Link" or "Copy" (the difference is obvious, choose "Link" if you do not plain to move around your Irrlicht Lime SDK and the project, and if you have a lot of them -- this way you will be able to update Irrlicht Lime easily by updating it in one place)
- choose Irrlicht.dll in you project tree and set its properties: Build action = None, Copy to output directory = PreserveNewest
From now on, each time you build your project, you will get Irrlicht.dll in output directory automatically.
The only thing you should remember is that we referenced and linked Debug builds of the wrapper and Irrlicht Engine. It better for developing. When you need release build, you just switch the build in SharpDevelop (Build -> Set configuration -> Release), you build the project and then you will have to manually replace IrrlichtLime.dll and Irrlicht.dll in your Release output directory on ones from Irrlicht Lime SDK /bin/Release directory. If you will not do so, the project will run just fine, but it will not use Release build of the wrapper and the engine, and therefore will run slower (in most cases) than it can. Also Debug build may not run on different machine (because it may has no development system dlls; Release build will run ok).
If you find the copying of release dlls is inconvenient, there is a universal way:
- in project properties you choose tab Build Events and here you can set up all the copying yourself, each configuration (debug and release) may have own "pre" and "post" build scripts. This way you can set up all the dlls to be correct at any build configuration. I do recommend this way if you making a big project
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
Thnaks for the fast and friendly reply!
I did everything as you told, and tried the different methods that you described, but I'm still getting the same error. I have also tried it with two different computers, one of which is running windows vista and the other windows 7, but I can't get Lime to work on them either. Strangely enough, we tried to use Lime in excatly the same way on my friends computer, and there we could compile Lime programs with no problems. We then tried to run the program compiled on my friends computer on the three other computers, but it crashed immidiadely on all of them giving the "file not found" error on the command line. The program did that despite the fact that we included all the same files on the programs folder that were on my friends computer, including irllichtLime.dll and irrlicht.dll. What's even more strange is that I can run the example .exe files that come with the Lime download on my computer without any porblems.
I then tried compile Lime from the sources files on codeblock and minGV, but that just gave me errors too.
Would you have any idea what is causing this problem? First explanation that would come to my mind would be that I'm missing some DLL. But I have installed the c++ 2010 redistributable files on my computer too, so I have no idea what it could be that I'm missing.
Thanks once more for your previous friendly answer.
P.S. My friend has Visual Studio installed on his computer, the other three computers don't have it. Could that be the problem?
I did everything as you told, and tried the different methods that you described, but I'm still getting the same error. I have also tried it with two different computers, one of which is running windows vista and the other windows 7, but I can't get Lime to work on them either. Strangely enough, we tried to use Lime in excatly the same way on my friends computer, and there we could compile Lime programs with no problems. We then tried to run the program compiled on my friends computer on the three other computers, but it crashed immidiadely on all of them giving the "file not found" error on the command line. The program did that despite the fact that we included all the same files on the programs folder that were on my friends computer, including irllichtLime.dll and irrlicht.dll. What's even more strange is that I can run the example .exe files that come with the Lime download on my computer without any porblems.
I then tried compile Lime from the sources files on codeblock and minGV, but that just gave me errors too.
Would you have any idea what is causing this problem? First explanation that would come to my mind would be that I'm missing some DLL. But I have installed the c++ 2010 redistributable files on my computer too, so I have no idea what it could be that I'm missing.
Thanks once more for your previous friendly answer.
P.S. My friend has Visual Studio installed on his computer, the other three computers don't have it. Could that be the problem?
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
I have tested on clean Windows 7 virtual machine and can say that FileNotFoundException or other errors you can get from next ways:
Trying to run 01.HelloWorld.exe without Microsoft .NET Framework 4.0 installed
+ Microsoft .NET Framework 4.0
+ Microsoft Visual C++ 2010 Redistributable Package (x86)
it is possible to run Release builds of apps which uses Lime.
To develop apps OR to run Debug builds of apps you need VS 2010 installed (or "VS 2010 Express" or "Visual C# 2010 Express" or "VS 2012 Express for Windows Desktop" (i also tested this one and it works just fine)). I also tested SharpDevelop and i confirm that is is possible to develop Lime apps with it; but i didn't tested if it is possible to run Debug app made with VS without VS but with SharpDevelop installed.
P.S.: maybe your system has some other problem which i never experienced.
Trying to run 01.HelloWorld.exe without Microsoft .NET Framework 4.0 installed
Trying to run 01.HelloWorld.exe without Microsoft Visual C++ 2010 Redistributable Package (x86) installed or without Irrlicht.dll---------------------------
01.HelloWorld.exe - .NET Framework Initialization Error
---------------------------
To run this application, you first must install one of the following versions of the .NET Framework:
v4.0.30319
Contact your application publisher for instructions about obtaining the appropriate version of the .NET Framework.
---------------------------
OK
---------------------------
Trying to run 01.HelloWorld.exe without IrrlichtLime.dllUnhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'IrrlichtLime.dll' or one of its dependencies. The specified module could not be found.
at _01.HelloWorld.Program.Main(String[] args)
After installing:Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'IrrlichtLime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at _01.HelloWorld.Program.Main(String[] args)
+ Microsoft .NET Framework 4.0
+ Microsoft Visual C++ 2010 Redistributable Package (x86)
it is possible to run Release builds of apps which uses Lime.
To develop apps OR to run Debug builds of apps you need VS 2010 installed (or "VS 2010 Express" or "Visual C# 2010 Express" or "VS 2012 Express for Windows Desktop" (i also tested this one and it works just fine)). I also tested SharpDevelop and i confirm that is is possible to develop Lime apps with it; but i didn't tested if it is possible to run Debug app made with VS without VS but with SharpDevelop installed.
P.S.: maybe your system has some other problem which i never experienced.
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
im trying to build irrlicht lime targeting framework 2.0 and vc90 toolset. thing is im getting pretty weird crashes. stepping over the next line causes memory access violation error..
Im not doing anything fancy either. grabbed irr 1.8 release from website, buit it using /MD with unicode and WCHAR filesystem (skipped dx8, no need of it).
Then im compiling lime with vc90 toolset and <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> under <PropertyGroup Label="Globals"> in vcxproj.
Everything compiles but this weird stuff is happening. Any idea what could be cause of this?
Im not doing anything fancy either. grabbed irr 1.8 release from website, buit it using /MD with unicode and WCHAR filesystem (skipped dx8, no need of it).
Then im compiling lime with vc90 toolset and <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> under <PropertyGroup Label="Globals"> in vcxproj.
Everything compiles but this weird stuff is happening. Any idea what could be cause of this?
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
Hello.
I cannot say right now why we have all these exceptions.
I will try to build IrrlichtLime with .NET Framework 2.0 and test it when i get home.
P.S.: besides exactly 3 years ago, today May 14 i made very first commit to IrrlichtLime repository
I cannot say right now why we have all these exceptions.
I will try to build IrrlichtLime with .NET Framework 2.0 and test it when i get home.
P.S.: besides exactly 3 years ago, today May 14 i made very first commit to IrrlichtLime repository
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
oh great - congratz! 3 years is a lot
P.S. dont forget to build irrlicht with vc90 toolset
P.S. dont forget to build irrlicht with vc90 toolset
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
Well.
Didn't get success to get .NET 2.0 lime dll version, since it requires VS2008 installed OR to use v100 platform toolset. I use VS2010 and I build with v100 and get DLL but its .NET 4.0 still (i wasn't able to use it in .NET 2.0 project). I will try to test this on my work tomorrow if i get time. I have VS2008 there.
Didn't get success to get .NET 2.0 lime dll version, since it requires VS2008 installed OR to use v100 platform toolset. I use VS2010 and I build with v100 and get DLL but its .NET 4.0 still (i wasn't able to use it in .NET 2.0 project). I will try to test this on my work tomorrow if i get time. I have VS2008 there.
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
OK.
I was able to compile Lime with .NET 2.0 and it works OK.
I must say i have VS2005, VS2008 and VS2010 installed and did all the work in VS2010.
To create IrrlichtLime.dll with .NET all i had to do is to added "<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>" to Lime' vcxproj file.
To compile 01.HelloWorld with this new DLL, i have changed Target framework to ".NET Framework 2.0" in project' Properties at Application tab. I also removed 3 referenced assemblies System.Core, System.Data.DataSetExtensions and System.Xml.Linq (because they all requires .NET 3.5 and actually i don't use any of them, they just added by default by IDE for any .NET 3.5+ new project).
Additionally for testing purposes i tried to use this DLL in VS2005 (as you may know, in this IDE you cannot use .NET higher than 2.0 at all).
I also had no problems with it, please see screenshot -- http://i.imgur.com/vjPvP2a.png
If you want, i can provide you Debug and Release DLLs of Lime for .NET 2.0 i made.
I was able to compile Lime with .NET 2.0 and it works OK.
I must say i have VS2005, VS2008 and VS2010 installed and did all the work in VS2010.
To create IrrlichtLime.dll with .NET all i had to do is to added "<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>" to Lime' vcxproj file.
To compile 01.HelloWorld with this new DLL, i have changed Target framework to ".NET Framework 2.0" in project' Properties at Application tab. I also removed 3 referenced assemblies System.Core, System.Data.DataSetExtensions and System.Xml.Linq (because they all requires .NET 3.5 and actually i don't use any of them, they just added by default by IDE for any .NET 3.5+ new project).
Additionally for testing purposes i tried to use this DLL in VS2005 (as you may know, in this IDE you cannot use .NET higher than 2.0 at all).
I also had no problems with it, please see screenshot -- http://i.imgur.com/vjPvP2a.png
If you want, i can provide you Debug and Release DLLs of Lime for .NET 2.0 i made.
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
thanks for the test, actually this was fault of mine (and bit of yours :p). i assumed that lime is compiled against official 1.8 release which was indicated by IrrCompileConfig.h, so i built irrlicht from 1.8 release and linked it to lime while allowing lime to use bundled headers. obvious incompatibility must be result of these weird crashes. closer inspection revealed bundled irrlicht headers contain stuff that exists only on svn. could let me know which irrlicht revision lime is compiled against? latest revision does not compile with wchar support. from there i should be able to build all i need
EDIT:
With some tweaks svn version compiled fine, everything works as expected!
EDIT:
With some tweaks svn version compiled fine, everything works as expected!
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
I always do not recommend to provide your own Irrlicht version (like you downloaded latest or so) until you really know what you do and what to expect.
I build Lime using trunk version (in most cases the latest version), i point this information in /irrlicht/version.txt (this file contain everything that is needed to get Irrlicht and set up for Lime). I must say that in rare cases Irrlicht doesn't compiles: sometimes at all, sometimes because of _IRR_WCHAR_FILESYSTEM, but that is quite rare cases. In these cases i manually change Irrlicht source to make it compile-able.
For example in the very latest trunk revision of Irrlicht (the current one which is 4525), it fails to compile due to uncompile-able stuff in source (i pointed this here -- http://irrlicht.sourceforge.net/forum/v ... 04#p280372 ), i actually simply comment out all the body of "problem" method. I didn't ported it to Lime, so you cannot call it for now, but i will change that as soon as it will be fixed in the Irrlicht' trunk.
I build Lime using trunk version (in most cases the latest version), i point this information in /irrlicht/version.txt (this file contain everything that is needed to get Irrlicht and set up for Lime). I must say that in rare cases Irrlicht doesn't compiles: sometimes at all, sometimes because of _IRR_WCHAR_FILESYSTEM, but that is quite rare cases. In these cases i manually change Irrlicht source to make it compile-able.
For example in the very latest trunk revision of Irrlicht (the current one which is 4525), it fails to compile due to uncompile-able stuff in source (i pointed this here -- http://irrlicht.sourceforge.net/forum/v ... 04#p280372 ), i actually simply comment out all the body of "problem" method. I didn't ported it to Lime, so you cannot call it for now, but i will change that as soon as it will be fixed in the Irrlicht' trunk.
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
oh snap version.txt - i totally outsmarted myself sigh.
could you aid me a bit here? i wish to expose texture buffer to .NET so i made property in TexturePainter:
Thing is .NET world sees it as ValueType, not IntPtr.. Any idea how to fix that?
I also suggest exposing buffer in lime. I myself am implementing berkelium-based UI. Berkelium returns some rects that programmer should copy around to assemble pixelbuffer representing screen. Now calling SetPixel for every pixel is quite some useless overhead. Operations on raw memory (since berkelium returns raw changed rect pixelbuffer, i keep raw pixelbuffer in memory and raw pixelbuffer is to be modified in texture) avoid lots of unneeded managed code.
could you aid me a bit here? i wish to expose texture buffer to .NET so i made property in TexturePainter:
Code: Select all
property System::IntPtr^ Pointer { System::IntPtr^ get(); }
I also suggest exposing buffer in lime. I myself am implementing berkelium-based UI. Berkelium returns some rects that programmer should copy around to assemble pixelbuffer representing screen. Now calling SetPixel for every pixel is quite some useless overhead. Operations on raw memory (since berkelium returns raw changed rect pixelbuffer, i keep raw pixelbuffer in memory and raw pixelbuffer is to be modified in texture) avoid lots of unneeded managed code.
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
Yeah, providing native pointers for such special cases is not bad idea at all.
You can test it, use it with anything appropriate and post here the results. I can add these new feature, but i would really like to provide it with new example which uses it. So its not like something which no one knows that it there... it like with TexturePainter class. Its not a standard thing as for Irrlicht, it doesn't have it, in C++ you call lock() and then its your business what to do with returned "void*". So TexturePainter has clear aim and dedicated example I hope you get me.
For your "System::IntPtr" issue. Its a struct, not a class, so this is a value type not a reference type.
This is something like DateTime for example. The difference between class and struct in very short and simple manner is that value types may not hold null (cannot be uninitialized). When you writing managed pointer sign (a "^") you tell that this is actually a pointer, so the value can be null. There is a very simple way to make any value type to be able to hold "null" simple by using its type name with "?" at the end, like "IntPtr? a = null; // OK" , but that is another story and you can read docs about it
For your particular case. I have made small example, i hope its quite clear for you:
So testPointer is a property which returns IntPtr, a container for unmanaged pointer.
testSizeFromIntPtr() is a method (which actually can be static because it doesn't uses own pointer of texture, but provided one -- only because that is a purpose of this example). So the method actually uses given pointer, "unpacks" the container and treats the content like its video::ITexture*, as an example of success it returns size of the provided texture.
You can test it, use it with anything appropriate and post here the results. I can add these new feature, but i would really like to provide it with new example which uses it. So its not like something which no one knows that it there... it like with TexturePainter class. Its not a standard thing as for Irrlicht, it doesn't have it, in C++ you call lock() and then its your business what to do with returned "void*". So TexturePainter has clear aim and dedicated example I hope you get me.
For your "System::IntPtr" issue. Its a struct, not a class, so this is a value type not a reference type.
This is something like DateTime for example. The difference between class and struct in very short and simple manner is that value types may not hold null (cannot be uninitialized). When you writing managed pointer sign (a "^") you tell that this is actually a pointer, so the value can be null. There is a very simple way to make any value type to be able to hold "null" simple by using its type name with "?" at the end, like "IntPtr? a = null; // OK" , but that is another story and you can read docs about it
For your particular case. I have made small example, i hope its quite clear for you:
Code: Select all
// This is very test code i added into TexturePainter.cpp
property System::IntPtr testPointer { System::IntPtr get() { return System::IntPtr(m_texture->m_Texture); } }
Dimension2Di^ testSizeFromIntPtr(System::IntPtr some_valid_ITexture)
{
video::ITexture* t = (video::ITexture*) some_valid_ITexture.ToPointer();
return gcnew Dimension2Di(t->getSize());
}
testSizeFromIntPtr() is a method (which actually can be static because it doesn't uses own pointer of texture, but provided one -- only because that is a purpose of this example). So the method actually uses given pointer, "unpacks" the container and treats the content like its video::ITexture*, as an example of success it returns size of the provided texture.
Code: Select all
// This is C# code which uses test code above
Texture t = node.GetMaterial(0).GetTexture(0); // t.Size == {308 x 193}
TexturePainter tp = t.GetTexturePainter();
IntPtr p = tp.testPointer;
Dimension2Di s = tp.testSizeFromIntPtr(p); // s == {308 x 193}
Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine
.NET peculiarities.. Lately i spent most of my time coding in c++ and python, no wonder i forgot .NET stuff i knew
As for example - i would be on the lazy side and say that you cant provide example for every little function, altho i must say quantity of examples is stunning and its a great plus!
For me this seems good enough:
Its nothing more than:
Besides this is almost like standard feature anyway. Actually - it may not be the best way to implement this either.
What do you think about IntPtr Texture.Lock(...)? IntPtr.Zero could perfectly signal of failure, its as close to original api as it gets and saves us creating a new object.
And i have another question. Grab/Drop stuff made me wonder..
In this example we have throw-away anim object created and disposing of it requires calling Drop(). .NET being managed and all - this is almost like delete operator in c++ (and all of its flaws). Forgetting to call Drop() would leak an object right?
I was wondering - would it not be possible to call .Drop() in wrapper object finalizer? Wrapper object would free native native object upon garbage collection because refcount=1 would be decremented when object is garbage-collected. Now as i see it - we could probably avoid further grabs/drops altogether in managed code because as long as object reference exists somehwere - it would never be collected as garbage. What do you think? Or maybe there is good reason it cant work like this?
P.S. in case you are not aware of finalizers: http://blog.mythicsoft.com/2008/03/05/36/
As for example - i would be on the lazy side and say that you cant provide example for every little function, altho i must say quantity of examples is stunning and its a great plus!
For me this seems good enough:
Code: Select all
<member name="P:IrrlichtLime.Video.TexturePainter.Pointer">
<summary>Pointer to unmanaged memory containing texture pixel buffer in ColorFormat specified when creating texture.</summary>
</member>
Code: Select all
unsafe
{
uint* buffer = (uint*)painter.Pointer;
buffer[0] = 0; // set first pixel to black color;
}
What do you think about IntPtr Texture.Lock(...)? IntPtr.Zero could perfectly signal of failure, its as close to original api as it gets and saves us creating a new object.
And i have another question. Grab/Drop stuff made me wonder..
Code: Select all
SceneNodeAnimator anim = scene.CreateFlyCircleAnimator(new Vector3Df(0, 15, 0), 30.0f);
cam.AddAnimator(anim);
anim.Drop();
I was wondering - would it not be possible to call .Drop() in wrapper object finalizer? Wrapper object would free native native object upon garbage collection because refcount=1 would be decremented when object is garbage-collected. Now as i see it - we could probably avoid further grabs/drops altogether in managed code because as long as object reference exists somehwere - it would never be collected as garbage. What do you think? Or maybe there is good reason it cant work like this?
P.S. in case you are not aware of finalizers: http://blog.mythicsoft.com/2008/03/05/36/