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.
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);
};
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);
};