PRIM MATERIAL/fr

From Second Life Wiki
< PRIM MATERIAL
Revision as of 12:54, 19 June 2008 by Gally Young (talk | contribs) (Localized to french)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

Constante: integer PRIM_MATERIAL = 2;
tutorial video sur les matières

<videoflash>6OXYO61kQCA</videoflash>

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 ]
• integer matière

Lorsque ce code est utilisé avec llSetPrimitiveParams & llSetLinkPrimitiveParams

llGetPrimitiveParams

llGetPrimitiveParams([ PRIM_MATERIAL ]);

Renvoie un list [ integer matière ]

• integer matière

Articles connexes

Constantes

codes matière Description
PRIM_MATERIAL_STONE 0 pierre
PRIM_MATERIAL_METAL 1 métal
PRIM_MATERIAL_GLASS 2 verre
PRIM_MATERIAL_WOOD 3 bois
PRIM_MATERIAL_FLESH 4 chair
PRIM_MATERIAL_PLASTIC 5 plastique
PRIM_MATERIAL_RUBBER 6 caoutchouc
PRIM_MATERIAL_LIGHT 7 lumineux, DESACTIVE: Renvoyait le même résultat que [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ]

Fonctions

•  llSetPrimitiveParams Permet de modifier les paramètres d'une prim.
•  llSetLinkPrimitiveParams Permet de modifier les paramètres d'une prim liée.
•  llGetPrimitiveParams Permet d'obtenir les paramètres d'une prim

Evénement

•  changed Evènement généré lors de la modification d'une prim.

Exemples

<lsl>// © 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();
       }
   }

}</lsl>