LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Apply texture on an 3D object

Hi,

I have a 3D scanner that outputs 3D model (STL file) as well as texture for that model (PNG file). I'm able to open the STL file in Labview (as mesh object), but I don't know how to plot texture on the mesh, because Apply Texture.vi doesn't work (at least not correctly). However, I'm able to apply the same texture on a simple sphere (see the attached example), therefore I don't understand why it's not working for my mesh.

Any help is greatly appreciated. Also the example is attached.

0 Kudos
Message 1 of 9
(5,837 Views)

AFAIK, STL do not contain any texture information. Try export to VRML with UV information to fix the texture mapping

See this also: http://digital.ni.com/public.nsf/allkb/94E716A426FAD46B862575CA005747E0

0 Kudos
Message 2 of 9
(5,783 Views)

It's true that STL doesn't contain any texture information. Therefore, I have a PNG file that contains texture information and I want to apply that texture to the 3D model (mesh) with Apply Texture.vi (according to the description it should do the job).

The scanning software that I have can only output PLY, OBJ, STL or ASC format, thus, I cannot use VRML format.

0 Kudos
Message 3 of 9
(5,777 Views)

Although STL doesn't have Texture, once you imported into LabVIEW, you can then apply texture to it. You can do two options (as far as I could see... maybe there are other options).

a. You can use the Texture Gen Code on the Property node to the object imported from STL.

texture.PNG

b. You can 'deconstruct' the polygons and reconstruct with 'Texture Information"

texture 2.PNG

 

Then you just need to apply texture to it:

texture 4.PNG

Here is this example... Please point to your STL and jpg files. Hopefully that works for you

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 4 of 9
(5,771 Views)

Thanks Barp. Now I can apply texture, however, I don't know how to set up all parameters to look like it should (hand from the JPG should be applied on the hand in the 3D model). Do you have any idea how to do that? (I attached my example)

0 Kudos
Message 5 of 9
(5,749 Views)

You need to make sure your model contains all the correct U,V co-ordinates- these tell each model vertex what part of the texture is stuck to it.

 

From a glance at the wikipedia article, STL doesn't seem to support them. It really would be easier to go with a better file format.

 

EDIT:Try PLY- wiki says it supports texture co-ordinates (the aforementioned U,V). If LabVIEW doesn't have a PLY loader (I don't have it here), you may need to run the file through a converter to something LV does support out of the box.

0 Kudos
Message 6 of 9
(5,739 Views)

Well, I think you need understand some concepts in how to use textures. First, your picture it is just a flat image of you arm:

small arm.JPG

 

When you to use this picture, you will have picture applied to each polygon of your arm and the other object in the back :

arm2.JPGarm3.JPG

 

So, LabVIEW is actually doing what you ask. If you try to change the pattern used for the cylinder, you will have a better idea of how the texture works:

 

arm4.JPG

 

So, you have think like this "what is the image that I have to apply to each polygon to show the effect you want". So, if you just want to make the 3D object look like skin, you have to obtain a patch of art that looks like skin and apply to the object:

arm5.JPG

So, then, applying this to each polygon would give you:

arm6.JPG

 

So it depends on what you are trying to do. Are you trying to make the hand more 'realistic'? then you'd have to be vary careful in how to obtain the polygons (like eveybody said) and you have to have a picture that allow you to place the right pattern to it.

 

 

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 7 of 9
(5,719 Views)

Now, I think that you probably want to show your 'hand' on top of your points. Then, although STL doesn't have Texture information, once you read into LabVIEW, you can manipulate the mesh to generate the missing infomation.

 

The Texture is specified by two parameters S and V. They correspond to the Horizontal and Vertical coordinates (normalize between 0 and 1) of the picture that will be use inside the triangle. So, I noticed that you want to see your hand 'projected' to the points measured. Also, I noticed that the X, Y position is 'similar' to the location of your picture, so I just tried to map the X and Y points (ignoring Z) into the S and V parameters. I also noticed that your dimensions were way bigger than the picture, so I normalized the X,Y,Z coordinates. Then, by applying a those two transformations, I was able to get this:

 

 

hand on 3D points.JPG

Now, I also noticed a relationship between the size of the picture and points, so that is the reason I tried 'eye ball' it. Also, I have to flip the picture vertically to match the inicial points.

Notice also that your measurements have several points that are not in the hand, so probably you'd want ot clean those points and also remove points that are 'off' the hand (probably errors).

 

In short, the trick in using textures and meshes is to map the part of the picture you want to map into your object (in your case, the triangles). If you look into the shipping example: "C:\Program Files (x86)\National Instruments\LabVIEW 2013\examples\Graphics and Sound\3D Picture Control\Using Meshes.vi", you will see how meshes work with textures.

 

Would this work for you?

Barp - Control, Simulation, RTT and HIL - National Instruments
Download All
0 Kudos
Message 8 of 9
(5,705 Views)

Hello Barp,

 

Could you send the file in Labview 2012?

 

Best regards

 

0 Kudos
Message 9 of 9
(5,208 Views)