Loading...
Logo
Processing Forum
Might sound like a stupid question but I am not succeeding in pre-loading the OBJ file for Javascript to display the object.

So I was thinking about converting the "box.obj" file into vertices/polygons etc. and building the object as normal in processing.. that way, I will not have to battle with the preload method in processing.js

I converted parts of the  OBJ  to vertices but it does not show the complete object yet.
Is there any way of letting loadShape("box.obj") do it's magic and obtain it's actual converted result?

Here is the test object file for reference:
Copy code
  1. v  -14.2585 -6.0209 15.4785
  2. v  -14.2585 -6.0209 -12.8278
  3. v  21.4724 -6.0209 -12.8278
  4. v  21.4724 -6.0209 15.4785
  5. v  -14.2585 5.5800 15.4785
  6. v  21.4724 5.5800 15.4785
  7. v  21.4724 5.5800 -12.8278
  8. v  -14.2585 5.5800 -12.8278
  9. # 8 vertices

  10. vn 0.0000 -1.0000 -0.0000
  11. vn 0.0000 1.0000 -0.0000
  12. vn 0.0000 0.0000 1.0000
  13. vn 1.0000 0.0000 -0.0000
  14. vn 0.0000 0.0000 -1.0000
  15. vn -1.0000 0.0000 -0.0000
  16. # 6 vertex normals

  17. g Box001
  18. f 1//1 2//1 3//1 4//1 
  19. f 5//2 6//2 7//2 8//2 
  20. f 1//3 4//3 6//3 5//3 
  21. f 4//4 3//4 7//4 6//4 
  22. f 3//5 2//5 8//5 7//5 
  23. f 2//6 1//6 5//6 8//6 
  24. # 6 polygons
The problem is that I do not know how to convert this OBJ file into plain vertices.

Any ideas?

Replies(1)

Referring to  Wiki
It's clear how to interpret an OBJ file :)
Basically, the example box consists of 6 faces and the group of polygons are as follows:
Face 1 consists of vertex 1,2,3,4
Face 2 consists of vertex 5,6,7,8
Face 3 consists of vertex 1,4,6,5
Face 4 consists of vertex 4,3,7,6
Face 5 consists of vertex 3,2,8,7
Face 6 consists of vertex 2,1,5,6

I will create a java script which will convert the OBJ file into a list vertices, which I will then paste into the processing project :) 
By doing that, I can create a high detail object in 3dsMax and plot it in a web browser, without using the problematic "preload" function.