コード例 #1
0
font_instance* font_factory::FaceFromStyle(SPStyle const *style)
{
    font_instance *font = NULL;

    g_assert(style);

    if (style) {

        //  First try to use the font specification if it is set
        if (style->font_specification.set
            && style->font_specification.value
            && *style->font_specification.value) {

            font = FaceFromFontSpecification(style->font_specification.value);
        }

        // If that failed, try using the CSS information in the style
        if (!font) {

            font = Face(style->font_family.value, font_style_to_pos(*style));

            // That was a hatchet job... so we need to check if this font exists!!
            Glib::ustring fontSpec = font_factory::Default()->ConstructFontSpecification(font);
            Glib::ustring newFontSpec = FontSpecificationBestMatch( fontSpec );
            if( fontSpec != newFontSpec ) {
                font->Unref();
                font = FaceFromFontSpecification( newFontSpec.c_str() );
            }
        }
    }

    return font;
}
コード例 #2
0
ファイル: mesh.cpp プロジェクト: mmozeiko/Squares3D-iPad
SphereMesh::SphereMesh(const Vector& radius, int stacks, int slices) : Mesh(GL_TRIANGLE_STRIP, true)
{   
    for (int stackNumber = 0; stackNumber <= stacks; ++stackNumber)
    {
        for (int sliceNumber = 0; sliceNumber <= slices; ++sliceNumber)
        {
            float theta = stackNumber * M_PI / stacks;
            float phi = sliceNumber * 2 * M_PI / slices + M_PI_2;
            float sinTheta = std::sin(theta);
            float sinPhi = std::sin(phi);
            float cosTheta = std::cos(theta);
            float cosPhi = std::cos(phi);

            float s = static_cast<float>(sliceNumber)/static_cast<float>(slices);
            float t = 1.0f-static_cast<float>(stackNumber)/static_cast<float>(stacks);

            m_faces.push_back(Face(UV(s, t),
                                   Vector(cosPhi * sinTheta, sinPhi * sinTheta, cosTheta),
                                   radius * Vector(cosPhi * sinTheta, sinPhi * sinTheta, cosTheta))
                             );
        }
    }

    for (int stackNumber = 0; stackNumber < stacks; ++stackNumber)
    {
        for (int sliceNumber = 0; sliceNumber <= slices; ++sliceNumber)
        {
            m_indices.push_back( stackNumber*(slices+1) + sliceNumber);
            m_indices.push_back( (stackNumber+1)*(slices+1) + sliceNumber);
        }
    }

    init();
}
コード例 #3
0
ファイル: mesh.hpp プロジェクト: LegendGraphics/regmm
    void loadMeshObject(const std::string& filename, MeshObject& mo)
    {
        std::vector<tinyobj::shape_t> shapes;
        std::vector<tinyobj::material_t> materials;

        std::string err = tinyobj::LoadObj(shapes, materials, filename.c_str());

        if (!err.empty()) {
            std::cerr << err << std::endl;
            exit(1);
        }

        assert(shapes.size() == 1 ? true : ("obj should be only one shape" && false));

        tinyobj::mesh_t& mesh = shapes[0].mesh;
        assert((mesh.positions.size() % 3) == 0);
        assert((mesh.normals.size() % 3) == 0);
        assert((mesh.indices.size() % 3) == 0);

        VerticesArray& vts = mo.getVertices();
        NormalsArray& nls = mo.getNormals();
        FacesArray& fs = mo.getFaces();

        for (size_t v = 0; v < mesh.positions.size() / 3; v++) 
            vts.push_back(VertexType(mesh.positions[3*v+0], mesh.positions[3*v+1], mesh.positions[3*v+2]));

        for (size_t n = 0; n < mesh.normals.size() / 3; n++) 
            nls.push_back(NormalType(mesh.normals[3*n+0], mesh.normals[3*n+1], mesh.normals[3*n+2]));

        for (size_t f = 0; f < mesh.indices.size() / 3; f++) 
            fs.push_back(Face(mesh.indices[3*f+0], mesh.indices[3*f+1], mesh.indices[3*f+2]));
    }
コード例 #4
0
font_instance* font_factory::FaceFromUIStrings(char const *uiFamily, char const *uiStyle)
{
    font_instance *fontInstance = NULL;

    g_assert(uiFamily && uiStyle);
    if (uiFamily && uiStyle) {

        // If font list, take only first font in list
        gchar** tokens = g_strsplit( uiFamily, ",", 0 );
        g_strstrip( tokens[0] );

        Glib::ustring uiString = Glib::ustring(tokens[0]) + Glib::ustring(uiStyle);

        g_strfreev( tokens );

        UIStringToPangoStringMap::iterator uiToPangoIter = fontStringMap.find(uiString);

        if (uiToPangoIter != fontStringMap.end ()) {
            PangoStringToDescrMap::iterator pangoToDescrIter = fontInstanceMap.find((*uiToPangoIter).second);
            if (pangoToDescrIter != fontInstanceMap.end()) {
                // We found the pango description - now we can make a font_instance
                PangoFontDescription *tempDescr = pango_font_description_copy((*pangoToDescrIter).second);
                fontInstance = Face(tempDescr);
                pango_font_description_free(tempDescr);
            }
        }
    }

    return fontInstance;
}
コード例 #5
0
ファイル: rasterization.hpp プロジェクト: xubingyue/oglplus
	/**
	 *  @glsymbols
	 *  @glfunref{Get}
	 *  @gldefref{CULL_FACE_MODE}
	 */
	static Face CullFaceMode(void)
	{
		GLint result;
		OGLPLUS_GLFUNC(GetIntegerv)(GL_CULL_FACE_MODE, &result);
		OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
		return Face(result);
	}
コード例 #6
0
	/**
	 *  @glsymbols
	 *  @glfunref{Get}
	 *  @gldefref{CULL_FACE_MODE}
	 */
	static Face CullFaceMode(void)
	{
		GLint result;
		OGLPLUS_GLFUNC(GetIntegerv)(GL_CULL_FACE_MODE, &result);
		OGLPLUS_VERIFY(OGLPLUS_ERROR_INFO(GetIntegerv));
		return Face(result);
	}
コード例 #7
0
void Tessellate(
	NodeVector & vecNodes,
	FaceVector & vecFaces
) {
	int nInitialNodeListSize = vecNodes.size();

	// Create centerpoint nodes
	for (int i = 0; i < vecFaces.size(); i++) {
		InsertQuadNodeCenter(
			vecNodes,
			vecNodes[vecFaces[i][0]],
			vecNodes[vecFaces[i][1]],
			vecNodes[vecFaces[i][2]],
			vecNodes[vecFaces[i][3]]);
	}

	// Construct tesselation
	SegmentMap mapSegment;
	ConstructSegmentMap(vecFaces, mapSegment, -1);

	vecFaces.clear();

	SegmentMapIterator iter = mapSegment.begin();
	for (; iter != mapSegment.end(); iter++) {
		Face faceNew = 
			Face(
				iter->first[1],
				nInitialNodeListSize + iter->second[0],
				iter->first[0],
				nInitialNodeListSize + iter->second[1]);

		vecFaces.push_back(faceNew);
	}
}
コード例 #8
0
void TrianglePyramid::_init(){
    
    
    //0
    vecs.push_back(ofVec3f( 0, 1, 0));
    //1
    vecs.push_back(ofVec3f( -.5, 0, -.4));
    //2
    vecs.push_back(ofVec3f( .5, 0, -.4));
    //3
    vecs.push_back(ofVec3f( 0, 0, .6));
    
    //zero
    indices.push_back(Index<int>(0, 1, 2));
    //first
    indices.push_back(Index<int>(1, 3, 2));
    //second
    indices.push_back(Index<int>(0, 2, 3));
    //third
    indices.push_back(Index<int>(1, 0, 3));
    
    
    for (int i=0; i<indices.size(); ++i){
        // to do
        //cout << indices[i].elem0 << ", " << indices[i].elem1 << ", " << indices[i].elem2 << endl;
        faces.push_back( Face(&vecs[indices[i].elem0], &vecs[indices[i].elem1], &vecs[indices[i].elem2]) );
    }
    
	setScale(ofVec3f(100.0, 100.0, 100.0));
}
static CompiledMesh* generate_glyph(VertexBuffer * vertex_buffer, unsigned c)
{
    Mesh msh;

    const float SCALE = 0.365f;

    font_data::glyph_record const & r = font_data::glyph_records[c];

    for(unsigned i = 0; i<r.v_count; ++i)
    {
        float x = r.vertices[i*2+0] * SCALE;
        float y = r.vertices[i*2+1] * SCALE;
        msh.addVertex(Vector3(x,y,0));
    }

    for(unsigned i = 0; i<r.i_count/3; ++i)
    {
        unsigned i0 = r.indices[i*3+0];
        unsigned i1 = r.indices[i*3+1];
        unsigned i2 = r.indices[i*3+2];
        msh.addFace(Face(i0, i1, i2, Color(255, 0, 0, 255)));
    }

    return msh.insert(vertex_buffer, 0.0f);
}
コード例 #10
0
font_instance* font_factory::FaceFromPangoString(char const *pangoString)
{
    font_instance *fontInstance = NULL;

    g_assert(pangoString);

    if (pangoString) {
        PangoFontDescription *descr = NULL;

        // First attempt to find the font specification in the reference map
        PangoStringToDescrMap::iterator it = fontInstanceMap.find(Glib::ustring(pangoString));
        if (it != fontInstanceMap.end()) {
            descr = pango_font_description_copy((*it).second);
        }

        // Or create a font description from the string - this may fail or
        // produce unexpected results if the string does not have a good format
        if (!descr) {
            descr = pango_font_description_from_string(pangoString);
        }

        if (descr && (sp_font_description_get_family(descr) != NULL)) {
            fontInstance = Face(descr);
        }

        if (descr) {
            pango_font_description_free(descr);
        }
    }

    return fontInstance;
}
コード例 #11
0
ファイル: MeshDesc.cpp プロジェクト: dabroz/Tamy
void MeshDesc::load(Serializer& serializer)
{
   std::string tmpStr;

   serializer.loadString(m_name);
   m_isSkin = serializer.loadBool();

   unsigned int count = serializer.loadInt();
   for (unsigned int i = 0; i < count; ++i)
   {
      serializer.loadString(tmpStr);
      m_materials.push_back(tmpStr);
   }

   count = serializer.loadInt();
   for (unsigned int i = 0; i < count; ++i)
   {
      m_vertices.push_back(LitVertex());
      m_vertices.back().load(serializer);
   }

   count = serializer.loadInt();
   for (unsigned int i = 0; i < count; ++i)
   {
      m_faces.push_back(Face());
      m_faces.back().load(serializer);
   }

   count = serializer.loadInt();
   for (unsigned int i = 0; i < count; ++i)
   {
      BonesInfluenceDefinition& influencingBones = m_bonesInfluencingAttribute[i];

      unsigned int namesCount = serializer.loadInt();
      for (unsigned int j = 0; j < namesCount; ++j)
      {
         serializer.loadString(tmpStr);
         influencingBones.push_back(tmpStr);
      }
   }

   count = serializer.loadInt();
   for (unsigned int i = 0; i < count; ++i)
   {
      m_skinBones.push_back(SkinBoneDefinition());
      m_skinBones.back().load(serializer);
   }

   serializer.loadMatrix(m_localMtx);

   count = serializer.loadInt();
   for (unsigned int i = 0; i < count; ++i)
   {
      MeshDesc* newChild = new MeshDesc();
      m_children.push_back(newChild);
      newChild->load(serializer);
      newChild->m_parent = this;
   }
}
コード例 #12
0
ファイル: Face.cpp プロジェクト: awarematics/SECONDO
/*
  1.26 ClipEar implements the Clipping-Ear-Algorithm.
  It finds an "Ear" in this Face, clips it and returns it as separate face.
  Note that the original Face is modified by this method!
  It is mainly used to implement evaporisation of faces
 
*/
Face Face::ClipEar() {
    Face ret;

    if (v.size() <= 3) {
        // Nothing to do if this Face consists only of three points
        return Face(v);
    } else {
        Pt a, b, c;
        unsigned int n = v.size();

        // Go through the corner-points, which are sorted counter-clockwise
        for (unsigned int i = 0; i < n; i++) {
            // Take the next three points
            a = v[(i + 0) % n].s;
            b = v[(i + 1) % n].s;
            c = v[(i + 2) % n].s;
            if (Pt::sign(a, b, c) < 0) {
                // If the third point c is right of the segment (a b), then
                // the three points don't form an "Ear"
                continue;
            }

            // Otherwise check, if any point is inside the triangle (a b c)
            bool inside = false;
            for (unsigned int j = 0; j < (n - 3); j++) {
                Pt x = v[(i + j + 3) % n].s;
                inside = Pt::insideTriangle(a, b, c, x) &&
                        !(a == x) && !(b == x) && !(c == x);
                if (inside) {
                    // If a point inside was found, we haven't found an ear.
                    break;
                }
            }

            if (!inside) {
                // No point was inside, so build the Ear-Face in "ret",
                ret.AddSeg(v[i + 0]);
                ret.AddSeg(v[(i + 1)%n]);
                Seg nw(v[(i + 1)%n].e, v[i + 0].s);
                ret.AddSeg(nw);
                
                // remove the Face-Segment (a b),
                v.erase(v.begin() + i);
                
                // and finally replace the segment (b c) by (a c)
                v[i].s = nw.e;
                v[i].e = nw.s;
                hullSeg.valid = 0;

                return ret;
            }
        }
    }
    
    DEBUG(2, "No ear found on face " << ToString());
    // If we are here it means we haven't found an ear. This shouldn't happen.
    // One reason could be that the face wasn't valid in the first place.
    return ret;
}
コード例 #13
0
ファイル: H.cpp プロジェクト: PrayStarJirachi/Exercise-Code
		void pushface(const int &a, const int &b, const int &c) {
			nFace++;
			tmp[nFace] = Face(a, b, c);
			tmp[nFace].isOnConvex = true;
			whe[a][b] = nFace;
			whe[b][c] = nFace;
			whe[c][a] = nFace;
		}
コード例 #14
0
font_instance *font_factory::FaceFromDescr(char const *family, char const *style)
{
    PangoFontDescription *temp_descr = pango_font_description_from_string(style);
    pango_font_description_set_family(temp_descr,family);
    font_instance *res = Face(temp_descr);
    pango_font_description_free(temp_descr);
    return res;
}
コード例 #15
0
//----------------------------------------------------------------------------
bool ObjLoader::GetFace (const vector<string>& tokens)
{
    if (tokens[0] == "f")
    {
        if (tokens.size() < 4)
        {
            // A face must have at least three vertices.
            assert(false);
            mCode = EC_TOO_FEW_TOKENS;
            return false;
        }

        Group& group = mGroups[mCurrentGroup];
        Mesh& mesh = group.Meshes[mCurrentMesh];
        mesh.Faces.push_back(Face());
        Face& face = mesh.Faces.back();

        // A vertex is one of the following.
        // v/vt/vn
        // v/vt/
        // v//vn
        // v//
        const int numVertices = (int)tokens.size() - 1;
        face.Vertices.resize(numVertices);
        for (int i = 0; i < numVertices; ++i)
        {
            string token = tokens[i+1];
            string::size_type slash1 = token.find_first_of("/");
            string::size_type slash2 = token.find_last_of("/");
            if (slash1 == 0 || slash1 == string::npos
            ||  slash2 == 0 || slash2 == string::npos
            ||  slash1 == slash2)
            {
                assert(false);
                mCode = EC_INVALID_VERTEX;
                return false;
            }

            string pos = token.substr(0, slash1);
            face.Vertices[i].PosIndex = atoi(pos.c_str()) - 1;
            int numDigits = slash2 - slash1 - 1;
            if (numDigits > 0)
            {
                string tcd = token.substr(slash1 + 1, numDigits);
                face.Vertices[i].TcdIndex = atoi(tcd.c_str()) - 1;
            }
            if (token.length() > slash2 + 1)
            {
                string nor = token.substr(slash2 + 1, string::npos);
                face.Vertices[i].NorIndex = atoi(nor.c_str()) - 1;
            }
        }
        return true;
    }
    return false;
}
コード例 #16
0
ファイル: Mesh.cpp プロジェクト: JoshuaBrookover/Jatta
_JATTA_EXPORT Jatta::Assimp::Face* Jatta::Assimp::Mesh::GetFaces() const
{
    Face* faces = new Face[mesh->mNumFaces];
    for (unsigned int i = 0; i < mesh->mNumFaces; i++)
    {
        faces[i] = Face(&mesh->mFaces[i]);
    }

    return faces;
}
コード例 #17
0
ファイル: mesh.cpp プロジェクト: mmozeiko/Squares3D-iPad
CubeMesh::CubeMesh(const Vector& size) : Mesh(GL_TRIANGLES, false)
{
    // -0.5 .. 0.5
    static const float vertices[][3] = {
        /* 0 */ { -0.5, -0.5, -0.5 },
        /* 1 */ {  0.5, -0.5, -0.5 },
        /* 2 */ {  0.5, -0.5,  0.5 },
        /* 3 */ { -0.5, -0.5,  0.5 },

        /* 4 */ { -0.5,  0.5, -0.5 },
        /* 5 */ {  0.5,  0.5, -0.5 },
        /* 6 */ {  0.5,  0.5,  0.5 },
        /* 7 */ { -0.5,  0.5,  0.5 },
    };

    static const int faces[][6] = {
        { 0, 1, 2, 3, 0, 2 }, // bottom
        { 4, 7, 6, 5, 4, 6 }, // up
        { 4, 5, 1, 0, 4, 1 }, // front
        { 6, 7, 3, 2, 6, 3 }, // back
        { 7, 4, 0, 3, 7, 0 }, // left
        { 5, 6, 2, 1, 5, 2 }, // right
    };
    
    static const float normals[][3] = {
        {  0.0, -1.0,  0.0 }, // bottom
        {  0.0,  1.0,  0.0 }, // up
        {  0.0,  0.0, -1.0 }, // front
        {  0.0,  0.0,  1.0 }, // back
        { -1.0,  0.0,  0.0 }, // left
        {  1.0,  0.0,  0.0 }, // right
    };

    static const float uv[][2] = {
        { 1.0, 0.0 },
        { 0.0, 0.0 },
        { 0.0, 1.0 },
        { 1.0, 1.0 },
        { 1.0, 0.0 },
        { 0.0, 1.0 },
    };

    for (size_t i = 0; i < sizeOfArray(faces); i++)
    {
        for (int k=0; k<6; k++)
        {
            m_faces.push_back(Face(UV(uv[k][0], uv[k][1]),
                                   Vector(normals[i][0], normals[i][1], normals[i][2]),
                                   size * Vector(vertices[faces[i][k]][0], vertices[faces[i][k]][1], vertices[faces[i][k]][2]))
                             );
        }
    }

    init();
}
コード例 #18
0
ファイル: traversor2.hpp プロジェクト: Peiffert/CGoGN
Face Traversor2VF<MAP>::begin()
{
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return Face(*m_ItDarts++);
	}

	current = start ;
	return current ;
}
コード例 #19
0
ファイル: SurfaceMesh.cpp プロジェクト: ctlee/gamer
void fillHoles(SurfaceMesh &mesh){
    std::vector<std::vector<SurfaceMesh::SimplexID<2>>> holeList;
    surfacemesh_detail::findHoles(mesh, holeList);

    for(auto& holeEdges : holeList){
        std::vector<SurfaceMesh::SimplexID<1>> sortedVertices;
        surfacemesh_detail::edgeRingToVertices(mesh, holeEdges, std::back_inserter(sortedVertices));

        surfacemesh_detail::triangulateHole(mesh, sortedVertices, Face(), holeEdges);
    }
}
コード例 #20
0
void ModelLoader::parseFace(char *line)
{
	faces.push_back(Face()); //add a new face to list of faces

	//if the .obj file does not include texture coordinates, store vertex and normal indexes for the face
	if(sscanf(line, "f %d//%d %d//%d %d//%d", &faces.back().v1, &faces.back().vn1, &faces.back().v2, &faces.back().vn2, &faces.back().v3, &faces.back().vn3) <= 1)
	{
		//if the .obj file includes texture coordinates, store vertex, normal and textel indexes
		sscanf(line, "f %d/%d/%d %d/%d/%d %d/%d/%d", &faces.back().v1, &faces.back().vt1, &faces.back().vn1, &faces.back().v2, &faces.back().vt2, &faces.back().vn2, &faces.back().v3, &faces.back().vt3, &faces.back().vn3);
	}
}
コード例 #21
0
void DebugGeometryBuilder::addCone( const FastFloat& baseSize, const Vector& start, const Vector& end, std::vector< LitVertex >& outVertices, std::vector< Face >& outFaces )
{
   // calculate additional vectors needed for cuboid construction
   Vector dir;
   dir.setSub( end, start );
   dir.normalize();

   Vector perpVec1, perpVec2;
   VectorUtil::calculatePerpendicularVector( dir, perpVec1 );
   perpVec1.normalize();
   perpVec2.setCross( dir, perpVec1 );

   perpVec1.mul( baseSize );
   perpVec2.mul( baseSize );

   // calculate the vertices and outFaces
   uint firstVtxIdx = outVertices.size();
   uint firstFaceIdx = outFaces.size();

   for( uint i = 0; i < 5; ++i )
   {
      outVertices.push_back( LitVertex() );
   }
   for( uint i = 0; i < 6; ++i )
   {
      outFaces.push_back( Face() );
   }

   Vector tmpVec;
   {
      perpVec1.mul( Float_6 );
      perpVec2.mul( Float_6 );

      tmpVec.setAdd( start, perpVec1 ); tmpVec.sub( perpVec2 ); tmpVec.store( outVertices[firstVtxIdx + 0].m_coords );
      tmpVec.setSub( start, perpVec1 ); tmpVec.sub( perpVec2 ); tmpVec.store( outVertices[firstVtxIdx + 1].m_coords );
      tmpVec.setAdd( start, perpVec1 ); tmpVec.add( perpVec2 ); tmpVec.store( outVertices[firstVtxIdx + 2].m_coords );
      tmpVec.setSub( start, perpVec1 ); tmpVec.add( perpVec2 ); tmpVec.store( outVertices[firstVtxIdx + 3].m_coords );

      FastFloat tipSizeMultiplier; tipSizeMultiplier.setFromFloat( 12 );
      tipSizeMultiplier.mul( baseSize );
      tmpVec.setMulAdd( dir, tipSizeMultiplier, end ); tmpVec.store( outVertices[firstVtxIdx + 4].m_coords );

      // cone bottom
      outFaces[firstFaceIdx + 0].idx[0] = firstVtxIdx + 0; outFaces[firstFaceIdx + 0].idx[1] = firstVtxIdx + 1; outFaces[firstFaceIdx + 0].idx[2] = firstVtxIdx + 2;
      outFaces[firstFaceIdx + 1].idx[0] = firstVtxIdx + 1; outFaces[firstFaceIdx + 1].idx[1] = firstVtxIdx + 3; outFaces[firstFaceIdx + 1].idx[2] = firstVtxIdx + 2;

      // cone top
      outFaces[firstFaceIdx + 2].idx[0] = firstVtxIdx + 0;   outFaces[firstFaceIdx + 2].idx[1] = firstVtxIdx + 4;   outFaces[firstFaceIdx + 2].idx[2] = firstVtxIdx + 1;
      outFaces[firstFaceIdx + 3].idx[0] = firstVtxIdx + 1;   outFaces[firstFaceIdx + 3].idx[1] = firstVtxIdx + 4;   outFaces[firstFaceIdx + 3].idx[2] = firstVtxIdx + 3;
      outFaces[firstFaceIdx + 4].idx[0] = firstVtxIdx + 3;   outFaces[firstFaceIdx + 4].idx[1] = firstVtxIdx + 4;   outFaces[firstFaceIdx + 4].idx[2] = firstVtxIdx + 2;
      outFaces[firstFaceIdx + 5].idx[0] = firstVtxIdx + 2;   outFaces[firstFaceIdx + 5].idx[1] = firstVtxIdx + 4;   outFaces[firstFaceIdx + 5].idx[2] = firstVtxIdx + 0;
   }

}
コード例 #22
0
font_instance *font_factory::Face(char const *family, int variant, int style, int weight, int stretch, int /*size*/, int /*spacing*/)
{
    PangoFontDescription *temp_descr = pango_font_description_new();
    pango_font_description_set_family(temp_descr,family);
    pango_font_description_set_weight(temp_descr,(PangoWeight)weight);
    pango_font_description_set_stretch(temp_descr,(PangoStretch)stretch);
    pango_font_description_set_style(temp_descr,(PangoStyle)style);
    pango_font_description_set_variant(temp_descr,(PangoVariant)variant);
    font_instance *res = Face(temp_descr);
    pango_font_description_free(temp_descr);
    return res;
}
コード例 #23
0
ファイル: mesh.cpp プロジェクト: emiax/pink-fluid
void Mesh::addData(std::vector<glm::vec3> vertices, std::vector<Face> faces) {
  int offset = this->vertices.size();

  // copy all vertex coordinates.
  for (int i = 0; i < vertices.size(); ++i) {
    this->vertices.push_back(vertices[i]);
  }
  
  for (int i = 0; i < faces.size(); ++i) {
    this->faces.push_back(Face(faces[i].x + offset, faces[i].y + offset, faces[i].z + offset));
  }
}
コード例 #24
0
ファイル: Scene_demo.cpp プロジェクト: Agamand/3D_Engine
Object* plafond()
{
	Texture* t = TextureMgr::getTextureMgr()->getTexture("../../src/img/interieur.bmp");
	Container* c = new Container();
	Mesh* m;
	m = new Mesh();
	m->setTexture(t);
	m->addVertex(new Vertex(-22.0F,-35.0F,25.0F,0,0,glm::vec3(0,0,-1)));
	m->addVertex(new Vertex(26.0F,-35.0F,25.0F,0,1,glm::vec3(0,0,-1)));
	m->addVertex(new Vertex(26.0F,18.0F,25.0F,1,0,glm::vec3(0,0,-1)));
	m->addVertex(new Vertex(-22.0F,18.0F,25.0F,1,1,glm::vec3(0,0,-1)));
	m->addFace(Face(0,1,2));
	m->addFace(Face(0,2,3));
	c->addObject(m);


	c->addObject(lustre(glm::vec3(0.0,10.0,22.75)));
	c->addObject(lustre(glm::vec3(0.0,-25.0,22.75)));
	c->addObject(lustre(glm::vec3(0.0,-7.5,22.75)));
	return c;
}
コード例 #25
0
ファイル: SegMeshLoader.cpp プロジェクト: BigkoalaZhu/StBl
SurfaceMeshModel* SegMeshLoader::extractSegMesh( QString gid )
{
	SurfaceMeshModel* subMesh = new SurfaceMeshModel(gid + ".obj", gid);

	QVector<int> part = groupFaces[gid];

	// vertex set from face
	QSet<int> vertSet;
	foreach(int fidx, part)
	{
		Surface_mesh::Vertex_around_face_circulator vit = entireMesh->vertices(Face(fidx)),vend=vit;
		do{ vertSet.insert(Vertex(vit).idx()); } while(++vit != vend);
	}
コード例 #26
0
ファイル: GameObject.cpp プロジェクト: superwills/Wryv
// Stand outside target within `distance` units
void AGameObject::RecomputePathTo( AGameObject* target, float fallbackDistance )
{
  // Sends ME to * which is fallbackDistance units from target.
  //            fallbackDistance
  // ME       * <-- target
  //
  if( !target )
  {
    warning( FS( "%s has a NULL AttackTarget", *GetName() ) );
    return;
  }

  // Depending on the target type, the point to move to may be the 'roid ro some other special point on the model
  FVector targetPos = target->Pos;
  if( AGoldmine* goldmine = Cast<AGoldmine>( target ) )
  {
    // Switch pos to entry point of mine when a mine is the target.
    targetPos = goldmine->GetEntryPoint();
    // Not sure about float level of goldmine.. so that doesn't matter,
    // equate the Z of the goldmine with CURRENT UNIT POSITION Z
    // so diff in Z doesn't mean no entry.
    targetPos.Z = Pos.Z;
    fallbackDistance = 0.f; // Overlap the goldmine's entry pt to enter.
  }
  
  //         len
  // Pos <---------- targetPos
  //            *<-- targetPos
  FVector targetToMe = Pos - targetPos;
  float len = targetToMe.Size();
  //    len
  // Pos <- targetPos
  //   *<-- targetPos
  if( len < fallbackDistance )
  {
    // Within fallbackDistance, so face only (no movement)
    Face( targetPos );
  }
  else if( len ) // If there is a distance to travel
  {
    // Normalize
    targetToMe /= len;
    // Set the fallback distance to being size of bounding radius of other unit
    SetDestination( targetPos + targetToMe*(fallbackDistance*.997f) );
  }
  else
  {
    // I'm already there
  }
}
コード例 #27
0
ファイル: polyhedra.cpp プロジェクト: SangitaSingh/elmerfem
int Polyhedra :: AddFace (int pi1, int pi2, int pi3, int inputnum)
{
  (*testout) << "polyhedra, add face " << pi1 << ", " << pi2 << ", " << pi3 << endl;

  if(pi1 == pi2 || pi2 == pi3 || pi3 == pi1)
    {
      ostringstream msg;
      msg << "Illegal point numbers for polyhedron face: " << pi1+1 << ", " << pi2+1 << ", " << pi3+1;
      throw NgException(msg.str());
    }

  faces.Append (Face (pi1, pi2, pi3, points, inputnum));
  
  Point<3> p1 = points[pi1];
  Point<3> p2 = points[pi2];
  Point<3> p3 = points[pi3];

  Vec<3> v1 = p2 - p1;
  Vec<3> v2 = p3 - p1;

  Vec<3> n = Cross (v1, v2); 
  n.Normalize();

  Plane pl (p1, n);
//   int inverse;
//   int identicto = -1;
//   for (int i = 0; i < planes.Size(); i++)
//     if (pl.IsIdentic (*planes[i], inverse, 1e-9*max3(v1.Length(),v2.Length(),Dist(p2,p3))))
//       {
// 	if (!inverse)
// 	  identicto = i;
//       }
//   //  cout << "is identic = " << identicto << endl;
//   identicto = -1;    // changed April 10, JS

//   if (identicto != -1)
//     faces.Last().planenr = identicto;
//   else
    {
      planes.Append (new Plane (p1, n));
      surfaceactive.Append (1);
      surfaceids.Append (0);
      faces.Last().planenr = planes.Size()-1;
    }

//  (*testout) << "is plane nr " << faces.Last().planenr << endl;

  return faces.Size();
}
コード例 #28
0
ファイル: GeometryHelper.cpp プロジェクト: wibbe/three-cpp
  void addQuad(Geometry * geom, Vector2 const& topLeft, Vector2 const& bottomRight, Vector2 const& uvTopLeft, Vector2 const& uvBottomRight, Color const& color)
  {
    uint16_t index = geom->vertices.size();

    float x0 = topLeft.x;
    float x1 = bottomRight.x;
    float y0 = topLeft.y;
    float y1 = bottomRight.y;
    float u0 = uvTopLeft.x;
    float u1 = uvBottomRight.x;
    float v0 = uvTopLeft.y;
    float v1 = uvBottomRight.y;

    geom->vertices.push_back(Vector3(x0, y0, 0));
    geom->vertices.push_back(Vector3(x0, y1, 0));
    geom->vertices.push_back(Vector3(x1, y1, 0));
    geom->vertices.push_back(Vector3(x1, y0, 0));

    geom->texCoord0.push_back(Vector2(u0, v0));
    geom->texCoord0.push_back(Vector2(u0, v1));
    geom->texCoord0.push_back(Vector2(u1, v1));
    geom->texCoord0.push_back(Vector2(u1, v0));

    geom->colors.push_back(color);
    geom->colors.push_back(color);
    geom->colors.push_back(color);
    geom->colors.push_back(color);

    geom->faces.push_back(Face(index + 0, index + 1, index + 2));
    geom->faces.push_back(Face(index + 2, index + 3, index + 0));

    geom->verticesNeedUpdate = true;
    geom->colorsNeedUpdate = true;
    geom->texCoord0NeedUpdate = true;
    geom->elementsNeedUpdate = true;
  }
コード例 #29
0
ファイル: GeometryHelper.cpp プロジェクト: wibbe/three-cpp
  void addBox(Geometry * geom, Matrix4 const& transform, Vector3 const& size, Color const& color)
  {
    Matrix4 normalMat = transform.inverse().transpose();

    for (int i = 0; i < 6; ++i)
    {
      Vector3 normal = dirs[i];

      Vector3 up = std::abs(dot(normal, Vector3(0, 1, 0))) > 0.9f ? Vector3(0, 0, 1) : Vector3(0, 1, 0);
      Vector3 side = cross(normal, up) * size * 0.5f;
      up = up * size * 0.5f;

      Vector3 pos = normal * size * 0.5f;

      uint16_t indexStart = geom->vertices.size();

      geom->vertices.push_back(transform * (pos + side + up));
      geom->vertices.push_back(transform * (pos + side - up));
      geom->vertices.push_back(transform * (pos - side - up));
      geom->vertices.push_back(transform * (pos - side + up));
      geom->normals.push_back(normalMat * normal);
      geom->normals.push_back(normalMat * normal);
      geom->normals.push_back(normalMat * normal);
      geom->normals.push_back(normalMat * normal);
      geom->colors.push_back(color);
      geom->colors.push_back(color);
      geom->colors.push_back(color);
      geom->colors.push_back(color);
      geom->texCoord0.push_back(Vector2(1, 1));
      geom->texCoord0.push_back(Vector2(1, 0));
      geom->texCoord0.push_back(Vector2(0, 0));
      geom->texCoord0.push_back(Vector2(0, 1));
      geom->faces.push_back(Face(indexStart + 0, indexStart + 1, indexStart + 2));
      geom->faces.push_back(Face(indexStart + 2, indexStart + 3, indexStart + 0));
    }
  }
コード例 #30
0
ファイル: R3Mesh.cpp プロジェクト: JasonAltschuler/WorldWarQ
R3Mesh::
~R3Mesh(void)
{
  // Delete faces
  for (int i = 0; i < NFaces(); i++) {
    R3MeshFace *f = Face(i);
    delete f;
  }

  // Delete vertices
  for (int i = 0; i < NVertices(); i++) {
    R3MeshVertex *v = Vertex(i);
    delete v;
  }
}