generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Simple OBJ model loader in Javascript

Previous Thread :: Next Thread 
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 04:58 PM
Does anyone have use for this? It's untested, and it's up to you to add textures. It does, however, load positions, normals, and texture coords and correctly handles the "o" line in the OBJ format.

http://pastebin.com/Bz4d3bgN

I don't care how you use it or if you even give me credit. Just thought I'd share this little bit of code with my fellow programmers.
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:00 PM
I might also add that you use it like so:

var obj_file_str = "......";
var result = LoadOBJ(obj_file_str);

result.vbo...;
result.ibo....;
result.objects[n]...;
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
16 Jan 2013 05:13 PM
You copied my creation yet AGAIN...
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:14 PM
Forgot to mention that it produces an interleaved vertex buffer. This is a more efficient format that stores vertices like so:

...[PPPPTTNNN][PPPPTTNNN][PPPPTTNN]...

Rather than

[PPPP][PPPP]...[TT][TT]...[NNN][NNN]

The interesting bit is that OBJ stores them in the second format. This is more efficient for data storage but not for using them. The second format allows you to eliminate duplicates more precisely. That doesn't really work in OpenGL, so I've converted it to the full interleaved format in which each vertex has a unique position, texture coordinate, and normal.

Interestingly, this does not allow for smooth shading. This isn't an issue for me since I'm not using forward rendering, but you won't want to use this in that context. But then again, OBJ isn't the best format for a final game anyway - this is just useful for demos/prototypes. If you wanted to modify it to work with smooth shading, you'd want to index your final vertices by their position so that the face declarations refer to the same vertex. This, however, adds an extra pass.

I might implement this extra pass anyway, just for fun and completeness. I think I'll do that now. Will report back with updated code.
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
16 Jan 2013 05:14 PM
Thanks for copying the documentation I've written for it!
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:14 PM
Tenal, I am not going to tolerate this here. You've been reported for harassment and I sincerely hope you don't get off easy this time. I've dropped it, you should too. Stop being immature.
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
16 Jan 2013 05:15 PM
Wait, harassment? The problem here is that you copied something I made. That's the bottom line. I may be good at programming and you're allowed to use the things I make but don't claim to make it yourself...
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:16 PM
Do not make false claims. You are not good at programming. You are only good at seeking attention.
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
16 Jan 2013 05:17 PM
Well, I may be good at seeking attention but by copying my work, you should imply I'm good...
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
16 Jan 2013 05:18 PM
getPlayer("Tenal").report("Harassment");
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:19 PM
Thanks DrHaximus. I would suggest that everyone does the same. Baseless flaming, poor trolling, and attempts at discrediting people are a blight on this forum.
Report Abuse
Charl3s7 is not online. Charl3s7
Joined: 07 Dec 2007
Total Posts: 4146
16 Jan 2013 05:20 PM
Hi Kahl
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:22 PM
So, hopefully a mod will delete the derailed posts so this serious thread may continue again. Any questions?
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
16 Jan 2013 05:22 PM
@nvi
I'm honestly unsure as to why you steal not one but two of my creations and claim it as your own. If anything you should be reported.
Report Abuse
ChuckTestaDotAvi is not online. ChuckTestaDotAvi
Joined: 03 Sep 2012
Total Posts: 439
16 Jan 2013 05:23 PM
You probably thought it's tenal on his spamming routine,

NOPE!
It's just Chuck Testa!
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
16 Jan 2013 05:24 PM
Back on topic, this is a great reference for me, I need to make one for OpenGL/C++. Do you mind if I use it?
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
16 Jan 2013 05:24 PM
Pro-tip: `[]` is shorter and more idiomatic than `new Array()` (but does the same thing).
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:27 PM
Thanks NXTBoy, I was wondering if there was a shortcut for that but it wasn't a big enough issue to warrant a search.

Go ahead, DrHaximus. Keep in mind, though, that this code is relatively inflexible - there are more possibilities in the OBJ format - check the Wikipedia page.

And if anyone wants an easy way to report Tenal with a comment, copy and paste this:

"Continued trolling, flaming, slander, harassment, spamming, intentional thread derailing, and general idiocy."
Report Abuse
Tenal is not online. Tenal
Joined: 15 May 2011
Total Posts: 18684
16 Jan 2013 05:33 PM
@NXT
Oh, thanks. I honestly didn't know it could have been done that way.
Report Abuse
Lombardo3 is not online. Lombardo3
Joined: 15 Dec 2012
Total Posts: 271
16 Jan 2013 05:37 PM
Obj loader?? umggg how you load machine codeee!!?!?!?11

this is awsum but i dont laik webgl!111 javascript and opengl? nou thankx
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
16 Jan 2013 05:39 PM
webgl is awesome :(
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:47 PM
I'm in love with WebGL. Between the new pointer lock API and that the community is pushing for multiple render targets in the ES specification, WebGL is looking extremely good. I think even loading your assets from Amazon S3 is possible via AJAX w/ credentials, but don't quote me on that.
Report Abuse
Lombardo3 is not online. Lombardo3
Joined: 15 Dec 2012
Total Posts: 271
16 Jan 2013 05:52 PM
but seriously? opengl 2.0 is laik a decade old... dunt laik
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
16 Jan 2013 05:54 PM
opengl 2.0?

why would you still be using it in the first place?
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
16 Jan 2013 05:54 PM
OpenGL 2.0 is, but not OpenGL ES 2.0 is not. Might want to fact-check before you make statements.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image