2009年08月02日
物体の回転その2(対空砲)
llRotBetween()という素敵な関数を見つけたのと、箱が傾いて見えるのが気に入らなかったので傾かない箱を。。。
XY平面上でのX軸(単位ベクトル<1,0,0>)からの回転(水平回転)
rotation newRot=llRotBetween(<1,0,0>,<norm.x,norm.y,0>);
垂直回転
rotation newRot2=llEuler2Rot(<0,llAcos(norm.z)-PI/2.0,0>);
回転実行(順番が大事)
llSetRot(newRot2*newRot);
だいぶシンプルになりました。が、相変わらず思考はvector。。。^^;
ホントにいいのかな、これで。。(笑
対空砲の動きをする箱の中身
default
{
state_entry()
{
llSensorRepeat("","",AGENT|ACTIVE,30,PI,0.1);
}
sensor(integer detectedNum)
{
if (llDetectedKey(0)==llGetOwner() && llDetectedKey(0)!=NULL_KEY)
{
vector targetVector=llDetectedPos(0)-llGetPos();
vector norm=llVecNorm(targetVector);
rotation newRot=llRotBetween(<1,0,0>,<norm.x,norm.y,0>);
rotation newRot2=llEuler2Rot(<0,llAcos(norm.z)-PI/2.0,0>);
llSetRot(newRot2*newRot);
}
}
no_sensor()
{
}
}
XY平面上でのX軸(単位ベクトル<1,0,0>)からの回転(水平回転)
rotation newRot=llRotBetween(<1,0,0>,<norm.x,norm.y,0>);
垂直回転
rotation newRot2=llEuler2Rot(<0,llAcos(norm.z)-PI/2.0,0>);
回転実行(順番が大事)
llSetRot(newRot2*newRot);
だいぶシンプルになりました。が、相変わらず思考はvector。。。^^;
ホントにいいのかな、これで。。(笑
対空砲の動きをする箱の中身
default
{
state_entry()
{
llSensorRepeat("","",AGENT|ACTIVE,30,PI,0.1);
}
sensor(integer detectedNum)
{
if (llDetectedKey(0)==llGetOwner() && llDetectedKey(0)!=NULL_KEY)
{
vector targetVector=llDetectedPos(0)-llGetPos();
vector norm=llVecNorm(targetVector);
rotation newRot=llRotBetween(<1,0,0>,<norm.x,norm.y,0>);
rotation newRot2=llEuler2Rot(<0,llAcos(norm.z)-PI/2.0,0>);
llSetRot(newRot2*newRot);
}
}
no_sensor()
{
}
}
斜面に沿って回転させる
秋祭り開催中(lsl+α:任意形状のあたり判定をする)
lsl 戦車砲をシミュレートする
lsl 連立一次方程式を解く
lsl 多倍長演算
lsl 特定の面のサイズと4隅のリージョン座標を取得する
秋祭り開催中(lsl+α:任意形状のあたり判定をする)
lsl 戦車砲をシミュレートする
lsl 連立一次方程式を解く
lsl 多倍長演算
lsl 特定の面のサイズと4隅のリージョン座標を取得する
Posted by RBK Drachnyd(しお) at 12:12│Comments(0)
│算数