tag:blogger.com,1999:blog-300549202009-06-16T14:59:15.883-07:00Code Monkey Jas BlogWelcome to the Cool world of programming! This site offers some technical thoughts, tutorials, great finds, solutions, and anything else I feel I might throw up here. I'ld love to here your feedback!DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.comBlogger34125tag:blogger.com,1999:blog-30054920.post-89352172334853468902009-06-16T11:42:00.001-07:002009-06-16T11:42:40.112-07:00What superhero am I?Your results:<BR><B>You are <FONT SIZE=6>Superman</FONT></B><br /><TABLE><TR><TD><TABLE><TR><TD>Superman</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=80></TD><TD> 80%</TD><br /></TR><TR><TD>Green Lantern</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=65></TD><TD> 65%</TD><br /></TR><TR><TD>Iron Man</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=65></TD><TD> 65%</TD><br /></TR><TR><TD>Hulk</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=60></TD><TD> 60%</TD><br /></TR><TR><TD>Spider-Man</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=55></TD><TD> 55%</TD><br /></TR><TR><TD>Supergirl</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=55></TD><TD> 55%</TD><br /></TR><TR><TD>Wonder Woman</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=50></TD><TD> 50%</TD><br /></TR><TR><TD>The Flash</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=50></TD><TD> 50%</TD><br /></TR><TR><TD>Catwoman</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=50></TD><TD> 50%</TD><br /></TR><TR><TD>Batman</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=40></TD><TD> 40%</TD><br /></TR><TR><TD>Robin</TD><br /><TD><HR ALIGN=LEFT NOSHADE SIZE=4 WIDTH=32></TD><TD> 32%</TD><br /></TR></TABLE></TD><br /><TD>You are mild-mannered, good, <BR>strong and you love to help others.<BR><br /><IMG SRC="http://www.thesuperheroquiz.com/pics/superman.jpg"></TD><br /></TR></TABLE><A HREF="http://www.thesuperheroquiz.com/"><br />Click here to take the "Which Superhero are you?" quiz...</A><BR><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-8935217233485346890?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1tag:blogger.com,1999:blog-30054920.post-63553854070204865502009-02-08T21:40:00.000-08:002009-02-12T09:23:51.610-08:00XNA Game Project<A href="http://1.bp.blogspot.com/_bqVAGqNrmmk/SZBze7BXIiI/AAAAAAAAAFk/ao2tQCpyvj4/s1600-h/tex.bmp"><IMG id=BLOGGER_PHOTO_ID_5300863736491745826 style="WIDTH: 264px; CURSOR: hand; HEIGHT: 297px" alt="" src="http://1.bp.blogspot.com/_bqVAGqNrmmk/SZBze7BXIiI/AAAAAAAAAFk/ao2tQCpyvj4/s320/tex.bmp" border=0></A> <br /><P>I've been working on a demo project in XNA. This completes my content process for games. I first use my own model editor (going into beta this year) to create the geometry and animations and export a .x file. The level is built in a custom level editor tool we've written for this XNA project, and everything is pulled together in an XNA game engine. </P><br /><P>My first goal for this phase of the project was to animate a .X model in XNA. I searched around on the web and found samples and found one that was close. I started with the skinning sample that is available for download from the XNA Creators Club. It animates a bald soldier ("dude") .FBX file. <A href="http://1.bp.blogspot.com/_bqVAGqNrmmk/SZBzCBI-B2I/AAAAAAAAAFc/38Wih_ENvFU/s1600-h/dude.bmp"><IMG id=BLOGGER_PHOTO_ID_5300863239918061410 style="WIDTH: 250px; CURSOR: hand; HEIGHT: 200px" alt="" src="http://1.bp.blogspot.com/_bqVAGqNrmmk/SZBzCBI-B2I/AAAAAAAAAFc/38Wih_ENvFU/s320/dude.bmp" border=0></A> The issue with this code is that it rendered FBX files AND .X format, but it didn't do any blending between the key frames. This wasn't a problem for the sample model "dude" because it had a ton of frames, but for my animation that was only 10 or so key frames, it posed a real problem. So, I rewrote the code, preprocessor, and HLSL .fx files to properly load and animate .x files. After that, I had used some level editing code to create a height map and load my own model and have him walk around on the height map. </P><br /><P>Here is a video of my western character running around on a test height map. It demonstrates character animation and basic height collision. </P><br /><object width="320" height="266" class="BLOG_video_class" id="BLOG_video-11850dec18cb5aee" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="movie" value="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAJRKzAPfu3a7ks9WIkYJqTG_sMilVdVIS0UA9wm5pfIp79aQ3TyTypyGG0s6WCuTXyOwaTuclK4ROfy0-HdLWRaikMPhsNuOra5S5meFyCtEHOKs7ewEwi98q_Jzoapt_8lNsDmx5NA39169XZ0WWDqw91kJ09HNG_9N0owS1DwjW0VQt_pNd0ypfAe_cxUbfY_QssJPRrC0jtCwEvU9ePLdkD3r0eTSobTV39qi5F16%26sigh%3DdlYFPTl24mLK9xlQKVOa-s4z9eE%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3D11850dec18cb5aee%26offsetms%3D5000%26itag%3Dw320%26sigh%3DCbFsbMQRxzVGbiRt9QGZTngbCOc&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den"><param name="bgcolor" value="#FFFFFF"><embed width="320" height="266" src="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAJRKzAPfu3a7ks9WIkYJqTG_sMilVdVIS0UA9wm5pfIp79aQ3TyTypyGG0s6WCuTXyOwaTuclK4ROfy0-HdLWRaikMPhsNuOra5S5meFyCtEHOKs7ewEwi98q_Jzoapt_8lNsDmx5NA39169XZ0WWDqw91kJ09HNG_9N0owS1DwjW0VQt_pNd0ypfAe_cxUbfY_QssJPRrC0jtCwEvU9ePLdkD3r0eTSobTV39qi5F16%26sigh%3DdlYFPTl24mLK9xlQKVOa-s4z9eE%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3D11850dec18cb5aee%26offsetms%3D5000%26itag%3Dw320%26sigh%3DCbFsbMQRxzVGbiRt9QGZTngbCOc&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den" type="application/x-shockwave-flash"></embed></object><br /><P>My next goal will be to add some objects with collision such as buildings, towers, and other objects the character can jump on. I'll also be animating a frog for an elementary school project coming up here real quick. I would love to here from anyone on ways to handle objects and areas such as a multi-floored building that the character can go into. </P><br /><P>Happy Coding!<BR>Jason</P><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-6355385407020486550?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1tag:blogger.com,1999:blog-30054920.post-8664254761861149792008-12-19T16:24:00.001-08:002008-12-22T08:54:16.323-08:00Hidden Text in WordThis post explains how to collapse multiple sections in a word doc.<br /><br /><br />There may come a time when you need to collapse sections of a word doc based on a checkbox. The sample form I'm using looks like this:<br /><br /><br /><a href="http://4.bp.blogspot.com/_bqVAGqNrmmk/SUw8M0YG_GI/AAAAAAAAAFE/kmWYjtaeOc8/s1600-h/sampleform.bmp"><img id="BLOGGER_PHOTO_ID_5281662653914610786" style="WIDTH: 366px; CURSOR: hand; HEIGHT: 230px" alt="" src="http://4.bp.blogspot.com/_bqVAGqNrmmk/SUw8M0YG_GI/AAAAAAAAAFE/kmWYjtaeOc8/s320/sampleform.bmp" border="0" /></a><br /><br />To create this form:<br /><br />1. Create a new word doc and add a checkbox.<br /><br />2. Type some text under the text box.<br /><br />3. Select the area you wish to hide and add a bookmark: Insert->Bookmark. The Bookmark dialog will appear. Type "Section 1" as bookmark name and close.<br /><br />4. Repeat the process two more times.<br /><br /><br /><br />What we've done is create "Enclosing Bookmarks" around some text. There are actually two types of bookmarks. These are:<br /><br />1) Placeholder Bookmarks which look like a beam.<br /><br />2) Enclosing Bookmarks that will show up as graphics.<br /><br />You can see these book marks by going to Tools->Options->Display Bookmarks.<br /><a href="http://1.bp.blogspot.com/_bqVAGqNrmmk/SUxAKGICzMI/AAAAAAAAAFM/Xz41dzYv_CY/s1600-h/bookmark.bmp"><img id="BLOGGER_PHOTO_ID_5281667005185969346" style="WIDTH: 443px; CURSOR: hand; HEIGHT: 176px" alt="" src="http://1.bp.blogspot.com/_bqVAGqNrmmk/SUxAKGICzMI/AAAAAAAAAFM/Xz41dzYv_CY/s320/bookmark.bmp" border="0" /></a><br />(Bookmark indicators in Red)<br /><br />Now for hooking up the checkboxes.<br />The Checkboxes need to call a function. So, first we have to write the function. The code should look like so:<br /><br /><br /><br /><blockquote><p><br />Public Sub Hideit()<br /><br /><span style="color:#33cc00;">'unprotect the document</span><br />If ActiveDocument.ProtectionType <> wdNoProtection Then <br />ActiveDocument.Unprotect Password:=""<br />End If<br /><br />ActiveDocument.ActiveWindow.View.ShowHiddenText = False<br /><br /><span style="font-size:85%;color:#33cc00;">'Get the range of the bookmark.</span><br />Dim rng As RangeSet rng = ActiveDocument.Bookmarks("Section1").Range<br /><br />If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then<br /><br />rng.Font.Hidden = 0<br />Else<br />rng.Font.Hidden = 1<br />End If<br /><br />ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True<br /><br />End Sub</p></blockquote><br /><p><br />Now in the Checkbox, select this function and your<br />done!</span> Additional Info here: <a href="http://word.mvps.org/faqs/MacrosVBA/WorkWithBookmarks.htm">http://word.mvps.org/faqs/MacrosVBA/WorkWithBookmarks.htm</a> <p></p><span style="font-size:85%;"></span><p><span style="font-size:85%;">Happy Coding!</span></p><p><span style="font-size:85%;">Jas</span></p></span></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-866425476186114979?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1tag:blogger.com,1999:blog-30054920.post-5571546089109532252008-12-03T18:00:00.000-08:002008-12-10T04:49:28.567-08:00Line Ring Selection AlgorithmI'm thinking about adding a tool that will select a ring of lines.<br />Here is an example of a ring you want to select.<br /><a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/SAZTY93X-sI/AAAAAAAAACA/MtF1apuXPrs/s1600-h/selectring1.bmp"><img id="BLOGGER_PHOTO_ID_5189927308979862210" style="CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/SAZTY93X-sI/AAAAAAAAACA/MtF1apuXPrs/s320/selectring1.bmp" border="0" /></a><br /><br />Okay, what I've come up so far is something pretty simple.<br />1. Copy the target face.<br />2. Check to see if the selected line is an edge.<br />3a. Yes, calculate all the edges that are attached to the selected edge and select. END<br />3b. No, remove all polys that have edges. goto 2.<br /><br />This image shows how it would work on the example.<br /><a href="http://2.bp.blogspot.com/_bqVAGqNrmmk/SAZTmt3X-tI/AAAAAAAAACI/lUBqoJkh8KA/s1600-h/selectring2.bmp"><img id="BLOGGER_PHOTO_ID_5189927545203063506" style="CURSOR: hand" alt="" src="http://2.bp.blogspot.com/_bqVAGqNrmmk/SAZTmt3X-tI/AAAAAAAAACI/lUBqoJkh8KA/s320/selectring2.bmp" border="0" /></a><br /><br />I know there are some exceptions. It seems simple enough. I'll let you know how it works.<br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-557154608910953225?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-14258501885629412802008-11-13T10:18:00.001-08:002008-11-13T11:06:14.558-08:00Character Modeling IIPicking up from the previous post, I've modeled a basic character using a billboard as a guide. See picture:<br /><a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/SRxwATwrqZI/AAAAAAAAAEk/zY7woGHSEnc/s1600-h/Screenshot-10.6.2008.21.4.32.bmp"><img style="cursor:pointer; cursor:hand;width: 320px; height: 245px;" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/SRxwATwrqZI/AAAAAAAAAEk/zY7woGHSEnc/s320/Screenshot-10.6.2008.21.4.32.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5268208814723410322" /></a> <br />You can see the bone system residing inside of the character. For the hands I only needed the ability to move the thumb, index, and rest of fingers as a group so I used three bones.<br /><a href="http://4.bp.blogspot.com/_bqVAGqNrmmk/SRxwea3wHlI/AAAAAAAAAEs/w5EGE9YJgsU/s1600-h/Screenshot-10.6.2008.21.26.16.bmp"><img style="cursor:pointer; cursor:hand;width: 320px; height: 245px;" src="http://4.bp.blogspot.com/_bqVAGqNrmmk/SRxwea3wHlI/AAAAAAAAAEs/w5EGE9YJgsU/s320/Screenshot-10.6.2008.21.26.16.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5268209332028186194" /></a><br />Assigning the geometry to the bones:<br />In my tool I do this by selecting the desired bone. I select the geometry I want to assign to it and associate the selection tot he bone. In the following image you can see that I have part of the spine selected and I'm assigning verts to the torso.(GREEN=assigned, Yellow=assigned to another bone, BLUE= not assigned at all)<br /><br />Note: In other tools, you'll be able to do this by some tool automatically, but since I haven't coded that, I alternated the model color to help in the assignment process.<br /><a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/SRx1OUeXydI/AAAAAAAAAE0/bM1u6fKQsNc/s1600-h/Screenshot-10.8.2008.21.32.13.bmp"><img style="cursor:pointer; cursor:hand;width: 320px; height: 245px;" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/SRx1OUeXydI/AAAAAAAAAE0/bM1u6fKQsNc/s320/Screenshot-10.8.2008.21.32.13.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5268214552991353298" /></a><br />After applying all the geometry to the bones, I created some test animations that ran the character through basic movments. Each joint was a different animation.<br /><br />As I tested the animations, I would make adjustments to the bone assignments, applying multiple bones to influence the points. This is great in areas like the shoulders, hips, knees, and neck. You'll need to add additional geometry to improve the animations. My character jumped from 1100 polys to over 1500+ polys by the time I was done with this process. <br /><br />Once the models movement looks acceptable with the test animations you're ready for texturing. (I made the mistake of texturing first and had to do it again later. Not too bad but could have saved time to wait.)<br /><br />When you're finished texturing your character is ready for producing the real animations.<br /><a href="http://4.bp.blogspot.com/_bqVAGqNrmmk/SRx2ketIDJI/AAAAAAAAAE8/TJAnrjAhh_A/s1600-h/Screenshot-11.11.2008.22.7.51.bmp"><img style="cursor:pointer; cursor:hand;width: 320px; height: 245px;" src="http://4.bp.blogspot.com/_bqVAGqNrmmk/SRx2ketIDJI/AAAAAAAAAE8/TJAnrjAhh_A/s320/Screenshot-11.11.2008.22.7.51.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5268216033206340754" /></a><br />The picture above shows my gunslinger (Guns aren't textured yet) in his loiter pose. This guy was exported in .x format and loaded quite nicely into a demo app. Total polys (1530).<br /><br />Note: I used my own editor to do this character. Let me know if you're interested in trying it out. I'm always looking for people who can give me some suggestions and feedback.<br /><br />Thanks for reading and happy coding!<br /><br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-1425850188562941280?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com3tag:blogger.com,1999:blog-30054920.post-36134909418038590372008-10-06T09:47:00.001-07:002008-10-06T10:12:56.915-07:00Character Modeling<a href="http://4.bp.blogspot.com/_bqVAGqNrmmk/SOpCmLlHlBI/AAAAAAAAACg/xbgIxhnsRyE/s1600-h/model2.bmp"><img style="cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_bqVAGqNrmmk/SOpCmLlHlBI/AAAAAAAAACg/xbgIxhnsRyE/s320/model2.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5254085138992043026" /></a><br /><a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/SOpCWMBSO5I/AAAAAAAAACY/4mdKhG7aCoI/s1600-h/model1.bmp"><img style="cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/SOpCWMBSO5I/AAAAAAAAACY/4mdKhG7aCoI/s320/model1.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5254084864232274834" /></a><br /><br />My goal was to create a model with 1000-1500 polygons. These are the steps I followed:<br /><br />1. First, I drew and scanned a finished character front and side view in standard pose. Take the time to get it as close as possible to the real thing here in pencil.<br /><br />2. I took the image and billboarded it in my editor for reference and started building geometry with the same general shape.<br /><br />3. Modeling: I started with a box and scaled it the size of the chest. I then worked down the torso and did the legs. Next, I worked up the neck and did the head. I then extruded out the arms on both sides, placing geometry in the proper joints to allow for animation. Doing the hands takes some time. Basically, extrude out the fingers and play with the vertices.<br /><br />The head took quite some time. After adding detail to the face and moving things around I kept shrinking the head and had to readjust things at the vertex level. In your tool you probably have a way of using a select box and scaling the selections. I'm missing that tool. Doing the ears were not so bad but I had to make it look the same on both sides of the head.<br /><br />4. Grouping the polygons. I went through and grouped the polygons. I'm basically associating polygons within region together for the texture mapping stage.<br /><br />5. Texture mapped all the groups (faces in my editor), and sized them to a 2048 bitmap. Note, this should be done after step 6 next time. because I'll have to do it again if I change any geometry.<br /><br />6. (Stopped here) Bone support: Start adding the skeleton and working on animations. Most likely in this process there will need to be some tweaking of the geometry to improve joint areas. (This version of my editor has not implement multiple weighted influences on vertices from multiple bones yet. Coming soon.)<br /><br />7. Once animation is good and a few of the animation sequences are finished, the geometry is stable and the texture can be generated to the model.<br /><br />8. Add additional animation sequences.<br /><br />What I learned or ran into during the process:<br />1. I'm really needing a mirror tool, and a few other essential modeling tools.<br />2. I don't know how I'm going to do the gun yet. That involved attaching and detaching a bone to the animation. I'm guessing this will be handled in the engine.<br />3. It was way more work than I thought it would be but I can use this model as a base for later models if it works out.<br />4. Been playing spore and would like to add additional features to my editor that allow me to modify geometry by using the bones themselves. (Cool!)<br />5. I'm not sure yet if the movement (up and down, and jump height) should be coded in the animation or when rendering the animation in the engine. I'm guessing that should be handled in the engine.<br /><br />Would love to hear how this process differed from your experience developing a fully animated model.<br /><br />Happy 3Ding!<br /><br />Jason<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-3613490941803859037?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com6tag:blogger.com,1999:blog-30054920.post-3590822076245586022008-09-22T19:12:00.000-07:002008-09-29T08:57:09.140-07:00DirectX Mesh LoadingIt's been awhile since my last post. I got a little burned out on meshes after working on the xfile format. I did recently write a little app that lets me load my walking sequence and walk the little "Jake" model around. Here's a video.<br /><object width="320" height="266" class="BLOG_video_class" id="BLOG_video-a5c5c5dae867bb64" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="movie" value="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAP0YN7YpWvFNWPjMMOzGjlWnMkPkAfhOox_liQNWPX60FLIKrNS4gedBupVGDZMY05SMvd3eHKEsCbvgct4UHXuhFoTdOWS6mfeqWtdrAN4jtH9h3BThL4Ojsqz6VxL-dKv5ymXd-isOrSbpUpBAF43RaGanLkdL-JF1jueEffnJ23c85yFLbi08hfLZjxmXLiu6P_7lS1aL2mQyiBE7xo1-KfEZBwbjfJ6_vP_GoTfj%26sigh%3DutXJN6cZ6HCdnWrVjgBCyqAqxQg%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Da5c5c5dae867bb64%26offsetms%3D5000%26itag%3Dw320%26sigh%3D3HupOUJmLwm9EkcnEzIB7adOgSQ&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den"><param name="bgcolor" value="#FFFFFF"><embed width="320" height="266" src="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAP0YN7YpWvFNWPjMMOzGjlWnMkPkAfhOox_liQNWPX60FLIKrNS4gedBupVGDZMY05SMvd3eHKEsCbvgct4UHXuhFoTdOWS6mfeqWtdrAN4jtH9h3BThL4Ojsqz6VxL-dKv5ymXd-isOrSbpUpBAF43RaGanLkdL-JF1jueEffnJ23c85yFLbi08hfLZjxmXLiu6P_7lS1aL2mQyiBE7xo1-KfEZBwbjfJ6_vP_GoTfj%26sigh%3DutXJN6cZ6HCdnWrVjgBCyqAqxQg%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Da5c5c5dae867bb64%26offsetms%3D5000%26itag%3Dw320%26sigh%3D3HupOUJmLwm9EkcnEzIB7adOgSQ&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den" type="application/x-shockwave-flash"></embed></object><br />This is just a DirectX 8 application with a skinned .x file loaded. I'm going to create a really simple character and start playing with breaking up the animations by lower and upper body as well as moving the head where the camera is pointing. It will support jump, swing, run, walk, back up, sit, and lay. We'll see how it goes. After that I might start working on lighting a little. but, it would be neat to get more than one person moving things. My editor is comign along well. I have a short buglist and then its on to deployment code. If anyone is interested in trying it out let me know in the reply. <br /><br />Happy Coding!<br />Jason<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-359082207624558602?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com7tag:blogger.com,1999:blog-30054920.post-57081918997027034102008-07-26T09:19:00.000-07:002008-09-29T08:57:27.797-07:00DirectX Animated CharacterThis one is a fully textured version of my Jake character. It has some smoothing on it as well. Only 828 polygons.<br /><br /><object width="320" height="266" class="BLOG_video_class" id="BLOG_video-eae83eed5754db8f" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="movie" value="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAEbqiT-pXmimn7VDny7-dKoK-0wWiNqB2-hX2edlHFkmSOb2WfZD4LhTDUgygr-0PY4RIiCYnuxlQ6Scf5Q22TmBPtnA2J1OqAL4HTEB4Fgz4XCGfcp-PNQbgdO5AwQczru7L2CW_zjovsE4a6j73waLtH_rEONimJ5mOTz1ZYD_LjkobehH9ZyBMxrZIbsZj8GSSarqUAX6rjz5_gN0wPOf9YhIiHEQrrHwigtwE69Z%26sigh%3DD63RhJBIvn7kfxXsvOBwp00BpMI%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Deae83eed5754db8f%26offsetms%3D5000%26itag%3Dw320%26sigh%3DjVrgE9sXvcx5ym7D2NYtqnwivNU&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den"><param name="bgcolor" value="#FFFFFF"><embed width="320" height="266" src="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAEbqiT-pXmimn7VDny7-dKoK-0wWiNqB2-hX2edlHFkmSOb2WfZD4LhTDUgygr-0PY4RIiCYnuxlQ6Scf5Q22TmBPtnA2J1OqAL4HTEB4Fgz4XCGfcp-PNQbgdO5AwQczru7L2CW_zjovsE4a6j73waLtH_rEONimJ5mOTz1ZYD_LjkobehH9ZyBMxrZIbsZj8GSSarqUAX6rjz5_gN0wPOf9YhIiHEQrrHwigtwE69Z%26sigh%3DD63RhJBIvn7kfxXsvOBwp00BpMI%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Deae83eed5754db8f%26offsetms%3D5000%26itag%3Dw320%26sigh%3DjVrgE9sXvcx5ym7D2NYtqnwivNU&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den" type="application/x-shockwave-flash"></embed></object><br /><br />I did notice that the new "DirectX Viewer" has some rendering issues with normals and lighting, but it still works.<br /><br />Next on the list is loading this file in XNA and blended animations. I'm hoping to walk this guy around in 3rd person. <br /><br />Happy Coding!<br />Jason<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-5708191899702703410?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1tag:blogger.com,1999:blog-30054920.post-59529584300837227042008-07-12T09:20:00.001-07:002008-07-12T09:36:08.346-07:00Xfile Export Done and completed build 0.07Yesterday I finally got my xfile exporter to work correctly. It was just a test but it worked! In this video I'm loading an xfile into the DirectX Viewer.<br /><object width="320" height="266" class="BLOG_video_class" id="BLOG_video-daa8fb42ac26259c" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="movie" value="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAABjzXX0P2a8vxnDt-OvRPGAqMRZp7IdSZUucu8hodbauVSVLkNBBKOkJ6t82f5iTLlKqeuUNDnbbfOgXad6MCZsHNbf2P5kf2N-XycMXLX-1F9-o6E7RwI0cxYHylm9STkFQqFe0xFbLUcN3hi-seE__r5vlpQvw3XmCpfbtQzGDbBjqKt14OWsSeM2s8ztPN7aGQqb-OJdHoSxgkGz0TCFH6KV-8nnCU3zjkQeTBGIp%26sigh%3DOx2q9Uk_ExyaRv_8BG1cQBPviDY%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Ddaa8fb42ac26259c%26offsetms%3D5000%26itag%3Dw320%26sigh%3D2fbhlxdsyDTv_8gY3wOhVRMAR_g&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den"><param name="bgcolor" value="#FFFFFF"><embed width="320" height="266" src="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAABjzXX0P2a8vxnDt-OvRPGAqMRZp7IdSZUucu8hodbauVSVLkNBBKOkJ6t82f5iTLlKqeuUNDnbbfOgXad6MCZsHNbf2P5kf2N-XycMXLX-1F9-o6E7RwI0cxYHylm9STkFQqFe0xFbLUcN3hi-seE__r5vlpQvw3XmCpfbtQzGDbBjqKt14OWsSeM2s8ztPN7aGQqb-OJdHoSxgkGz0TCFH6KV-8nnCU3zjkQeTBGIp%26sigh%3DOx2q9Uk_ExyaRv_8BG1cQBPviDY%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Ddaa8fb42ac26259c%26offsetms%3D5000%26itag%3Dw320%26sigh%3D2fbhlxdsyDTv_8gY3wOhVRMAR_g&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den" type="application/x-shockwave-flash"></embed></object>This model is working as designed. My next test will be a more detailed model. If it works I'll texture it as well. Fun Stuff!<br /><br />Happy Coding!<br />Jason<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-5952958430083722704?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-61556850106356188422008-06-27T08:17:00.000-07:002008-06-27T09:15:07.475-07:00Exporting DirectX Files for AnimationThere are two approaches to writing DirectX files. The first is to take your geometry and animation data and stuff it into the D3DX Mesh classes and use Saving functionality. The second approach is to skip the D3DX classes and write a file directly that conforms to the .x format specifications. <br /><br />I chose to write my own. I found the documentation and examples for loading D3DX classes inadequate when writing an exporter. Every book/article(msdn site, 3D Game Programming With DirectX 9.0, Managed DirectX 9 KickStart, etc.) will have a chapter on how a Bone hierarchy works and then it will show you the "Tiny.X" file and how to load it from file and animate it. But, where are the good examples (Managed code) and documentation on how to initialize and use these objects when you have all the data already? There are only a few and most are written in outdated versions. Since I didn't build my model and animation classes on D3DX classes, filling those objects did not appeal to me.<br /><br />I worked on the format for a few days. I was able to export static meshes quite well. In fact, I had better results with the .x file I wrote then with the one written by the D3DX classes, which I had previously used to export static meshes. The ones from D3DX didn't load well in the newer Mesh Viewer that comes with the DirectX SDK. It only worked in the old one.<br /><br />Exporting the Animated Meshes has proven more difficult but I am seeing some good results. I've been tinkering with the transformations and I got it really close. With a little time and some files I'll be exporting.<br /><br />Happy Coding.<br /><br />Jason<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-6155685010635618842?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-56323982961971148062008-06-18T08:36:00.000-07:002008-06-18T08:50:46.955-07:00DirectX Character Animation IIIn this animation I've upgraded the model a little. There is the stand, walk, run, and swing sequence. Here's the video: <br /><br /><object width="320" height="266" class="BLOG_video_class" id="BLOG_video-c287da8a7de691f" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="movie" value="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DpgAAAHZQAKfu6jF-JfdYz_38Vli7wr5MSPkqAt40wT6tZ40YrpoAVAvvNxmPaRY0ot_0NanH8ycdo9ixxBO0hKsyWwXEt7b9nAmYhZeheMm6xEjTG-s2X5CLWUDTWVWY34Hbp-ANHzpmcgvyyxXBIw5cdwfxeotEQ6Tn_VPfLYrRU38MB7g8gKpzPPrghMNl0LCZiC7AYywEtXhxdNsdr7XXdXqDO03tt2nCrOqeblbELH6x%26sigh%3DlOeVBWt5bG41ZpGDpgJg-bPR4yQ%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Dc287da8a7de691f%26offsetms%3D5000%26itag%3Dw320%26sigh%3DlQsIQZwx5q9QMEoqebOqoNjEy2U&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den"><param name="bgcolor" value="#FFFFFF"><embed width="320" height="266" src="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DpgAAAHZQAKfu6jF-JfdYz_38Vli7wr5MSPkqAt40wT6tZ40YrpoAVAvvNxmPaRY0ot_0NanH8ycdo9ixxBO0hKsyWwXEt7b9nAmYhZeheMm6xEjTG-s2X5CLWUDTWVWY34Hbp-ANHzpmcgvyyxXBIw5cdwfxeotEQ6Tn_VPfLYrRU38MB7g8gKpzPPrghMNl0LCZiC7AYywEtXhxdNsdr7XXdXqDO03tt2nCrOqeblbELH6x%26sigh%3DlOeVBWt5bG41ZpGDpgJg-bPR4yQ%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3Dc287da8a7de691f%26offsetms%3D5000%26itag%3Dw320%26sigh%3DlQsIQZwx5q9QMEoqebOqoNjEy2U&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den" type="application/x-shockwave-flash"></embed></object><br /><br />I've also fixed the lighting as you can see in this video. The next one will be fully textured I promise! <br /><br />Happy Coding! <br /><br />Jason<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-5632398296197114806?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1tag:blogger.com,1999:blog-30054920.post-9960964030204432072008-06-10T08:01:00.000-07:002008-06-10T08:23:06.181-07:00DirectX Character AnimationI've made a little progress on my animation system. I made a test model I like to call Fred and attached him to an animated skeleton. See Video.<br /><object width="320" height="266" class="BLOG_video_class" id="BLOG_video-56c93053a6e5941b" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="movie" value="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAPEbdexZYqODP9Nt5kZfcH1jdbnNVblnNcN27mQPT0_LqnOTrRq8yMojd68hXMWoX1lIhYAqTUbmINemQKZsEOwJvcc3N5EJKXhzHGCNICzrNUlIMHCjOrIBsYCMcEKduHbrryk0-ZcfcBI6zQbw9ulVMvHC_tR8QEb9Uk9XJNenizQcYpkBpeI9FUrwgEWIY4sIeCqMHuACdXaSBEI27BQOYwZy6GbxRma3F1otcDfV%26sigh%3Dx-vEHnOBAsFo6aewTqx6s9FWcGU%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3D56c93053a6e5941b%26offsetms%3D5000%26itag%3Dw320%26sigh%3DrA3VaaNgbQhrYe5dgeIdjjRFOzE&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den"><param name="bgcolor" value="#FFFFFF"><embed width="320" height="266" src="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAPEbdexZYqODP9Nt5kZfcH1jdbnNVblnNcN27mQPT0_LqnOTrRq8yMojd68hXMWoX1lIhYAqTUbmINemQKZsEOwJvcc3N5EJKXhzHGCNICzrNUlIMHCjOrIBsYCMcEKduHbrryk0-ZcfcBI6zQbw9ulVMvHC_tR8QEb9Uk9XJNenizQcYpkBpeI9FUrwgEWIY4sIeCqMHuACdXaSBEI27BQOYwZy6GbxRma3F1otcDfV%26sigh%3Dx-vEHnOBAsFo6aewTqx6s9FWcGU%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3D56c93053a6e5941b%26offsetms%3D5000%26itag%3Dw320%26sigh%3DrA3VaaNgbQhrYe5dgeIdjjRFOzE&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den" type="application/x-shockwave-flash"></embed></object><br /><br />I know the character isn't that pretty but the important thing is that his skin isn't flying around the screen and he is performing the cheesy walk sequence. Although I haven't transformed the normals yet so his lighting is really bad. Next step is to fix normals and start working on weighted blends.<br /><br />Later I'll support .x format so I'm going to take a close look at the "Simple Animation" demo from microsoft and utilize their AnimationController and D3DFrame structure. I did find that DirectX render state does support vertex blending with the D3DRS_VERTEXBLEND flag. You can read about it here:<br /><a href="http://msdn.microsoft.com/en-us/library/bb173463(VS.85).aspx">http://msdn.microsoft.com/en-us/library/bb173463(VS.85).aspx</a><br /><br />Happy Coding!<br />Jas<br />(Note I'm not DXJas anymore because microsoft stopped supporting MDX and that upset me. Their alternative was to use XNA or roll your own. XNA Rocks though! Don't get me started...) :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-996096403020443207?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com2tag:blogger.com,1999:blog-30054920.post-60401653798070137182008-05-26T22:32:00.000-07:002008-05-26T22:38:04.580-07:00DirectX Skeletal Mesh Cont.I've been making progress on my animation. So far I can add bones and frames and animate the bones. See this video of my first animation of a hand.<br /><object width="320" height="266" class="BLOG_video_class" id="BLOG_video-4f4494dbeed29239" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="movie" value="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAPCZD0ddCGBZjZs6HcCGJYdnMeOa7C2zNmsUS_HpiBHY3kDY2Vcx0oEljyUJCJ3J9KZbKSkQ0l9XZ4Bs0whO0jgphsOvvqkbdw33vjb0-IUB4IZ4Xnniefho4dzdCdwbzEzVb7GQo6cDOFb9siMZvNAnfzi7cXcpyM5U4l6CpuI2dJJQzl9lm9ReftGR5Ie2RcL88rcVovIP1jmjqU-iYCglpc9Mj8EZAD0Nrv0V8Nha%26sigh%3Da83zmrH0A2IyHq7vLdlWiY8RgIA%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3D4f4494dbeed29239%26offsetms%3D5000%26itag%3Dw320%26sigh%3D7Q82sduaeLH1A8MG0JjagXtIvYY&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den"><param name="bgcolor" value="#FFFFFF"><embed width="320" height="266" src="http://www.blogger.com/img/videoplayer.swf?videoUrl=http%3A%2F%2Fvp.video.google.com%2Fvideodownload%3Fversion%3D0%26secureurl%3DqAAAAPCZD0ddCGBZjZs6HcCGJYdnMeOa7C2zNmsUS_HpiBHY3kDY2Vcx0oEljyUJCJ3J9KZbKSkQ0l9XZ4Bs0whO0jgphsOvvqkbdw33vjb0-IUB4IZ4Xnniefho4dzdCdwbzEzVb7GQo6cDOFb9siMZvNAnfzi7cXcpyM5U4l6CpuI2dJJQzl9lm9ReftGR5Ie2RcL88rcVovIP1jmjqU-iYCglpc9Mj8EZAD0Nrv0V8Nha%26sigh%3Da83zmrH0A2IyHq7vLdlWiY8RgIA%26begin%3D0%26len%3D86400000%26docid%3D0&nogvlm=1&thumbnailUrl=http%3A%2F%2Fvideo.google.com%2FThumbnailServer2%3Fapp%3Dblogger%26contentid%3D4f4494dbeed29239%26offsetms%3D5000%26itag%3Dw320%26sigh%3D7Q82sduaeLH1A8MG0JjagXtIvYY&messagesUrl=video.google.com%2FFlashUiStrings.xlb%3Fframe%3Dflashstrings%26hl%3Den" type="application/x-shockwave-flash"></embed></object><p>This was using four key frames. My next task will be to clean up the code, and save the bone animation to file for reloading. After that I'll start working on attaching geometry to the skeleton. Woo Hoo! Can you tell I'm having lots of fun?<br /><br />I'm pretty sure the attached mesh will have issues in certain areas but I'm hoping that within a few weeks I'll have my first animated mesh and shortly after that my first animated .x file. My goal here is to create a walk sequence and load the animated mesh into a demo game engine. I still haven't figured out how I'm going to let the user edit the geometry. That's going to be quite a shift in process flow. Oh well.<br /><br />Happy Coding!<br /><br />DXJas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-6040165379807013718?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-22796125789794366132008-05-06T13:52:00.000-07:002008-12-10T04:49:29.562-08:00DirectX Skeletal System<a href="http://1.bp.blogspot.com/_bqVAGqNrmmk/SCDGP3sflwI/AAAAAAAAACQ/aIIES7n_iBU/s1600-h/bones.bmp"><img style="cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_bqVAGqNrmmk/SCDGP3sflwI/AAAAAAAAACQ/aIIES7n_iBU/s320/bones.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5197371945936459522" /></a><br /><br />Now that I'm able to create static meshes, I've begun developing a skeletal system that will allow me to animate them. (See screenshot)<br /><br />Next, I'll add gizmos to manipulate the bones, including forward and inverse kinematics, and start playing with key frames and animation. <br /><br />The last stage involves attaching the mesh to the skeleton. In some areas it will be necessary to assign vertices to multiple bones to smooth the animation a little.<br /><br />I would be happy to here from some of you on what features you feel are essential in a skeletal system. Is path-based movement important or is it easier to create a few key frames? Do you break up your sequences on the mesh for different body parts so they can be combined? For example, the character can play the run sequence AND the eat sequence at the same time?<br /><br />Fun stuff! I'll probably be working on this area for the rest of the year.<br /><br />Slightly off the subject, the best character editor that I ever saw was the character creator in City of Villains. Another good one was in the <a href="http://video.google.com/videosearch?q=spore+video&sitesearch=">Spore Video</a> created by Will Wright, the maker of Sims.<br /><br />Happy Coding!<br /><br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-2279612578979436613?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1tag:blogger.com,1999:blog-30054920.post-73171825377809713932008-03-17T08:30:00.000-07:002008-12-10T04:49:29.780-08:00SQL Reporting Services: Dividing by ZeroYou finally finish that report in SQL Reporting Services that you've been slaving over and find that there is a big ugly #Error text in the middle of your data. You can't publish that! But, how do you handle it? Lets cover a few ways of fixing this.<br /><br />Sample data:<br /><table border = "1" style=""><br /><tr><th>Budgeted</th><th>Spent</th><th>% Avail</th></tr><br /><tr><td>1000</td><td>500</td><td>50.00%</td></tr><br /><tr><td>0</td><td>100</td><td>#ERR</td></tr><br /></table><br /><br />Your first try at protecting from the divide by zero error might be something like writing an expression in the value field like so:<br /><blockquote><font color="blue">= IIF( Fields!Budgeted.Value=0, 0, Fields!Spent.Value / Fields!Budgeted.Value)</font></blockquote><br /><br />This wouldn't work. Why? the Reporting Services compiler evaluates the results before the IIF. So, the compiler attempted the division by zero before applying the IIF expression. (Thanks Dataman!)<br /><br />There are a few ways to handle this. <br /><br /><strong>1. Denominator DeColorization</strong><br />A quick way to avoid this is to write a little expression for the font color that will turn the font to white if the denominator = zero.<br /><blockquote><font color="blue">= IIF( Fields!budgeted.Value = 0,"White","Black")</font></blockquote><br /><a href="http://1.bp.blogspot.com/_bqVAGqNrmmk/R96UPF-UsLI/AAAAAAAAABo/TSoD5zshuKk/s1600-h/denominatordecolorization.bmp"><img style="cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_bqVAGqNrmmk/R96UPF-UsLI/AAAAAAAAABo/TSoD5zshuKk/s320/denominatordecolorization.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5178739608545177778" /></a><br /><br /><strong>2. Denominator De-Demonization.</strong><br />This is the "Dataman" approach when you REALLY feel the urge to fix the data because otherwise the universe may be out of alignment. :)<br /><br /><blockquote><font color="blue">= IIF( Fields!Budgeted.Value=0, 0, Fields!Spent.Value / IIF( Fields!Budgeted.Value=0,1,Fields!.Budgeted.Value))</font></blockquote><br /><br /><strong>3. Division SafeCode Routine.</strong><br />This is pretty cool. In Reporting Services, in the Report Parameters there is a tab for Code. You can put in a custom function and call it in your report. The code would be like so:<br /><br /><blockquote><font color="blue">Public Function SafeDivide(Numerator as Double, Denominator as Double) as Double<br /> If Denominator = 0 then return 0<br /> Return (Numerator / Denominator)<br />End Function</font></blockquote><br /><br />In your report you would just set the value like so:<br /><blockquote>><font color="blue">=Code.SafeDivide(Fields!Spent.Value, Fields!Budgeted.Value)</font></blockquote><br /><br />That's all for pesky #Error messages in your code.<br /><br />Happy Coding!<br />P.S. Thanks goes to Charley for your input.<br />Jason<br />"We are the musicians. We are the dreamers of dreams." - Willy Wonka<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-7317182537780971393?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com2tag:blogger.com,1999:blog-30054920.post-81749492322985413122008-02-11T08:19:00.000-08:002008-12-10T04:49:30.052-08:00Face Texture Mapping<a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/R7B2q26pc1I/AAAAAAAAABU/19BCI30IE-s/s1600-h/girlface.bmp"><img style="cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/R7B2q26pc1I/AAAAAAAAABU/19BCI30IE-s/s320/girlface.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5165759251262042962" /></a><br />Well, I'm working on version 0.0.6 of my 3D Editor. I'm currently adding a UV Mapping tool and its coming along nicely. When I'm done, it will have a good set of tools for creating textures. No need to export and import into another art tool. I've included a head that I did this weekend. This build has been very stable and few bugs noted. Next will be animation.<br /><br />If anyone is interested in trying out my beta version of the software, let me know. I will also be adding support for exporting 2D templates for 2D engines as well. 3D is exported in .x format right now. But, it also exports xml if you need to read them into your engine that way. <br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-8174949232298541312?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-71181015273678874592007-10-23T11:33:00.001-07:002007-10-23T11:37:18.286-07:00ASP.NET ObjectDataSource Setting the ObjectLets say you have a business object on your webpage and want to bind some listbox or something to it. You can use the ObjectDataSource object but you have to handle the ObjectCreating event for the ObjectDataSource. In your handle just set the ObjectInstance argument and you're good to go.<br /><br />Reference:<br /><a href = "http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasourceeventargs.objectinstance(vs.80).aspx">msdn2.microsoft.com article</a><br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-7118101527367887459?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-90873979500441783242007-10-05T10:06:00.000-07:002008-12-10T04:49:30.360-08:00Binding with ObjectDataSourceIt seems like every time I write a page that retrieves data, I end up writing the mega search page. It takes a lot of extra code to search by several criteria including date ranges and sort types. You've probably seen these before. Something like the following image:<br /><br><br /><a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/RwZxmDKC3NI/AAAAAAAAABM/i4MvDmrY8k8/s1600-h/searchby.bmp"><img style="cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/RwZxmDKC3NI/AAAAAAAAABM/i4MvDmrY8k8/s320/searchby.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5117902925049552082" /></a><br /><br />Now, one way of handling this might be to write a case statement in the search event and write the sql query dynamically for each search type. That's one way to drive yourself insane. Why? Because your query will be strung out across 100 lines of code mangled in a mess of case statements and code logic. When it comes time to update the query its not going to be fun.<br /><br />One thing that worked well for me is binding the GridView to an ObjectDataSource. I wrote a simple base class for my queries with a generic function for running a query.<br />Example:<br /><font color="blue" size="smaller"><br />public virtual DataTable RunQueryRange(string criteria,string dtstart,string dtend)<br /> {<br /><br /> return mDT;<br /> }<br /></font><br /><br />For each query type that you have, create a new class that inherits from your base class. Override the RunQueryRange function and place your query in there. Just a nice clean query that might pass that string off to a function in your base class that runs a SqlCommand and returns a dataTable. That way you're not writing the Connection code everytime. Once you're rolling it takes you about 30 seconds to create a new search type and add it to your page. Code might look like this:<br /><font color="blue" size="smaller"><br /> public override DataTable RunQuery(string criteria)<br /> {<br /> SqlCommand cmd = new SqlCommand("spSearchByEyeColor");<br /> cmd.CommandType = CommandType.StoredProcedure;<br /><br /> cmd.Parameters.Add("@EyeColor", SqlDbType.VarChar).Value = criteria;<br /> //pass dummy date params to procedure.<br /> cmd.Parameters.Add("@DTStart", SqlDbType.DateTime).Value = System.DBNull.Value;<br /> cmd.Parameters.Add("@DTEnd", SqlDbType.DateTime).Value = System.DBNull.Value;<br /><br /> return base.RunSqlCmd(ref cmd);<br /> }<br /></font><br /><br />So, now lets say you have 10 different classes that do different queries. In your webpage, you bind the gridview to a new datasource, select object, choose your default search and choose your generic method.<br /><br />Now, in your search event write a small case statement that will set the datasources class like so:<br /><font color = "blue"><br /> ObjectDataSource1.TypeName = "classQueryByDate";<br /></font><br /><br />Before we say we're done let me explain a little about that generic function we wrote. It expects some data. A string criteria, and some dates. Now, in my case I had to do optional date range searches. Yours might only need the string criteria. What you do is set these parameters to a control-textbox when configuring the objectdatasource. So, whenever the thing fires, it will grab whatever you put into the textbox and pass it to your class. That's the key. Now, in the case of date ranges, I always pass values into my classes but I don't always use them if they're not required. You'll probably need to play with it a little. I found the objectdatasource would hang up sometimes if I didn't have default values for those dates.<br /><br />Another thing you'll need to juggle is postbacks. I automatically set the ObjectDataSource1.TypeName every time based on the search.SelectedValue in the dropdown. This solved my problems.<br /><br />So, the idea here is writing code that is easy to update and maintain. If someone says, can you add a search by hair color to that? You can do it in a minute or so.<br /><br />Keep in mind there may be a hundred ways to do this. This is just one of them. If you have other ways you would like to share I would love to here them. Specifically if you've been able to remove the switch statement in the search event completely by using some factory pattern or something, please share.<br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-9087397950044178324?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-20421710211619917302007-06-12T08:32:00.001-07:002008-12-10T04:49:30.655-08:00What not to do with a progress bar.<a href="http://4.bp.blogspot.com/_bqVAGqNrmmk/Rm68ph4N-pI/AAAAAAAAAA8/WPYF3_PVtTs/s1600-h/adobeinstall.bmp"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_bqVAGqNrmmk/Rm68ph4N-pI/AAAAAAAAAA8/WPYF3_PVtTs/s320/adobeinstall.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5075201251747953298" /></a><br />This morning I installed an update for adobe software. As the software updated this dialog would display progress from 0% to 50% over and over again for over a minute. The text on the dialog didn't change at all during the process. It just seemed to be stuck in one of those out of control infinite updater loops from hell where it tries to perform a task and can't so it just keeps trying over and over again until you run out of patience and kill it. For your software you may think of a few other ways to utilize the progress bar and dialog in your apps.<br /><br />First, the progress bar does go all the way to 100%. Test your update dialog and make sure it is listing the progress smoothly.<br /><br />Second, If you have a long install you have a few choices. One way to do it is to break them up into a bunch of small tasks and display progress of each individual task and properly display and update the message to the user so that they know what your updater is doing.<br /><br />Third, and probably the best way for a large update is to show the total progress for the entire update and change the message text to indicate that something is actually being done. Your users really want to know how long its going to take so that they can get on with their life. Why not tell them? That's why this is the best choice. <br /><br />This updater is a good example of an update dialog. This is an updater for a Blizzard product. It shows the progress of the udpate, the percentage completed, and even tells the user an estimated time to completion. It even has some blinky lights in the title bar that indicates that its doing something!<br /><a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/Rm7FlR4N-qI/AAAAAAAAABE/X7euy5IgNDU/s1600-h/wowupdate.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/Rm7FlR4N-qI/AAAAAAAAABE/X7euy5IgNDU/s320/wowupdate.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5075211074338159266" /></a><br /><br />P.S. The game is pretty good too.<br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-2042171021161991730?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-31485028080440780712007-05-07T08:34:00.000-07:002008-09-29T08:55:15.052-07:00Unit Testing and Mock Objects with NMock2 in VB.NETI've been reading through Jean-Paul Boodhoo's article in Code Magazine "Layered Architecture, Dependency Injection, and Dependency Inversion" and spent some time reading up on the presenter pattern in his original article on microsoft's site in Design patterns on the Model View Presenter.<br /><br /><a href="http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/">http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/</a><br /><br />In his article he explains the benefits of using mock objects in your unit tests. Although this post isn't going to go over the details of the article I will cover how I migrated his C# example to VB.NET and other issues I noted in the article.<br /><br />First, the NMock2 framework is a useful tool for unit testing. Its a tool that can be added to NUnit to enhance your NUnit tests. If you aren't familiar with unit testing with NUnit I suggest starting there.<br /><br />This is a sample of an NMock2 test found on the design patterns article:<br />C#:<br /><font color="blue" size="1"><br />[Test]<br />public void ShouldLoadListOfCustomersOnInitialize()<br />{<br />mockery = new Mockery();<br />ICustomerTask mockCustomerTask = mockery.NewMock<ICustomerTask>();<br />IViewCustomerView mockViewCustomerView = <br />mockery.NewMock<IViewCustomerView>();<br />ILookupList mockCustomerLookupList = mockery.NewMock<ILookupList>();<br /><br />ViewCustomerPresenter presenter = <br />new ViewCustomerPresenter(mockViewCustomerView,<br />mockCustomerTask);<br /><br />ILookupCollection mockLookupCollection = <br />mockery.NewMock<ILookupCollection>(); <br /><br />Expect.Once.On(mockCustomerTask).Method(<br />"GetCustomerList").Will(Return.Value(mockLookupCollection));<br />Expect.Once.On(mockViewCustomerView).GetProperty(<br />"CustomerList").Will(Return.Value(mockCustomerLookupList));<br />Expect.Once.On(mockLookupCollection).Method(<br />"BindTo").With(mockCustomerLookupList);<br /><br />presenter.Initialize();<br />}<br /></font><br /><br />Without duplicating the article and taking this line for line I'll just point out a few obvious things. Its a function with an NUnit annotation that tells Nunit it is a test. It creates a mockery class, some objects, and it runs three tests. Now, if you were to run this against your code it would completely pass assuming all your interfaces are created. Why? because the article left out that in the sample code this function also exists in the test code:<br /><br />C#:<br /><font color="blue" size="1"><br />[TearDown]<br />public void TearDown()<br />{<br />mockery.VerifyAllExpectationsHaveBeenMet();<br />}<br /></font><br /><br />This little tidbit gets the mockery class to spit out the results of the tests. Okay, now you have a test that fails... Now lets take a look at the VB.NET version. <br /><br /><font color="blue" size="1"><br /><Test()> _<br />Public Sub ShouldLoadlListOfCustomersOnInitialize()<br />mockery = New Mockery()<br /><br />Dim mockCustomerTask As ICustomerTask = mockery.NewMock(GetType(ICustomerTask))<br />Dim mockViewCustomerView As IViewCustomerView = mockery.NewMock(GetType(IViewCustomerView))<br />Dim mockCustomerLookupList As ILookupList = mockery.NewMock(GetType(ILookupList))<br />Dim mockLookupCollection As ILookupCollection = mockery.NewMock(GetType(ILookupCollection))<br /><br />Expect.Once.On(mockCustomerTask).Method("GetCustomerList").Will(NMock2.Return.Value(mockLookupCollection))<br />Expect.Once.On(mockViewCustomerView).GetProperty("CustomerList").Will(NMock2.Return.Value(mockCustomerLookupList))<br />Expect.Once.On(mockLookupCollection).Method("BindTo").With(mockCustomerLookupList)<br /><br />Dim presenter As ViewCustomerPresenter = New ViewCustomerPresenter(mockViewCustomerView, mockCustomerTask)<br />presenter.Initialize()<br /><br /><br />End Sub<br /></font><br /><br />You'll notice it's pretty much the same thing. It just has a few syntax changes but the test will work fine. I hope this helps out some VB.NET programmers when trying to get this to work. I found little documentation on it.<br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-3148502808044078071?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-61537682683699985632007-04-26T23:13:00.000-07:002008-12-10T04:49:30.937-08:00Editor Update build 0.03<a href="http://2.bp.blogspot.com/_bqVAGqNrmmk/RjGXYbuR69I/AAAAAAAAAA0/ydH1ntTAcNw/s1600-h/3Dstarwars.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_bqVAGqNrmmk/RjGXYbuR69I/AAAAAAAAAA0/ydH1ntTAcNw/s320/3Dstarwars.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5057990302528302034" /></a><br /><br />I've been working on additional features for my editor. The two main items I added were:<br /><br />Spherical Mapping: <br />While doing research for spherical mapping textures to geometry I ran across several examples and tutorials. Some of which were in published books such as 3D Game Programming with DirectX9.0c A Shader Approach. Another good one was by the zman(I'll include link later). I found that all of these examples had a rendering issue at the poles. It took me a little time to come up with a way of solving the problem. If you need to find out how to do it feel free to post a reply. I'll post this fix later when I have time.<br /><br />Relative Extrusion:<br />Wrote a new algorithm that takes into account faces with shared edges that are to be extruded. This feature was a blast to code.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-6153768268369998563?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com2tag:blogger.com,1999:blog-30054920.post-39618481257126419732007-03-21T10:25:00.000-07:002007-03-21T10:38:30.268-07:00ASP.NET SqlDataSource Parameters Don't play with HiddenField controlsA little piece of information that might be helpful to someone...<br />If you have a SqlDataSource that has parameters and you are binding them to a control, you may have problems if you try binding them to HiddenField controls.<br /><br />I had a simple gridview that was looking up records based on an ID. I had everything working fine with the sqldatasource bound to a session variable called session("myid"). But, I decided I wanted to cache the value on the page to eliminate timeout issues. So I added a hiddenfield to the page. In the page load event I set this hiddenfield with the ID value, just like I did with the session, but the grid would not pull the records anymore. I tried calling DataBind on the grid and even on the SqlDataSource and it doesn't pull the records.<br /><br />When I changed the variable back to a session variable it worked just fine. I didn't have to call Databind. The SqlDataSource is smart enough to detect a change in the parameter and will refresh.<br /><br />I also tried using a label control. This one worked fine too. In my instance, I just wrote at the top of the page "Welcome [label with my userid]" and I was on to the next task.<br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-3961848125712641973?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1tag:blogger.com,1999:blog-30054920.post-56776506573029245922007-03-19T12:03:00.000-07:002007-03-19T12:04:39.964-07:00Nerd Test<a href="http://www.nerdtests.com/ft_nq.php?im"><img src="http://www.nerdtests.com/images/ft/nq.php?val=5771" alt="I am nerdier than 90% of all people. Are you nerdier? Click here to find out!"></a><br />Just took the nerd test. If you want to take it click on the image. Happy coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-5677650657302924592?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com0tag:blogger.com,1999:blog-30054920.post-39489934393474418232007-02-16T17:08:00.000-08:002008-12-10T04:49:31.140-08:00VB.NET 2005 MDI Docking to Floating WindowHave you ever wanted to create a tool panel that can dock on your GUI and free float as a tool window anywhere no the screen?<br /><br />You may think that you can just create a child window and set its mdi parent and dock it to the left. But there are issues with this approach when you make it floating and try to redock it. Especially if you have a child window that is using that area of the screen. What I propose here is to to use panels to pull off the trick.<br /><br /><a href="http://3.bp.blogspot.com/_bqVAGqNrmmk/RdX2Kz4s-MI/AAAAAAAAAAM/DjkcGBLukeU/s1600-h/dock.bmp"><img id="BLOGGER_PHOTO_ID_5032198824243558594" style="CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_bqVAGqNrmmk/RdX2Kz4s-MI/AAAAAAAAAAM/DjkcGBLukeU/s320/dock.bmp" border="0" /></a><br /><br />The first step is to create an MDI Parent window. Just create a new project in vs2005 (VB or C#) and set the "IsMdiContainer" property to True. Go ahead and add a menustrip and add a view option with sub options of Left, Right, Floating.<br /><br />Next, we want to add a panel to the form and dock it. Go ahead and add panel1. Dock it to the left and throw a textbox on it for testing. Write the code in the menu events to change the dock property of your form. Leave the floating event blank. We'll get to that... If you run your app, you should be able to switch the docking to left and right.<br /><br />Create a new form called frmTools. This window will be the container for our panel when we want it to float. Change the FormBorderStyle to SizableToolWindow. Now hit F7 to go to the code view. Add 2 member variable. 1 panel called mPanel and 1 Form1 call mParent. Modify the constructor of frmTools so that you can pass in a reference to Form1 and a reference to a panel. Set these variables before "Initializecomponent."<br /><br />Next, create a private function call InitPanel(). What we'll do here is add the panel to the Controls Collection so that it can be rendered. You'll also want to set the Dock property to DockStyle.Fill and remember to use the SuspendLayout() and ResumeLayout(). Essentially, what we've done is create a secondary "Initializecomponent" function. I wouldn't recommend changing the "Initializecomponent" to do this code as it could cause issues during design time in Visual Studio 2005 designer. Once you've created this function call it in your constructor function after "InitializeComponent()."<br /><br />Now, lets go back to Form1. In the event for View->Floating we'll create the frmTools window and call Show().<br /><div class="code"><br /><span style="color:#3366ff;">private void floatingToolStripMenuItem_Click(object sender, EventArgs e)<br />{<br />Form1 form = this;<br />frmTools tools = new frmTools(ref form, ref panel1);<br /><br />this.SuspendLayout();<br />this.Controls.Remove(this.panel1);<br />this.ResumeLayout(false);<br />this.PerformLayout();<br />tools.Show();</span><span style="color:#3366ff;"><br />}</span> </div><div class="code"><br />Notice that I created a form and set it to "this" and then passed the reference to form into the function. There are other ways of referencing the main form. This was just a quick and dirty way. Maybe we'll get into that on another day. :) </div><div class="code"></div><div class="code">In addition, we removed the item from the controls collection. Now, in testing I was able to remove this code completely and got the same results but lets play it safe. (BTW: If you know why this is so, please comment on the blog, thanks.)</div><div class="code"></div><div class="code">Anyway, if you run your application you get your panel to float! Not to bad. One problem remains though. If you close the tool window your panel is now gone. Its been destroyed with the frmTool Control collection. So, we need to let the Parent window know that we are done with the panel. And we have to code a function in the parent window so that it can reinitialize the panel. </div><div class="code"></div><div class="code">In Form1, create a new function called SetToolPanel(ref Panel panel).</div><div class="code"><br /><span style="color:#3366ff;">public void SetToolPanel(ref Panel panel)<br />{<br />this.SuspendLayout();<br />this.panel1 = panel;<br />//set the dockstate to default.<br />panel1.Dock = DockStyle.Left; </span><span style="color:#3366ff;"><br />this.Controls.Add(this.panel1);<br />this.Controls.SetChildIndex(this.panel1, 0);<br />this.ResumeLayout(false);<br />this.PerformLayout();<br />}<br /></span><br />What we're doing here is something similar to "InitializeComponent()." We're just adding this control back in. Notice that I called "Controls.SetChildIndex." I did this because if you don't have these controls in the right order it could affect other docking controls. If you were to comment out this line and test, it would mess up the docking on your menustrip. So, remember to set it properly in your app.</div><div class="code"></div><div class="code"></div><div class="code">Next, we need to modify the frmTools window so that it passes this panel back to the parent when its closing. In the properties window of frmTools, click the Events lightning bolt and override the "FormClosing" event under "Behavior." Call it onClosing. In this function we're only going to call "SetToolPanel" and remove the panel from the control collection so it doesn't get wiped out.</div><div class="code"><br /><span style="color:#3366ff;">private void onClosing(object sender, FormClosingEventArgs e)<br />{<br />//Pass it off to the parent.<br />mParent.SetToolPanel(ref mPanel);<br />//Remove the control so it doesn't get ditched.<br />this.Controls.Remove(mPanel);<br />}</span></div><div class="code"><span style="color:#3366ff;"></span></div><div class="code"></div><div class="code">Thats it. Running the program you'll have a floatable dockable panel for your app. While testing, type something in the panel's textbox to show that its the same panel when it cycles through its states.</div><div class="code"></div><div class="code"></div><div class="code">If you need source code let me know...</div><div class="code"></div><div class="code"></div><div class="code">Happy Coding!</div><div class="code"></div><div class="code">Jas </div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-3948993439347441823?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com16tag:blogger.com,1999:blog-30054920.post-1169621727563069562007-01-23T22:50:00.000-08:002007-01-23T23:11:13.150-08:003D Blueman<a href="http://photos1.blogger.com/x/blogger/2306/3216/1600/861599/Screenshot-1.23.2007.22.44.26.jpg"><img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/x/blogger/2306/3216/320/227739/Screenshot-1.23.2007.22.44.26.jpg" border="0" alt="" /></a><br />This is a quick post of the first human head I've done in my editor (120 polys). I'm working on build 0.03 now. This one exports .x files for import into engines. Although it does texture mapping this picture doesn't show it. I'm really trying to keep the feature set down to a minumum until I work out the geometry workflow.<br /><br />Happy Coding!<br />Jas<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/30054920-116962172756306956?l=codemonkeyjas.blogspot.com'/></div>DX Jashttp://www.blogger.com/profile/08269048232617030811noreply@blogger.com1