//
mesh2custom
Risultati da 1 a 3 di 3

Discussione: mesh2custom

  1. #1

    Post mesh2custom

    Ciao ragazzi,
    sto cercando lo script "mesh2custom" di Bob Hood senza successo. Credevo di averlo visto all'interno di una cartella "Lscript" (o simile) nel disco "Content" ma non c'è traccia né in quello di LW9 né in quello di LW10. Sono completamente suonato?
    Grazie mille a chi può darmi info
    Bye.
    ____________

  2. #2
    Licantropo L'avatar di SlowMan
    Data Registrazione
    May 2008
    Località
    Lugo di Romagna
    Messaggi
    1,790
    Ho trovato qualcosa all'interno dell'help di LW, alla voce Custom Objects, leggibile anche da questo link:

    Lscript -> User Manual -> Custom Objects

    se è quello che cerchi alla fine della pagina si trova il sorgente dello script che segue:

    //-----------------------------------------------
    // Mesh2Custom
    //
    // Convert the mesh in the currently visible
    // layer(s) into a Layout Custom Object LScript
    //

    @warnings
    @version 2.3

    main
    {
    vectors = nil;
    indices = nil;
    pointcount() || error("I need some mesh to work with!");
    reqbegin("Mesh2Custom");
    c1 = ctlfilename("Script file","mycustobj.ls");
    return if !reqpost();
    filename = getvalue(c1);
    reqend();
    // construct the arrays
    editbegin();
    foreach(poly,polygons)
    {
    pnts = polyinfo(poly);
    m = pnts.count();
    for(x = 2;x < m;x++)
    {
    vec1 = pointinfo(pnts[x]);
    vec2 = pointinfo(pnts[x + 1]);
    ndx1 = 0;
    ndx2 = 0;
    if(!vectors)
    {
    // initialize the array
    vectors += vec1;
    vectors += vec2;
    ndx1 = 1;
    ndx2 = 2;
    }
    else
    {
    // find the index for each vector
    // in the array
    for(y = 1;y <= vectors.size();y++)
    {
    if(vectors[y] == vec1)
    ndx1 = y;
    if(vectors[y] == vec2)
    ndx2 = y;
    }
    if(!ndx1)
    {
    vectors += vec1;
    ndx1 = vectors.size();
    }
    if(!ndx2)
    {
    vectors += vec2;
    ndx2 = vectors.size();
    }
    }
    indices += ndx1;
    indices += ndx2;
    }
    }
    editend();

    // optimize the indices by removing duplicate lines
    x = 1;
    while(x <= indices.size())
    {
    if(indices[x])
    {
    y = x + 2;
    while(y <= indices.size())
    {
    if(indices[y])
    {
    if((indices[x] == indices[y] && indices[x+1]
    == indices[y+1]) ||
    (indices[x] == indices[y+1] && indices[x+1]
    == indices[y]))
    {
    indices[y] = nil;
    indices[y+1] = nil;
    }
    }
    y += 2;
    }
    }
    x += 2;
    }
    indices.pack();
    indices.trunc();

    // generate the Custom script from the array data
    file = File(filename,"w") || error("Couldn't open output file!");
    file.writeln("@warnings");
    file.writeln("@version 2.3");
    file.writeln("@script custom"); file.nl();
    file.write("vert = @ ");
    for(x = 1;x <= vectors.size();x++)
    {
    if(x > 1)
    {
    file.writeln(",");
    file.write(" ");

    }
    file.write("<",vectors[x].x,",",
    vectors[x].y,",",vectors[x].z,">");
    }
    file.writeln(" @;"); file.nl();
    file.write("edge = @ ");
    for(x = 1;x <= indices.size();x++)
    {
    if(x > 1)
    {
    file.write(",");
    if(x & 1)
    {
    file.nl();
    file.write(" ");
    }
    }
    file.write(indices[x]);
    }
    file.writeln(" @;"); file.nl();
    file.writeln("process: ca");
    file.writeln("{");
    file.writeln(" for(x = 1;x < ",indices.size() + 1,";x += 2)");
    file.writeln("ca.drawLine(vert[edge[x]], vert[edge[x+1]]);");
    file.writeln("}");
    file.close();
    }

  3. #3
    Potrebbe essere lui! Ora provo.
    Grazie mille SlowMan
    Bye.
    ____________

Segnalibri

Segnalibri

Permessi di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  •