Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by greenya »

I haven't check your code.
But you can check example L09.SimpleLOD, there when you enable drawing labels (by pressing L) it draws labels to all near and visible planets. To do that it uses exactly what you need -- it translates 3d world coordinates to 2d screen coordinates.

Code: Select all

            if (LabelPositions != null && currentLOD <= 4)
            {
                Vector2Di p = device.SceneManager.SceneCollisionManager.GetScreenCoordinatesFrom3DPosition(transformation.Translation);
 
                // now we filter here results which will not be visible; we know that:
                // - GetScreenCoordinatesFrom3DPosition() returns {-10000,-10000} for behind camera 3d positions
                // - we do not need to draw out small text if its out of the screen
                // p.s.: without this filtering we will have about 200-300 labels to draw (instead of about 10-20 which are trully visible)
                if (p.X > -200 && p.X < screenSize.Width + 200 &&
                    p.Y > -100 && p.Y < screenSize.Height + 100)
                {
                    int t = meshLODs[currentLOD].GetMeshBuffer(0).IndexCount / 3;
                    int d = (int)(transformation.Translation - cameraPosition).Length;
 
                    LabelPositions.Add(p);
                    LabelTexts.Add(
                        "LOD: " + currentLOD.ToString() +
                        "\nTrinagles: " + t.ToString() +
                        "\nDistance: " + d.ToString());
                }
            }
So p is waht you need.
Just remember, GetScreenCoordinatesFrom3DPosition() returns {-10000,-10000} if provided 3d coordinate located behind the camera (in the back hemisphere). It doesn't mean its visible, exactly for this you see the following comment and the condition check: if resulting 2d point located more then 200 pixels away horizontally or 100 away vertically from the screen, we assume that its not visible. In your case it depends on what length of the text or what kind of the stuff you want to draw at the screen. I think you get the point.
render_noob
Posts: 2
Joined: Wed Feb 26, 2014 7:16 am

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by render_noob »

Oh great, I didn't see that function, thanks.

I'll take a look at the code and see how it work, thanks so much for the tip!
michaldawn
Posts: 4
Joined: Tue Apr 08, 2014 11:36 am

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by michaldawn »

Hello all. I'm thinking about using IrrLicht Lime for my next project. I'm trying some basic code, but I stuck with application building.
  • I set IrrLichtLime.dll reference
    I set Platform to Active(x86) in project properties
    I also set Platform target to x86
Building application works fine, but when application is started FileNotFoundException occures. FileName is IrrlichtLime.dll.
I have all three files (Irrlicht.dll, IrrlichtLime.dll, IrrlichtLime.xml) in my project bin directory with EXE file.
I'm using Windows 8, 64bit, MVS Proffesional 2012, Microsoft Visual C++ 2010 x86 Redistributable (10.0.40219).

I know this has been solved several times, but now I am clueless. Is there someone who use IrrLicht at same configuration?
michaldawn
Posts: 4
Joined: Tue Apr 08, 2014 11:36 am

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by michaldawn »

More info...: I'm using Windows 8.1 (to be precise). I still searching at internet and I'm starting to worry that it will be some system DLL missing problem.
michaldawn
Posts: 4
Joined: Tue Apr 08, 2014 11:36 am

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by michaldawn »

It looks like "API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL" and "EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL" problem.... :( This relates with windows 8.1
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by greenya »

michaldawn wrote:Building application works fine, but when application is started FileNotFoundException occures. FileName is IrrlichtLime.dll.
I have all three files (Irrlicht.dll, IrrlichtLime.dll, IrrlichtLime.xml) in my project bin directory with EXE file.
Can you start your app outside Visual Studio, simply by locating the output folder in Explorer and starting your app manually?
Also make sure that you don't mix different Irrlicht Lime versions and you don't provide different Irrlicht.dll (you have to use the dll which provided with the Lime's SDK only).
michaldawn
Posts: 4
Joined: Tue Apr 08, 2014 11:36 am

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by michaldawn »

When I start application directly by clicking on EXE file a get same error.....

But after some test I found solution. When I add MSVCR100D.dll into bin directory, it works (even with debug in VS2012). I have MV C++ 2010 x86 Redistributable and MV C++ 2012 Redistributable (x86) installed, but for some reason I had to put this file directly to the bin directory.

I found this using Dependency Walker..... There are more missing DLLs, but this one was critical. I suppose it's a problem Windows 8.1 only.
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

x64 Build Successful

Post by Foaly »

Hello.
Today I had success building Irrlicht Lime 1.4 + Irrlicht rev 4527 for 64 bit.
It was possible without altering any Irrlicht Lime code.
It works without problems with the usual Examples (when they are compiled for x64, of course).

Direct3D 8 is not included because I could not find the libraries.
I would be happy if the next Irrlicht Lime Release would contain x64 dlls.
joemeng967
Posts: 2
Joined: Fri Apr 18, 2014 3:26 am

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by joemeng967 »

Just rewrote the Hello World in VB Net

Code: Select all

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports IrrlichtLime
Imports IrrlichtLime.Core
Imports IrrlichtLime.Video
Imports IrrlichtLime.Scene
Imports IrrlichtLime.GUI
Namespace _01.HelloWolrd
    Class Program ' Starts the Main Class
        Public Shared Sub Main() ' Starts the Program itself
            Dim device As Object = IrrlichtDevice.CreateDevice(DriverType.Software, New Dimension2Di(640, 480), 16, False, False, False)
            ' Starts the Irrlicht Driver and Device
        device.SetWindowCaption("Irrlicht Engine Demo in VB. NET")
        ' Starts the Caption
            Dim driver As Object = device.VideoDriver
            Dim smgr As Object = device.SceneManager
            Dim gui As Object = device.GUIEnvironment
            gui.AddStaticText("This is Irrlicht written in Visual Basic .NET using Irrlicht Lime", New Recti(10, 10, 260, 22), True)
            Dim mesh As Object = smgr.GetMesh("media/sydney.md2")
            Dim node As Object = smgr.AddAnimatedMeshSceneNode(mesh)
        ' Assigns all the Variables as Objects
 
            If node IsNot Nothing Then
                node.SetMaterialFlag(MaterialFlag.Lighting, False)
                node.SetMD2Animation(AnimationTypeMD2.Stand)
                node.SetMaterialTexture(0, driver.GetTexture("media/sydney.bmp"))
            End If
            ' If node is not null start loading the models and textures
            smgr.AddCameraSceneNode(Nothing, New Vector3Df(0, 30, -40), New Vector3Df(0, 5, 0))
            While device.Run()
                driver.BeginScene(True, True, New Color(100, 101, 140))
                smgr.DrawAll()
                gui.DrawAll()
                driver.EndScene()
            End While
            device.Drop()
        End Sub
        ' Render the Scene and Delete the Device
 
    End Class
End Namespace
' End the Program
Pretty Easy, the wrapper works flawlessly no Slow Downs or Lag
stefany
Posts: 58
Joined: Wed Dec 07, 2011 10:50 am

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by stefany »

Compiled and running in Windows 8.1 64 bits in release mode. But in debug mode i get a FileNotFoundException, some strange dependency problem, i think.
AltSoftLab
Posts: 15
Joined: Thu May 01, 2014 5:53 pm
Contact:

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by AltSoftLab »

Hi Irrlicht Lime Developers!

I'm developer of AltSoftLab Team
http://www.AltSoftLab.com

We presented Irrlicht HW Render Backend (via Irrlicht Lime) of our AltSketch Vector Graphics Library here on forum thread http://irrlicht.sourceforge.net/forum/v ... =6&t=49917

After the work on Irrlicht integration we have some feature requests & maybe useful recomendations for you.

Feature Requests:

1. It's more efficient to realize S3DVertex in C# or managed C++ and just put the pointer to DrawVertexPrimitiveList than operate with often created/destroied classes with Vertex3D & memory copies.

We implemented S3DVertex like this:

Code: Select all

 
    [StructLayout(LayoutKind.Sequential)]
    public struct S3DVertex
    {
        public Vector3f Pos;
        public Vector3f Normal;
        public int Color;
        public Vector2f TCoords;
    }
 
Vector3f, Vector2f - it's AltSketch structures and can be replaced with just floats like x, y, z, etc.

Please add following method to VideoDriver (or with IntPtr-s if you like more):

Code: Select all

 
    void DrawVertexPrimitiveList(const void* vertices, u32 vertexCount,
                const void* indexList, u32 primCount,
                VertexType vType,
                Scene::PrimitiveType pType,
                IndexType iType)
    {
        m_VideoDriver->drawVertexPrimitiveList(vertices, vertexCount,
                    indexList, primCount,
                    (E_VERTEX_TYPE) vType,
                    (scene::E_PRIMITIVE_TYPE) pType,
                    (E_INDEX_TYPE) iType);
    }
 
We use it like this:

Code: Select all

 
                    unsafe
                    {
                        fixed (void* vertices = &m_S3DVertexArray[0])
                        {
                            fixed (void* indexList = &indicesUInt16[0])
                            {
                                videoDriver.DrawVertexPrimitiveList(vertices, (uint)Positions.Length,
                                    indexList, (uint)PrimitiveCount,
                                    VertexType.Standard, PrimitiveType, IndexType._16Bit);
                            }
                        }
                    }
 
Also DrawVertexPrimitiveList is only way now to put S3DVertex2TCoords to render with custom PrimitiveType

2. It's need Cursor support!

We realized it like this (please add same support to CursorControl):

Code: Select all

 
    public enum class Cursor_Icon
    {
        // Following cursors might be system specific, or might use an Irrlicht icon-set. No guarantees so far.
        Normal = irr::gui::ECI_NORMAL,  // arrow
        Cross = irr::gui::ECI_CROSS,    // Crosshair
        Hand = irr::gui::ECI_HAND,  // Hand
        Help = irr::gui::ECI_HELP,  // Arrow and question mark
        IBeam = irr::gui::ECI_IBEAM,    // typical text-selection cursor
        No = irr::gui::ECI_NO,      // should not click icon
        Wait = irr::gui::ECI_WAIT,  // hourclass
        SizeAll = irr::gui::ECI_SIZEALL,    // arrow in all directions
        SizeNESW = irr::gui::ECI_SIZENESW,  // resizes in direction north-east or south-west
        SizeNWSE = irr::gui::ECI_SIZENWSE,  // resizes in direction north-west or south-east
        SizeNS = irr::gui::ECI_SIZENS,  // resizes in direction north or south
        SizeWE = irr::gui::ECI_SIZEWE,  // resizes in direction west or east
        Up = irr::gui::ECI_UP,      // up-arrow
 
        // Implementer note: Should we add system specific cursors, which use guaranteed the system icons,
        // then I would recommend using a naming scheme like ECI_W32_CROSS, ECI_X11_CROSSHAIR and adding those
        // additionally.
 
        Count = irr::gui::ECI_COUNT     // maximal of defined cursors. Note that higher values can be created at runtime
    };
 
 
public ref class CursorControl : ReferenceCounted
{
public:
 
        ...
 
    void SetActiveIcon(Cursor_Icon iconId)
    {
        m_CursorControl->setActiveIcon((ECURSOR_ICON)iconId);
    }
 
        ...
};
 

Also I just try to give you some recomendations. Maybe it will be useful for you:

1. Some theory (sorry): Yes, for maximum similarity with C++ code it's more efficient to use C++ wrapper classes. But in many cases it's too much extensive because of massive additional operations where only simple operation must use. For example: the only way now to set/get color of Vertex3D or color pixel in TexturePainter is to create a Color object. But is more simple and fastest way is to set Int value, or Color struct that contains Int. In many cases when we process massive data (vector arrays, etc.) just operations with structures is more efficient then with class instancies. Yes C# (or .NET at all) is different from native C++ and we must not to create absolutely comparable interfaces. More good way to use platform features and differences form native interfaces to create efficient programs.

2. Just a few optimisation recomendations:
In Draw2DVertexPrimitiveList (and same funcs) you create index and vertex arrays, copy there src data, call native draw2DVertexPrimitiveList, and then delete temporary arrays. It's not good because of addition memory allocations and copy operations. And of course slower then use src data simpliciter.

a) For Int (Int16) arrays (or other arrays of simple data) is more good and faster to use pin_ptr like this (you not need temporary arrays at all):

Code: Select all

 
   pin_ptr<int> p = &arr[0];   // pin pointer to first element in arr
   int* np = p;   // pointer to the first element in arr
 
b) Just to not create and destroy vertex temporary arrays you can use common temporary array of large size. For example just create pointer variable to temporary array in VideoDriver and int variable for size. When you need temporary array you just compare existing tempArray size with needed. If it's lesser, then delete old and create new of larger size. If larger or equals, just copy data to there and in draw2DVertexPrimitiveList put the needed data size. If putted array is larger then needed - it's not bad, because you put needed size. But you don't need to create/destroy memory of large data size.

Best regards!

Evgeny,
AltSoftLab Team
AltSoftLab Team
Be Individuality - Choose Alternative ©
http://www.AltSoftLab.com/
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by Foaly »

Hello!

I'm really happy about IrrlichtLime being used in a bigger project!
It's need Cursor support!
I think this has been missed, I'll add it soon.
In Draw2DVertexPrimitiveList (and same funcs) you create index and vertex arrays, copy there src data, call native draw2DVertexPrimitiveList, and then delete temporary arrays. It's not good because of addition memory allocations and copy operations. And of course slower then use src data simpliciter.
Thank you. I'll try it.
Yes, for maximum similarity with C++ code it's more efficient to use C++ wrapper classes. But in many cases it's too much extensive because of massive additional operations where only simple operation must use. For example: the only way now to set/get color of Vertex3D or color pixel in TexturePainter is to create a Color object. But is more simple and fastest way is to set Int value, or Color struct that contains Int. In many cases when we process massive data (vector arrays, etc.) just operations with structures is more efficient then with class instancies. Yes C# (or .NET at all) is different from native C++ and we must not to create absolutely comparable interfaces. More good way to use platform features and differences form native interfaces to create efficient programs.
I was already thinking about replacing some classes by structs. Maybe I'll implement it.
AltSoftLab
Posts: 15
Joined: Thu May 01, 2014 5:53 pm
Contact:

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by AltSoftLab »

Foaly wrote:Hello!

I'm really happy about IrrlichtLime being used in a bigger project!
You are welcome! We also had good experience with Irllicht thanks to Irrlicht Lime! Thank you for good work!
Foaly wrote:
It's need Cursor support!
I think this has been missed, I'll add it soon.
Thanks!
Foaly wrote:
In Draw2DVertexPrimitiveList (and same funcs) you create index and vertex arrays, copy there src data, call native draw2DVertexPrimitiveList, and then delete temporary arrays. It's not good because of addition memory allocations and copy operations. And of course slower then use src data simpliciter.
Thank you. I'll try it.
We already tried this and it works. It's very easy and not takes much time
Foaly wrote:I was already thinking about replacing some classes by structs. Maybe I'll implement it.
Good luck!

Evgeny,
AltSoftLab Team
AltSoftLab Team
Be Individuality - Choose Alternative ©
http://www.AltSoftLab.com/
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by greenya »

AltSoftLab wrote:1. It's more efficient to realize S3DVertex in C# or managed C++ and just put the pointer to DrawVertexPrimitiveList than operate with often created/destroied classes with Vertex3D & memory copies.
It is faster to reimplement them of cause. But i choose wrapping because its easier to further support the project. If Irrlicht devs fixes bug in native Vertex3D, than that fix automatically used in Lime after you rebuild it. You also don't need to convert/copy data all over managed/unmanaged arguments when you call any native Irrlicht' stuff. You just pass the pointer on native object. I don't say that my approach was the best.

For methods like DrawVertexPrimitiveList() and others which takes an array of some Vectors or Vertices for performance reasons can be implemented additional classes like Vector3DArray or Vertex3DArray. So they internally manages native array of what they need. And additional overloading for DrawVertexPrimitiveList() and similar methods can be added to be able to work with that kind of data.

I know that calling to DrawVertexPrimitiveList() in current implementation is slow, it does allocation, copying and deallocation. But that is simple method, it doesn't leaves any trases or hidden workarounds. We need to work with a mesh fast, well, maybe actually working is not that fast in managed language than in native c++, but if just draw your editabale mesh - that should be fast as native routine. Please take a look at L16.SphereCamera example (in SpherePath.cs), it uses special classes VertexBuffer and IndexBuffer (which are not something that is Lime-only, they are Irrlicht's native things). With them you can handle your mesh more or less easily, but the main advantage is that you draw these buffers very fast, since no conversion between managed/unmanaged is taking place when simply draw them. I must admit that is more "advanced" level. Besides those vertex/index buffers are drawn using DrawVertexPrimitiveList() overloadings.
AltSoftLab
Posts: 15
Joined: Thu May 01, 2014 5:53 pm
Contact:

Re: Irrlicht Lime is a .NET wrapper for Irrlicht Engine

Post by AltSoftLab »

Hi greenya! Sorry for delay... We worked on new AltSketch release. You can see description here http://irrlicht.sourceforge.net/forum/v ... =6&t=49917
greenya wrote:
AltSoftLab wrote:1. It's more efficient to realize S3DVertex in C# or managed C++ and just put the pointer to DrawVertexPrimitiveList than operate with often created/destroied classes with Vertex3D & memory copies.
It is faster to reimplement them of cause. But i choose wrapping because its easier to further support the project. If Irrlicht devs fixes bug in native Vertex3D, than that fix automatically used in Lime after you rebuild it. You also don't need to convert/copy data all over managed/unmanaged arguments when you call any native Irrlicht' stuff. You just pass the pointer on native object. I don't say that my approach was the best.
I think you can create some code tests for those types. For example, check the size of type, check field offset, etc. It's not many types and I think they don't change often. If you use only 1 vertex, it's not a problem. But when you use vertex array - it's a problem! I need to create Color object each time when I need to set a color. But Color in Irrlicht is just a UInt32 value. Also YOU ALWAYS COPY S3DVertex in Draw2DVertexPrimitiveList. Every render operation. It's not good at all! In other words, I think structures must stay structures.

Also some times Dimension2Di generate Exceeptions. Yes... Some times it try to delete already deleted native object. Simple structure, but many trubbles. I think it owned by any other Irrlicht object and deleted by it. So when you try to delete it then you are wrong... It's another reason to use structures.
greenya wrote:For methods like DrawVertexPrimitiveList() and others which takes an array of some Vectors or Vertices for performance reasons can be implemented additional classes like Vector3DArray or Vertex3DArray. So they internally manages native array of what they need. And additional overloading for DrawVertexPrimitiveList() and similar methods can be added to be able to work with that kind of data.
Yes, it's another way.
greenya wrote:I know that calling to DrawVertexPrimitiveList() in current implementation is slow, it does allocation, copying and deallocation. But that is simple method, it doesn't leaves any trases or hidden workarounds. We need to work with a mesh fast, well, maybe actually working is not that fast in managed language than in native c++, but if just draw your editabale mesh - that should be fast as native routine. Please take a look at L16.SphereCamera example (in SpherePath.cs), it uses special classes VertexBuffer and IndexBuffer (which are not something that is Lime-only, they are Irrlicht's native things). With them you can handle your mesh more or less easily, but the main advantage is that you draw these buffers very fast, since no conversion between managed/unmanaged is taking place when simply draw them. I must admit that is more "advanced" level. Besides those vertex/index buffers are drawn using DrawVertexPrimitiveList() overloadings.
Yes, vetex and index buffers are more good way! We use it in Axiom/MOGRE integrations. BUT! We need to change data VERY often!!! Each frame we need to fill vertex and index data. SO we need to fill beffers. And agayn it's slow with your dynamic classes. It's not only Managed trouble. It's not good way at all. And not good way in languages that hasn't inlines and compile time templates.

Best regards!
AltSoftLab Team
Be Individuality - Choose Alternative ©
http://www.AltSoftLab.com/
Post Reply