<?xml version="1.0" encoding="UTF-8"?>
<X3D>
<Scene>
<ProtoDeclare name='BlickTexture'>
<ProtoInterface>
<field accessType='initializeOnly' type='SFColor' name='brickColor' value='0.5 0 0'/>
<field accessType='initializeOnly' type='SFFloat' name='bumpRate' value='0'/>
</ProtoInterface>
<ProtoBody>
<!-- ピクセルテクスチャー -->
<PixelTexture DEF='PT'/>
<!-- テクスチャー作成スクリプト -->
<Script DEF='Sc'>
<field accessType='outputOnly' type='SFImage' name='image'/>
<field accessType='initializeOnly' type='SFColor' name='brkCol'/>
<field accessType='initializeOnly' type='SFFloat' name='bpRate'/>
<field accessType='initializeOnly' type='SFInt32' name='dt' value='64'/>
<IS>
<connect nodeField='brkCol' protoField='brickColor'/>
<connect nodeField='bpRate' protoField='bumpRate'/>
</IS>
<![CDATA[ecmascript:
function initialize () {
// 基本色
var baseR = Math.floor ( brkCol.r * 255 );
var baseG = Math.floor ( brkCol.g * 255 );
var baseB = Math.floor ( brkCol.b * 255 );
var baseCol = baseR * 65536 + baseG * 256 + baseB;
// 凹凸率
var bRate = Math.max ( 0, Math.min ( 128, 128 * bpRate ));
var bR = baseR - bRate / 2;
var bG = baseG - bRate / 2;
var bB = baseB - bRate / 2;
// 繋ぎ目の明るい色
var LR = Math.min ( 255, baseR + 40 );
var LG = Math.min ( 255, baseG + 40 );
var LB = Math.min ( 255, baseB + 40 );
var LCol = LR * 65536 + LG * 256 + LB;
// 繋ぎ目の暗い色
var DR = Math.max ( 0, baseR - 40 );
var DG = Math.max ( 0, baseG - 40 );
var DB = Math.max ( 0, baseB - 40 );
var DCol = DR * 65536 + DG * 256 + DB;
var ary = new MFInt32 ();
var px = dt * (dt - 1);
// 凹凸含めて表面を描く
var i,ra,r,g,b;
for ( i = 0; i < px; i++ ) {
ra = Math.random() * bRate;
r = Math.max ( 0, Math.min ( 255, Math.floor ( ra + bR )));
g = Math.max ( 0, Math.min ( 255, Math.floor ( ra + bG )));
b = Math.max ( 0, Math.min ( 255, Math.floor ( ra + bB )));
ary[i] = r * 65536 + g * 256 +b;
}
// 繋ぎ目を描く
var s,t;
var dtp2 = dt / 2;
for ( s = 0; s < dt; s++ ) {
ary[s ] = DCol;
ary[s + ( dt - 1 ) * dt] = LCol;
ary[s + ( dtp2 + 1 ) * dt] = DCol;
ary[s + dtp2 * dt] = LCol;
}
for ( t = 1; t <= dtp2; t++ ) {
ary[ t * dt] = DCol;
ary[dt - 1 + t * dt] = LCol;
}
for ( t = dtp2 + 2; t < dt; t++) {
ary[dtp2 + 1 + t * dt] = DCol;
ary[dtp2 + t * dt] = LCol;
}
image = new SFImage ( dt, dt, 3, ary );
}
]]>
</Script>
<ROUTE fromNode='Sc' fromField='image' toNode='PT' toField='image'/>
</ProtoBody>
</ProtoDeclare>
<!-- ====== PROTO BlickTexture End =================================================================================== -->
<Viewpoint position='0 1.6 5' description='"initial"'/>
<Viewpoint position='0 1.6 5' orientation='1 0 0 0.7' description='"ceiling"'/>
<Viewpoint position='0 1.6 5' orientation='1 0 0 -0.7' description='"floor"'/>
<NavigationInfo headlight='FALSE'
type='"WALK"'
/>
<PointLight location='0 3 0'/>
<!-- 床 -->
<Transform translation='3.5 -0.1 3.5'>
<Shape DEF='Floor-Sp'>
<Appearance>
<ProtoInstance name='BlickTexture' containerField='texture'>
<fieldValue name='brickColor' value='0.5 0.3 0'/>
<fieldValue name='bumpRate' value='0.3'/>
</ProtoInstance>
<TextureTransform scale='6 14' rotation='1.5708'/>
<Material DEF='Mt'/>
</Appearance>
<Box size='7 0.2 7'/>
</Shape>
</Transform>
<Transform translation='-3.5 -0.1 3.5'>
<Shape USE='Floor-Sp'/>
</Transform>
<Transform translation='3.5 -0.1 -3.5'>
<Shape USE='Floor-Sp'/>
</Transform>
<Transform translation='-3.5 -0.1 -3.5'>
<Shape USE='Floor-Sp'/>
</Transform>
<!-- 天井 -->
<Transform translation='3.5 5 3.5'>
<Shape DEF='Ceiling-Sp'>
<Appearance>
<ProtoInstance name='BlickTexture' containerField='texture'>
<fieldValue name='brickColor' value='0.8 0.6 0.4'/>
<fieldValue name='bumpRate' value='0.5'/>
</ProtoInstance>
<TextureTransform scale='5 2.5'/>
<Material DEF='Mt'/>
</Appearance>
<Box size='7 0.2 7'/>
</Shape>
</Transform>
<Transform translation='-3.5 5 3.5'>
<Shape USE='Ceiling-Sp'/>
</Transform>
<Transform translation='3.5 5 -3.5'>
<Shape USE='Ceiling-Sp'/>
</Transform>
<Transform translation='-3.5 5 -3.5'>
<Shape USE='Ceiling-Sp'/>
</Transform>
<!-- 壁 -->
<Group DEF='Walls-Gp'>
<Transform translation='2.5 2.5 -5'>
<Shape DEF='Wall-Sp'>
<Appearance>
<ProtoInstance name='BlickTexture' DEF='Stone-BT' containerField='texture'>
<fieldValue name='brickColor' value='0.6 0.6 0.6'/>
<fieldValue name='bumpRate' value='0.1'/>
</ProtoInstance>
<TextureTransform scale='8 8'/>
<Material USE='Mt'/>
</Appearance>
<Box size='5 5 0.2'/>
</Shape>
</Transform>
<Transform translation='-2.5 2.5 -5'>
<Shape USE='Wall-Sp'/>
</Transform>
<Transform translation='3.2 2.5 5'>
<Shape USE='Wall-Sp'/>
</Transform>
<Transform translation='-3.2 2.5 5'>
<Shape USE='Wall-Sp'/>
</Transform>
</Group>
<Transform rotation='0 1 0 1.5708'>
<Group USE='Walls-Gp'/>
</Transform>
<!-- 柱 -->
<Transform translation='5 2.5 -5'>
<Shape DEF='Piller-Sp'>
<Appearance>
<ProtoInstance USE='Stone-BT' containerField='texture'/>
<TextureTransform scale='1.6 8'/>
<Material USE='Mt'/>
</Appearance>
<Box size='1 5 1'/>
</Shape>
</Transform>
<Transform translation='-5 2.5 -5'>
<Shape USE='Piller-Sp'/>
</Transform>
<Transform translation='5 2.5 5'>
<Shape USE='Piller-Sp'/>
</Transform>
<Transform translation='-5 2.5 5'>
<Shape USE='Piller-Sp'/>
</Transform>
<Transform translation='0.8 2.5 5'>
<Shape DEF='Piller2-Sp'>
<Appearance>
<ProtoInstance USE='Stone-BT' containerField='texture'/>
<TextureTransform scale='0.8 8'/>
<Material USE='Mt'/>
</Appearance>
<Box size='0.5 5 0.5'/>
</Shape>
</Transform>
<Transform translation='-0.8 2.5 5'>
<Shape USE='Piller2-Sp'/>
</Transform>
<Transform translation='5 2.5 -0.8'>
<Shape USE='Piller2-Sp'/>
</Transform>
<Transform translation='5 2.5 0.8'>
<Shape USE='Piller2-Sp'/>
</Transform>
<!-- 暖炉 -->
<Transform translation='0 0.1 -4.5'>
<Shape DEF='Fireplace0-Sp'>
<Appearance>
<ProtoInstance name='BlickTexture' DEF='Fireplace-BT' containerField='texture'>
<fieldValue name='brickColor' value='0.6 0.1 0'/>
<fieldValue name='bumpRate' value='0.3'/>
</ProtoInstance>
<TextureTransform scale='3 3'/>
<Material DEF='Mt'/>
</Appearance>
<Box size='2 0.2 1'/>
</Shape>
</Transform>
<Transform translation='-1.1 0.5 -4.5'>
<Shape DEF='Fireplace1-Sp'>
<Appearance>
<ProtoInstance USE='Fireplace-BT' containerField='texture'/>
<TextureTransform scale='0.8 3'/>
<Material DEF='Mt'/>
</Appearance>
<Box size='0.4 1 1'/>
</Shape>
</Transform>
<Transform translation='1.1 0.5 -4.5'>
<Shape USE='Fireplace1-Sp'/>
</Transform>
<Transform translation='0 0.5 -4.8'>
<Shape>
<Appearance>
<ProtoInstance USE='Fireplace-BT' containerField='texture'/>
<TextureTransform scale='3 3'/>
<Material DEF='Mt'/>
</Appearance>
<Box size='2 1 0.2'/>
</Shape>
</Transform>
<Transform translation='0 1.25 -4.5'>
<Shape>
<Appearance>
<ProtoInstance USE='Fireplace-BT' containerField='texture'/>
<TextureTransform scale='5 1.5'/>
<Material DEF='Mt'/>
</Appearance>
<Box size='2.6 0.5 1'/>
</Shape>
</Transform>
<!-- 煙突 -->
<Transform translation='0 4 -5'>
<Shape>
<Appearance>
<ProtoInstance USE='Fireplace-BT' containerField='texture'/>
<TextureTransform scale='10 15'/>
<Material DEF='Mt'/>
</Appearance>
<Cylinder radius='0.6' height='5'/>
</Shape>
</Transform>
</Scene>
</X3D>