3D box tool update

Hi everyone,
following Gail's example, I would like to post a short note on my progress, too, and at the same time announce version 0.1 of the 3D box tool. :) Well, that's probably too much of a promise. It is _extremely_ limited, the only thing it may be useful for is giving an impression of the envisaged behaviour (also see http://www.rzuser.uni-heidelberg.de/~malbert/core_functionality.shtml ). I'd appreciate comments, although I admit that there is not much to comment on yet. ;)
All you can do at the current stage is create a box in a fixed perspective. No dragging of corner nodes is possible yet, nor of vanishing points (VPs) or perspective lines (PLs), nothing. Although you can of course treat boxes as "normal" groups of paths and edit them in the usual way. However, since currently the transform method is not implemented, you should hit Ctrl+Shift+G and Ctrl+G before doing so (in order to ungroup and regroup the paths representing the faces, which removes the 'sodipodi:type="inkscape:3dbox"' attribute from the group so that it is not recognized as a 3D box any more; this mainly fixes issues with undo/redo).
In the current fixed perspective the edges of the box are drawn along parallel PLs directed towards "infinite" VPs in x-, y- and z-direction. You will notice, however, that as soon as the 3D box tool is activated, three points are drawn on the canvas. They represent "finite" VPs and it is possible to switch between "finite" (i.e., the PLs meet in the respective VP) and "infinite" (i.e., the PLs are parallel) in each direction by toggling the corresponding button in the 3D box toolbar. The VPs will be color-filled when their state is finite. Sorry that they don't disappear again when switching to another tool, but I didn't want to invest a lot of time in making them work better when I need to rewrite the code anyway as soon as they become draggable. BTW, already drawn boxes are not updated live yet, toggling the VPs' states only affects the drawing of new boxes (also note that when the VPs are white they don't affect the drawing of boxes, although they appear on the canvas; this is a bit counter-intuitive when using the tool for the first time).
Since the functionality is so limited I decided to hide the tool's icon for the time being. To make it visible, simply uncomment line #129 in src/toolbox.cpp. You can also change the position/direction of finite/infinite VPs by setting the corresponding values in src/box3d-context.cpp (starting from line #122) and recompiling. Very inconvenient, I know. And if anyone wants to design a *nice* icon for the toolbox, you are most welcome (I haven't invested any time in that so far).
Well, I really hope to make faster progress starting from next week. I have just handed in my Diplom thesis (whose completion took a lot more time than expected) so that I could only work part-time on SoC during the past weeks.
Cheers, Max

Alexandre Prokoudine wrote:
On 6/21/07, Maximilian Albert wrote:
Hi everyone,
following Gail's example, I would like to post a short note on my progress, too, and at the same time announce version 0.1 of the 3D box tool. :)
...which we can get from...? :)
http://inkscape.svn.sourceforge.net/viewvc/inkscape?view=rev&revision=15...
Aaron

Hi everyone,
following Gail's example, I would like to post a short note on my progress, too, and at the same time announce version 0.1 of the 3D box tool. :)
...which we can get from...? :)
http://inkscape.svn.sourceforge.net/viewvc/inkscape?view=rev&revision=15...
Thanks, Aaron. Yes, I obviously forgot to mention that I made my first (real) commit to SVN today ... ;)
Best regards, Max

On 6/21/07, Maximilian Albert <Anhalter42@...173...> wrote:
I'd appreciate comments, although I admit that there is not much to comment on yet. ;)
It's a great start, thanks a lot!
Now, apart from all the other things you need to do, one more thing to take care of: styles. Now the tool paints all sides of the box the same last-used style. This is less than useful. In a scene, I usually want all sides that are parallel to be one color but different from the color of all other sides.
This means the tool must store not one style, but SIX possibly different styles, one for each side, and apply them to the newly created boxes. This means you cannot simply reuse the existing style-remembering machinery that all other object-creating tools use; it must be extended.
Here's how (I think) this should be done. As you probably know, each tool may be in one of two modes: using its own fixed style or using the last-set style for new objects. The 3DBox style should be no different in that. The fixed style is stored in prefs. So, you just need to add the six default colors (make them meaningfully different) to prefs, for example instead of the current
<eventcontext id="3dbox" style="..." />
use six child elements under eventcontext:
<eventcontext id="3dbox" style="..."> <side id="XYtop" style="..."/> <side id="XYbottom" style="..."/> <side id="XZtop" style="..."/> <side id="XZbottom" style="..."/> <side id="YZtop" style="..."/> <side id="YZbottom" style="..."/> </eventcontext>
This way, you can have a separate style for the entire box group in <evencontext> and styles for each of the sides. If a side has not specified some style property, it will be automatically inherited from the parent eventcontext's style.
Then in the box3d-context, add code to use these substyles on the six sides of a box you create.
However, more useful is the mode where the tool uses the last-set style on the newly created boxes. This mode needs to be similarly extended to store six different styles (plus one style of the entire box), but this needs to be done not in the 3dbox tool but deeper - because you can Ctrl+click to select a side and paint it in almost any tool. Here's what you need to do.
Currently, the last-set style is stored in prefs as the style of the desktop group:
<group id="desktop" style="..." />
No matter how you set style on an object, that style= value is written in one single place: in the beginning of sp_desktop_set_style function (see comment 1a). This is where you need to add the following, in pseudocode:
iterate over desktop->selection: for each selected object, if it's a XYtop side of a 3Dbox: write the style to <group id="sideXYtop"/> inside desktop group if it's a XYbottom side of a 3Dbox: write the style to <group id="sideXYbottom"/> inside desktop group .... etc for all 6 sides
Then, this style-remembering will work in any tool or context, and in the 3D tool you will be able to use these remembered last-assigned styles for newly created boxes. Note that for this to work, you will also need to add some sodipodi:type attribs to the sides, not only to the box group as you do now. Also note that this code will work in addition to the existing code that writes to <group id="desktop" style="..." />, not replacing it, so the regular last-used style will still be set for other tools to use.
Does this make sense? Please write me with any questions you may have.

Maximilian Albert wrote:
And if anyone wants to design a *nice* icon for the toolbox, you are most welcome (I haven't invested any time in that so far).
I think that when the style stuff bulia mentioned is implemented and the tool is more interactive, creating an icon (using your tool even) will be a snap! :-)
-Josh

Thu, 21 Jun 2007 15:04:50 +0200 Maximilian Albert <Anhalter42@...173...> kirjoitti:
following Gail's example, I would like to post a short note on my progress, too, and at the same time announce version 0.1 of the 3D box tool. :) Well, that's probably too much of a promise. It is _extremely_ limited, the only thing it may be useful for is giving an impression of the envisaged behaviour (also see http://www.rzuser.uni-heidelberg.de/~malbert/core_functionality.shtml ). I'd appreciate comments, although I admit that there is not much to comment on yet. ;)
It seems that this won't compile on 64 bit platforms.
In sp_3dbox_toggle_vp_changed (toolbox.cpp:2109) a pointer (64 bits) is casted to an integer of a smaller size (32 bits), which is a big no-no. (even though in this case there's a good reason)
For a quick solution, the offending line could be changed to intptr_t dir = (intptr_t)data; but as intptr_t is a C99 feature, this may prove to be a problem, too. (I don't know if it is or not)

On 6/21/07, Maximilian Albert wrote:
following Gail's example, I would like to post a short note on my progress, too, and at the same time announce version 0.1 of the 3D box tool. :) Well, that's probably too much of a promise. It is _extremely_ limited, the only thing it may be useful for is giving an impression of the envisaged behaviour (also see http://www.rzuser.uni-heidelberg.de/~malbert/core_functionality.shtml ). I'd appreciate comments, although I admit that there is not much to comment on yet. ;)
There are some things :)
1. 3D box enabled version seems to have erased contents of ~/.inkscape/preferences.xml and now on every start it complains that the file is either not an XML file or has wrong permissions :-)
2. The tool's icon should notbe between Rectangle an Ellipse tools icons. I would place it between Text tool and Connector tools icons.
3. There should be a (possibly) one-key keyboard shortcut for the tool.
Alexandre

Alexandre Prokoudine schrieb:
There are some things :)
Thanks for your reply! (And sorry that mine has taken so long).
- 3D box enabled version seems to have erased contents of
~/.inkscape/preferences.xml and now on every start it complains that the file is either not an XML file or has wrong permissions :-)
Hmm, I can't seem to duplicate this (otherwise I would of course have fixed it in advance). And I am not sure what it is exactly that causes this problem. Can you specify more precisely what is being changed/deleted? Do others see this as well?
- The tool's icon should notbe between Rectangle an Ellipse tools
icons. I would place it between Text tool and Connector tools icons.
OK, done.
- There should be a (possibly) one-key keyboard shortcut for the tool.
Absolutely. I don't have a very good general overview over the many, many shortcuts in use, however. Since the 3D Box tool is somewhat similar to the Rectangle tool, I would introduce Shift+F4 as one possibility. For an easy to remember one-key shortcut, how about 'x' (for boX)? It seems that it's the only one coming to mind that is not currently occupied. Any other suggestions? If no one complains, I'll add both of these.
Max
participants (6)
-
Aaron Spike
-
Alexandre Prokoudine
-
bulia byak
-
Josh Andler
-
Maximilian Albert
-
Niko Kiirala