Hi Martin,
you have already hinted at a search term you can use. Google for
"projective texturing". Also try "automatic texture coordinate
generation". An example in OSG of this is the OverlayNode of osgSim
(this is used to project a texture onto terrain e.g.).
Using this technique you can project your painted texture onto an
object, but the texture would not become part (be "baked into") of the
object (I suspect you actaully want to do this).
You can also maybe have a look at MeshLab, I know they recently added
projective painting, but I'm also not sure how the data is stored in the
end.
jp
Großer Martin wrote:
Hey Maxim,
first, thanks for your help. Now I know the way to manipulate values in
my image. But now I have the problem to find out the right pixel in the
texture. A little example: I have a complex object with a texture. All
triangles of the object are randomly distributed on the texture. And I
would like project a texture on my object (planar mapping?!). This
texture is my paint brush. Now I want to copy the image data of the
paint brush texture in the texture of the object.
Can you see my problem?
Cheers,
Martin
PS: However, your code example are very helpful.
Am Mittwoch, den 01.07.2009, 00:50 +0600 schrieb Maxim Gammer:
FindTextureVisitor .. in files)
2009/7/1 Maxim Gammer <maxgam...@gmail.com>:
//Находим объект
osg::ref_ptr<FindNamedNodeVisitor> fnnv = new
FindNamedNodeVisitor(ObjectName);
root->accept(*fnnv.get());
//Если такой объект есть, ищем текстуру
if (!fnnv->_foundNodes.empty())
{
if (fnnv->_foundNodes.size()>1) std::cout << "Warning: Duplicate
names - " << ObjectName << std::endl;
osg::ref_ptr<FindTextureVisitor> zzz = new
FindTextureVisitor(UnitNumber);
fnnv->_foundNodes.front().get()->accept (*zzz.get());
//Если текстура есть
if (zzz->image.get())
{
/*
std::cout << "texture find";
std::cout << zzz->image->s() << std::endl; //ширина
std::cout << zzz->image->t() << std::endl; //высота
std::cout << zzz->image->r() << std::endl; //глубина
*/
int format = zzz->image->getPixelSizeInBits();
//std::cout <<"getPixelSizeInBits : "<< format
<<std::endl;
int width = zzz->image->s();
int heught = zzz->image->t();
//
GLubyte *ptr;
int inc=0;
ptr = zzz->image->data();
if (x>=width) x= 0;
if (y>=heught) y= 0;
if (x<0) x= 0;
if (y<0) y= 0;
inc=(y*width + x)*format/8; //смещение по
RGBARGBARGBA... или 4
*(ptr+inc+0) = (GLubyte)(r*255.0f);
*(ptr+inc+1) = (GLubyte)(g*255.0f);
*(ptr+inc+2) = (GLubyte)(b*255.0f);
//если RGBA
if ((format/8)>24)
{
*(ptr+inc+3) = (GLubyte)(a*255.0f);
}
//Отправляем текстуру в видеопамять)
if (flush)
{
//osg::Image* dest =dynamic_cast<osg::Image*>
(zzz->image->clone(osg::CopyOp::DEEP_COPY_ALL));
//zzz->texture->setImage(dest);//zzz->image
// dirty the image (increments the modified
count) so that any textures
// using the image can be informed that they
need to update.
zzz->image->dirty();
//zzz->texture->setDataVariance(osg::Object::DYNAMIC);
//zzz->stateset->setTextureAttributeAndModes(UnitNumber,
zzz->texture, osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
//zzz->drawable->setStateSet(zzz->stateset);
}
}
else
{
std::cout << "texture NOT find";
//delete zzz;
//delete fnnv;
return false;
}
//Чистим мусор
//delete zzz;
}
else
{
std::cout << "Find objects in Root - FALSE! " << ObjectName <<
std::endl;
//delete fnnv;
return false;
}
//Чистим мусор
//delete fnnv;
return true;
2009/6/30 Großer Martin <grosser.mar...@gmx.de>:
Hello,
i would like paint on a 3d object in my scene. This object has a texture
and i want to paint into this texture. My paint brush should be another
texture. There are a nice solution in OSG? This problem is not trivial
for me.
I hope everyone can give me a example, a tip or a suitable keyword for
my research.
Cheers,
Martin
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
Maxim Gammer
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org