void UVDataWrapper::getUV(int uv_index, float *uv)
{
	int stride = mVData->getStride(0);
	if (stride == 0) stride = 2;

	switch (mVData->getType()) {
		case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
		{
			COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
			if (values->empty()) return;
			uv[0] = (*values)[uv_index * stride];
			uv[1] = (*values)[uv_index * stride + 1];
			
		}
		break;
		case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
		{
			COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
			if (values->empty()) return;
			uv[0] = (float)(*values)[uv_index * stride];
			uv[1] = (float)(*values)[uv_index * stride + 1];
			
		}
		break;
		case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
		default:
			fprintf(stderr, "MeshImporter.getUV(): unknown data type\n");
	}
}
示例#2
0
void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride)
{
	i *= stride;
	
	switch (arr.getType()) {
		case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
		{
			COLLADAFW::ArrayPrimitiveType<float> *values = arr.getFloatValues();
			if (values->empty()) return;

			v[0] = (*values)[i++];
			v[1] = (*values)[i++];
			v[2] = (*values)[i];

		}
		break;
		case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
		{
			COLLADAFW::ArrayPrimitiveType<double> *values = arr.getDoubleValues();
			if (values->empty()) return;

			v[0] = (float)(*values)[i++];
			v[1] = (float)(*values)[i++];
			v[2] = (float)(*values)[i];
		}
		break;
		default:
			break;
	}
}
void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
{
	int stride = mVData->getStride(0);
	if (stride == 0) stride = 3;

	switch (mVData->getType()) {
		case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
		{
			COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
			if (values->empty()) return;

			mloopcol->r = FTOCHAR((*values)[v_index * stride]);
			mloopcol->g = FTOCHAR((*values)[v_index * stride + 1]);
			mloopcol->b = FTOCHAR((*values)[v_index * stride + 2]);
		}
		break;

		case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
		{
			COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
			if (values->empty()) return;

			mloopcol->r = FTOCHAR((*values)[v_index * stride]);
			mloopcol->g = FTOCHAR((*values)[v_index * stride + 1]);
			mloopcol->b = FTOCHAR((*values)[v_index * stride + 2]);
		}
		break;
		default:
			fprintf(stderr, "VCOLDataWrapper.getvcol(): unknown data type\n");
	}

}
void WVDataWrapper::print()
{
	fprintf(stderr, "UVs:\n");
	switch (mVData->getType()) {
		case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
		{
			COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
			if (values->getCount()) {
				for (int i = 0; i < values->getCount(); i += 2) {
					fprintf(stderr, "%.1f, %.1f\n", (*values)[i], (*values)[i + 1]);
				}
			}
		}
		break;
		case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
		{
			COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
			if (values->getCount()) {
				for (int i = 0; i < values->getCount(); i += 2) {
					fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i + 1]);
				}
			}
		}
		break;
	}
	fprintf(stderr, "\n");
}