Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Link to an OBJ loader, have not tested it extensively. It loads only the vertices/face/normal data, not anything else, such as materials and hierarchy. Don't load too big objects. Again, most of it is based on CopperLicht code, so the same license applies to it. Link: http://pastebin.com/cb74GGQW Example:
EDIT: One remark: Since the loader doesn't stop the execution of the rest of the program, I had difficulty implementing collisions for the object. To resolve this issue, I had to add the TriangleSelector after the mesh was loaded. Before loading the mesh, create a MetaSelector and apply it to the camera. Then, in the pastebin code, at line 113, create a TriangleSelector and add that to the allready existing MetaSelector. |
||||
|
that's cool. I think a few people in this forum wanted something like this :) |
||||
|
ty for sharing! I just dug into CopperLicht yesterday and knew this would be the first task at hand. Sadly, it seems to only render every other poly for me. I am set on finding out why though :) |
||||
|
In the meanwhile, I've been improving the routine somewhat more, experimenting with more models. One model was also showing only half of its faces. I don't remember exactly how, but it was fixed. So try this version, perhaps it works better: http://pastebin.com/ExGC0yyc This version includes an 'On Load' function (written without space) If this still doesn't work correctly, I could have a look if you can link me the model. |
||||
|
Thanks warner yes it works now! I am using a cube exported from blender with the default settings |
||||
|
hi Warner, I am testing this solution in WebGL target , I put the Pasterbin code in the html page into the head section, in the click event / run java script, I put the code var vaso = new ObjLoaderNode(); vaso.load(engine, "vaso.obj", 0.05); scene.getRootSceneNode().addChild(vaso); but it does not work, does not load the object in my scene the application is correct? Should I change something? not good programming notions, could you please guide me |
||||
|
I am very thankful for this. It works for me. I used it with version 1.14 of CopperLicht. (In case anyone is wondering, I didn't use the script from warner's first post. I used the one from his second post.) When I first tried it, I thought it didn't work, like the person named "quintella" mentioned above, but I changed the scale from "0.05" to "1", and the object appeared. Different graphic-design programs use different measurements, so my first OBJ image appeared small at the size of "1", while another object looked gigantic at that size, so I set the scale of that second object to "0.05" to shrink it, while the first object was invisible at that scale! In the console of my Firefox browser, I saw this error, even though the OBJ file seems to be imported normally: sampleobject.obj:1:2 It says an error is in Column 2 of Line 1 of my "OBJ" file. As far as I'm aware, some errors in consoles are safe to ignore, but I am not qualified to claim whether that error is important. In case people want to see the contents of my OBJ file so they can try to discern what causes the error, I opened it with a text editor so I could share what I see (an octothorpe symbol is in the file, right before the word "Exported", but it won't appear on this forum because of strong security): Exported from 3D Builder I haven't tried to interact with the objects imported with this OBJ loader yet, so I don't know how reliable the script is. I tested only to see if they appear on my screen. |
|