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
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

Hey, I found an error, take this bit of code, I did to get around it.

SceneManager scene = device.SceneManager;
LightSceneNode myLight = scene.AddLightSceneNode();
myLight.Position = new Vector3Df(17.00f, 17.00f, 0.00f);
Light lightData = new Light();
lightData.DiffuseColor = new Colorf(0.00f, 0.00f, 1.00f, 1.00f);
myLight.LightData.DiffuseColor = lightData.DiffuseColor; (Should be: myLight.LightData = lightData; That gives a read only error.)

Now, Lightdata is not supposed to be read only, but it is. I would think that is why there is a Light type, also in Irrlicht, there is a SetLightData. I could likily fix the issue myself, but I thought I would also pass it along.
I want to thank you for all your hard work, and I am so grateful you made this wrapper.

Edit: I came across another class that has a property that also should not be read only, Light.Type. As Light is just a class that only holds data, , all of its properties should not be read only.

New Edit: I don't know how to set a light type in a scene, as it is read only too. I tried:

LightSceneNode mySpotLight = scene.AddLightSceneNode();
mySpotLight.LightData.Type = LightType.Spot; (Wont work, LightData.Type is read only.)

New Edit: I found it, by going to the definition, should have done that first, its mySpotLight.LightType = LightType.Spot;

New Edit: I looked over the Light definition, and it has a few read only properties, though I don't know why. Could you explain please why that is? I don't understand, here they are.

public bool CastShadows {get; }
public Vector3Df Direction {get; }
public Vector3Df Position {get; }
public float Radius {get; }

New Edit:
I did some looking at the wrapper source, and I think it may be you had no choice, unless you wanted to make translation functions. It may be that you just left the Light class in there because it was in Irrlicht, and it is no longer needed. I just wont use it any more, as the book does for Irrlicht using the ILightSceneNode->setLightData() function.

Thank you for your time.
if (Try()) Do(); else DoNot();
if (Try()) Do(); else DoNot();
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 »

LanceJZ wrote:Edit: I came across another class that has a property that also should not be read only, Light.Type. As Light is just a class that only holds data, , all of its properties should not be read only.
I did some properties of LightData to be read-only because when i was porting it, doc states that they are read-only (like now):
http://irrlicht.sourceforge.net/docu/st ... light.html
please note all the properties with "Read-ONLY!" mark.

The Type, Radius and CastShadows of light can be set via LightSceneNode properties.
The Position is supposed to be set via SceneNode.Position.
The Direction is supposed to be changed via SceneNode.Rotation.

As you see, you are able to change all the values from default light.
If we look into /source/Irrlicht/CLightSceneNode.cpp (in Irrlicht source) we see that LightData is a struct which gets recalculated in some circumstances, for example:

Code: Select all

void CLightSceneNode::setRadius(f32 radius)
{
        LightData.Radius=radius;
        LightData.Attenuation.set(0.f, 1.f/radius, 0.f);
        doLightRecalc();
}
So when we set Radius via ILightSceneNode::setRadius(), we get changed some of the values automatically. Besides doLightRecalc() is a private method, which depend on light type recalculates LightData. So i really don't know why we need setLightData(), if some values (which are states as read-only) will be ignored, since for instance Position and Direction will be taken from current ILightSceneNode' Position and Rotation value.

This is quite a question for me for now, that is why i didn't ported that method.
imho, the only reason why this method is useful, is that you can set couple of light-parameters at once.

P.S.: thank you for this investigation.


--------------------------------------------------------------- ADDED ----------------------------------------------------------------


1) i will port ILightSceneNode::setLightData();
2) i will make set-able (currently read-only) props in Light class; because we have VideoDriver.AddDynamicLight(), which takes Light argument, and i don't know how user can set all up;
3) i will add proper notes to doc;

P.S.: thanks again, LanceJZ.
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

Thank you so much, I'm happy to help. I'm doing the Beginners Guide book, and that is how I came about the issue. Ah, I did not find that information during my search, I must be a bad searcher. I'm looking forward to the update!
My plans are to port an almost finished game I did in XNA to Irrlicht Lime, its current name is Base Defender. It is a little like Williams Defender, with some 'Tower Defense' mixed in. Currently it is in 2D, I'm also converting it to 3D graphics.
Here is a link to my web site: http://tinyurl.com/LanceXNA
Thank you again, for taking the time to answer that in such a clear and concise manner. I did not know about those other things.
As for what the method is for, I think it is so if you are setting a bunch of settings, you don't need to make a call for each one, you pass them in one method call. Each method call to pass one property takes a little CPU time. It is the only reason I can think of. It is not of that much importance, as I understand it, it is more for performance and readability.

Thank you for your time.
if(Try()) Do(); else DoNot();
if (Try()) Do(); else DoNot();
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 »

LanceJZ, I have committed the changes i mentioned above to svn trunk. I don't know what you use (1.0 or svn trunk). Soon i release 1.1 where all these changes will be included, i just waiting for zlib updates merge from 1.7.3 to svn trunk of native Irrlicht Engine.
bdpdonp
Posts: 68
Joined: Sat Oct 10, 2009 6:35 am

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

Post by bdpdonp »

I am anxiously waiting the next release. I experimented with Lime and the performance and I am quite pleased. C# and irrlicht, programming cannot get any better.
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

I thought I would post a nice Game Template for other users out there. I've included a Positioned Object class, that will move, or rotate using the timer, based on velocity and acceleration. Feel free to Download and use it yourself!

Always happy to help.

If (Try()) Do(); else DoNot();
if (Try()) Do(); else DoNot();
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

greenya wrote:LanceJZ, I have committed the changes i mentioned above to svn trunk. I don't know what you use (1.0 or svn trunk). Soon i release 1.1 where all these changes will be included, i just waiting for zlib updates merge from 1.7.3 to svn trunk of native Irrlicht Engine.
Oh thank you! I use TortoiseSVN!
if (Try()) Do(); else DoNot();
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

bdpdonp wrote:I am anxiously waiting the next release. I experimented with Lime and the performance and I am quite pleased. C# and irrlicht, programming cannot get any better.
I've gotten very good performance as well, I'm very excited about this wrapper as well.
if (Try()) Do(); else DoNot();
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

I've found another error. This seems to be an issue with the camera node. I can't move it by using Vector3f.X I have to feed in the Vector3f. IE:

Vector3Df move = new Vector3Df(playerShipPO.Position.X, 0, -40);
Vector3Df moveTarget = new Vector3Df(playerShipPO.Position.X, 0, 0);
cameraSceneNode.Position = move;
cameraSceneNode.Target = moveTarget;

This will have no effect on the CameraNode's Position or Target properties:
Trying to use cameraSceneNode.Position.X = playerShipPO.Position.X; or cameraSceneNode.Target.X = playerShipPO.Position.X;

If you could look into this for me, that would be great.

Thank you for your time.
if(Try()) Do(); else DoNot();
if (Try()) Do(); else DoNot();
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 »

LanceJZ,
this works as expected.
And it is not about CameraNodes only, its about almost any method and property in the Lime that returns some type like Vector3Df, Color, AABBox etc.

----------

Position prop returns a copy, to avoid next situation:

Code: Select all

Vector3Df v = node.Position;
v.X = ...;
// now node.Position.X also has changed !
in this case we would force user to write (every time):

Code: Select all

Vector3Df v = new Vector3Df(node.Position);
v.X = ...;
i choose to return a copy, so Position is a copy already, and writing node.Position.X = ...; is invalid (makes no sense); the only i feel bad about that i cannot catch writing node.Posotion.X = ... with some assert check for user.

I can add get-only prop named PositionRef, which will allow to write node.PositionRef.X = ...; but i don't feel like this is good approach.

P.S.: in native Irrlicht it is works next way:
ISceneNode::getPosition() returns a const reference, but in C# you cannot define "const" in the variety of meanings that C++ has (like const return values or const methods).
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

greenya wrote:LanceJZ,
this works as expected.
And it is not about CameraNodes only, its about almost any method and property in the Lime that returns some type like Vector3Df, Color, AABBox etc.

----------

Position prop returns a copy, to avoid next situation:

Code: Select all

Vector3Df v = node.Position;
v.X = ...;
// now node.Position.X also has changed !
in this case we would force user to write (every time):

Code: Select all

Vector3Df v = new Vector3Df(node.Position);
v.X = ...;
i choose to return a copy, so Position is a copy already, and writing node.Position.X = ...; is invalid (makes no sense); the only i feel bad about that i cannot catch writing node.Posotion.X = ... with some assert check for user.

I can add get-only prop named PositionRef, which will allow to write node.PositionRef.X = ...; but i don't feel like this is good approach.

P.S.: in native Irrlicht it is works next way:
ISceneNode::getPosition() returns a const reference, but in C# you cannot define "const" in the variety of meanings that C++ has (like const return values or const methods).
Oh. Thank you for explaining that.
if (Try()) Do(); else DoNot();
bdpdonp
Posts: 68
Joined: Sat Oct 10, 2009 6:35 am

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

Post by bdpdonp »

In irrlicht there was a way to prevent the DOS box from coming up. Is there a way to do that in C#/IrrlichtLime?

Nevermind, forgot in C# it is a setting in preferences.
LanceJZ
Posts: 23
Joined: Mon Feb 13, 2012 12:46 am
Location: Seattle
Contact:

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

Post by LanceJZ »

bdpdonp wrote:In irrlicht there was a way to prevent the DOS box from coming up. Is there a way to do that in C#/IrrlichtLime?

Nevermind, forgot in C# it is a setting in preferences.
LOL
if (Try()) Do(); else DoNot();
bdpdonp
Posts: 68
Joined: Sat Oct 10, 2009 6:35 am

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

Post by bdpdonp »

A question, if it has been tried. I can try it myself later, but what about x64? From the IrrlichtLime if I rebuild irrlicht then Live as 64 bit, does it work?
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 »

bdpdonp,
I haven't tried to build x64, so cannot say is it possible to build it at all.
Post Reply