セカンドライフでタッチしたプリムの情報を取得する

セカンドライフ制作
スポンサーリンク

はじめに

セカンドライフでプリムをクリックしたときにどこの位置を触ったのか、
といった情報をずらーっと出してみるサンプルです。

サンプル

とにかくいろいろ情報を取得してみます。
全部表示すると訳が分からなくなるのでちょっと表示しています。
ちなみに、テクスチャのUUIDに関しては権限を持っていないと取得できません。

integer	detected_link		= 0;
integer	detected_face		= 0;
vector	detected_touch_pos	= ZERO_VECTOR;
vector	detected_touch_uv	= ZERO_VECTOR;

integer	selected_link		= 0;
integer	selected_face		= 0;
vector	selected_touch_pos	= ZERO_VECTOR;
vector	selected_touch_uv	= ZERO_VECTOR;
string	selected_name;
string	selected_description;
vector	selected_position;
rotation selected_rotation;
vector	selected_size;
string	selected_texture_name;
vector	selected_texture_repeats;
vector	selected_texture_offsets;
float	selected_texture_rotation_in_radians;
vector	selected_color;
float	selected_alpha;
integer	selected_isfullbright;
float	selected_intensity;
string	selected_normal_name;
vector	selected_normal_repeats;
vector	selected_normal_offsets;
float	selected_normal_rotation_in_radians;
string	selected_specular_name;
vector	selected_specular_repeats;
vector	selected_specular_offsets;
float	selected_specular_rotation_in_radians;
vector	selected_specular_color;
integer	selected_specular_glossiness;
integer	selected_specular_environment;
integer	selected_alpha_mode;
integer	selected_mask_cutoff;

setSelected(integer target_link, integer target_face, vector target_touch_pos, vector target_touch_uv) {
	integer num = 0;
	list x = llGetLinkPrimitiveParams(target_link,
		[
			PRIM_NAME,						// string name
			PRIM_DESC,						// string description
			PRIM_POS_LOCAL,					// vector position
			PRIM_ROT_LOCAL,					// rotation rot
			PRIM_SIZE,						// vector size
			PRIM_TEXTURE, target_face,		// string texture, vector repeats, vector offsets, float rotation_in_radians
			PRIM_COLOR, target_face,		// vector color, float alpha
			PRIM_FULLBRIGHT, target_face,	// integer boolean
			PRIM_GLOW, target_face,			// float intensity
			PRIM_NORMAL, target_face,		// string texture, vector repeats, vector offsets, float rotation_in_radians
			PRIM_SPECULAR, target_face,		// string texture, vector repeats, vector offsets, float rotation_in_radians, vector color, integer glossiness integer environment
			PRIM_ALPHA_MODE, target_face	// integer alpha_mode, integer mask_cutoff 
		]
	);
	selected_link			= target_link;
	selected_face			= target_face;
	selected_touch_pos		= target_touch_pos;
	selected_touch_uv		= target_touch_uv;
	selected_name			= llList2String(x, num++);
	selected_description	= llList2String(x, num++);
	selected_position		= llList2Vector(x, num++);
	selected_rotation		= llList2Rot(x, num++);
	selected_size			= llList2Vector(x, num++);
	selected_texture_name					= llList2String(x, num++);
	selected_texture_repeats				= llList2Vector(x, num++);
	selected_texture_offsets				= llList2Vector(x, num++);
	selected_texture_rotation_in_radians	= llList2Float(x, num++);
	selected_color							= llList2Vector(x, num++);
	selected_alpha							= llList2Float(x, num++);
	selected_isfullbright					= llList2Integer(x, num++);
	selected_intensity						= llList2Float(x, num++);
	selected_normal_name					= llList2String(x, num++);
	selected_normal_repeats					= llList2Vector(x, num++);
	selected_normal_offsets					= llList2Vector(x, num++);
	selected_normal_rotation_in_radians		= llList2Float(x, num++);
	selected_specular_name					= llList2String(x, num++);
	selected_specular_repeats				= llList2Vector(x, num++);
	selected_specular_offsets				= llList2Vector(x, num++);
	selected_specular_rotation_in_radians	= llList2Float(x, num++);
	selected_specular_color					= llList2Vector(x, num++);
	selected_specular_glossiness			= llList2Integer(x, num++);
	selected_specular_environment			= llList2Integer(x, num++);
	selected_alpha_mode						= llList2Integer(x, num++);
	selected_mask_cutoff					= llList2Integer(x, num++);
}

showSelectedData() {
	llOwnerSay(
		"linknum: "		+ (string)selected_link + ", " + 
		"facenum: "		+ (string)selected_face + "\n" +
		"linkpos: "		+ (string)selected_position + "\n" +
		"linksize: "	+ (string)selected_size + "\n" +
		"color: "		+ (string)selected_color + "\n" +
		"alpha: "		+ (string)selected_alpha + "\n" +
		"texture: "		+ (string)selected_texture_name + "\n" +
		"normal: "		+ (string)selected_normal_name + "\n" +
		"specular: "	+ (string)selected_specular_name + "\n" + 
		"touchuv: "		+ (string)selected_touch_uv + "\n" +
		"touchpos: "	+ (string)selected_touch_pos + "\n" +
		""
	);
}

touchStart() {
	// 押した場所を確認
	setSelected(detected_link, detected_face, detected_touch_pos, detected_touch_uv);
	showSelectedData();
}

default {
	
	touch_start(integer num_detected){
		detected_link		= llDetectedLinkNumber(0);
		detected_face		= llDetectedTouchFace(0);
		detected_touch_pos	= llDetectedTouchPos(0);
		detected_touch_uv	= llDetectedTouchUV(0);
		touchStart();
	}
	
}

 

コメント

タイトルとURLをコピーしました