Rendering学習日記

日々3DCGの世界は進歩しているけど、勉強して理解したことをまとめていきたい。RenderMan互換レンダラーやグローバル・イルミネーション。いろんなことに好奇心を持ち面白くなってくる。目指せShader書き!!

Python27とcgkit install (Windows7 32bit)

Python2.7.10をインストールするとpipもインストールされました。とても便利になりました。
pythonのモジュールはwhlが多くなってきました。

>pip install hoge****.whl

のような感じで簡単にインストールできます。

■Python2.7.10をインストールした後、
Windowsの環境変数Pathに以下を追記します。
気をつけて行います。既存のパスの最後に付けます

;C:\Python27;C:\Python27\Scripts

■ここで再起動します。

■次に、以下からダウンロードします。

http://www.lfd.uci.edu/~gohlke/pythonlibs/

Pillow-2.8.2-cp27-none-win32.whl
pygame-1.9.2a0-cp27-none-win32.whl
ode-0.13.1-cp27-none-win32.whl
PyOpenGL-3.1.1a1-cp27-none-win32.whl
cgkit-2.0.0-cp27-none-win32.whl

をダウンロードします。
またVpythonを使いたいならば
VPython-5.74-cp27-none-win32.whl

Microsoftから
VCForPython27.msiをダウンロードして
インストールします。

以下は、試したログです。
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

D:\Aplication>pip install Pillow-2.8.2-cp27-none-win32.whl
Processing d:\aplication\pillow-2.8.2-cp27-none-win32.whl
Installing collected packages: Pillow
Successfully installed Pillow-2.8.2

D:\Aplication>pip freeze
Pillow==2.8.2
pyglet==1.2.2
pyprocessing==0.1.3.22

D:\Aplication>pip install pygame-1.9.2a0-cp27-none-win32.whl
Processing d:\aplication\pygame-1.9.2a0-cp27-none-win32.whl
Installing collected packages: pygame
Successfully installed pygame-1.9.2a0

D:\Aplication>pip install ode-0.13.1-cp27-none-win32.whl
Processing d:\aplication\ode-0.13.1-cp27-none-win32.whl
Installing collected packages: ode
Successfully installed ode-0.13.1

D:\Aplication>pip install cgkit-2.0.0-cp27-none-win32.whl
Processing d:\aplication\cgkit-2.0.0-cp27-none-win32.whl
Installing collected packages: cgkit
Successfully installed cgkit-2.0.0

D:\Aplication>pip install PyOpenGL-3.1.1a1-cp27-none-win32.whl
Processing d:\aplication\pyopengl-3.1.1a1-cp27-none-win32.whl
Installing collected packages: PyOpenGL
Successfully installed PyOpenGL-3.1.1a1
■ここは時間かかります。しばらく待ちます。


■ここからVpythonのインストールです。
最初、エラーでインストールできませんでした。

D:\Aplication>pip install VPython-5.74-cp27-none-win32.whl
Processing d:\aplication\vpython-5.74-cp27-none-win32.whl
Collecting fonttools (from VPython==5.74)
Downloading FontTools-2.4.tar.gz (323kB)
100% |################################| 327kB 369kB/s
Collecting TTFQuery (from VPython==5.74)
Downloading TTFQuery-1.0.5.tar.gz
Collecting Polygon2 (from VPython==5.74)
Downloading Polygon2-2.0.7.zip (73kB)
100% |################################| 77kB 561kB/s
Collecting numpy (from fonttools->VPython==5.74)
Downloading numpy-1.9.2.tar.gz (4.0MB)
100% |################################| 4.0MB 79kB/s
Installing collected packages: numpy, fonttools, TTFQuery, Polygon2, VPython
Running setup.py install for numpy
Complete output from command C:\Python27\python.exe -c "import setuptools, t
okenize;__file__='c:\\windows\\temp\\pip-build-2wkd41\\numpy\\setup.py';exec(com
pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
ile__, 'exec'))" install --record c:\windows\temp\pip-hob8vx-record\install-reco
rd.txt --single-version-externally-managed --compile:
non-existing path in 'numpy\\distutils': 'site.cfg'
non-existing path in 'numpy\\f2py': 'docs'
non-existing path in 'numpy\\f2py': 'f2py.1'
F2PY Version 2
blas_opt_info:
blas_mkl_info:
libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Py
thon27\\libs']
NOT AVAILABLE

openblas_info:
libraries openblas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python2
7\\libs']
NOT AVAILABLE

atlas_3_10_blas_threads_info:
Setting PTATLAS=ATLAS
libraries tatlas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\
\libs']
NOT AVAILABLE

atlas_3_10_blas_info:
libraries satlas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\
\libs']
NOT AVAILABLE

atlas_blas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in ['C:\\Python27\\lib', 'C:\\
', 'C:\\Python27\\libs']
NOT AVAILABLE

atlas_blas_info:
libraries f77blas,cblas,atlas not found in ['C:\\Python27\\lib', 'C:\\', '
C:\\Python27\\libs']
NOT AVAILABLE

blas_info:
libraries blas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\l
ibs']
NOT AVAILABLE

blas_src_info:
NOT AVAILABLE

NOT AVAILABLE

non-existing path in 'numpy\\lib': 'benchmarks'
lapack_opt_info:
openblas_lapack_info:
libraries openblas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python2
7\\libs']
NOT AVAILABLE

lapack_mkl_info:
mkl_info:
libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Py
thon27\\libs']
NOT AVAILABLE

NOT AVAILABLE

atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
libraries tatlas,tatlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries tatlas,tatlas not found in C:\
libraries lapack_atlas not found in C:\
libraries tatlas,tatlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_3_10_threads_info
NOT AVAILABLE

atlas_3_10_info:
libraries satlas,satlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries satlas,satlas not found in C:\
libraries lapack_atlas not found in C:\
libraries satlas,satlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_3_10_info
NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries ptf77blas,ptcblas,atlas not found in C:\
libraries lapack_atlas not found in C:\
libraries ptf77blas,ptcblas,atlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_threads_info
NOT AVAILABLE

atlas_info:
libraries f77blas,cblas,atlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries f77blas,cblas,atlas not found in C:\
libraries lapack_atlas not found in C:\
libraries f77blas,cblas,atlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_info
NOT AVAILABLE

lapack_info:
libraries lapack not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\
\libs']
NOT AVAILABLE

lapack_src_info:
NOT AVAILABLE

NOT AVAILABLE

running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler
options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler
options
running build_src
build_src
building py_modules sources
creating build
creating build\src.win32-2.7
creating build\src.win32-2.7\numpy
creating build\src.win32-2.7\numpy\distutils
building library "npymath" sources
No module named msvccompiler in numpy.distutils; trying from distutils
Running from numpy source directory.
c:\windows\temp\pip-build-2wkd41\numpy\numpy\distutils\system_info.py:1603:
UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
c:\windows\temp\pip-build-2wkd41\numpy\numpy\distutils\system_info.py:1612:
UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
warnings.warn(BlasNotFoundError.__doc__)
c:\windows\temp\pip-build-2wkd41\numpy\numpy\distutils\system_info.py:1615:
UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
warnings.warn(BlasSrcNotFoundError.__doc__)
c:\windows\temp\pip-build-2wkd41\numpy\numpy\distutils\system_info.py:1505:
UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
c:\windows\temp\pip-build-2wkd41\numpy\numpy\distutils\system_info.py:1516:
UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
warnings.warn(LapackNotFoundError.__doc__)
c:\windows\temp\pip-build-2wkd41\numpy\numpy\distutils\system_info.py:1519:
UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
warnings.warn(LapackSrcNotFoundError.__doc__)
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution opt
ion: 'define_macros'
warnings.warn(msg)
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27

----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\wi
ndows\\temp\\pip-build-2wkd41\\numpy\\setup.py';exec(compile(getattr(tokenize, '
open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install
--record c:\windows\temp\pip-hob8vx-record\install-record.txt --single-version-
externally-managed --compile" failed with error code 1 in c:\windows\temp\pip-bu
ild-2wkd41\numpy

■エラーが出ました!!!
MicrosoftがPython 2.7用のコンパクトなVC++ 9.0コンパイラMicrosoft Visual C++ Compiler for Python 2.7を配布しています。
Microsoftから
VCForPython27.msiをダウンロードして
インストールします。
■ここを参考にしました。ありがとうございます。
http://www.regentechlog.com/2014/04/13/build-python-package-on-windows/




仕切りなおします。再度チャレンジ!
D:\Aplication>pip install VPython-5.74-cp27-none-win32.whl
Processing d:\aplication\vpython-5.74-cp27-none-win32.whl
Collecting fonttools (from VPython==5.74)
Using cached FontTools-2.4.tar.gz
Collecting TTFQuery (from VPython==5.74)
Using cached TTFQuery-1.0.5.tar.gz
Collecting Polygon2 (from VPython==5.74)
Using cached Polygon2-2.0.7.zip
Collecting numpy (from fonttools->VPython==5.74)
Using cached numpy-1.9.2.tar.gz
Installing collected packages: numpy, fonttools, TTFQuery, Polygon2, VPython
Running setup.py install for numpy
Running setup.py install for fonttools
Running setup.py install for TTFQuery
Running setup.py install for Polygon2
Successfully installed Polygon2-2.0.7 TTFQuery-1.0.5 VPython-5.74 fonttools nump
y-1.9.2

■内容を確認します
D:\Aplication>pip freeze
cgkit==2.0.0
FontTools==2.4
numpy==1.9.2
ode==0.13.1
Pillow==2.8.2
Polygon2==2.0.7
pygame==1.9.2a0
pyglet==1.2.2
PyOpenGL==3.1.1a1
pyprocessing==0.1.3.22
TTFQuery==1.0.5
VPython==5.74

●ありがとうございます。
cgkit | - | -

Metasequoia PythonでPxrDisneyマテリアル設定

Metasequoia Pythonを使って、RenderMan RIS用のマテリアルPxrDisneyを設定してみました。ありがとうございます。
boxesrnd.jpg


import random

def p(*args):
"""
プリント関数
複数の引数を渡せる。
"""
if len(args)==0:
# 改行させる
MQSystem.println("")
return

for arg in args:
MQSystem.println(str(arg))


# 基本図形、新規オブジェクトで立方体複数つくる
#meta_cube_def_rndc.py
doc = MQSystem.getDocument()
out = MQSystem.println


#
def unitcube(L=50,x=0,y=0,z=0):
obj = MQSystem.newObject() #新規オブジェクト
num=doc.numObject
a=num
obj.name="cube_%d" % a #オブジェクト名をつける

obj.addVertex(x-L/2.0,y-L/2.0,z+L/2.0) #0 頂点番号
obj.addVertex(x+L/2.0,y-L/2.0,z+L/2.0) #1
obj.addVertex(x+L/2.0,y+L/2.0,z+L/2.0) #2
obj.addVertex(x-L/2.0,y+L/2.0,z+L/2.0) #3
obj.addVertex(x-L/2.0,y-L/2.0,z-L/2.0) #4
obj.addVertex(x-L/2.0,y+L/2.0,z-L/2.0) #5
obj.addVertex(x+L/2.0,y+L/2.0,z-L/2.0) #6
obj.addVertex(x+L/2.0,y-L/2.0,z-L/2.0) #7

obj.addFace([0,3,2,1])
obj.addFace([1,2,6,7])
obj.addFace([4,7,6,5])
obj.addFace([0,4,5,3])
obj.addFace([3,5,6,2])
obj.addFace([0,1,7,4])
doc.addObject( obj )

mat1=MQSystem.newMaterial()
doc.addMaterial(mat1) #マテリアルをドキュメントに追加
num0 = doc.numMaterial #現在の材質数を数える
numm=num0-1 #マテリアル番号は一つ少ない
doc.material[numm].shader=5
doc.material[numm].shaderFilename="PxrDisney"
doc.material[numm].color=MQSystem.newColor(random.random(),random.random(),random.random())
doc.material[numm].specular=0.5
doc.material[numm].reflection=0.75

for face in obj.face:
face.material=numm #マテリアルnumm番を面に割り当てる


import traceback
import sys
#dist=0
try:
for dist in range(0,600,200):
for dist2 in range(0,600,200):
#out(str(i))
out(str(dist))
unitcube(100,50+dist,50,dist2)



except:
info=sys.exc_info()
p(info[0])
p(info[1])
p(*traceback.extract_tb(info[2]))

num = doc.numObject #オブジェクトの数
out("オブジェクトの数 %d" % num) #オブジェクトの数を表示


Metasequoia | - | -
1/1