Exemple #1
0
    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]));
    }
Exemple #2
0
QcPath3DDouble::QcPath(const QVector<double> & coordinates, bool closed)
  : m_vertexes(),
    m_edges(),
    m_interval(),
    m_closed(closed)
{
  int number_of_coordinates = coordinates.size();
  int dimension = QcVector3DDouble::dimension();
  if (number_of_coordinates % dimension == 1)
    throw std::invalid_argument("Odd number of coordinates");

  for (int i = 0; i < number_of_coordinates; i += dimension)
    add_vertex(VertexType(coordinates[i], coordinates[i+1], coordinates[i+2]));
}
void WaterFountain::defineVertices()
{
	//create vertex to represent the corners of the Cube
	for(UINT i = 0; i < numVertices; i++)
	{
		vertices.push_back(VertexType());
		vertices[i].position = emitterPos;
		vertices[i].size = size;
		vertices[i].fade = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
		active.push_back(false);

		age.push_back(0);
		speed.push_back(randomVectorPosY());
		speed[i].y *= 5;
		accel = D3DXVECTOR3(0.0f, -9.82f, 0.0f);
	}
}
 virtual bool verifySolution(const Permutation& p)
   {
       for(int i : range1(points.vertices()))
       {
           const vec1<VertexType>& p_i = points.neighbours(i);
           vec1<VertexType> image_set;
           for(const auto& edge : p_i) {
               int pnt = edge.target();
               int pnt_image = p[pnt];
               image_set.push_back(VertexType(pnt_image, edge.colour()));
           }
           std::sort(image_set.begin(), image_set.end());
           
           if(points.neighbours(p[i]) != image_set) {
             return false;
           }
       }
       return true;
   }
	void XM_CALLCONV PrimitveDrawer::DrawQuad(FXMVECTOR P0, FXMVECTOR P1, FXMVECTOR P2, GXMVECTOR P3, CXMVECTOR Color)
	{
		VertexType Vertices [] = { VertexType(P0,Color),VertexType(P1,Color),VertexType(P2,Color),VertexType(P3,Color) };
		m_pDirectXBatch->DrawQuad(Vertices[0], Vertices[1], Vertices[2], Vertices[3]);
	}
	void XM_CALLCONV PrimitveDrawer::DrawLine(FXMVECTOR P0, FXMVECTOR P1, FXMVECTOR Color)
	{
		VertexType Vertices [] = { VertexType(P0,Color),VertexType(P1,Color) };
		m_pDirectXBatch->DrawLine(Vertices[0], Vertices[1]);
	}
void ShaderFrame::AddVertex(Vector3 _position, Vector2 _textureCoordinates)
{
	m_VertexArray.Add(VertexType(_position, _textureCoordinates));
}
Entity makewiimote(const VRBackendBasics& graphics_objects) {
	std::vector<Vertex> vertices;
	VertexType vertex_type = VertexType(std::vector<D3D11_INPUT_ELEMENT_DESC>({
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
	}));
	vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }));

	vertices.push_back(Vertex(vertex_type, { -1.0f,  1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, {  1.0f,  1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, {  1.0f,  1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, {  1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f }));

	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f }));

	vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f }));

	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f }));

	vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f }));
	vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f }));

	Model model = graphics_objects.resource_pool->LoadModel("wiimote", vertices, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	ConstantBufferTyped<TransformationMatrixAndInvTransData>* object_settings = new ConstantBufferTyped<TransformationMatrixAndInvTransData>(CB_PS_VERTEX_SHADER);
	object_settings->CreateBuffer(graphics_objects.view_state->device_interface);
	object_settings->SetBothTransformations(DirectX::XMMatrixMultiply(DirectX::XMMatrixRotationY(3.14f), DirectX::XMMatrixTranslation(0, 0, -4)));
	object_settings->PushBuffer(graphics_objects.view_state->device_context);

	return Entity(
		ES_NORMAL,
		graphics_objects.resource_pool->LoadPixelShader("shaders.hlsl"),
		graphics_objects.resource_pool->LoadVertexShader("shaders.hlsl", vertex_type.GetVertexType(), vertex_type.GetSizeVertexType()),
		ShaderSettings(NULL),
		model,
		object_settings);
}