This commit is contained in:
Guido Ranzuglia 2016-07-25 12:36:29 +02:00
commit 16694a31cf
6 changed files with 226 additions and 188 deletions

View File

@ -666,7 +666,7 @@ public:
CoordType dirR=vcg::tri::CrossField<MeshType>::Rotate(f0,f1,dir0); CoordType dirR=vcg::tri::CrossField<MeshType>::Rotate(f0,f1,dir0);
///then get the closest upf to K*PI/2 rotations ///then get the closest upf to K*PI/2 rotations
CoordType dir1=f1.cPD1(); CoordType dir1=f1.cPD1();
CoordType ret=vcg::tri::CrossField<MeshType>::K_PI(dirR,dir1,f1.cN()); CoordType ret=vcg::tri::CrossField<MeshType>::K_PI(dir1,dirR,f1.cN());
return ret; return ret;
} }

View File

@ -368,7 +368,6 @@ Note: The faux bit is used to color polygonal faces uniformly
} }
/*! \brief Perlin Noise. /*! \brief Perlin Noise.
\return the number of changed vertexes (the selected ones)
Simple Perlin noise. To make things weirder each color band can have its own offset and frequency. Simple Perlin noise. To make things weirder each color band can have its own offset and frequency.
Period is expressed in absolute terms. Period is expressed in absolute terms.
@ -396,6 +395,34 @@ static void PerVertexPerlinNoise(MeshType& m, CoordType period, CoordType offset
} }
/*! \brief Perlin Color mixing.
Simple Perlin color mixing. Color 1 and 2 are mixed according the perlin noise function, with period and offset.
*/
static void PerVertexPerlinColoring(MeshType& m, ScalarType period, CoordType offset = CoordType(0, 0, 0), Color4b color1 = Color4b::Black, Color4b color2 = Color4b::White, bool onSelected = false)
{
RequirePerVertexColor(m);
CoordType p;
for (VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
if (!(*vi).IsD())
if ((!onSelected) || ((*vi).IsS()))
{
// perlin noise is defined in 022
p = (vi->P() / period) + offset;
double factor = (math::Perlin::Noise(p[0], p[1], p[2]) + 1.0) / 2.0;
int rr = (color1[0] * factor) + (color2[0] * (1.0 - factor));
int gg = (color1[1] * factor) + (color2[1] * (1.0 - factor));
int bb = (color1[2] * factor) + (color2[2] * (1.0 - factor));
int aa = (color1[3] * factor) + (color2[3] * (1.0 - factor));
(*vi).C() = Color4b(rr, gg, bb, aa);
}
}
/*! \brief Simple Noise adding function. /*! \brief Simple Noise adding function.
It simply add signed noise to the color of the mesh. The noise has uniform distribution and the amplitude is +/-2^(noisebits-1). It simply add signed noise to the color of the mesh. The noise has uniform distribution and the amplitude is +/-2^(noisebits-1).
*/ */

View File

@ -57,7 +57,7 @@ inline bool IsEdgeBorder(EdgeType const & e, const int j )
} }
template <class VertexType> template <class VertexType>
void VVStarVE(VertexType* vp, std::vector<VertexType *> &starVec) void VVStarVE(const VertexType* vp, std::vector<VertexType *> &starVec)
{ {
starVec.clear(); starVec.clear();
edge::VEIterator<typename VertexType::EdgeType> vei(vp); edge::VEIterator<typename VertexType::EdgeType> vei(vp);

View File

@ -1561,12 +1561,12 @@ namespace vcg
} }
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
if ((isgloptsvalid) && ((glopts->_perpoint_fixed_color_enabled) || (glopts->_perpoint_mesh_color_enabled))) if ((isgloptsvalid) && ((glopts->_perpoint_fixed_color_enabled) || (glopts->_perpoint_mesh_color_enabled))){
if (glopts->_perpoint_fixed_color_enabled) if (glopts->_perpoint_fixed_color_enabled)
glColor(glopts->_perpoint_fixed_color); glColor(glopts->_perpoint_fixed_color);
else else
glColor(_mesh.C()); glColor(_mesh.C());
}
if (req[INT_ATT_NAMES::ATT_VERTCOLOR]) if (req[INT_ATT_NAMES::ATT_VERTCOLOR])
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);

File diff suppressed because it is too large Load Diff

View File

@ -496,7 +496,7 @@ namespace nanoply
for (int i = 0; i < faceDescr.dataDescriptor.size(); i++) for (int i = 0; i < faceDescr.dataDescriptor.size(); i++)
if (faceDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY) if (faceDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY)
delete faceDescr.dataDescriptor[i]; delete faceDescr.dataDescriptor[i];
mesh.textures = info.textureFile;
return info.errInfo; return info.errInfo;
} }
@ -687,6 +687,7 @@ namespace nanoply
infoSave.AddPlyElement(vertexElem); infoSave.AddPlyElement(vertexElem);
infoSave.AddPlyElement(edgeElem); infoSave.AddPlyElement(edgeElem);
infoSave.AddPlyElement(faceElem); infoSave.AddPlyElement(faceElem);
infoSave.textureFile = mesh.textures;
std::vector<ElementDescriptor*> meshDescr; std::vector<ElementDescriptor*> meshDescr;
meshDescr.push_back(&cameraDescr); meshDescr.push_back(&cameraDescr);
meshDescr.push_back(&vertexDescr); meshDescr.push_back(&vertexDescr);