Collision Detection example conversion....

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
Guest

Collision Detection example conversion....

Post by Guest »

Hello all,

I'm converting the collision detection example to c#, however, when I try to add the OctTree node I get the following error:

No overload for method 'AddOctTreeSceneNode' takes '1' arguments
Here's the code I'm using:

Code: Select all

			// add a zip archive
			device.FileSystem.AddZipFileArchive("../../media/map-20kdm2.pk3");
                                                // load the level mesh
			IAnimatedMesh q3levelmesh = device.SceneManager.GetMesh("20kdm2.bsp");
			ISceneNode q3node = device.SceneManager.AddOctTreeSceneNode(q3levelmesh.GetMesh(0));
Any suggestions?
Guest

gu

Post by Guest »

use:
ISceneNode node = device.SceneManager.AddOctTreeSceneNode(mesh, null, -1);

always check the function prototypes.
Guest

Post by Guest »

awesome. thanks for the answer.
Guest

Sliding Value

Post by Guest »

What is the purpose of the last overload a.k.a the 'sliding' value in the following constructor:

Code: Select all

ISceneNodeAnimator anim = device.SceneManager.CreateCollisionResponseAnimator(
selector, 
camera, 
new Vector3D(30,50,30), 
new Vector3D(0,-3,0), 
new Vector3D(0,50,0), 
0);
If I set it to -1, then the camera drops through the floor and keeps going, however, if I set it to 1 the camera obeys collision detection. Why would you need to set this other than with a positive value?
Guest

Sliding Value

Post by Guest »

What is the purpose of the last overload a.k.a the 'sliding' value in the following constructor:

Code: Select all

ISceneNodeAnimator anim = device.SceneManager.CreateCollisionResponseAnimator(
selector, 
camera, 
new Vector3D(30,50,30), 
new Vector3D(0,-3,0), 
new Vector3D(0,50,0), 
0);
If I set it to -1, then the camera drops through the floor and keeps going, however, if I set it to 1 the camera obeys collision detection. Why would you need to set this other than with a positive value?
Guest

Post by Guest »

The .cpp source contains the following:

Code: Select all

		if (smgr->getSceneCollisionManager()->getCollisionPoint(
			line, selector, intersection, tri))
		{
			bill->setPosition(intersection);
				
			driver->setTransform(video::ETS_WORLD, core::matrix4());
			driver->setMaterial(material);
			driver->draw3DTriangle(tri, video::SColor(0,255,0,0));
		}
When I convert the matrix4() over to c# I get build errors...here's what I used:


Code: Select all

					if (device.SceneManager.SceneCollisionManager.GetCollisionPoint(line, selector, intersection, tri))
					{
						billboard.Position = intersection;				
						device.VideoDriver.SetTransform(new TransformationState WORLD, new Matrix4 Matrix4());
						device.VideoDriver.SetMaterial(material);
						device.VideoDriver.Draw3DTriangle(tri, new Irrlicht.Video.Color(0,255,0,0));
					}
I've been looking at this too long. The error is in the Matrix4 use...any suggestions?
Foole
Posts: 87
Joined: Mon Aug 29, 2005 10:08 am

Post by Foole »

Try:

Code: Select all

device.VideoDriver.SetTransform(TransformationState.WORLD, new Matrix4());
I can't think why you would put Matrix4 in there twice.
Guest

Post by Guest »

Well Foole, your suggestion was tested and unfortunately i get a different type of build error now.

Code: Select all

A new expression requires () or [] after type
; expected
Invalid expression term ','
; expected
; expected
Invalid expression term ')'
Foole
Posts: 87
Joined: Mon Aug 29, 2005 10:08 am

Post by Foole »

It works here.

I can only guess that you didn't replace the line. ie replace your line (the one with "SetTransform" in it) with my line.

If you still can't get it working, post the whole block of code again.
Guest

Post by Guest »

Hi Foole:: Good one. I'm no longer getting that error for that statement. Thanks for the help.
Guest

Post by Guest »

When creating the line for collision detection, I get the following build error:

Code: Select all

Operator '+' cannot be applied to operands of type 'Irrlicht.Core.Vector3D' and 'Irrlicht.Core.Vector3D'

from the following line:

Code: Select all

Line3D line;
line.start = camera.Position;
line.end = line.start + (camera.Target - line.start).Normalize() * 1000; //produces build error
Foole
Posts: 87
Joined: Mon Aug 29, 2005 10:08 am

Post by Foole »

Anonymous wrote:When creating the line for collision detection, I get the following build error:

Code: Select all

Operator '+' cannot be applied to operands of type 'Irrlicht.Core.Vector3D' and 'Irrlicht.Core.Vector3D'
Yup that's a bug in the bindings. I wrote a post about it a while ago but I didn't get a response.

Your options are:
  • - Fix the bindings.
    - Write your own vector addition function in C#
    - Use Vector3D.op_Addition(o1, o2) instead (Not sure if this works)
Locked