Convert scanner from meters to millimeters?


#1

How can I get the scanner to use millimeters instead of meters?


#2

@timterry73 scaling the mesh vertex data by 1000 before saving the mesh is the way to accomplish that. Or, do the scaling when importing the data into whatever editing / modeling program you’re using.

-jim


#4

what files/lines of code do i need to change in the “scanner sample” to update the mesh vertex data before saving?


#5

@timterry73, take a look at the documentation for STMesh. presentMeshViewer in ViewController.mm is a good example of how to iterate through the mesh data.

Assuming you’re using [STMesh writeToFile] to save the mesh, you’ll want to do your scaling before writeToFile is called in the function emailMesh in MeshViewController.mm.

-jim


#6

@jim_selikoff, I’m trying to scale down to millimeters but am a little lost. I tried creating a new GLKVector3 and then assigning it here

    [meshToSend meshVertices:i] = vertexUpdating

but am getting a warning “Assigning to ‘readonly’ return result of an Objective-C message not allowed.”
How can we scale the vertex if this is a read only? Should I be looking somewhere else?

STMesh* meshToSend;

for ( int i=0; i<_mesh.numberOfMeshes; ++i)
{
    int numVertices = [_mesh numberOfMeshVertices:i];
    const GLKVector3* vertex = [_mesh meshVertices:i];

    GLKVector3* vertexUpdating;
    
    for( int j=0; j<numVertices; j++ )
    {
        vertexUpdating[j].x = vertex[j].x * .001;
        vertexUpdating[j].y = vertex[j].y * .001;
        vertexUpdating[j].z = vertex[j].z * .001;
    }
    
    [meshToSend meshVertices:i] = vertexUpdating
}

BOOL success = [meshToSend writeToFile:zipPath options:options error:&error];

#7

@cgranthovey

I believe it is just a matter of changing the syntax used in the following line:

[meshToSend meshVertices:i] = vertexUpdating

to

[meshToSend meshVertices(i): vertexUpdating]

or

meshToSend.meshVertices(i) = vertexUpdating

I believe I have the correct syntax above, but JIC I found the solution on the following page: https://stackoverflow.com/questions/10303508/assigning-to-readonly-return-result-not-allowed-but-property-is-declared-rea


#8

@anthony.monaco I’m getting errors with each of those.

[meshToSend meshVertices(i): vertexUpdating]

At the first parenthesis I’m getting an error - Expected ‘]’
I noticed the stack overflow answer had added the word “set” so I tried experimenting with that but couldn’t get it to work.

And for

meshToSend.meshVertices(i) = vertexUpdating

Error - Property ‘meshVertices’ not found on object of type ‘STMesh *’

Do you have any other ideas? Can the meshVertices be set?


#9
GLKVector3 scaleFactor = GLKVector3Make(0.001, 0.001, 0.001);
[self.meshRef meshVertices:0][0] = GLKVector3Multiply([self.meshRef meshVertices:0][0],scaleFactor);

That compiles :slight_smile:


#10

@jim_selikoff @anthony.monaco Great! Got it working, thanks for your help.


#11

What @synthesize statement did you use and where?


#12

@cgranthovey Could you please post the solution you had for converting the scale from Meter to Millimeter?

Thanks!