# Render OBJ model with XMP files

**URL:** <https://forums.unrealengine.com/t/render-obj-model-with-xmp-files/712249>\
**Category:** Asset Creation\
**Tags:** realityscan\
**Created:** [December 15, 2021, 10:18am UTC](https://forums.unrealengine.com/t/render-obj-model-with-xmp-files/712249 "2021-12-15T10:18:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_982929a7ef](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_982929a7ef](https://forums.unrealengine.com/u/Anonymous_982929a7ef)\
**Post date:** [December 15, 2021, 10:18am UTC](https://forums.unrealengine.com/t/render-obj-model-with-xmp-files/712249/1 "2021-12-15T10:18:12Z")

</div>

Hi,

I tried to project vertices of a model to image with XMP files. and i followed the process in this tutorial [https://support.capturingreality.com/hc/en-us/articles/360017783459-RealityCapture-XMP-Camera-Math](https://forums.unrealengine.com/hc/en-us/articles/360017783459-RealityCapture-XMP-Camera-Math).

However, x and y coordinates of projected point m are not in range \<-0.5, 0.5\>. I have checked the code several times and can not find what’s wrong. Here is some code.

```
glm::vec3 DistortBrown(glm::vec3 point, float k1, float k2, float k3)
{
float r = ((point.x * point.x) + (point.y * point.y));
glm::vec3 res = point * (1 + k1 * r * r + k2 * pow(r, 4) + k3 * pow(r, 6));

return res;
}

//https://support.capturingreality.com/hc/en-us/articles/360017783459-RealityCapture-XMP-Camera-Math
glm::vec3 Project(glm::vec4 point, glm::mat4 headRotation, glm::vec4 headTranslation, glm::mat3 cameraIntricsic, int imgWidth, int img_height)
{
float distortCoefficients[3] = { 0.267794801323342, 1.75333829998265 ,-3.09898757948234 };
glm::vec4 point1 = headRotation * point + headTranslation;
point1 = point1 / point1.z;

glm::vec3 point2(point1.x, point1.y, point1.z);

glm::vec3 pointDistort = DistortBrown(point2, distortCoefficients[0], distortCoefficients[1], distortCoefficients[2]);
glm::vec3 point3 = cameraIntricsic * pointDistort;
point3 = point3 / point3.z;

int scale = max(imgWidth, img_height);
point3.x = point3.x * scale + imgWidth / 2.0;
point3.y = point3.y * scale + img_height / 2.0;
return point3;
}

void myRenderScan()
{
string objPath = "D:/hair_low_default_transform.obj";
string saveFolder = "./";

float rotateArray[16] = { 0.00822257804236592, 0.115988745747896, 0.993216492044996, 0,
0.997496652513794, -0.070713706053177, -1.11022302462516e-16, 0.0,
0.0702340190656374, 0.990730126036377, -0.116279834579487, 0.0,
0, 0, 0.0, 1.0 }; //tiff2 21

float translateArray[3] = { -5.07654498116938,-74.9080755382079, 26.5896625365347 }; //tiff2 21

float AspectRatio = 1.0f;

float focalx = 84.9087857946017 / 36.0, focaly = AspectRatio * focalx, fu = 0.0159303940758487, fv = 0.00294879565420105; // in mm

float cameraIntrinsicArray[16] = { focalx, 0, fu,
0, focaly, fv,
0.0, 0.0, 1.0 };

glm::vec4 headTranslation = glm::vec4(translateArray[0], translateArray[1], translateArray[2], 1.0);
glm::mat4 headRotation = glm::transpose(glm::make_mat4(rotateArray));
glm::mat3 cameraIntricsic = glm::transpose(glm::make_mat3(cameraIntrinsicArray));
}

```

---

<div class="post-metadata">

**Author:** ![Anonymous\_982929a7ef](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_982929a7ef](https://forums.unrealengine.com/u/Anonymous_982929a7ef)\
**Post date:** [December 15, 2021, 10:26am UTC](https://forums.unrealengine.com/t/render-obj-model-with-xmp-files/712249/2 "2021-12-15T10:26:21Z")

</div>

and the export parameters&nbsp;
