Posted by at

2008年07月19日

OpenSimサーバ構築記録その6(ブレンダーで土地作り編)

● はじめに

OpenSimの基盤系やネット系の構築方法は大体理解できたので、
いいかげん、土地作りを勉強しないと。。。

Simオーナの皆様は、どんなツールで土地作りをしているのでしょう?

ここは、やっぱり使い慣れたブレンダーで作ってみました。




● Blenderで土地形状をつくる

スカルプじゃないので、頂点数とか気にせず、好き勝手にモデリングできますが、
とりあえず、練習なので基本的なピラミッド型を。(南米の階段ピラミッド風)

UV展開は、スカルプ作りでおなじみの手順です。

テクスチャは、XマップとYマップは不要です。 Z軸データをUV平面状にBakeすればいいので
Zマップのみ使えばいいです。

ちなみに、Blender 2.46 から、UVエディタに、トーンカーブツールが追加されました。
これが、UVテクスチャの調整に、なかなか役立つんですよ~ ^^

UVエディタで、256x256のイメージを作成して、BakeできたらPNG形式で保存します。






● 画像のアップロード

画像ファイルは、OpenSim.exeのある場所に、配置します。
( 私のLinuxの場合 )  /usr/local/opensim/0.58/bin/test-pyramid.png

OpenSimのコンソールから、terrainコマンドでロードします。(ロードの前に、fillオプションで平地にならします。)

Region# : terrain fill 10
Region# : terrain load test-pyramid.png


terrainコマンドはオプションがいっぱいあります。 勉強しよう。




● ど~ん、と出現

超巨大、ピラミッド型SIMのできあがりです~。 ^^;
でも、テクスチャが繰り返しでちょっと気になります。 Repeat数とか調整できるのかな?




だけど、これまたBlenderで、いろいろ遊べそうです。^^
シリンダーやスフィアなどイロイロなプリムを、Modifierのブーリアン演算で融合させて
いろんな形の土地を作ってみよう。
Sculp Paint モードも、土地作りに活用できますけど、タブレットがあったほうがいいかな。

それから、Blender以外の土地作りツールも捜そう。




【資料6.1】
terrainコマンド ヘルプ

Region# : terrain help


===Terrain===
* multiply - Multiplies the heightmap by the value specified.
* fill - Fills the current heightmap with a specified value.
* newbrushes - Enables experimental brushes which replace the standard terrain brushes.
        WARNING: This is a debug setting and may be removed at any time.
* elevate - Raises the current heightmap by the specified amount.
* lower - Lowers the current heightmap by the specified amount.
* load - Loads a terrain from a specified file.
* stats - Shows some information about the regions heightmap for debugging purposes.
* save - Saves the current heightmap to a specified file.
* load-tile - Loads a terrain from a section of a larger file.
* bake - Saves the current terrain into the regions revert map.
* effect - Runs a specified plugin effect
* revert - Loads the revert map terrain into the regions heightmap.

blender v2.46 Blender Foundation
  


Posted by ぱすてる at 00:07Comments(8)OpenSim

2008年07月17日

サブモジュール:Scene Render


インポートモジュール
from Blender.Scene import Render


現在のシーンとアクティブカメラで、レンダリングの実行
import Blender
from Blender.Scene import Render

# 現在のシーンを得る
scn = Scene.GetCurrent()

# 現在のシーンから、レンダーコンテキストを得る
context = scn.getRenderingContext()

# アンチエイリアス有効
context.enableOversampling(True)

# 影有効
context.enableShadow(True)

# レンダーウィンドウサイズ
context.imageSizeX(640)
context.imageSizeY(480)

# レンダリング実行
context.render()


blender v2.46 Blender Foundation
  


Posted by ぱすてる at 00:49Comments(0)Render

2008年07月17日

サブモジュール:World


インポートモジュール
from Blender import World


ワールド名「world」に、Horizonカラー、Zenithカラー、Blend、Paperを設定
from Blender import World
import Blender

# ワールドデータを得る
wld = Blender.World.Get('World')

# 天空Zenithの色を設定
wld.setZen([0.32, 0.62, 0.9])

# 地平Horizonの色を設定
wld.setHor([0.93, 0.92, 0.85])

# マッピング方法
# Paper(4) : 平面状
# Real(2)  : 球状
# Blend(1) : HorizonとZenithの色をブレンド
wld.setSkytype(4+1)


blender v2.46 Blender Foundation
  


Posted by ぱすてる at 00:33Comments(0)World

2008年07月17日

サブモジュール:Lamp


インポートモジュール
from Blender import Lamp


シーン上の、全ランプオブジェクトを得る
lamplist = Lamp.Get()
print lamplist


新規ライトを作成する
from Blender import Lamp, Scene, Window

# スポットライトを新規作成する
lmpobj = Lamp.New('Spot')

# 円形の光、影を発生させる
lmpobj.setMode('Sphere', 'Shadows')

# ライトの強さ
lmpobj.setEnergy(5.0)

# 光の色(白色)
lmpobj.col = [1, 1, 1]

# 現在のシーンを得る
scn = Scene.GetCurrent()

# 現在のシーンにライトを作成する
obj = scn.objects.new(lmpobj)

# ライトの位置(真上)
obj.loc = (0, 0, 10)

Window.Redraw()


blender v2.46 Blender Foundation
  


Posted by ぱすてる at 00:22Comments(0)Lamp

2008年07月17日

サブモジュール:Camera


インポートモジュール
from Blender import Camera


シーン上の、全カメラオブジェクトを得る
camlist = Camera.Get()
print camlist


カメラ名を指定して、カメラオブジェクトを得る
camobj = Camera.Get('Camera.001')
print camobj


blender v2.46 Blender Foundation
  


Posted by ぱすてる at 00:13Comments(0)Camera

2008年07月16日

サブモジュール:Window


インポートモジュール
from Blender import Window


エディットモードだったら、オブジェクトモードに切り替える
editmode = Window.EditMode()
if editmode:
  Window.EditMode(0)


3Dカーソルの現在位置を取得
cpos = Window.GetCursorPos()
print cpos


3Dカーソルを指定の座標に設定する
Window.SetCursorPos(1, 1, 1)
Window.Redraw()


ビューをトップにする
Window.SetViewQuat(1, 0, 0, 0)
Window.Redraw()


ビューをフロントにする
from math import *

Window.SetViewQuat(cos(45*pi/180), -cos(45*pi/180), 0, 0)
Window.Redraw()


ビューをサイドにする
Window.SetViewQuat(0.5, -0.5, -0.5, -0.5)
Window.Redraw()


指定したカメラをビューにする
import Blender
from Blender import Scene, Window

# 現在のシーンを得る
scn = Scene.GetCurrent()

# カメラ「Camera.001」を得る
object = Blender.Object.Get('Camera.001')

「Camera.001」をアクティブにする
scn.setCurrentCamera(object)

アクティブカメラの視点にする
Window.CameraView()


カメラを新規作成して、ビューにする
from math import *
from Blender import Scene, Camera, Window

# ortho(平行投影)のカメラデータを新規に生成する
camobj = Camera.New('ortho')

# orthoビューのscale値をセットする
camobj.scale = 10.0

# 現在のシーンを得る
scn = Scene.GetCurrent()

# 現在のシーンにカメラを追加
obj = scn.objects.new(camobj, 'myCamera')

# カメラの座標と角度を設定
obj.loc = (-10, -10, 10)
obj.rot = (55*pi/180, 0, -45*pi/180)

# カメラをアクティブにする
scn.setCurrentCamera(obj)

# アクティブカメラを視点にする
Window.CameraView()


blender v2.46 Blender Foundation
  


Posted by ぱすてる at 20:56Comments(0)Window

2008年07月16日

サブモジュール:Scene


インポートモジュール
from Blender import Scene
from Blender import Window


「myScene」という名のシーンを作って、現在のシーンにする
scn = Scene.New('myScene')
scn.makeCurrent()


シーン名を指定して、シーンを削除する
scn = Scene.Get('Scene.099')
Scene.unlink(scn)


全てのシーンのリストを得る
scenelist = Scene.Get()
for scn in scenelist:
  print scn


現在のシーン上にある、全てのオブジェクトの名前・タイプ・座標を表示する
scn = Scene.GetCurrent()
for obj in scn.objects:
  print obj.name, obj.type, obj.loc


現在のシーン上にある、全てのMeshオブジェクトの名前・座標を表示する
scn = Scene.GetCurrent()
for obj in scn.objects:
  if obj.type=='Mesh':
    print obj.name, obj.loc



blender v2.46 Blender Foundation
  


Posted by ぱすてる at 20:37Comments(0)Scene

2008年07月16日

サブモジュール:MeshPrimitives


インポートモジュール
from Blender import Scene, Window
from Blender import Mesh


現在のシーンに、Cubeを作成する
# 現在のシーンを得る
scn = Scene.GetCurrent()

# キューブを作成する (一辺2)
msh = Mesh.Primitives.Cube(2.0)

# シーンにキューブを追加する
obj = scn.objects.new(msh, 'myCube')

# 位置と角度を設定
obj.loc = (0, 0, 0)
obj.rot = (0, 0, 0)

# 3D Viewを再描画
Window.Redraw()


# プレーンを作成する (一辺2)
msh = Mesh.Primitives.Plane(2.0)


# サークルを作成する (頂点数32、直径4)
msh = Mesh.Primitives.Circle(32, 4.0)


# シリンダを作成する (頂点数32、直径4、長さ5)
msh = Mesh.Primitives.Cylinder(32, 4.0, 5.0)


# チューブを作成する (頂点数32、直径4、長さ5)
msh = Mesh.Primitives.Tube(32, 4.0, 5.0)


# UVスフィアを作成する (回転軸方向分割数32、円周方向分割数16、直径5)
msh = Mesh.Primitives.UVsphere(32, 16, 5.0)



blender v2.46 Blender Foundation


  


Posted by ぱすてる at 20:19Comments(0)MeshPrimitives

2008年07月13日

Blender Python API あれこれ試して覚え書き


● はじめに

今、仕事で、Google APIとPython言語を利用したWebアプリを作ってます。
そのおかげで、BlenderのPythonスクリプトなんかも、少しずつ読めるようになってきました。 ^^/
これは、こつこつと非公開でため込んだ、更新中の覚え書きメモです。
SLのものづくりとは直接関係ないですけど、スカルプテッドプリム作成専用ツールが作れたらいいな~
いつになることやら、ですが。。。。
完成した頃には、Google Livelyにとって変わってたりして。。 ーー;



Pythonスクリプトだけで、シーン作りからレンダリングまで

from math import *
from Blender import Scene, Mesh, Window, Camera, Lamp

#### make new scene ####
scn = Scene.New('myScene')
scn.makeCurrent()

#### rez plane ####
scn = Scene.GetCurrent()
msh = Mesh.Primitives.Plane(20.0)
obj = scn.objects.new(msh, 'myPlane')
obj.loc = (0, 0, 0)

#### rez cube ####
msh = Mesh.Primitives.Cube(1.7)
obj = scn.objects.new(msh, 'myCube')
obj.loc = (0, 0, 1.5)
obj.rot = (0, 0, 40*pi/180)

#### camera setting ####
camobj = Camera.New()
camobj.scale = 35.0
obj = scn.objects.new(camobj, 'myCamera')
obj.loc = (0, -6.508, 5.344)
obj.rot = (55*pi/180, 0, 0)
scn.setCurrentCamera(obj)

#### light setting (Center Spot Light) ####
lmpobj = Lamp.New('Spot')
lmpobj.setMode('Shadows')
lmpobj.setEnergy(0.7)
lmpobj.col = [1, 1, 1]
obj = scn.objects.new(lmpobj)
obj.loc = (0, 0, 10)

#### light setting (Color Red) ####
lmpobj = Lamp.New('Spot')
lmpobj.setMode('Sphere', 'Shadows')
lmpobj.setEnergy(3)
lmpobj.setSpotSize(20)
lmpobj.col = [1, 0, 0]
obj = scn.objects.new(lmpobj)
obj.loc = (5, 0, 10)
obj.rot = (0, 30*pi/180, 0)

#### light setting (Color Green) ####
lmpobj = Lamp.New('Spot')
lmpobj.setMode('Sphere', 'Shadows')
lmpobj.setEnergy(3)
lmpobj.setSpotSize(20)
lmpobj.col = [0, 1, 0]
obj = scn.objects.new(lmpobj)
obj.loc = (-5, 0, 10)
obj.rot = (0, -30*pi/180, 0)

#### light setting (Color Blue) ####
lmpobj = Lamp.New('Spot')
lmpobj.setMode('Sphere', 'Shadows')
lmpobj.setEnergy(3)
lmpobj.setSpotSize(20)
lmpobj.col = [0, 0, 1]
obj = scn.objects.new(lmpobj)
obj.loc = (0, -5, 10)
obj.rot = (26.3*pi/180, 0, 0)

#### Rendering ####
context = scn.getRenderingContext()
context.enableOversampling(True)
context.enableShadow(True)
context.imageSizeX(640)
context.imageSizeY(480)
context.render()







感謝のリンク先

少し古いけど、とっても助かってる、The Blender Python API Reference 日本語版
http://www.geocities.co.jp/SiliconValley-Cupertino/2019/blender/api-jpn.html

最新版The Blender Python API Reference
http://www.blender.org/documentation/246PythonDoc/API_intro-module.html

blender v2.46 Blender Foundation
  


Posted by ぱすてる at 14:39Comments(0)Blender Python API

2008年07月08日

OpenSimサーバ構築記録その5(外部Simサーバ接続編)

● またまた間違いのお詫び (08.07.17)

この記事を読んでくださった方から、
「他サーバのOpenSimからつながりません。MySQLの接続不可のエラーがでます。」
と相談いただきました。
記事を読み返したら、肝心な2点を説明し忘れてました。。。。申し訳ない。  ><;

(1) MySQL設定ファイルmy.cnfで、外部からの接続を許可する。

 MySQLのデフォルトは、ローカル(127.0.0.1)のみから接続可、となってます。
 以下の項目をコメントにします。

 【/etc/mysql/my.cnf】

 (変更前)
 48: bind-address = 127.0.0.1

 (変更後)
 48: # bind-address = 127.0.0.1

(2) 外部から接続できるユーザアカウントを登録する

 SQLコマンドで、外部ユーザアカウント(+外部ホスト名)を、userテーブルに追加します。

 mysql> grant all on *.* to root@opensim2 identified by '********';



 修正後、MySQLの再起動をお忘れなく。




● タイトル変更 (08.07.08)

最初に、この記事を投稿したとき、タイトルを「グリッドサーバ間接続編」としたのですが、
よくよく仕組みを調べたら、グリッドサーバ同士を接続しているのではなく、
仮想サーバ2のOpenSimサーバのみをOpenSim1に接続しているのだと理解できました。
(仮想サーバ2で、UGAIサーバを動かす必要がなかった。。。。><;)
というわけで、タイトルを変更しました。
不適切なタイトルでゴメンナサイ。。。。_| ̄|○




● はじめに

VMWareを利用して、1台のPC内に複数の仮想PCを立てられる様になったので、
複数のOpenSimサーバでマルチレジョンを試してみました。

1台のPCで、マルチレジョンにするなら、bin/Regions/default.xmlを複数
作成するだけなのですが、やっぱり複数サーバどうしを接続していると、
OpenSimのネットワークを構築している、、という実感がして面白いです。




● 仮想サーバのネットワーク定義

【1台目の仮想サーバ】

① IPアドレス: 192.168.85.129/24

② ホスト名: opensim1

  /etc/hostsで定義してます。

③ OpenSim Region定義: bin/Regions/1000-1000.xml

  スタンドアロンの時から変更なし

   sim_name="OpenSim1"
   sim_location_x="1000"
   sim_location_y="1000"
   internal_ip_address="192.168.85.129"
   internal_ip_port="9000"
   external_host_name="opensim1

④ OpenSim定義:bin/OpenSim.ini

  変更なし




【2台目の仮想サーバ】

OpenSim1に接続します。

① IPアドレス: 192.168.85.130/24

② ホスト名: opensim2

③ OpenSim Region定義: bin/Regions/1001-1000.xml

   sim_name="OpenSim2"
   sim_location_x="1001"
   sim_location_y="1000"
   internal_ip_address="192.168.85.130"
   internal_ip_port="9000"
   external_host_name="opensim2

  ※ sim_UUIDは1台目のUUIDと競合しないように。
  ※ sim_locationは1台目と競合しないように。
  ※ internal_ip_portは、9000のままでいい。
    (1PCで複数Regionsを立てる場合は、競合しないように)

④ OpenSim定義: bin/OpenSim.ini

  ネットワークカテゴリで、opensim1を指定する。

  [Network]
  remoteDataPort = 20800
  grid_server_url = "http://opensim1:8001"
  user_server_url = "http://opensim1:8002"
  asset_server_url = "http://opensim1:8003"
  inventory_server_url = "http://opensim1:8004"




● ログで確認

 1台目のグリッドサーバのログには、2台目のopensim2が接続してきた事の記録が出力されてます。

 【bin/OpenSim.Grid.GridServer.log】

2008-07-06 21:14:39,021 INFO - [LOGIN BEGIN]: Received login request from simulator: OpenSim2
2008-07-06 21:14:39,029 DEBUG - [LOGIN]: Contacting http://opensim2:9000/simstatus/ for status of region OpenSim2
2008-07-06 21:14:39,081 INFO - [LOGIN END]: New sim login successful: OpenSim2





● VMWareの仮想グリッドに、ようこそ~

かなたに見えるのが、別サーバで動いているOpenSim2です。
次は、インターネット上のSIMともつないで見たいですね~。



でも、マメタンの様なSIMにはいいかげん見飽きてしまいました。^^;
土地造成や、画像から取り込む勉強をしよう。




● わかりません。 ><

検索とか、できないなぁ~
まだまだ、わからない事だらけです。。。


  


Posted by ぱすてる at 19:43Comments(0)OpenSim