by Jim » Wed Feb 17, 2010 6:14 pm
This is not a plugin - but a rudimentary code snippet that extracts data from a binary .3ds and outputs it to std out.
usage:
$ 3ds2obj.rb model.3ds > model.obj
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by thomthom » Wed Feb 17, 2010 6:22 pm
You got hold of file format specs for 3ds?
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Jim » Wed Feb 17, 2010 6:23 pm
It is readily available online.
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by xrok1 » Wed Feb 17, 2010 6:28 pm
thomthom, does it work, does it work?? 
“There are three classes of people: those who see. Those who see when they are shown. Those who do not see.” http://www.Twilightrender.com try it!
-
xrok1
-
- Posts: 1957
- Joined: Sat Feb 16, 2008 1:53 am
- Location: Canada
- Name: Rocky
by thomthom » Wed Feb 17, 2010 6:34 pm
xrok1 wrote:thomthom, does it work, does it work?? 
A bit early to ask that. 
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Jim » Wed Feb 17, 2010 6:35 pm
It appears there is a CAMERA chunk (0x4700), so if you can't find the format for that chunck, then you should be able to dump the chunk and view it in a hex editor to see if it can be deciphered. So once the chuck is identified, it is followed by its length. this line gives you the number of bytes to read the rest chunk: - Code: Select all
when 0x4700 puts "# CAMERA DATA" # NOT sure of the proper way to unpack? chunk_len = f.read(2).unpack('s')[0] chuck_len.times do # something? end next
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Jim » Wed Feb 17, 2010 6:43 pm
Whoops, check that command-line example I gave for usage - I changed it.
$ 3ds2obj.rb model.3ds > model.obj
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Jim » Wed Feb 17, 2010 6:53 pm
getting closer.. - Code: Select all
* 4700 - Camera
Describes the details of the camera in the scene
start end size type name 0 3 4 float Camera pos X 4 7 4 float Camera pos Y 8 11 4 float Camera pos Z 12 15 4 float Camera target X 16 19 4 float Camera target X 20 23 4 float Camera target X 24 27 4 float Camera bank ( rotation angle ) 28 31 4 float Camera lens
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Jim » Wed Feb 17, 2010 7:04 pm
I see , the camera is a fixed-length chuck so has no length - you just start reading the values: - Code: Select all
when 0x4700 puts "# CAMERA DATA" xpos = f.read(4).unpack('f')[0] puts "xpos:#{xpos}" ypos = f.read(4).unpack('f')[0] puts "ypos:#{ypos}" zpos = f.read(4).unpack('f')[0] puts "zpos:#{zpos}" next
Although strangely the values are close but not exact as: Sketchup.send_action(10624)
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by thomthom » Wed Feb 17, 2010 7:05 pm
Ah, I see. It's a standalone ruby - not a SU ruby. have not looked at the code yet.
28 31 4 float Camera lens - what would this be then?
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by thomthom » Wed Feb 17, 2010 7:08 pm
Jim wrote:I see , the camera is a fixed-length chuck so has no length - you just start reading the values: - Code: Select all
when 0x4700 puts "# CAMERA DATA" xpos = f.read(4).unpack('f')[0] puts "xpos:#{xpos}" ypos = f.read(4).unpack('f')[0] puts "ypos:#{ypos}" zpos = f.read(4).unpack('f')[0] puts "zpos:#{zpos}" next
Although strangely the values are close but not exact as: Sketchup.send_action(10624)
would this not be doing the same? xpos, ypos, zpos = f.read(12).unpack('fff')a one-liner.
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by thomthom » Wed Feb 17, 2010 7:09 pm
Jim wrote:Although strangely the values are close but not exact as:
How close? Minor - something that could be explained by floating precision?
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Jim » Wed Feb 17, 2010 7:10 pm
thomthom wrote:would this not be doing the same? xpos, ypos, zpos = f.read(12).unpack('fff')
Maybe - I'm in "make it work" mode. Optimize mode comes later.
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Jim » Wed Feb 17, 2010 7:29 pm
Yeah, that's pretty much all there is to it. Make sure to read all the values; you can't skip them even if you don't use them. I made a mistake when I said the values did not match - it works out no problem. - Code: Select all
when 0x4700 puts "# CAMERA DATA" xpos, ypos, zpos = f.read(12).unpack('fff') puts "eye: (#{xpos}, #{ypos}, #{zpos})"
tx, ty, tz = f.read(12).unpack('fff') puts "target(#{tx}, #{ty}, #{tz})"
rotation = f.read(4).unpack('f')[0] puts "#rotation:#{rotation}"
lens = f.read(4).unpack('f')[0] puts "#lens:#{lens}" next
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by thomthom » Wed Feb 17, 2010 7:37 pm
Jim wrote:Yeah, that's pretty much all there is to it. Make sure to read all the values; you can't skip them even if you don't use them.
Because of variable chunk length? Jim wrote:I made a mistake when I said the values did not match - it works out no problem.
You managed to recreate an SU camera? What's the lens value? AOV? FOV?
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Developers' Forum
|