From Second Life Wiki
PRIM_MATERIAL
Description
Constante: integer PRIM_MATERIAL = 2;
La constante PRIM_MATERIAL de type integer a la valeur 2
Change la matière de la prim. La matière n'influe pas sur la masse mais modifie les frottements, l'élasticité et les sons de collision. Sur une planche en bois inclinée de 33 degrés, le script ci dessous donne les résultats suivants :
Tableau donnant la vitesse max et la distance parcourue sur le plan incliné.
| Type
| Velocity (m/s)
| Distance (m)
|
| Pierre
| 0.453181
| 0.361655
|
| Métal
| 5.475444
| 10.211180
|
| Verre
| 6.483150
| 11.678304
|
| Bois
| 2.154549
| 9.433724
|
| Chair
| 0.351543
| 0.188043
|
| Plastique
| 4.502428
| 9.590952
|
| Caoutchouc
| 0.374964
| 0.187106
|
llSetPrimitiveParams
[ PRIM_MATERIAL, integer matière ]
llGetPrimitiveParams
llGetPrimitiveParams([ PRIM_MATERIAL ]);
Renvoie un list [ integer matière ]
| • integer
| matière
| –
| codes PRIM_MATERIAL_*
|
|
Articles connexes
Constantes
Fonctions
Evénement
| •
| changed
| –
| Evènement généré lors de la modification d'une prim.
|
|
Exemples
// © 2008 par Karzita Zabaleta
// Auteur de Scripting Your World, Wiley, October 2008.
list gMaterialTypes = [
"STONE",
"METAL",
"GLASS",
"WOOD",
"FLESH",
"PLASTIC",
"RUBBER"
];
vector gHomePosition;
rotation gHomeRotation;
integer gWaitCount = 0;
float gMaxVelMag;
integer gPrimMaterial;
moveTo(vector origin, vector destination) {
float dist = llVecDist(origin, destination);
integer passes = llCeil( llLog(dist/10.0) / llLog(2.0) );
integer i;
list params = [PRIM_POSITION, destination];
for (i=0; i<passes; i++) {
params = (params=[]) + params + params;
}
// Bouge la prim.
llSetPrimitiveParams(params);
}
returnHome()
{
llSetStatus(STATUS_PHYSICS, FALSE);
moveTo(llGetPos(),gHomePosition);
llSetTimerEvent(0);
llSetRot(gHomeRotation);
}
calculate_velocity()
{
float velMag = llVecMag(llGetVel());
if (velMag > gMaxVelMag) {
gMaxVelMag = velMag;
}
}
default
{
state_entry() {
gHomePosition = llGetPos();
gHomeRotation = llGetRot();
}
on_rez(integer _n) {
llResetScript();
}
touch_start(integer n) {
gMaxVelMag = 0;
llSetPrimitiveParams([PRIM_MATERIAL, gPrimMaterial]);
llSetStatus(STATUS_PHYSICS,TRUE);
llSetTimerEvent(0.1);
llResetTime();
gWaitCount=0;
gPrimMaterial++;
if (gPrimMaterial == 7 ) gPrimMaterial = 0;
}
timer() {
calculate_velocity();
gWaitCount++;
if (gWaitCount > 100) { // 10 seconds
string type = llList2String( gMaterialTypes, gPrimMaterial-1 );
llOwnerSay(type+" Vitesse max : "+(string)gMaxVelMag+
" & distance max : "+(string)llVecDist(llGetPos(), gHomePosition)+" mètres.");
returnHome();
}
}
}