示例#1
0
	void testPlyLoaderCylinders( void ) {
		//ply file with two cylinders
		string cylinders = getString("cylinders");
		MeshdataPtr mdp = loadMDP(cylinders);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 2);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 2);
		for(uint32 i = 0; i < mdp->geometry.size(); i++) {
			TS_ASSERT_EQUALS(mdp->geometry[i].positions.size(), 96);
			TS_ASSERT_EQUALS(mdp->geometry[i].skinControllers.size(), 0);
			TS_ASSERT_EQUALS(mdp->geometry[i].primitives.size(), 1);
			TS_ASSERT_EQUALS(mdp->geometry[i].primitives[0].indices.size(), 276);
		}
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 0);
		TS_ASSERT_EQUALS(mdp->materials.size(), 1);
		TS_ASSERT_EQUALS(mdp->materials[0].textures.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
		TS_ASSERT_EQUALS(mdp->globalTransform, Matrix4x4f::identity());
	}
示例#2
0
FilterDataPtr SaveFilter::apply(FilterDataPtr input) {
    assert(input->single());

    ModelsSystem* parser = ModelsSystemFactory::getSingleton().getConstructor("any")("");
    MeshdataPtr md = input->get();
    bool success = parser->convertMeshdata(*md.get(), mFormat, mFilename);
    if (!success) {
        std::cout << "Error saving mesh." << std::endl;
        return FilterDataPtr();
    }
    return input;
}
示例#3
0
	void testPlyLoaderBunny( void ) {
		//ply file with bunny
		string bunny = getString("bunny/reconstruction/bun_zipper_res4");
		MeshdataPtr mdp = loadMDP(bunny);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 1);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].positions.size(), 453);
		TS_ASSERT_EQUALS(mdp->geometry[0].skinControllers.size(), 0);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives[0].indices.size(), 2844);
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 0);
		TS_ASSERT_EQUALS(mdp->materials.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
	}
示例#4
0
	void testPlyLoaderLine( void ) {
		//ply file with a line
		string line = getString("line");
		MeshdataPtr mdp = loadMDP(line);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 1);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].skinControllers.size(), 0);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives[0].indices.size(), 2);
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 0);
		TS_ASSERT_EQUALS(mdp->materials.size(), 1);
		TS_ASSERT_EQUALS(mdp->materials[0].textures.size(), 0);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
		TS_ASSERT_EQUALS(mdp->globalTransform, Matrix4x4f::identity());
	}
示例#5
0
	void testPlyLoaderCircleT( void ) {
		//ply file with one texturized circle
		string circleT = getString("circleT");
		MeshdataPtr mdp = loadMDP(circleT);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 1);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].positions.size(), 48);
		TS_ASSERT_EQUALS(mdp->geometry[0].skinControllers.size(), 0);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives[0].indices.size(), 132);
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 1);
		TS_ASSERT_EQUALS(mdp->materials.size(), 1);
		TS_ASSERT_EQUALS(mdp->materials[0].textures.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
		TS_ASSERT_EQUALS(mdp->globalTransform, Matrix4x4f::identity());
	}
示例#6
0
	void testPlyLoaderPrism( void ) {
		//ply file with partially textured hexagonal prism
		string prism = getString("prism");
		MeshdataPtr mdp = loadMDP(prism);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 3);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 3);
		for(uint32 i = 0; i < mdp->geometry.size(); i++) {
			TS_ASSERT_EQUALS(mdp->geometry[i].skinControllers.size(), 0);
			TS_ASSERT_EQUALS(mdp->geometry[i].primitives.size(), 1);
		}
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 2);
		TS_ASSERT_EQUALS(mdp->materials.size(), 3);
		TS_ASSERT_EQUALS(mdp->materials[0].textures.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
		TS_ASSERT_EQUALS(mdp->globalTransform, Matrix4x4f::identity());
	}
示例#7
0
	void testPlyLoaderSquare( void ) {
		//ply file with a square (actually a rectangle)
		string square = getString("square");
		MeshdataPtr mdp = loadMDP(square);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 1);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].positions.size(), 4);
		TS_ASSERT_EQUALS(mdp->geometry[0].skinControllers.size(), 0);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives[0].indices.size(), 6);
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 0);
		TS_ASSERT_EQUALS(mdp->materials.size(), 1);
		TS_ASSERT_EQUALS(mdp->materials[0].textures.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
		TS_ASSERT_EQUALS(mdp->globalTransform, Matrix4x4f::identity());
	}
示例#8
0
	void testPlyLoaderDrill( void ) {
		//ply file with drill
		//its results deviate significantly from those of the collada version...
		//but then again, the two formats are bettter for different things...
		//also, this loads *very* slowly, showing the inefficiency of the ply plugin
		string drill = getString("drill/reconstruction/drill_shaft_zip");
		MeshdataPtr mdp = loadMDP(drill);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 7);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 7);
		TS_ASSERT_EQUALS(mdp->geometry[0].positions.size(), 845);
		TS_ASSERT_EQUALS(mdp->geometry[0].skinControllers.size(), 0);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives[0].indices.size(), 3831);
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 0);
		TS_ASSERT_EQUALS(mdp->materials.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
	}
示例#9
0
	void testPlyLoaderSquare2s( void ) {
		//ply file with square with two sides, one of which is specially texturized
		string square2s = getString("square2s");
		MeshdataPtr mdp = loadMDP(square2s);

		//asserts
		TS_ASSERT_DIFFERS(mdp, MeshdataPtr());
		TS_ASSERT_EQUALS(mdp->getInstancedGeometryCount(), 1);
		TS_ASSERT_EQUALS(mdp->getInstancedLightCount(), 0);
		TS_ASSERT_EQUALS(mdp->getJointCount(), 0);
		TS_ASSERT_EQUALS(mdp->geometry.size(), 1);
		TS_ASSERT_EQUALS(mdp->geometry[0].positions.size(), 8);
		TS_ASSERT_EQUALS(mdp->geometry[0].skinControllers.size(), 0);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives.size(), 2);
		TS_ASSERT_EQUALS(mdp->geometry[0].primitives[0].indices.size(), 6)
		TS_ASSERT_EQUALS(mdp->lights.size(), 0);
		TS_ASSERT_EQUALS(mdp->textures.size(), 1);
		TS_ASSERT_EQUALS(mdp->materials.size(), 2);
		for(uint32 i = 0; i < mdp->materials.size(); i++)
			TS_ASSERT_EQUALS(mdp->materials[i].textures.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes.size(), 1);
		TS_ASSERT_EQUALS(mdp->nodes[0].transform, Matrix4x4f::identity());
		TS_ASSERT_EQUALS(mdp->globalTransform, Matrix4x4f::identity());
	}
示例#10
0
FilterDataPtr PrintFilter::apply(FilterDataPtr input) {
    assert(input->single());

    MeshdataPtr md = input->get();

    if(mTexturesOnly) {
        for(TextureList::const_iterator it = md->textures.begin(); it != md->textures.end(); it++) {
            printf("%s\n", it->c_str());
        }
        return input;
    }

    printf("URI: %s\n", md->uri.c_str());
    printf("ID: %ld\n", md->id);
    printf("Hash: %s\n", md->hash.toString().c_str());

    printf("Texture List:\n");
    for(TextureList::const_iterator it = md->textures.begin(); it != md->textures.end(); it++) {
        printf("   %s\n", it->c_str());
    }

    printf("Submesh Geometry List:\n");
    for(SubMeshGeometryList::const_iterator it = md->geometry.begin(); it != md->geometry.end(); it++) {
        printf("   Name: %s, Positions: %d Normals: %d Primitives: %d, UVs: %d (sets) x %d (stride) x %d (count)\n", it->name.c_str(),
            (int)it->positions.size(), (int)it->normals.size(), (int)it->primitives.size(),
            (int)it->texUVs.size(), (int)( it->texUVs.size() ? it->texUVs[0].stride : 0), (int)( it->texUVs.size() ? it->texUVs[0].uvs.size() : 0));

        for(std::vector<SubMeshGeometry::Primitive>::const_iterator p = it->primitives.begin(); p != it->primitives.end(); p++) {
            printf("      Primitive: material: %d, indices: %d, type: %s\n", (int)p->materialId, (int)p->indices.size(), PrimitiveTypeToString(p->primitiveType));
        }
    }

    printf("Lights:\n");
    for(LightInfoList::const_iterator it = md->lights.begin(); it != md->lights.end(); it++) {
        printf("   Type: %d Power: %f\n", it->mType, it->mPower);
    }

    printf("Material Effects:\n");
    for(MaterialEffectInfoList::const_iterator it = md->materials.begin(); it != md->materials.end(); it++) {
        printf("   Textures: %d Shininess: %f Reflectivity: %f\n", (int)it->textures.size(), it->shininess, it->reflectivity);
        for(MaterialEffectInfo::TextureList::const_iterator t_it = it->textures.begin(); t_it != it->textures.end(); t_it++)
            printf("     Texture: %s, color = %s, affects %s, %s, min: %s, mag: %s, wrap = (%s, %s, %s), max_mip = %d, mip_bias = %f\n",
                t_it->uri.c_str(),
                t_it->color.toString().c_str(),
                AffectingToString(t_it->affecting),
                SamplerTypeToString(t_it->samplerType),
                SamplerFilterToString(t_it->minFilter),
                SamplerFilterToString(t_it->magFilter),
                WrapModeToString(t_it->wrapS),
                WrapModeToString(t_it->wrapT),
                WrapModeToString(t_it->wrapU),
                t_it->maxMipLevel,
                t_it->mipBias
            );
    }

    printf("Geometry Instances: (%d in list, %d instanced)\n", (int)md->instances.size(), (int)md->getInstancedGeometryCount());
    for(GeometryInstanceList::const_iterator it = md->instances.begin(); it != md->instances.end(); it++) {
        printf("   Index: %d MapSize: %d\n", it->geometryIndex, (int)it->materialBindingMap.size());
        for(GeometryInstance::MaterialBindingMap::const_iterator m = it->materialBindingMap.begin(); m != it->materialBindingMap.end(); m++) {
            printf("      map from: %d to: %d\n", (int)m->first, (int)m->second);
        }
    }

    printf("Light Instances: (%d in list, %d instanced)\n", (int)md->lightInstances.size(), (int)md->getInstancedLightCount());
    for(LightInstanceList::const_iterator it = md->lightInstances.begin(); it != md->lightInstances.end(); it++) {
        printf("   Index: %d Matrix: %s\n", it->lightIndex, md->getTransform(it->parentNode).toString().c_str());
    }

    printf("Material Effect size: %d\n", (int)md->materials.size());

    printf("Nodes size: %d (%d roots)\n", (int)md->nodes.size(), (int)md->rootNodes.size());
    for(uint32 ri = 0; ri < md->rootNodes.size(); ri++) {
        std::stack<NodeState> node_stack;
        node_stack.push( NodeState(md->rootNodes[ri]) );
        String indent = "";

        while(!node_stack.empty()) {
            NodeState& curnode = node_stack.top();

            if (curnode.curChild == -1) {
                // First time we've seen this node, print info and move it
                // forward to start procesing children
                printf("%s %d\n", indent.c_str(), curnode.node);
                curnode.curChild++;
                indent += " ";
            }
            else if (curnode.curChild >= (int)md->nodes[curnode.node].children.size()) {
                // We finished with this node
                node_stack.pop();
                indent = indent.substr(1); // reduce indent
            }
            else {
                // Normal iteration, process next child
                int32 childindex = curnode.curChild;
                curnode.curChild++;
                node_stack.push( NodeState(md->nodes[curnode.node].children[childindex]) );
            }
        }
    }

    printf("Joints: %d instanced (%d in list)\n", md->getJointCount(), md->joints.size());

    // Compute the expected number of draw calls assuming no smart
    // transformation is occuring. This should be:
    // Number of instances * number of primitives in instance
    // This really should trace from the root to make sure that all instances
    // are actually drawn...
    uint32 draw_calls = 0;

    Meshdata::GeometryInstanceIterator geoinst_it = md->getGeometryInstanceIterator();
    uint32 geoinst_idx;
    Matrix4x4f pos_xform;
    while( geoinst_it.next(&geoinst_idx, &pos_xform) ) {
        draw_calls += md->geometry[ md->instances[geoinst_idx].geometryIndex ].primitives.size();
    }
    printf("Estimated draw calls: %d\n", draw_calls);

    return input;
}