C# Vectors

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
NextDesign

C# Vectors

Post by NextDesign »

Hi, I am trying to follow the tutorials, converting them to C#, and whenever the tutorial says "vector3df" C# won't let me. This is the code that Im trying to make.
scene::ILightSceneNode* light = smgr->addLightSceneNode(0,
core::vector3df(-15,5,-105), video::SColorf(1.0f, 1.0f, 1.0f));
But C# doesn't have the vector3df. only vector3d. so when I write the code:
ILightSceneNode light = smgr.AddLightSceneNode(0, Vector3D(-15, 5, -105), irr.video.SColorf(1.0f, 1.0f, 1.0f));
It gives me these errors:
'Irrlicht.Core.Vector3D' is a 'type' but is used like a 'variable'
'irr.video.SColorf' is a 'type', which is not valid in the given context
Am I just setting it incorrectly? Could someone help me with this? Also, if someone had a MSN address that would be awsome!

Thanks
groats
Posts: 7
Joined: Tue Mar 21, 2006 11:49 am

Post by groats »

In c# you need to use the new keyword to make a new instance of the Vector3d and Colorf i.e

ILightSceneNode light = smgr.AddLightSceneNode(0, new Vector3D(-15, 5, -105), new irr.video.SColorf(1.0f, 1.0f, 1.0f));

hope this helps
Last edited by groats on Tue May 02, 2006 4:55 pm, edited 1 time in total.
NextDesign
Posts: 12
Joined: Mon Mar 20, 2006 11:10 pm
Contact:

Post by NextDesign »

Ok so I inputed that code and now I get these errors.
The type 'irr.video.SColorf' has no constructors defined
No overload for method 'AddLightSceneNode' takes '3' arguments
groats
Posts: 7
Joined: Tue Mar 21, 2006 11:49 am

Post by groats »

ok, the protoype of the c# is a little different than the C++, the first param
is null if you don't want to set a parent node and you need to set the radius and an id, in this case I have chosen 50 for the radius and -1 (for no id.)

Code: Select all

ILightSceneNode light = smgr.AddLightSceneNode(null, new Vector3D(-15, 5, -105), new Colorf(1.0f, 1.0f, 1.0f), 50, -1); 
also don't forget to set any nodes in your scene to have

Code: Select all

node.SetMaterialFlag(MaterialFlag.LIGHTING, true);
else they won't dynamically light.

Hope this helps a bit more :D
Last edited by groats on Tue May 02, 2006 4:55 pm, edited 1 time in total.
NextDesign
Posts: 12
Joined: Mon Mar 20, 2006 11:10 pm
Contact:

Post by NextDesign »

thank you so much!
Last edited by NextDesign on Wed Mar 22, 2006 12:47 am, edited 3 times in total.
Post Reply