1/1

Installed python cgkit on Mx Linux21.3 using python2.7

LANG=C xdg-user-dirs-gtk-update
sudo apt update
sudo apt upgrade
sudo apt install build-essential

sudo apt install python-is-python2
sudo apt install python2-dev
sudo apt install libode-dev
sudo apt install lib3ds-dev
sudo apt install freeglut3-dev
sudo apt install libboost-all-dev

■Download cgkit.
https://sourceforge.net/p/cgkit/code/ci/master/tree/


glmaterial.py, line 141, in _passPILImage
self.texData(w, h, format, GL_UNSIGNED_BYTE, img.tostring())

replaced tostring() with tobytes().

self.texData(w, h, format, GL_UNSIGNED_BYTE, img.tobytes())

■Download PyProtocol.
http://peak.telecommunity.com/dist/

■Download get-pip.py for 2.7.
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
# python get-pip.py


mak@mx:~/.local/bin
$ ./pip install pygame
$ ./pip install pyopengl
$ ./pip install serial
$ ./pip install pyode
$ ./pip install pillow
$ ./pip install scons

$ unzip PyProtocols-0.9.3.zip
$ sudo python setup.py --without-speedups install

$ ./pip list
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Package Version
----------- -------
future 0.18.3
iso8601 0.1.16
Pillow 6.2.2
pip 20.3.4
pygame 2.0.3
PyODE 1.2.1
PyOpenGL 3.1.7
PyProtocols 0.9.3
PyYAML 5.4.1
scons 3.1.2
serial 0.0.97
setuptools 44.1.1
wheel 0.37.1




$ cd ~/Downloads/cgkit-code/utilities/
mak@mx:~/Downloads/cgkit-code/utilities
$ python checkenv.py
----------------------------------------------------------------------
Python 2.7.18 (default, Jul 14 2021, 08:11:37)
[GCC 10.2.1 20210110]
Platform: linux2
----------------------------------------------------------------------
Python version: 2.7........... OK
PyProtocols................... is installed
PyOpenGL...................... is installed
PIL........................... is installed
pygame........................ pygame 2.0.3 (SDL 2.0.16, Python 2.7.18)
Hello from the pygame community. https://www.pygame.org/contribute.html
is installed
PyODE......................... is installed
PySerial...................... is installed
cgkit (base).................. missing
cgkit (C++ lib)............... failed

The cgkit supportlib could not be imported. One possible reason for that
is that shared libraries (such as the boost_python runtime or OpenGL)
could not be found.

cgkit (all)................... failed


$ ls /usr/lib/x86_64-linux-gnu/libboost_python*.*
/usr/lib/x86_64-linux-gnu/libboost_python39.a
/usr/lib/x86_64-linux-gnu/libboost_python39.so
/usr/lib/x86_64-linux-gnu/libboost_python39.so.1.74.0

■Download following:
libboost-python1.67.0_1.67.0-17ubuntu8_amd64.deb
libboost-python1.67-dev_1.67.0-17ubuntu8_amd64.deb

$ dpkg -x libboost-python1.67.0_1.67.0-17ubuntu8_amd64.deb usr
$ dpkg -x libboost-python1.67-dev_1.67.0-17ubuntu8_amd64.deb usr

■Copy following:
libboost_python27.so
libboost_python27.so.1.67.0
libboost_python27.a


$ sudo cp libboost_python27*.* /usr/lib/x86_64-linux-gnu/

$ ls /usr/lib/x86_64-linux-gnu/libboost_python*.*
/usr/lib/x86_64-linux-gnu/libboost_python27.a
/usr/lib/x86_64-linux-gnu/libboost_python27.so
/usr/lib/x86_64-linux-gnu/libboost_python27.so.1.67.0
/usr/lib/x86_64-linux-gnu/libboost_python39.a
/usr/lib/x86_64-linux-gnu/libboost_python39.so
/usr/lib/x86_64-linux-gnu/libboost_python39.so.1.74.0

$ ls /usr/lib/x86_64-linux-gnu/lib3ds*.*
/usr/lib/x86_64-linux-gnu/lib3ds-1.so
/usr/lib/x86_64-linux-gnu/lib3ds-1.so.3.0.0
/usr/lib/x86_64-linux-gnu/lib3ds-1.so.3
/usr/lib/x86_64-linux-gnu/lib3ds.so

■scons
$ /home/mak/.local/bin/scons

■changed config.cfg
######################################################################
# Boost.Python settings
######################################################################

# Name of the Boost.Python library to link with
BOOST_LIB = "boost_python27"


####### Libd3DS #######

LIB3DS_AVAILABLE = True
LIB3DS_PATH = r"/usr/lib/x86_64-linux-gnu/"

#LIB3DS_LIBNAME = "lib3ds-120s"


■Build cgkit.
$ python setup.py build


1.Build error;

wrappers/py_arrayslots1.cpp: In function ‘void class_ArraySlots()’:
wrappers/py_slot.h:43:75: error: unable to find string literal operator ‘operator""sname’ with ‘const char [11]’, ‘long unsigned int’ arguments
43 | #define ARRAYSLOT(sname,stype) class_<_ArraySlotIterator >("_"sname"_Iterator", init&>()) \
| ^~~~~~~~~~~
wrappers/py_slot.h:43:75: note: in definition of macro ‘ARRAYSLOT’
43 | #define ARRAYSLOT(sname,stype) class_<_ArraySlotIterator >("_"sname"_Iterator", init&>()) \
| ^~~~~~~~~~~
wrappers/py_slot.h:43:75: error: unable to find string literal operator ‘operator""sname’ with ‘const char [11]’, ‘long unsigned int’ arguments
43 | #define ARRAYSLOT(sname,stype) class_<_ArraySlotIterator >("_"sname"_Iterator", init&>()) \
| ^~~~~~~~~~~
wrappers/py_slot.h:43:75: note: in definition of macro ‘ARRAYSLOT’
43 | #define ARRAYSLOT(sname,stype) class_<_ArraySlotIterator >("_"sname"_Iterator", init&>()) \
|


1.Build error;

[solved]
py_slot.h,line:43, Put blank spaces on both sides of sname.

>("_" sname "_Iterator",



2.Build error;

wrappers/py_geoms1.cpp: In member function ‘boost::python::api::object _VariableIterator::next()’:
wrappers/py_geoms1.cpp:145:24: error: could not convert ‘std::make_tuple(_Elements&& ...) [with _Elements = {std::__cxx11::basic_string, std::allocator >&, const support3d::VarStorage&, const support3d::VarType&, const int&}](info.support3d::PrimVarInfo::storage, info.support3d::PrimVarInfo::type, info.support3d::PrimVarInfo::multiplicity)’ from ‘std::tuple, std::allocator >, support3d::VarStorage, support3d::VarType, int>’ to ‘boost::python::api::object’
145 | return make_tuple(name, info.storage, info.type, info.multiplicity);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| std::tuple, std::allocator >, support3d::VarStorage, support3d::VarType, int>
wrappers/py_geoms1.cpp: In function ‘boost::python::api::object findVariable(support3d::GeomObject*, std::string)’:
wrappers/py_geoms1.cpp:166:22: error: could not convert ‘std::make_tuple(_Elements&& ...) [with _Elements = {std::__cxx11::basic_string, std::allocator >&, support3d::VarStorage&, support3d::VarType&, int&}](info->support3d::PrimVarInfo::storage, info->support3d::PrimVarInfo::type, info->support3d::PrimVarInfo::multiplicity)’ from ‘std::tuple, std::allocator >, support3d::VarStorage, support3d::VarType, int>’ to ‘boost::python::api::object’
166 | return make_tuple(name, info->storage, info->type, info->multiplicity);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| std::tuple, std::allocator >, support3d::VarStorage, support3d::VarType, int>
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

2.Build error;
[solved]
py_geoms1.cpp,line:145 and line:166 boost::python::make_tuple

replaced make_tuple with boost::python::make_tuple.

---------------------------------------------------------------------------

■Install cgkit.
sudo python setup.py install --record files.txt

if you uninstall cgkit...
cat files.txt | sudo xargs rm -rf

mak@mx:~/Downloads/cgkit-code/utilities
$ python checkenv.py
-------------------------------------------------do ---------------------
Python 2.7.18 (default, Jul 14 2021, 08:11:37)
[GCC 10.2.1 20210110]
Platform: linux2
----------------------------------------------------------------------
Python version: 2.7........... OK
PyProtocols................... is installed
PyOpenGL...................... is installed
PIL........................... is installed
pygame........................ pygame 2.0.3 (SDL 2.0.16, Python 2.7.18)
Hello from the pygame community. https://www.pygame.org/contribute.html
is installed
PyODE......................... is installed
PySerial...................... is installed
cgkit (base).................. 2.0.0 (Aug 12 2023)
cgkit (C++ lib)............... OK
cgkit (all)................... OK


$ viewer.py -N softimage demo1.py

$ viewer.py -N softimage demo4.py
pygame 2.0.3 (SDL 2.0.16, Python 2.7.18)
Hello from the pygame community. https://www.pygame.org/contribute.html
Texname: 1
Loading "maps/uvmap.png"...

texturing is ok.
It is light and fun.

but pyode1.2.1 is old?
$ viewer.py -N softimage piddemo1.py
The ball moves freely.

Thank you for your support.
  • -
  • -

3Delight nsi viewTransformation

■以下はMayaのPerspのチャンネルボックスのデフォルト位置を例として
Translate X: 28
Translate Y: 21
Translate Z: 28
Rotate X: -27.938
Rotate Y: 45
Rotate Z: 0
Scale X: 1
Scale Y: 1
Scale Z: 1

3Delight nsiでは、
SetAttributeAtTime "|persp" -0.20000000000000001
"transformationmatrix" "doublematrix" 1 [ 0.70710678118654791 0 -0.70710678118654713 0 -0.33129457822453973 0.88345220859877216 -0.33129457822454006 0 0.62469504755442384 0.46852128566581852 0.6246950475544244 0 28 21 28 1 ]

これをpython cgkitで計算してみました。
python cgkitで求めてみます。インタラクティブモードを起動
$ python
Python 2.7.18 (default, Jul 14 2021, 08:11:37)
[GCC 10.2.1 20210110] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cgkit.all import *
移動位置を入力
>>> tr=mat4(1).translation(vec3(28,21,28))
>>> import math
x軸回転を入力
>>> rx=mat4(1).rotate(-27.938*math.pi/180,vec3(1,0,0))
>>> rx
[1, 0, 0, 0]
[0, 0.883455, 0.468516, 0]
[0, -0.468516, 0.883455, 0]
[0, 0, 0, 1]
y軸回転を入力
>>> ry=mat4(1).rotate(45*math.pi/180,vec3(0,1,0))
>>> ry
[0.707107, 0, 0.707107, 0]
[0, 1, 0, 0]
[-0.707107, 0, 0.707107, 0]
[0, 0, 0, 1]
移動、x軸回転、y軸回転の順で積を求める
>>> v=tr*ry*rx
>>> v
[-0.707107, -0.331291, 0.624697, 28]
[0, 0.883455, 0.468516, 21]
[-0.707107, 0.331291, -0.624697, 28]
[0, 0, 0, 1]
転置行列を求める。
>>> v.transpose()
[0.707107, 0, -0.707107, 0]
[-0.331291, 0.883455, -0.331291, 0]
[0.624697, 0.468516, 0.624697, 0]
[28, 21, 28, 1]
できあがり!


■posとtargetから求めるとしたら、RenderManでのplacecam.cをもとに計算してみます。
----------------------------------------
python placecam.py 3 3 3 0 0 0
position: 3.00, 3.00, 3.00
aim: 0.00, 0.00, 0.00
coneangle: 0.0000
roll: 0.00

RIBでのx軸、y軸の角度がわかります。
Rotate -35.26 1.00 0.00 0.00
Rotate 135.00 0.00 1.00 0.00
Translate -3.00 -3.00 -3.00

Translateの行列は、TX,TX,-TZで求めます。python cgkitで計算します。
インタラクティブモードを起動
>>> from cgkit.all import *
>>> tr=mat4(1).translation(vec3(3,3,-3))
>>> import math
>>> rx=mat4(1).rotate(-35*math.pi/180,vec3(1,0,0))
>>> rx
[1, 0, 0, 0]
[0, 0.819152, 0.573576, 0]
[0, -0.573576, 0.819152, 0]
[0, 0, 0, 1]
>>> ry=mat4(1).rotate(135*math.pi/180,vec3(0,1,0))
>>> ry
[-0.707107, 0, 0.707107, 0]
[0, 1, 0, 0]
[-0.707107, 0, -0.707107, 0]
[0, 0, 0, 1]
>>> v=tr*ry*rx
>>> v
[-0.707107, -0.40558, 0.579228, 3]
[0, 0.819152, 0.573576, 3]
[-0.707107, 0.40558, -0.579228, 3]
[0, 0, 0, 1]
>>> v.transpose()
[-0.707107, 0, -0.707107, 0]
[-0.40558, 0.819152, 0.40558, 0]
[0.579228, 0.573576, -0.579228, 0]
[3, 3, 3, 1]

>>> s2=mat4(1).scaling(vec3(-1,1,1))
>>> s3=mat4(1).scaling(vec3(1,1,-1))
>>> s2*v.transpose()*s3
[0.707107, 0, -0.707107, 0]
[-0.40558, 0.819152, -0.40558, 0]
[0.579228, 0.573576, 0.579228, 0]
[3, 3, 3, 1]
>>>
できあがり!
[0.707107 0 -0.707107 0
-0.40558 0.819152 -0.40558 0
0.579228 0.573576 0.579228 0
3 3 3 1]


■視野変換をする。3Delight nsiでは、
-----------------------------------------------------------------------
SetAttributeAtTime "|persp" -0.20000000000000001
"transformationmatrix" "doublematrix" 1 [ 0.57928117234268439 -5.5511151231257827e-17 -0.81512779572855032 0 -0.59748736723752183 0.68023036589218888 -0.42461217046824468 0 0.55447467873732514 0.73299839653179255 0.39404464381712034 0 3.2762530755722121 4.6062003801361309 2.8864228342103333 1 ]

MayaのPerspの位置
Translate X: 3.276
Translate Y: 4.606
Translate Z: 2.886
Rotate X: -47.138
Rotate Y: 54.6
Rotate Z: 0
Scale X: 1
Scale Y: 1
Scale Z: 1

python cgkitで求めてみます。
tr=mat4(1).translation(vec3(3.276,4.606,2.886))
rx=mat4(1).rotate(-47.138*math.pi/180,vec3(1,0,0))
ry=mat4(1).rotate(54.6*math.pi/180,vec3(0,1,0))
v=tr*ry*rx
v.transpose()

インタラクティブモードを起動
Python 2.7.18 (default, Jul 14 2021, 08:11:37)
[GCC 10.2.1 20210110] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cgkit.all import *
>>> import math
>>> tr=mat4(1).translation(vec3(3.276,4.606,2.886))
>>> tr
[1, 0, 0, 3.276]
[0, 1, 0, 4.606]
[0, 0, 1, 2.886]
[0, 0, 0, 1]
>>> rx=mat4(1).rotate(-47.138*math.pi/180,vec3(1,0,0))
>>> rx
[1, 0, 0, 0]
[0, 0.680235, 0.732994, 0]
[0, -0.732994, 0.680235, 0]
[0, 0, 0, 1]
>>> ry=mat4(1).rotate(54.6*math.pi/180,vec3(0,1,0))
>>> ry
[0.579281, 0, 0.815128, 0]
[0, 1, 0, 0]
[-0.815128, 0, 0.579281, 0]
[0, 0, 0, 1]
>>> v=tr*ry*rx
>>> v
[0.579281, -0.597484, 0.554478, 3.276]
[0, 0.680235, 0.732994, 4.606]
[-0.815128, -0.42461, 0.394047, 2.886]
[0, 0, 0, 1]
>>> v.transpose()
[0.579281, 0, -0.815128, 0]
[-0.597484, 0.680235, -0.42461, 0]
[0.554478, 0.732994, 0.394047, 0]
[3.276, 4.606, 2.886, 1]
>>>


■directionalLightを求める
--------------------------------------------------------------
SetAttributeAtTime "|directionalLight1" 0.20000000000000001
"transformationmatrix" "doublematrix" 1 [ 0.70710678118654746 5.5511151231257827e-17 0.70710678118654746 0 0.5 0.70710678118654746 -0.49999999999999994 0 -0.49999999999999994 0.70710678118654746 0.49999999999999989 0 0 0 0 1 ]

Translate X: 0
Translate Y: 0
Translate Z: 0
Rotate X: -45
Rotate Y: -45
Rotate Z: 0
Scale X: 1
Scale Y: 1
Scale Z: 1

>>> rx2=mat4(1).rotate(-45*math.pi/180,vec3(1,0,0))
>>> rx2
[1, 0, 0, 0]
[0, 0.707107, 0.707107, 0]
[0, -0.707107, 0.707107, 0]
[0, 0, 0, 1]
>>> ry2=mat4(1).rotate(-45*math.pi/180,vec3(0,1,0))
>>> ry2
[0.707107, 0, -0.707107, 0]
[0, 1, 0, 0]
[0.707107, 0, 0.707107, 0]
[0, 0, 0, 1]
>>> v2=ry2*rx2
>>> v2
[0.707107, 0.5, -0.5, 0]
[0, 0.707107, 0.707107, 0]
[0.707107, -0.5, 0.5, 0]
[0, 0, 0, 1]
>>>
>>> v2.transpose()
[0.707107, 0, 0.707107, 0]
[0.5, 0.707107, -0.5, 0]
[-0.5, 0.707107, 0.5, 0]
[0, 0, 0, 1]

ren05_dlRenderSettings1_0001.jpg
  • -
  • -

1/1