Mesh line shape
-
Legars2101
- Posts: 8
- Joined: Fri Mar 07, 2008 11:34 am
- Location: Rouen, FR
Mesh line shape
Hello everyone,
I am working on the displaying of a 3D mesh which is the result of a 3D hardware scanning.
The result gives me an obj file.
I can load it, turn around, zoom, and select a triangle.
The next step is to be able to select a line following the shape of the model. To be more visual : immagine a laser line projected on body. The line on the body will not be straight but will follow distortion of the body.
I would like to have the same result on my model...
The problem is that I just know I may use collision (as for a triangle selector) but that's all...
If someone have an idea, a starting point or already did it, it will be great !
I am working on the displaying of a 3D mesh which is the result of a 3D hardware scanning.
The result gives me an obj file.
I can load it, turn around, zoom, and select a triangle.
The next step is to be able to select a line following the shape of the model. To be more visual : immagine a laser line projected on body. The line on the body will not be straight but will follow distortion of the body.
I would like to have the same result on my model...
The problem is that I just know I may use collision (as for a triangle selector) but that's all...
If someone have an idea, a starting point or already did it, it will be great !
Re: Mesh line shape
Your requirement seems to match this tutorial:
http://irrlicht.sourceforge.net/tut007.html
http://irrlicht.sourceforge.net/tut007.html
Do you want a laser which comes from the camera and points onto the car and shows you the collision point from the camera to the car?
Or do you want a line which is projected onto the car and lies on the surface of the car, taking its shape, like projective texturing..? Like this sort of thing:

where the texture get projected onto the surfaces and gets distorted based on those surfaces, much like how a projector would work if you projected the image onto a non-flat surface instead of a wall.
Or do you want a line which is projected onto the car and lies on the surface of the car, taking its shape, like projective texturing..? Like this sort of thing:

where the texture get projected onto the surfaces and gets distorted based on those surfaces, much like how a projector would work if you projected the image onto a non-flat surface instead of a wall.
-
Legars2101
- Posts: 8
- Joined: Fri Mar 07, 2008 11:34 am
- Location: Rouen, FR
the ideal way to do this would be with projective texturing. It's a bit elusive in irrlicht, hard to do, but someone (can't remember who) is working on a fixed function pipeline version (possibly only opengl currently) which means you can do it without shaders. Other people have done shader versions before i think.
-
Legars2101
- Posts: 8
- Joined: Fri Mar 07, 2008 11:34 am
- Location: Rouen, FR
This is not a perfect solution, but it works well. It's limited on mesh vertices.
Currently this is how I do (Every optimisation is welcome
) :
Create this object :
Associate with the mesh of interest :
In the render loop :
with :
And then :
Currently this is how I do (Every optimisation is welcome
Create this object :
Code: Select all
scene::ISceneManager* _smgr;
core::triangle3df tri_selected;
core::vector3df inter;
scene::ITriangleSelector* tri_selector;
core::line3df line;
Code: Select all
tri_selector = _smgr->createOctTreeTriangleSelector(_mesh->getMesh(0), _meshSN);Code: Select all
// Get line between mouse and screen
line = _smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(_device->getCursorControl()->getPosition());
// If intersection, draw things
if(_smgr->getSceneCollisionManager()->getCollisionPoint(line, tri_selector, inter, tri_selected))
DrawMouseEffect(true, tri_selected);
Code: Select all
void DrawMouseEffect(bool doI, core::triangle3df triSelected)
{
if(doI)
{
int i;
std::list<video::S3DVertex> lsVerticesX;
std::list<video::S3DVertex> lsVerticesY;
float myX = triSelected.pointA.X;
float myY = triSelected.pointA.Y;
video::S3DVertex* vertices = (video::S3DVertex*)_meshMB->getVertices();
int nVertex = _meshMB->getVertexCount();
// Add vectors of interest
for(i = 0; i < nVertex; i++)
{
if(vertices[i].Pos.X == myX)
lsVerticesX.push_back(vertices[i]);
if(vertices[i].Pos.Y == myY)
lsVerticesY.push_back(vertices[i]);
}
// Draw X curve
this->DrawCurve(lsVerticesX);
// Draw Y curve
this->DrawCurve(lsVerticesY);
}
}
Code: Select all
void DrawCurve(std::list<video::S3DVertex> lsVertex)
{
core::vector3df deb, fin;
std::list<video::S3DVertex>::iterator it;
it = lsVertex.begin();
while(it != lsVertex.end())
{
deb = (*it++).Pos;
if(it != lsVertex.end())
{
fin = (*it).Pos;
_driver->draw3DLine(deb, fin, video::SColor(0, 123, 45, 78));
}
}
}
-
Legars2101
- Posts: 8
- Joined: Fri Mar 07, 2008 11:34 am
- Location: Rouen, FR
Email it to me, REMOVESPAMnguoidanongvidai@REMOVESPAMgmail.com, I glad to store your screenshot !Legars2101 wrote:I would like to put a picture of the result, but I don't know how... I don't have webspace to put pictures on...
-
Legars2101
- Posts: 8
- Joined: Fri Mar 07, 2008 11:34 am
- Location: Rouen, FR
Thanks, I send it to you.
I test it with other model than one from my 3d scan, it don't work very well or at all.
I my case, vertex are align in X and Y so finally it's easy to get line shape from the meshbuffer.
Second step is too find another solution which permit the same things for any model...
I'll keep working on
I test it with other model than one from my 3d scan, it don't work very well or at all.
I my case, vertex are align in X and Y so finally it's easy to get line shape from the meshbuffer.
Second step is too find another solution which permit the same things for any model...
I'll keep working on
-
Legars2101
- Posts: 8
- Joined: Fri Mar 07, 2008 11:34 am
- Location: Rouen, FR
