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");
	}
}
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() || values->getCount() <= (v_index * stride + 2)) return;  // xxx need to create an eror instead

			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() || values->getCount() <= (v_index * stride + 2)) return; // xxx need to create an eror instead

			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");
	}

}
示例#3
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;
	}
}