Page 1 of 1

Plane intersection

Posted: Sun Feb 21, 2010 10:13 pm
by Escen
Hello guys

I'm struggling several days now and I need some help here...

I have made an simple CustomSceneNode (pic A). I want to extent the edges with line3df and get the intersection with the underlying plane, like wanted result in pic B.

After Rotating the node I do get intersections but it looks like the plane turns within the Node.
The object shape stays unchanged and looks like the original shape (pic A).

Can anyone give my some advice? How do I get the intersections with a static ground plane?

I tweaked the code snip a little but this is in general what I'm doing.

Image

Render part:

Code: Select all

 void vofcameraNode::render()
{
		u16 indices[] = {0,2,3, 1,3,0, 2,0,1, 3,2,4, 4,2,1, 3,1,4};
		
		video::IVideoDriver* driver = SceneManager->getVideoDriver();
		SenMaterial.BackfaceCulling=false;

		driver->setMaterial(SenMaterial);
        driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
		
		driver->drawIndexedTriangleList(&Vertices[0], 5, &indices[0], 6);

        video::SColor color =video::SColor(255,255,255,0);
        LineMaterial.Thickness=1;
        LineMaterial.AmbientColor = LineMaterial.DiffuseColor = LineMaterial.EmissiveColor = color;

		driver->setMaterial(LineMaterial);

        //sensor edges
        driver->draw3DLine(Vertices[2].Pos,Vertices[0].Pos,color);
        driver->draw3DLine(Vertices[2].Pos,Vertices[1].Pos,color);
        driver->draw3DLine(Vertices[2].Pos,Vertices[3].Pos,color);
        driver->draw3DLine(Vertices[2].Pos,Vertices[4].Pos,color);
        //footprint
        driver->draw3DLine(Vertices[0].Pos,Vertices[1].Pos,color);
        driver->draw3DLine(Vertices[1].Pos,Vertices[4].Pos,color);
        driver->draw3DLine(Vertices[4].Pos,Vertices[3].Pos,color);
        driver->draw3DLine(Vertices[3].Pos,Vertices[0].Pos,color);

        driver->draw3DLine(LineRay.start,LineRay.end,color);

};
Calculate intersection vertex #1

Code: Select all

void SensorManager::changeRoll()
{
        //calculate intersection vertex #1
        core::vector3df vert_pos (VOFNode->Vertices[0].Pos);

        line3df LineRay;
        irr::core::vector3df targetPosition;

        LineRay.start=VOFNode->getAbsolutePosition();
        LineRay.end=LineRay.start+(vert_pos-LineRay.start).normalize()*1000;

        vector3df normal = irr::core::vector3df(0,1,0);

        plane3df plane;
        plane.setPlane( irr::core::vector3df(0,0,0), normal);
        plane.getIntersectionWithLine(LineRay.start, LineRay.end, targetPosition);

        VOFNode->Vertices[0] = video::S3DVertex(targetPosition.X,targetPosition.Y,targetPosition.Z, 0,0,0,
        video::SColor(255,0,255,255), 0, 1);
};

Re: Plane intersection

Posted: Sun Feb 21, 2010 11:33 pm
by Zeus
Escen wrote: Can anyone give my some advice? How do I get the intersections with a static ground plane?
if i understand you correct and you only want to know if a corner "intersects" the plane you just have to check if the Z coordinate of the corner of the mesh is greater or less the Z coordinate of the plane ...

Posted: Mon Feb 22, 2010 9:20 am
by Escen
Well, that's maybe a good suggestion, bud I wonder if that approach works for me. I do not see any way of applying this method.

In general I'm holding a (digital) camera at a given altitude, lets say 150 meter, face straight down...
With a lens ratio FOV Horizontal 56 degrees and 40.3 degrees Vertical my Image footprint on ground will be 110 meter high and 160 meter width.

I'm not moving this Node around, except in altitude and rotation, I want to keep this FOV ratio. Later I will use different camera's and different lens ratio.
When rotating the camera the footprint will lost this rectangle shape. My goal is to illustrate this changing footprint. (and do some calculation later)

My approach for now:

1. first calculate four corners at given altitude and FOV ratio.
2. get Image width and high.
3. create lines from camera position to every corner and extent.
4. get intersections with plane.
5. apply intersections to corners.
6. render.

To make sure that I using a correct FOV ratio I recalculate this before any new rendering.

When I place a plane below the camera at vector3df(0,0,0) normal vector3df(0,1,0) everything looks good.
but when I rotate the Node the plane stick to the Node. Everything stays the same like illustrated in Picture A.
I think this happens because all calculations are in a relative position of the origin and then rendered afterward with AbsoluteTransformation.

And this is were I got stuck. How do I get the intersections with a static ground plane?
Can someone give me some direction?

Posted: Mon Feb 22, 2010 9:39 pm
by Escen
Anyone?

Posted: Tue Feb 23, 2010 3:44 pm
by Escen
Hi Escen,

Maybe this is useful for you..
It align your plane in opposite Node rotation.

Code: Select all

 
        core::vector3df normal=core::vector3df(0, 1, 0);
        VOFNode->getAbsoluteTransformation().inverseRotateVect(normal);
        plane3df plane;

        plane.setPlane( irr::core::vector3df(0,0,0), normal);

Re: Plane intersection

Posted: Sat May 25, 2019 5:22 pm
by Escen
AHA...I figured out the problem

Re: Plane intersection

Posted: Sat May 25, 2019 5:59 pm
by devsh
Long time no see Escen