Py淡

Python, Python, Python! In the spirit of "import antigravity"

Making 3D model from 2D side view image with Smoothie-3D


Smoothie-3D: squirrel modeling - YouTube

I made a 3d fish model for my current project. As you can see in the above Youtube demo video, they made making 3d model really easy. It would have been quite a lot of work if I did this in blender from scratch...

Basically, you only need to upload a photo, preferably a side view of it and then outline each part that needs to be in a separate volume. This will give us a 3d mesh that we can scale, rotate, and move. After a few minutes, I got a fish model consisting of the main body and a few fins. This can be exported into blender or other 3D modeling tools. I think I exported it as obj file and then used Blender to import, and YABEE plugin to make an egg file for panda3d.

I think you can even see my fish model at http://smoothie-3d.com/?p=Itoi@8 if you are logged into Smoothie.

忍者ブログの独自タグをつかって各記事をはてなブログに転送してみた。

忍者ブログでは複数のカテゴリを設定できないという制限があり、英語のページを分けるのが簡単ではないということではてなブログへと移転しました。

無料ブログから独自ドメインに引っ越すときに便利。忍者ブログから独自ドメインにjavascriptでリダイレクトをかける方法で紹介されている「4.javascriptのlocation.hrefで飛ばす」という方法を参考に忍者ブログからはてなへとリダイレクトしてみました。

<script>

var new_url = "http://pytan.hatenablog.com/entry"; //移転先のURLを入力(末尾にスラッシュなし)
var year = "<!--$entry_year-->"; //忍者ブログの独自タグ
var month = "<!--$entry_mon-->"; //忍者ブログの独自タグ
var date = "<!--$entry_day-->"; //忍者ブログの独自タグ
var hour = "<!--$entry_hour-->"; //忍者ブログの独自タグ
var min = "<!--$entry_min-->"; //忍者ブログの独自タグ
var sec = "<!--$entry_sec-->"; //忍者ブログの独自タグ

var lastpart = [hour, min, sec],join('')
var redirect_url = [year, month, date, lastpart].join('/')

setTimeout("redirect()", 0);

function redirect() {
     location.href = redirect_url ;
}
</script>

はてなのURLは日時になるように設定したので、構文辞典INDEX|ヘルプ|忍者ブログを参考に、忍者ブログの独自タグをつかって、Javascriptで投稿日時からはてなURLを生成しました。

これをデザインー>PC用テンプレートの設定からー>修正を選び、別ウインドウで出てくるテンプレートのエディターで記事($entry_text)のタブに行きEntryTextクラス内に貼りました。忍者ブログのテンプレートの部分は見た感じPHPっぽいですが、それで変数の置き換えをやってもらったJavascriptが走ることで各記事の転送が可能になっているっぽい。

はてなブログを初めて使いましたが、やっぱりすごいですねぇ。はてな記法シンタックスハイライトできるのがかなりうれしい。

Using buffer protocol to dynamically texture with 2D numpy array in Panda3d

 

I followed this official blog post "Buffer protocol support" and came up with a short example of simple video player in panda3d using numpy 2d array as texture. The trick was to use setRamImage on Texture object. To do that, we have to setup the memory layout using setup2dTexture method.

setup2dTexture ( int x_size, int y_size, Texture::ComponentType component_type, Texture::Format format )

Texture format and Texture componentType need to be set correctly. By try and error, I figured that the combination of T_unsigned_byte and F_luminance works for 8 bit gray scale image.

 

f:id:i-namekawa:20150716180048p:plain

 

Panda3d has an avi file texture support by default. Read here: Playing MPG and AVI files - Panda3D Manual

So, normally you will not need what I showed above. That is merely for demonstration of dynamic texturing using numpy array.