Пример #1
0
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");
	}

}
Пример #2
0
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");
}