PHP SDK & Graph API base Facebook Connect Tutorial

http://thinkdiff.net/facebook/php-sdk-graph-api-base-facebook-connect-tutorial/


In this article I’m focusing facebook latest php sdk to integrate facebook features in your site. Some days ago facebook released their new graph api system and updated their core structure. They also officially released php sdk so that you can easily call facebook latest graph api and old legacy api from server side by php.


Before proceeding first have a look my previous article specially Facebook connect authentication part.


In this post I’ll show



  1. How to check valid session of user, if user successfully logged in

  2. How to call graph api

  3. How to call legacy api

  4. How to update status dynamically using graph api

  5. How to use FQL Query

So take a look my demo of this tutorial. Please login by FBConnect and approve all the permission if you’re first time accessing the page.


 


STEP 1:


First download the php sdk libary from here . Now copy the facebook.php from /src/ to your project dir.


STEP 2:


Create a file named fbmain.php. And copy below code to this file.










01 <?php






02     $fbconfig['appid' ]  = “your application id”;






03     $fbconfig['api'   ]  = “your application api key”;






04     $fbconfig['secret']  = “your application secret key”;






05  






06     try{






07         include_once “facebook.php”;






08     }






09     catch(Exception $o){






10         echo ‘<pre>’;






11         print_r($o);






12         echo ‘</pre>’;






13     }






14     // Create our Application instance.






15     $facebook = new Facebook(array(






16       ‘appId’  => $fbconfig['appid'],






17       ‘secret’ => $fbconfig['secret'],






18       ‘cookie’ => true,






19     ));






20  






21     // We may or may not have this data based on a $_GET or $_COOKIE based session.






22     // If we get a session here, it means we found a correctly signed session using






23     // the Application Secret only Facebook and the Application know. We dont know






24     // if it is still valid until we make an API call using the session. A session






25     // can become invalid if it has already expired (should not be getting the






26     // session back in this case) or if the user logged out of Facebook.






27     $session = $facebook->getSession();






28  






29     $fbme = null;






30     // Session based graph API call.






31     if ($session) {






32       try {






33         $uid = $facebook->getUser();






34         $fbme = $facebook->api(‘/me’);






35       } catch (FacebookApiException $e) {






36           d($e);






37       }






38     }






39  






40     function d($d){






41         echo ‘<pre>’;






42         print_r($d);






43         echo ‘</pre>’;






44     }






45 ?>

First update $fbconfig array by your application’s id, api key and secret key. In the code you’ll see I included facebook.php by include_once. If your server has no curl extension and json extension, you’ll see error message. Until you don’t install curl and json extension this sdk will not work.

 $session = $facebook->getSession();

This method returns session information of user. It may be empty if user yet not logged in your site or user’s session is invalid. To check user’s session validity you’ve to first call an api, if user’s session is valid then the api will return result.


So if $fbme is not null that means user successfully logged in via facebook and user’s session is valid. So before calling any api use conditional logic like if ($fbme) { then call api}.


I also defined a method named d() to dump data quickly.


STEP 3:


Now create another file named index.php and copy below code and checkout my description at the end.











001 <?php






002     include_once “fbmain.php”;






003     $config['baseurl']  =   http://thinkdiff.net/demo/newfbconnect1/php/index.php;






004  






005     //if user is logged in and session is valid.






006     if ($fbme){






007         //Retriving movies those are user like using graph api






008         try{






009             $movies = $facebook->api(‘/me/movies’);






010         }






011         catch(Exception $o){






012             d($o);






013         }






014  






015         //Calling users.getinfo legacy api call example






016         try{






017             $param  =   array(






018                 ‘method’  => ‘users.getinfo’,






019                 ‘uids’    => $fbme['id'],






020                 ‘fields’  => ‘name,current_location,profile_url’,






021                 ‘callback’=>






022             );






023             $userInfo   =   $facebook->api($param);






024         }






025         catch(Exception $o){






026             d($o);






027         }






028  






029         //update user’s status using graph api






030         if (isset($_POST['tt'])){






031             try {






032                 $statusUpdate = $facebook->api(‘/me/feed’, ‘post’, array(‘message’=> $_POST['tt'], ‘cb’ => ));






033             } catch (FacebookApiException $e) {






034                 d($e);






035             }






036         }






037  






038         //fql query example using legacy method call and passing parameter






039         try{






040             //get user id






041             $uid    = $facebook->getUser();






042             //or you can use $uid = $fbme['id'];






043  






044             $fql    =   “select name, hometown_location, sex, pic_square from user where uid=” . $uid;






045             $param  =   array(






046                 ‘method’    => ‘fql.query’,






047                 ‘query’     => $fql,






048                 ‘callback’  =>






049             );






050             $fqlResult   =   $facebook->api($param);






051         }






052         catch(Exception $o){






053             d($o);






054         }






055     }






056 ?>






057 <!DOCTYPE html>







059     <head>






060         <meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8″/>






061         <title>PHP SDK & Graph API base FBConnect Tutorial | Thinkdiff.net</title>






062     </head>






063 <body>






064     <div id=“fb-root”></div>






065         <script type=“text/javascript”>






066             window.fbAsyncInit = function() {






067                 FB.init({appId: ‘<?=$fbconfig['appid' ]?>’, status: true, cookie: true, xfbml: true});






068  






069                 /* All the events registered */






070                 FB.Event.subscribe(‘auth.login’, function(response) {






071                     // do something with response






072                     login();






073                 });






074                 FB.Event.subscribe(‘auth.logout’, function(response) {






075                     // do something with response






076                     logout();






077                 });






078             };






079             (function() {






080                 var e = document.createElement(‘script’);






081                 e.type = ‘text/javascript’;






082                 e.src = document.location.protocol +






083                     ‘//connect.facebook.net/en_US/all.js’;






084                 e.async = true;






085                 document.getElementById(‘fb-root’).appendChild(e);






086             }());






087  






088             function login(){






089                 document.location.href = “<?=$config['baseurl']?>”;






090             }






091             function logout(){






092                 document.location.href = “<?=$config['baseurl']?>”;






093             }






094 </script>






095 <style type=“text/css”>






096     .box{






097         margin: 5px;






098         border: 1px solid #60729b;






099         padding: 5px;






100         width: 500px;






101         height: 200px;






102         overflow:auto;






103         background-color: #e6ebf8;






104     }






105 </style>






106  






107     <h3>PHP SDK & Graph API base FBConnect Tutorial | Thinkdiff.net</h3>






108     <?php if (!$fbme) { ?>






109         You’ve to login using FB Login Button to see api calling result.






110     <?php } ?>






111     <p>






112         <fb:login-button autologoutlink=“true” perms=“email,user_birthday,status_update,publish_stream”></fb:login-button>






113     </p>






114  






115     <!– all time check if user session is valid or not –>






116     <?php if ($fbme){ ?>






117     <table border=“0″ cellspacing=“3″ cellpadding=“3″>






118         <tr>






119             <td>






120                 <!– Data retrived from user profile are shown here –>






121                 <div class=“box”>






122                     <b>User Information using Graph API</b>






123                     <?php d($fbme); ?>






124                 </div>






125             </td>






126             <td>






127                 <div class=“box”>






128                     <b>User likes these movies | using graph api</b>






129                      <?php d($movies); ?>






130                 </div>






131             </td>






132         </tr>






133         <tr>






134             <td>






135                 <div class=“box”>






136                     <b>User Information by Calling Legacy API method “users.getinfo”</b>






137                     <?php d($userInfo); ?>






138                 </div>






139             </td>






140             <td>






141                 <div class=“box”>






142                     <b>FQL Query Example by calling Legacy API method “fql.query”</b>






143                     <?php d($fqlResult); ?>






144                 </div>






145             </td>






146         </tr>






147     </table>






148     <div class=“box”>






149         <form name=“” action=“<?=$config['baseurl']?>” method=“post”>






150             <label for=“tt”>Status update using Graph API</label>






151             <br />






152             <textarea id=“tt” name=“tt” cols=“50″ rows=“5″>Write your status here and click ‘submit’</textarea>






153             <br />






154             <input type=“submit” value=“Update My Status” />






155         </form>






156         <?php if (isset($statusUpdate)) { ?>






157             <br />






158             <b style=“color: red”>Status Updated Successfully! Status id is <?=$statusUpdate['id']?></b>






159          <?php } ?>






160     </div>






161     <?php } ?>






162  






163     </body>






164 </html>

The code is very easy to understand. First part contains php logic, api call and collection of data. Next part is html/javascript to view data (javascript for fbconnect authentication).


Please change

$config['baseurl']  =   “http://thinkdiff.net/demo/newfbconnect1/php/index.php”;

And set baseurl to your project url. And never forget to set your facebook application Connect URL. It would be your project url.


In index.php I used javascript based fbconnect authentication and fbml tag  to show login button and logout button. If you don’t want to use javascript for this purpose, you can generate login/logout links using php code.


Generate login/logout button using this php code










1 // login or logout url will be needed depending on current user state.






2 if ($fbme) {






3   $logoutUrl = $facebook->getLogoutUrl();






4 } else {






5   $loginUrl = $facebook->getLoginUrl();






6 }

And show the generated links by below code










1 <?php if ($fbme) { ?>






2     <a href=“<?=$logoutUrl?>”>







4     </a>






5     <?php else: ?>






6     <a href=“<?=$loginUrl?>”>







8     </a>






9     <?php } ?>

So user will see php generated login and logout button.


In the facebook.php sdk the getLoginUrl() function is defined as










1 / * The parameters:






2    * – next: the url to go to after a successful login






3    * – cancel_url: the url to go to after the user cancels






4    * – req_perms: comma separated list of requested extended perms






5    * – display: can be “page” (default, full page) or “popup”






6    *






7    * @param Array $params provide custom parameters */






8 public function getLoginUrl($params=array()){….}

So if you want that your user approve additional permissions at the first time then generate the url by providing some parameters










1 $loginUrl = $facebook->getLoginUrl(






2      array(‘req_perms’ => ‘email,read_stream’)






3 );

Now lets discuss more about api calling…


1. How to check valid session of user, if user successfully logged in


I already discussed it in the STEP 1. So I think you already have learned how to check valid session of user. Just remember to use if ($fbme) {call api}


2. How to call graph api


Its very simple. For http://graph.facebook.com/me  you’ve to use










1 $fbme = $facebook->api(‘/me’);


3. How to call legacy api


This is almost same as of graph api calling.










1 $param  =   array(






2    ‘method’  => ‘users.getinfo’,






3    ‘uids’       => $fbme['id'],






4    ‘fields’     => ‘name,current_location,profile_url’,






5    ‘callback’  =>






6 );






7 $userInfo   =   $facebook->api($param);

So $facebook->api() is used to call both graph api and old legacy api. If you check the api() method in facebook.php sdk you’ll see










1 public function api() {






2    $args = func_get_args();






3    if (is_array($args[0])) {






4      return $this->_restserver($args[0]);






5    } else {






6      return call_user_func_array(array($this, ‘_graph’), $args);






7    }






8  }

That means if 1st argument is array then the api will call the old restserver.php  otherwise it will call the new graph server.


4. How to update status dynamically using graph api










1 try {






2       $statusUpdate = $facebook->api(‘/me/feed’, ‘post’, array(‘message’=> ‘sample status message’, ‘cb’ => ));






3 } catch (FacebookApiException $e) {






4       d($e);






5 }

in facebook.php you’ll see










1 function _graph($path, $method=‘GET’, $params=array()) {…}

So the first parameter is for graph path in here https://graph.facebook.com/me/feed, 2nd parameter defines HTTP post or get parameter and 3rd parameter defines array that contains necessary values. So ‘message’ is the message we want as status and ‘cb’ is the callback function which I set to null. Here http://developers.facebook.com/docs/api you’ll see all the information about graph api and their parameters, like











Method Description Arguments
/PROFILE_ID/feed write to the given profile’s feed/wall messagepicturelinkname,description

So to call any graph api just check the manual if you need to pass additional parameters or not.


Another example to retrieve user favorite movie names (https://graph.facebook.com/me/movies) use










1 $movies = $facebook->api(‘/me/movies’);

5. How to use FQL Query


Currently I don’t find any way to call fql query using graph api. So use the technique of legacy api calling to run fql query










1 $fql    =   “select name, hometown_location, sex, pic_square from user where uid=xxxxxxxxxxxxxxx”;






2 $param  =   array(






3        ‘method’     => ‘fql.query’,






4         ‘query’     => $fql,






5       ‘callback’    =>






6 );






7 $fqlResult   =   $facebook->api($param);

I hope this article will help you to understand the usage of php-sdk easily. Demo URL


 


 


Related Posts




Related Posts


Posted in Facebook, PHP | Tagged , , , | Leave a comment

Tour de Flex

http://www.adobe.com/devnet/flex/tourdeflex.html

Tour de Flex is a desktop application for exploring Flex capabilities and resources, including the core Flex components, Adobe AIR, data integration, and a variety of third-party components, effects, skins, and more.

Tour de Flex has three primary goals:

  • Provide non-Flex developers with an overview of what is possible in Flex in a “look and see” environment
  • Provide Flex developers with an illustrated reference tool
  • Provide commercial and non-commercial Flex developers with a place to showcase their work

System requirements:

  • Microsoft Windows, Mac OS X, or Linux
Posted in ActionScript, Coding, Flash, Flex / Flash Builder, Library / Plugin, Useful Website | Tagged | Leave a comment

Open Collada

http://code.google.com/p/opencollada/downloads/list

Posted in 3D Graphics, 3DSMax, Library / Plugin, Useful Website | Tagged | Leave a comment

MenuBar control

MenuBar control

A MenuBar control displays the top level of a menu as a horizontal bar of menu items, where each item on the bar can pop up a submenu. The MenuBar control interprets the data provider in the same way as the Menu control, and supports the same events as the Menu control. Unlike the Menu control, a MenuBar control is static; that is, it does not function as a pop-up menu, but is always visible in your application. Because the MenuBar is static, you can define it directly in MXML.

For complete reference information, see the ActionScript 3.0 Reference for the Adobe Flash Platform. For more information on the Menu control, see Menu control events.

Posted in Flex / Flash Builder | Tagged , , | Leave a comment

Kung Fu Panda Animation

http://www.escalight.com/tutorials/3dsmax-tutorials/kung-fu-panda-animation.html

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda AnimationThis tutorial is the last of Kung Fu Panda tutorial series. After all hard work from modeling, texturing, rigging, and skinning, now ready for final lesson. You will create animation for our Kung Fu Panda model. This time you will use motion capture data to create animation. Motion capture (mocap) data is animation data stored from capturing real actor movement. We can re-use this animation data to any object, like our Kung Fu Panda model. Using mocap, you can create animation in a minute

1. Continue your previous lesson or download required 3dsmax file here. Select one of biped and go to Motion tab. In Biped rollout, click Load File button.

Image

2. A window will open. In this window, you can select any motion capture data file you have. This motion capture data should have BIP extension. You can use BIP file available in your 3dsmax CD/DVD. Usually they are located in Samples/Motion folder or you can look for free motion capture data available in the net, for example here’s a blog providing free mocap data

Image

3. After you load BIP file, your model will use the animation movement stored in that file. Image below shows Kung Fu Panda doing some backflip kick.

Image

Here’s another example of Kung Fu Panda Animation

Other tutorial :
Kung Fu Panda Modeling
Kung Fu Panda Texturing
Kung Fu Panda Skinning And Rigging

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

Posted in 3DSMax | Tagged , , | Leave a comment

Kung Fu Panda Skinning And Rigging

http://www.escalight.com/tutorials/3dsmax-tutorials/kung-fu-panda-skinning-and-rigging-part-1.html

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda Skinning And RiggingAfter you model and texture Po, character from Kung Fu Panda The Movie. Now, you can rig that panda model. Rigging is the process of placing skeleton system inside a mesh. There are 2 types of “skeleton” you can use in 3dsmax: Bones and Biped. Bones is usually used if you want to create bones manually. Otherwise, Biped is like a pre-built skeleton system. It’s quick and fast to use. This tutorial will show you how to apply Biped to our Kung Fu Panda Model!

1. First, open textured kung fu panda model you created earlier. Or you can download required 3D model here. Select model, go to Display tab and Freeze this model. You need to freeze this model, so you can’t accidentally select this model.

Image

2. Next step is creating Biped. Go to Create>Systems. Click Biped button. Then, click and drag in Front viewport to create Biped. Biped systems consist of several linked “bones”. Each “bones” is called “biped”. After you created Biped, in Structure rollout, modify Biped structure to fit model requirement. Look at image below for reference.

Image

3. Next, you need to position Biped inside the model. Make sure Bip01 in Biped is selected and go to Motion tab. Then in Biped rollout, click Figure mode. This mode allows you to modify Biped structure and shape. Position Bip01 in the middle of model (look at image below for reference). Because Bip01 is the parent of all biped, all other biped are also moved.

Image

4. Next, you need to modify each biped shape and position. Using Select and Non Uniform Tool strecth biped shape to fit the model. Also you need to rotate several biped arm.

Image

5. Modify each biped shape. It’s so simple, just use Select and Non-Uniform Scale in Front and Left viewport. You don’t need to modify all biped. Just modify one side of model (left or right side).

Image

6. Special note: When you modify biped for fingers, extend biped farther than finger mesh. This is the trick so that you don’t need tweaking in skinning process later.

Image

7. Next, we are going to copy-paste biped shape position to other side. Double click one of shoulder biped. The rest of arm and finger biped will be selected. Open Copy/Paste rollout. Click New Collection button to name the selection, then click Copy Posture button. Finally, click Paste Posture Opposite to paste to the other side.

Image

8. Using the same process like above, copy-paste leg posture. When finished, de-activate Figure mode and unfreeze the model..

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Skinning And Rigging Part 1 | Part 2 | Part 3

Other tutorial :
Kung Fu Panda Modeling
Kung Fu Panda Texturing
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda Skinning And RiggingAfter we add Biped to model in Part 1 tutorial, next we are going to go into skinning process. Skinning is required to make skeleton system works by deforming the mesh. In 3dsmax, you can use Skin or Physique modifier to skin a model. In this tutorial, you will use Physique modifier to skin Kung Fu Panda Model. Physique is faster to use, if you use Biped for skeleton system.

1. This process is not necessary, but can help you to see biped inside model in Perspective viewport (Smooth and Highlight display). Select model, right click and choose Properties. Activate See-Through and click OK.

Image

2. While model is still selected, apply Physique modifier to object. In Modifier Stack, position Physique modifier below Turbosmooth modifier. In Physique rollout, click Attach to Node button. Then click Bip01 in viewport. If you have difficulties in selecting Bip01. You can press H in keyboard. Highlight Bip01, and click Pick button. A new window will open. Click Initialize button. Now, your model is skinned.

Image

3. Try to select one of biped. Rotate, watch the mesh also deformed. Click Undo (Ctrl+Z) to reset biped position.

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Skinning And Rigging Part 1 | Part 2 | Part 3

Other tutorial :
Kung Fu Panda Modeling
Kung Fu Panda Texturing
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda Skinning And RiggingSkinning process is not finished yet. We need to check whether model is deformed in the way we want. If not, we need to modify several Physique attributes. Most of the time, this adjusting process is quite complicated. This tutorial will show you only the basic. But, I believe it’s quite enough to create nice animation.

1. First, try to select one of upper arm biped. Rotate. Notice that some part of arm is not deformed along arm movement. Click Undo (Ctrl+Z) to reset biped position..

Image

2. Before you begin adjusting, you may want to hide biped in viewport. Sometimes it’s hard to see clearly in viewport when biped is visible. Go to Modify tab. Highlight Physique modifier in Modifier Stack. In Physique Level of Detail rollout, check Hide Attached Nodes. Biped will be invisible. If you want to display Biped again, just uncheck this option. Whithout Biped visible in the screen, you can see only biped links (orange lines)

Image

3.In Modifier Stack, click plus (+) sign at left of Physique modifier. Then, select Envelope. Biped link will turn yellow. Select biped link at the upper arm. You will see red and grey circle. Those circles are called Envelope, which define area influenced by certain biped. Envelope has 2 areas, inner and outer. Biped influence in inner area is higher than outer area. Notice that, enveloped in upper arm is not covering all desired area. You can fix this by enlarging envelope. In Blending Envelopes rollout, focus on Envelope Parameters. Make sure Both is selected. Increase Radial Scale to 2.23. Both inner and outer envelope will be enlarged. After that, in Edit Commands click Copy button

Image

4. You need to apply Envelope changes to the other side of arm. You can modify it manually. But, remember that you clicked Copy button before. Now, select other upper arm link and click Paste button. Both arm is now fix. You can de-activate Envvelope selection. Un-hide Attached Nodes to display all biped objects. Ttry to rotate upper arm biped to check.

Image

5. Now try to rotate upper leg biped. Notice that, mesh in other legs is also deform. To fix this, just go to Envelope selection again

Image

6. Select biped link in lower leg. First, make sure Both option is active. Decrease Radial Scale to 0.68. And then activate Outer option, then decrease Radial Scale to 1. Copy-paste envelope to the other side of lower leg

Image

7. If you rotate upper leg biped, you will notice that belt area is also deform. To fix this, go to Envelope selection.

Image

8. Select biped link in pelvis area. With Both option active, decrease Radial Scale to 0.5. Copy-paste to the other side of pelvis.

Image

9. The last one. Select biped link in head. In Active Blending, uncheck Deformable and check Rigid. Head should not deformed a lot in animation. When finished, de-activate Envelope selection. Skinning process is done. Actually we need more adjustment in skinning process, but that should be enough for now. I will try to write more tutorial about this subject in the future.

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Skinning And Rigging Part 1 | Part 2 | Part 3

Other tutorial :
Kung Fu Panda Modeling
Kung Fu Panda Texturing
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

Posted in 3DSMax | Tagged , , , | Leave a comment

Kung Fu Panda Texturing

http://www.escalight.com/tutorials/3dsmax-tutorials/kung-fu-panda-texturing-part-1.html

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda TexturingIt’s time to texture our little panda, after we created him in Kung Panda Modeling tutorial. We are going to use Unwrap UVW. If you are unfamiliar with Unwrap UVW, consider to look at our previous tutorial: Understanding Unwrap UVW and Unwrap UVW Texturing. It is quite hard to unwrap a complex model like human character or this panda. But, if you follow this detailed and step by step tutorial, you will be able to use techniques describe in this tutorial at any model. Let’s unwrap!

1. First, open kung fu panda model you created earlier. Or you can download required 3D model here. Then, go to Modify tab. Remove Turbosmooth modifier. Then, apply Unwrap UVW modifier to model.

Image

2. Next step is selecting model parts and name each of them. You need to do this in order to recall each object part later easily. In Modifier stack, click plus (+) sign left of Unwrap UVW modifer. Then highlight Face. Now, you are able to select faces. Select panda’s head using Select Object tool. Don’t select panda’s ears.You can uncheck Ignore Backfacing for easy selection. If this option inactive, you can select front and back faces altogether. Use Ctrl+click to select more faces. And Alt+click to reduce selection. After all faces in the head are selected, name these faces in Named Selection Set (located in top of the screen). For example type “head” and press Enter in keyboard

Image

3. Next you need select anoother parts of model and name everyone of them. Use images below as references. In total, you should have 16 named selection sets.

Image

Image

Image

Image

Image

4. If you are happen to have wrong selection or name, click Edit Named Selection Sets button. In opened dialog box, you can highlight and delete the selection.

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Texturing Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Modeling
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda TexturingYou have selected and named each part of panda model in Part 1 tutorial. Next step is to assign each object to its proper mapping type. For example head is suitable with spherical mapping type. Arm is suitable with cylindrical mapping type and so on.

1. Continue your previous lesson. Make sure Face selection is active in Unwrap UVW. In Named Selection Sets, choose “head”. All faces in the head will be selected. In Map Parameters rollout, click Spherical. Next, clcik Align Z for mapping orientation. Don’t forget to uncheck Normalize map. If this option is active, you will get deformed unwrap faces (3dsmax will force unwrapped faces to fit rectangle)

Image

2. Repeat procedure above with other part of model. Refer to table below. Note: some mapping need to be adjusted, like in “tail”, “ear left” and “ear right”. Just rotate Gizmo to fit selected faces. Watch image below for reference.

Named faces Mapping Type Orientation
body Spherical Align Z
head Spherical Align Z
arm left / arm right Cylindrical Align X
leg left / leg right Cylindrical Best Align
tail Cylindrival Best Align + Rotate Gizmo
sole left / sole right Planar Align Z
palm left / palm right Planar Align Z
briefs Spherical Align X
foot left / foot right Planar Best Align
ear left / ear right Cylindrical Best Align + Rotate Gizmo

Image

3. In Parameters rollout, click Edit button. Edit UVWs window will open. Click Zoom Extents button in the right corner. Now, you can see all faces.

Image

4. Select all faces. Scale down to make them smaller. Then, move them near blue rectangle. You need to scale all faces several times before they are small enough to fit the rectangle. To make you able to see blue rectangle clearly, click Options>Advanced Options. In opened window, uncheck Show grid and Tile Bitmap. You can also de-activate Show Map button.

Image

5. Use Named Selection Sets again to select each model part. Move and arrange each them inside the rectangle. Just arrange so that you can see all object part clearly. Later, you’ll have to to arrange again.

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Texturing Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Modeling
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda TexturingIn previous tutorial (Part 1 and Part 2), you have unwrapped faces. But you can’t directly use this unwrapped faces for texturing. We need to fix some face position for easier texture drawing. There are several places we need to fix, like in head, body, briefs and leg.

1. In Edit UVWs window. Focus on head faces. Select several faces at left side (look at image below). In main menu, choose Tool>Break (Shortcut Ctrl+B). Then, move detached faces to the right side. Change selection to Edge. Select several edges like image below. Use Ctrl+click to select more than one edge. You need to zoom in to select all edges. Then, choose Tools>Stitch Selected.Just click OK in opened dialog box. You’ll have perfect symmetry head.

Image

2. Next, we are going to fix body, briefs, and leg faces. Most people use Pelt Mapping when unwrapping legs. But in this tutorial I will only use standard unwrap uvw. Pelt Mapping will be discussed in another tutorial.

Select right side briefs faces. Use Break (Ctrl+B), and move each of them near the body. Look at image below fore reference. Use Rotate and Mirror Horizontal to each side of briefs.

Then, change selection to Edge. Select 2 edges in body. Choose Tools>Stich selected. In opened dialog box, uncheck Scale Clusters and then OK. Repeat the same proces with other side of briefs.

Image

3. Change selection to Face. Select faces at left side of body. Break, move to the right and Stich them.

Image

4. Now, leve body faces for a while. Let’s modify legs faces first. Select both legs. Click Mirror Vertical, then Mirror Horizontal. Mirror Vertical is available when you click and hold Mirror Horizontal button.

Image

5. Select several faces at right side of legs (look at image below). Break, move them to the left and Stitch

Image

6. Now, select both legs faces. Use Scale Horizontal to reduce legs width. You can get Scale Horizontal button, if you click and hold Scale button. Then move each leg to its proper position near body (look at image below). Place legs as near as possible to body.

Image

7. Change selection to Edge. Select several edges like image below. Then choose Tools>Stich Selected. This time uncheck Align clusters and Scale clusters. Click OK. Do stitching on one leg at a time. After stitching, you’ll notice that in circled area there are unweld vertices. Change selection to Vertex. Go to Tools>Target Weld. Select one vertex in circled area, and move them to another vertex. We have finished fixing the faces position.

Image

8. Now, you can arrange model parts to fit rectangle area. Use scale if necessary. Make sure they are all inside the rectangle. Note: I use mirror to change arm orientation.

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Texturing Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Modeling
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

by Didik Wijaya
This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda TexturingAfter we have created and fixed unwrapped faces in previous tutorials, we are ready to make texture template.

1. In Edit UVWs window, choose Tools>Render UVW Template. Enter texture size. For example I use 512×512 pixel. Then, click Render UV Template button. You can save texture template as bitmap image.

Image

2. Open saved image in your image editing software, like Photoshop. Draw texture based on that image. Image below shows rough texture I created based on template.

Image

3. Back to 3dsmax. Open Material Editor. There’s one material applied to panda model. Remember, you applied this material while in modeling process. Select this material. Click Show Map button, to make applied material appear in viewport. In Blinn Basic Parameters, click small button right next to Diffuse. In Material/Map Browser choose bitmap, and then select texture image you have created before. When finished, close Material Editor

Image

4. Apply Turbosmooth and render your scene. Image below shows example of rendered result. Next step, I will show you how I create more realistic material.

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Texturing Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Modeling
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

by Didik Wijaya
This tutorial needs you to understand basic use of Photoshop.

Kung Fu Panda TexturingThis tutorial section will show you how to create more realistic texture for your Kung Fu Panda model. Original Kung Fu Panda Movie uses hair and fur, which did not explained here. Here, I just show you how to apply bitmap texture. Note: This tutorial is not a detailed step by step tutorial. I assume you are familiar with Photoshop. I just give a brief explanation how I create my texture.

First, prepare images for references. One from Kung Fu Panda Movie image, and the other is real life panda image.

Image

Image

1. Let’s begin with panda’s head. I crop half of real panda image and drag to the tempate. Scale that cropped image to fit the template. Then use Clone Stamp tool to create surrounding fur and face

Image

2. I crop the eye from Kung Fu Panda Movie image, and drag into texture template. Then also crop some part in hand area of real panda image to add black fur. For left side of face, I just duplicate layer and use Flip Horizontal (Edit>Transform>Flip Horizontal). Next, use Clone Stamp tool to cover middle seam.

Image

3. Next, draw dark color in ear area, to make smoother color transistion between head and ears. Then, fix eyes shape. Just use Clone Stamp tool with small brush size. Clone from dark fur area and white fur area.

Image

4. For body, I crop several part of fur in real panda image. Resize and copy them several times to cover body. Then I use Clone stamp tool to make all fur copies blend well.

Image

5. The same technique applied with black fur. Cropping, copying and clone stamping. Note, add a little white fur with Clone stamp tool in armpit area, to make color transition between body and arm.

Image

6. For belt, I just crop some belt image from Kung Fu Panda Movie image. Unfortunately I have curvy cropped belt image. To modify it, I use Edit>Transform>Warp. After that, resize and postion it in belt area. Sometimes I need to distort image (Edit>Transform>Distort). I repeat this process several times until I get full belt image.

Image

7. For legs, same techniques applied here. I cropped from Kung Fu Pada Move image. Distort and copy paste to create desired looks

Image

8. After that, I duplicate layer and flipped to create other side of body. Next is pants. I draw several pieces of solid color in one layer. Then under this layer, I create texture layer. I just randomize several texture with different texture size and rotation. Then, change top layer mode into Multiply. Sometime you can use Color mode too, depends on what color and texture you are using

Image

9. For stitch effect. I just use Line Tool a lot of times.

Image

10. For another part of texture image, like in palm and foot, same technique applied here. I just use crop, copy from other image and sometimes drawing. Image below shows example of finished texture. Then, save texture and use as Diffuse map. You can add your own bump or specular map if you want.

Image

11. Congrats you have finished Kung Fu Panda Texturing tutorial. Image below shows rendered result, applied with texture above. Next is Kung Fu Panda Skinning and Rigging tutorial.

Image

Image

Download Finished Kung Fu Panda Model (Textured)

Kung Fu Panda Texturing Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Modeling
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

Posted in 3DSMax | Tagged , , | Leave a comment

Kung Fu Panda Modeling

http://www.escalight.com/tutorials/3dsmax-tutorials/kung-fu-panda-modeling-part-1.html

This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda ModelingHave you seen Kung Fu Panda The Movie (2008)? It’s the story about a lazy, irreverent slacker panda, named Po, who is the biggest fan of Kung Fu around. But unwittingly Po becomes the chosen one when enemies threaten the village he lived in. In this tutorial you will learn to create Po model, low poly model version. Don’t compare the model you will create with the real one you saw in movie. I simplified many things. But at least you’ll understand how to create one. I planned to create Po character from modeling, texturing, rigging and skinning, also animate him. So let’s prepare for the first one: modeling.

Kung Fu Panda The Movie
Kung Fu Panda The Movie. I really love this movie.

1. First, we need a reference image. Too bad, I can’t find any reference image I want in the net. So, I decide to draw myself. Look at image below, I prepared a blueprint for you, complete with Po drawing (left and side image). How to create blueprint like this, read previous tutorial Modeling Using Blueprint.

You can download 3dsmax file with blueprint here (3dsmax ver 8) . Also you need to download bitmap images for blueprint

Image

2. Start by creating a sphere in Top viewport. Use Radius=78 and Segments=12. Position this sphere at Po head (look at image below). Apply material to this sphere. Use Opacity=50% so you can see blueprint behind. You can use any color you want. Later, you can change Opacity value at ay time to help you in modeling.

Image

3. In Left or Front viewport, move sphere down while holding Shift. You will get sphere clone. Use Copy for cloning method. In Command Panel, go to Modify tab, increate cloned sphere radius to 117. Place this cloned sphere in Po’s belly. Select one sphere—any sphere you want—then right click and choose Convert to>Convert to Editable Poly. Next, go to Modify tab, in Edit Geometry rollout, click Attach button and click another sphere. Two sphere will be combined into one object.

Image

4. Activate Polygon selection. Select several polygons like image below, and delete them.

Image

5. Change to Vertex selection. In Front and Left viewport, move vertices position. Tips: In Front viewport, you can select a loop of vertices and scale them along horizontal axis using Select and Non-Uniform Scale tool. Use image below for reference.

Image

6. Now, choose Border selection. Select two borders like image below. To select more than one border, hold Ctrl while selecting. In Edit Borders rollout, click Bridge to fill gap with new polygons.

Image

7. This conclude first part of Po modeling process. Next, you will modify head area.

Image

Donwload 3dsmax lesson file up to this point

Kung Fu Panda Modeling Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Texturing
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda ModelingIn Part 1 tutorial, you have created Po’s basic body shape. Next, you will modify Po’s head to create eyes, ears, and nose. You will use several tools like Bevel, Extrude, Connect, and many more. Let’s begin this tutorial section.

1. Continue previous tutorial. Activate Edge selection. In Left viewport, select all vertical edges in head area (look at image below). Then, in Edit Edges rollout, click Connect. Those edges will be divided.

Image

2. Change selection to Vertex. Now, move vertices using image below for reference..

Image

3. Let’s move on. We are going to create a nose. Select two polygons in nose area. Hold Ctrl while selecting to select more than one polygons. In Edit Polygons rollout, click Bevel. Click and drag in viewport, to add slight Bevel to these polygons. Then, scale polygons using Select And Non-Uniform Scale along horizontal axis, to narrow the polygons. Then add another bevel..

Image

4. Next, select several vertices in nose area (look at image below, make sure vertices in the back are not selected), and move them up and down to create better nose shape.

Image

5. Activate Polygon selection. In Front viewport, select half of object (right side). Then, delete those polygons. De-activate all sub-object selection. Next, apply Symmetry modifier. Make sure Mirror Axis=X and Flip is active.

Image

6. Let’s continue by creating eyes. In Modifier Stack, click plus (+) sign left of Editable Poly row, then highlight Vertex selection. In Front viewport, select one vertex in eye area. Then in Edit Vertices rollout, click Chamfer button. Click and drag in viewport to chamfer vertex..

Image

7. Change to Edge selection. Select four edges from chamfering result. Then, in Edit Edges rollout, click Settings button right next to Extrude. A small dialog box will open. Enter Extrusion Height = -5 and Extrusion Base Width = 2. Click OK.

Image

8. Next, we are going to create an ear. Change to Polygon selection. In Left viewport, select one polygon like image below. Add bevel to this polygon. Then, using Select and Non-Uniform Scale decrease polygon width. Next step, extrude this polygon twice. Modify vertices position to make ear shape.

Image

9. Po’s head is now finished.

Image

Download 3dsmax lesson file up to this point

Kung Fu Panda Modeling Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Texturing
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda ModelingPhew, in Part 1 tutorial, you have create basic body shape, and in Part 2 tutorial you sucessfully modify Po’s head. Now, it’s time to create Po’s leg. You know, Po’s leg is relatively smaller than original panda’s. Moreover, if you compared to his belly.

1. Begin by selecting several polygons in Front viewport (look at image below). Delete them.

Image

2. In Perspective viewport, rotate view until you can see bottom part of Po’s model. Make sure you are still in Polygon selection. Activate 3D Snap Toggle. Then, in Edit Geometry rollout, click Create button. Click four times in order (1-4) in viewport to create new polygon. 3D Snap Toggle is activated to make you select vertex position precisely.

Image

3. Change to Edge selection. Select two edges in newly created polygon (look at image below). Then use Connect to create new edge. Change selection to Vertex. Select vertices in newly created edge. In Front viewport, move them down. Then select one vertex only, and move it closer to another vertex (right image below)

Image

4. Activate Border selection. Select border in leg area (look at left image below). Move border while holding Shift button in keyboard. Position vertices using blueprint as reference (look at middle image below). Select border again and Shift+drag to create more polygons for leg. This time, in Edit Geometry rollout, click Make Planar: Z button. The result is like right image below.

Image

5. Shift+drag border three more times again. Then modify vertices position, both in Front and Left viewport.

Image

6. Let’s continue to create foot. In Left viewport, select several polygons (left image below). Extrude them. Change to Vertex selection. Modify vertices position to create foot shape (right image below).

Image

7. Next, change to Border selection. Select one border in the bottom of foot. Then, in Edit Borders rollout, click Cap button, to fill the hole with polygon..

Image

8. To finish modeling the foot, we need one more step. Activate Edge selection. Select all vertical edges in the bottom area of foot. In Edit Geometry rollout, click Slice Plane button. Slice plane will appear in viewport (yellow rectangle). Move slice plane down at the most bottom part of foot. Then click Slice button. When finished, turn off Slice Plane button.

Image

9. Next, you are going to create arm and hand.

Image

Donwload 3dsmax lesson file up to this point

Kung Fu Panda Modeling Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Texturing
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda ModelingWe have created basic body shape (Part 1), modeling a head (Part 2), and adding legs (Part 3). Now, we are going to create arm and hand.

1. Continue your previous lesson. In Left viewport, modify several vertices position (left image below). We need to do that before creating arm. When finished, activate Polygon selection. Select several polygons in area where you will create an arm.

Image

2. Apply Extrude to this polygons. In Edit Geometry rollout, click Make Planar: X. Adjust size of polygons using Select and Uniform Scale. In Front viewport, move polygons if necessary to fit blueprint behind. Next, apply Extrude three more times again. You also need to position and scale polygons. When finished, don’t deselect polygons but delete them. Finally de-activate all sub-object selection.

Image

3. To create a hand, we are going to create from a box. Later, we will attach this hand object to Po model. Start by creating Box in Top viewport. Use parameters like image below. Move this box close to Po’s arm.

Image

4. Convert box into Editable Poly. Adjust several vertices position. Start from Top viewport. Use left image below fro reference. Next, in Front viewport move several vertices up.

Image

5. Activate Polygon selection. Select three polygons in hand object. Extrude twice to create fingers. Then, select one polygon, and extrude to create thumb.

Image

6. Select, 4 polygons in the wrist area of hand object. Delete them. De-activate all sub-object selection. Now, select Po model object. Go to Modify tab. Highlight Editable Poly row in Modifier Stack. In Edit Geometry rollout, click Attach button, then click hand object in viewport. After this, activate Border selection. Select two borders between hand and arm. In Edit Borders rollout, click Bridge to connect hand and arm.

Image

7. In Front viewport, compare model and blueprint. Fit arm and hand based on blueprint behind. You can scale or move vertices..

Image

8. Your Kung Fu Panda model is almost finished. Next, we are going to create Po’s pants.

Image

Donwload 3dsmax lesson file up to this point

Kung Fu Panda Modeling Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Texturing
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

This tutorial needs you to understand basic use of 3dsmax.

Kung Fu Panda ModelingAfter a quite long tutorial step, Part 1, Part 2, Part 3 and Part 4, we had a full model of Kung Fu Panda. Well, your Kung Fu Panda model is almost finish. We are only need to add pants for Kung Fu Panda model.

1. Continue your previous lesson. In Left viewport, modify several vertices position (left image below). Use blueprint behind for reference.

Image

2. Change selection to Edge. Select vertical edges like image below. Use Connect to create horizontal edges. Activate Vertex selection and modify several vertices position to match blueprint..

Image

3. Again activate Edge selection. Select vertical edges like image below. Click Settings button right next to Connect. In opened dialog box, enter Slide = -14. Click OK.

Image

4. Select horizontal edges like image below. Tips: you can select one or two edges and then in Selection rollout click Loop. Click Settings button right next to Chamfer. In opened dialog box, makes sure Chamfer Amount=1. Then click OK. You have added small amount of chamfer.

Image

5. Activate Polygon selection. Select all polygons constructing pant. Make sure you select only polygons between chamfered edges. Then using Select and Uniform Tool, give slight enlargement..

Image

6. Activate Edge selection. Select edges like image below. Apply Chamfer with Amount=1. Change selection to Polygon. Select polygons like middle image below (you need to select 6 polygons here). Then enlarge them a little bit. You will get a belt.

Image

7. Next, select edges like image below (these edges separate pant and body). Give a slight amount of Chamfer, to make boundary between pants and body looks sharp, when we apply model with Turbosmooth.

Image

8. Do we forgetting something? Yup, a tail. De-activate all sub-object selection. Right click model and choose Convert to Editable Poly. Then, in Perspective viewport, rotate view until you can see back of Po model. Activate Vertex selection. Select one vertex in the middle of Po’s buttocks. Use Chamfer. Change selection to Polygon. Select newly created polygon. Then use Bevel three times to create a tail. De-activate all sub-object selection.

Image

9. To finish this model. Apply Turbosmooth modifer. Increase Iterations value if you want to get more smooth model.

Image

10. Congrats, you have created Kung Fu Panda model. In the next tutorial, we are going to add texture.

Image

Donwload Finished Kung Fu Panda Model

Kung Fu Panda Modeling Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Other tutorials:
Kung Fu Panda Texturing
Kung Fu Panda Rigging and Skinning
Kung Fu Panda Animation

Any question or comments regarding this tutorial should be sent to:
Didik Wijaya, email: escalight@yahoo.com This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Discuss this tutorial

Posted in 3DSMax | Tagged , , | Leave a comment

ActionScript 3 Design Patterns

http://www.as3dp.com/

Posted in ActionScript, Coding, Useful Website | Tagged , | Leave a comment

http://papervision2.com/

http://papervision2.com/

Posted in Papervision3D, Useful Website | Tagged , | Leave a comment