Subscribe to
Posts
Comments

多餘的程式碼

自己的日文程度不好的原故,

反覆揣摩老師繭羅小姐講過的話,

到今天才發現自己還蠻多地方寫錯了^^;

將一些無用的程式碼寫了進去.

LSL是沒我想像的那麼笨吧.(笨的是我吧,哈哈哈^^)

將今天修改的版本在Post一次.

//*****************************************************
//***   JH-Auto-Chair-Generate Table Ver. 0901      ***
//*****************************************************
// For LSL programming practice. Advisee Teacher : Mayura Johin
//
// Reversion History:
// **** 0826 Functional method
// **** 0901 Remove unnecesary code
//

// Known Bugs:
//
// System variables
vector DeskPos;
vector AgentPos;
float DeltaX;
float DeltaY;
float Theta;
float NewX;
float NewY;
rotation rot;

// Functions 

Pos_Detect()
{
    DeskPos = llGetPos();
    AgentPos = llDetectedPos(0);
    DeltaX = AgentPos.x - DeskPos.x;
    DeltaY = AgentPos.y - DeskPos.y;
}

Angle_Calculator(float DX,float DY)
{
    Theta = llAtan2(DeltaY,DeltaX) * RAD_TO_DEG;
}

New_Pos(float TA, float Radious)
{
    NewX =  Radious * llCos(TA * DEG_TO_RAD);
    NewY =  Radious * llSin(TA * DEG_TO_RAD);
}

Deg_To_Rot(float TA, vector Off_Rot)
{
    vector e_deg = <0, 0, (TA)> + Off_Rot;
    vector e_rad = e_deg * DEG_TO_RAD;
    rot = llEuler2Rot(e_rad);
}
Rez_Object(string Obj_Name,vector Offset)
{
    llRezAtRoot(Obj_Name, DeskPos + <(NewX),(NewY),0> + Offset, ZERO_VECTOR, rot , 0);
}
       
Display_Word(string display_word)
{
  llSetText(display_word,<1.0,1.0,0.0>,0.5);
}

// Main Part
default
{
    state_entry()
    {
        Display_Word(”Touch to rez chair\nVersion:0901″);
    }

    touch_start(integer total_number)
    {
        Pos_Detect();                           //====== To call Position Detector =========
       
        Angle_Calculator(DeltaX,DeltaY);        //====== To call Angle Calculate Engine =========

        New_Pos(Theta,1.5);                     //====== To call New Chair Position Calculate Engine =========

        Deg_To_Rot(Theta,<0,0,180>);                      //====== To call Deg to rot transfer =========

        Rez_Object(”JH-Chair-(Temp)”,<0,0,-0.28>);        //====== Chair Rezzer =========
    }
}

Leave a Reply