Showing posts with label how-to. Show all posts
Showing posts with label how-to. Show all posts

Debugging made easy

I know that debugging and how it's done is a very personal thing. Still - I'd like to share some of my experiences and tips I've gathered during my years of programming. Here goes...

The situation: I know a specific line that I'd like to debug to in a file. The solution before: navigate to the line, add a breakpoint, press F5. It's pretty simple in essence but still a bit cumbersome. And what if this breakpoint is a one-timer - you'd have to remove it afterwards. Furthermore, if you forget to remove it, the next time the debugger breaks at the line it ever so rudly interupts your already mentally challenging debugging session. It just so happens to be there's a solution for all this - a command called Run to cursor. I've set it under the F8 key so it's close to all the rest of the debugging keys. What it does is runs the code and breaks the debugger at the line where the caret is positioned - no need for temporary breakpoints etc. Cool, huh? :)

Next on the list - the Debugger.Break() method in the System.Diagnostics namespace. This method signals a breakpoint to an attached debugger. One might wonder - what's the point - I could have just as easily defined a breakpoint myself, why the fuss about defining it in code. A very valid point. Now imagine a case when there is no debugger yet attached or there is no simple way to attach one. If this is the case then calling this method asks the user to select a debugger. This method comes in handy when debugging e.g. windows services and processes than cannot be started out of Visual Studio. Awesome - I know.

Last but not least - DebuggerStepThroughAttribute in the System.Diagnostics namespace. This attribute can be used to decorate a class, struct, method and constructor and tells the debugger to ignore the decorated piece of code and not step into it, although a breakpoint can still be set an be breaked to. The step through attribute can also be defined on a property but has to be declared on the setter and getter individually. Common uses would be e.g. .net base class library extension methods, simple field accessor properties on domain objects etc. Here's a nuisance this attribute helps to overcome: some object properties are passed into a method as parameters and you want the debugger to step into the method withouth having to initially step through all the properties. Once the getters on the properties have the step through attribute on them the debugger can step right into the desired method ignoring the properties.

I sincerely hope any of this is helpful to some of the fellow programmers out there and once again - it wouldn't hurt to hear you, the reade's, handy tips about code debugging in Visual Studio in the comments section.


Debug away...
Mihkel

Modeling a car - a quick run-through

I wrote this little instructional how-to at CGSociety on the topic of modeling a car in a poly-modeling fashion and thought it might be a good idea to make it a blog post. This question get's asked quite ofter - what is your modeling workflow like, so here's how I do it.

First step is to create a splinecage. This consists of setting up the blueprints and getting them aligned on all four planes - side, top, front and back. Then it's just a matter of creating splines where the edges run on the car. For the body panels I draw the spline e.g. for the hood in the top view, then go into side and front view to get the splineS bent exactly how it should be in all three dimensions. But take great care at this step as it is NOT a no-brainer to change splinecage once you start building the mesh on top of it.

Second step is not always that straight forward. I now have a spline cage in place which I can use for points snapping when creating plygons. Sometimes to understand the mesh flow better, I do some wireframe paintovers on some reference photos in photoshop with my wacom. But do remember that this step cannot be taught in my opinion, this can only be learned through practice. Then I create a single polygon which basically covers the particular area in the most simplistic fashion. e.g. for the door panel I just create a simple quad which stretches out into all the corners of the door panel. Then comes the cutting and finetuning. I then do the cuts in the polygon where they're necessary e.g. the crease in the door, more edges to achieve the curvature etc. Never manually place the points on the edges of panels, only use snapping to the splinecage!!!

At this point you should have the main body panels created, but without the bevel on the edges, which gives a nice thick feel to the body panels. This totally boils down to the tools that your particular applican offers. The end result for the panel edges and corners should look something like this:

There's one row of polygons going inwards and there are two rows of polygons on the surface edge of the body plate. The two polygon rows have a total width of about 2,5-3,5 mm. To produce the edge bevels in Cinema 4D I use the following steps:

  • select all polygons
  • clone
  • extrude inward or do a negative smooth shift of about 1,5mm
  • delete the cloned polygons
  • optimize to weld overlaping points at the newly created crease
  • the outer facing polygons I extrude inner for two steps, 1-1,5mm each
  • add the necessary cuts at the corners to crea a sharp corner

As for all the rest of the points on the bodyplate that aren't exactly on the splinecage, there I use the brush tool in smear mode with very low strength to give minute adjustments where necessary. This is the most time consuming part of the whole process as one change needs to be view at and adjusted from all the angles. It's also possible to use the iron tool or the brush tool in the smooth mode to achieve some inital smoothing from which to work onwards.

I hope this gives a little more insight into the way I model. Look forward for more modeling tutorials covering some very specific subjects like proper edge beveling, sharp corner modeling etc. And don't think this tutorial applies to only cars - the described process can be used to produce almost any hard surface(non-organic) object.

kthnxbai,
Mihkel

DIY ringflash adapter

Here's another DIY project i undertook - an Orbis style ringflash adapter.

Dimensions

  • inner diameter - 85 mm
  • outer diameter - 235 mm
  • depth - 60 mm
  • neck length - 95 mm
  • ventilation pipe - 110 x 55 mm

Materials used:

  • a rectangular ventilation pipe for the neck
  • a flower pot for the inner surface
  • a fruit bowl for the outer surface
  • Rosco white diffusion filter
  • aluminium foil tape
  • black ducktape
  • white tape for covering the inner surface
  • wire for tying the parts together

Tips:

  • use of a dremel type of mini drill strongly suggested
  • tying the pieces together makes the final product more rigid than one where glue or tape was used
  • apply 2-3 layers of filter near the adapter neck area as this gets illuminated much brighter than the rest of the diffusion area
  • cover the exterior with black tape for a more professional look :)
  • make four plastic flaps on each side of the neck and add a rubber band around it to make the adapter fit flash heads of various sizes

A minidrill comes in very handy when cutting out the tricky sufaces - WEAR SAFETY GOGGLES AT ALL TIMES!!! The drill pictured above is produced by VELLMAN and costs around $45 (in Estonia). People on the other side of the pond should look for Dremel products. It's an all-around great investmen.

Light distribution test in a 3D software package using GI (global illumination)

Cut the top off the vase which forms the inner surface of the ringflash adapter.

The wire connections are hidden under the tape

Apply aluminium foil tape to allow light to spread out more from the neck

Rosco filter applied. Rubber band around the neck allows attatchment of flashes of various sizes. BEAWARE: flash might drop out if not held firmly enough!!!

Back side of the adapter covered with black duck tape

Notice the double layered filter near the neck area. It has the same arched shape at the ends as did the bright light on the 3D light distribution test image. Orbis incorporates the same feature.

Ringflash adapter in action - attached is a Sunpak PZ-5000AF - a fairly powerful strobe light in manual mode. I'm pretty satisfied with how the project turned out.
Til next time,
Mihkel

DIY softbox

Here's a DIY i was working on the last weekend - a softbox for my Sunpak PZ-5000AF strobe. Diffusion area dimensions are 20 x 16 cm and it could be fit on any similarly sized flash. Thickness when folded flat is about 8mm.

Materials used:

  • light, strong cardboard
  • ducktape - black
  • aluminium foil tape (a truly awesome piece of material for photography DIY-ers)
  • Rosco white diffusion filter
  • black rubber hair band


Aluminium foil tape

Tips:

  • all the hinged parts are made with ducktape to protect them from wear'n'tear.
  • make a small trame around the diffusion area, but make sure to cover the corners with ducktape to protect from wear'n'tear.
  • inside of the softbox is largely covered with foil tape to allow light to spread

And some images of the final product:

Folded flat

Folded flat

Even coverage

Inside covered with aluminium foil tape

Notice the folds made of ducktape
Coming up next - DIY ringflash.

Stay tuned.
Mihkel