Jump to content

subabrain

Members
  • Posts

    194
  • Joined

  • Last visited

Posts posted by subabrain

  1. Hello Again,


    this is the last question i have :)


    i get the following if i do some actions with the terrain painter.


    i get some groundcover and paint a material on the ground and now there is some graphical problem it always stucks a little bit and the groundcover will disappear for a moment.


    It would be nice if you could help me to solve this problem :)


    Greetings

    Robert

  2. hi,


    yes i tried this already - i think its from the player class?


    So i tried this with included the player.h :( :


    Player *pl = new Player();

    Point3F pos = pl->getPosition();


    but its not the active position it always goes to point 0.000 0.000 100.000 :/


    maybe you know why?


    thx and greetz!

    Robert

  3. Okay now,


    i get it 8-)



    So for change the groundcover (here the terrain Material which can layered by Groundcover) from torquescript do the following (without c++):



    go to the file "EditorGui.ed.gui" in the folder "tools/worldEditor/gui" and change the line:

     

    processUsesBrush = "0";

     

    into

     

    processUsesBrush = "1";

     

    then go to "scripts/server/" and create a File - name it "grass.cs" with the following content:

     

    function grass(%this) {
     
       //Make the size of the brush
       ETerrainEditor.setBrushSize(2, 2);
     
       //Set the Shape of the brush
       ETerrainEditor.setBrushType("box");
     
       //Change "grass1" to the material you like
       %matIndex = ETerrainEditor.getMaterialIndex( "grass1" );
     
       //Change "test" to a terrain id you like
       ETerrainEditor.setPaintMaterial(%matIndex, "test"); 
     
       //%curPos = LocalClientConnection.Player.getPosition();
     
       //%x = getword(%curPos, 0);  
       //%y = getword(%curPos, 1);  
       //%pZ = getword(%trans, 2);   
     
       //ETerrainEditor.processAction(%pX, %pY, %pZ, "paintMaterial");
     
       //ETerrainEditor.setBrushPos(getWord(%curPos, 0) + %x, getWord(%curPos, 1) + %y);
     
       //Run the thing
       ETerrainEditor.processAction("paintMaterial");
       //$eventID = schedule(230,0,grass); 
     
    }

     

    please recognize that the Comments are important for make the brush pos to the player ...


    Then add a entry in "scriptExec.cs" with the folder "scripts/server/" somewhere in the file:

     

    ...
    exec("./grass.cs");
    ...

     

    Okay now you can add a material texture with run the command "grass();"

    in the console (can be opened with "^" in game).


    There is a thing to get the Ground of the Player to be changed ->


    From C++ it works with some arguments...


    But it should do it also with the TorqueScript -> therefore is a function:

     

    %curPos = LocalClientConnection.Player.getPosition();
     
       %x = getword(%curPos, 0);  
       %y = getword(%curPos, 1);  
       //%pZ = getword(%trans, 2);  
     
    ETerrainEditor.setBrushPos(getWord(%curPos, 0) + %x, getWord(%curPos, 1) + %y);

     

    But its not working in my case :/


    I get the following error:

     

    scripts/server/grass.cs (19): ETerrainEditor::setBrushPos - wrong number of arguments (got 4, expected min 3 and max 3).

     

    maybe someone could help me here :roll:



    but thats the way how to do it without C++ ;)


    Greetings

    Robert


    PS: As soon as it works perfect ill make a bigger tutorial - but i think im not getting it without c++ :roll:

  4. Hello there,


    okay - its almost perfect - just have to move the brush position - but its working:

     

    //Set the Brush size here - not necessary
     ETerrainEditor.setBrushSize(30, 30);
     
    //Read the index from a specific material - in this case the material with name "sand"
       %matIndex = ETerrainEditor.getMaterialIndex( "sand" );
     
    //Here set the paint material and paint it - "test" is in this case the name of your terrain
       ETerrainEditor.setPaintMaterial(%matIndex, "test" ); 
       ETerrainEditor.processAction("paintMaterial");

     

    i hope i could help you 8-)


    the only thing to do is the brush position .... but thats all you need - you dont have to make anything with c++ ;)



    so thanks a lot!


    Greetings Robert

  5. Hey,


    here a cool thing - this is the solution:

     

    void TerrainEditor::processAction(const char* sAction)
    {
       if(!checkTerrainBlock(this, "processAction"))
          return;
     
       TerrainAction * action = mCurrentAction;
       if (dStrcmp(sAction, "") != 0)
       {
          action = lookupAction(sAction);
     
          if(!action)
          {
             Con::errorf(ConsoleLogEntry::General, "TerrainEditor::cProcessAction: invalid action name '%s'.", sAction);
             return;
          }
       }
     
       if(!getCurrentSel()->size() && !mProcessUsesBrush)
          return;
     
       mUndoSel = new Selection;
     
       Gui3DMouseEvent event;
       if(mProcessUsesBrush)
          action->process(mMouseBrush, event, true, TerrainAction::Process);
       else
          action->process(getCurrentSel(), event, true, TerrainAction::Process);
     
       // check if should delete the undo
       if(mUndoSel->size())
          submitUndo( mUndoSel );
       else
          delete mUndoSel;
     
       mUndoSel = 0;
    }

     

    this code makes all you need!


    and call it from torque script like this:

     

    ETerrainEditor.processAction("paintMaterial");

     

    but it needs some specific things i didnt know at the moment but it has to do like this!



    So stay tuned and good luck!!!



    Greetings

    Robert

  6. Hi Guys,


    after working endless i found the key function... how to change material on a specific Position - but im not ready now with it ...

     

    void TerrainEditor::on3DMouseDown(const Gui3DMouseEvent & event)
    {   
       getRoot()->showCursor( false );
     
       if(mTerrainBlocks.size() == 0)
          return;
     
       if (!dStrcmp(getCurrentAction(),"paintMaterial"))
       {
          Point3F pos;
          TerrainBlock* hitTerrain = collide(event, pos);
     
          if(!hitTerrain)
             return;
     
          // Set the active terrain
          bool changed = mActiveTerrain != hitTerrain;
          mActiveTerrain = hitTerrain;
     
          if (changed)
          {
             Con::executef(this, "onActiveTerrainChange", Con::getIntArg(hitTerrain->getId()));
             mMouseBrush->setTerrain(mActiveTerrain);
             //if(mRenderBrush)
                //mCursorVisible = false;
             mMousePos = pos;
     
             mMouseBrush->setPosition(mMousePos);         
     
             return;
          }
       }
       else if ((event.modifier & SI_ALT) && !dStrcmp(getCurrentAction(),"setHeight"))
       {
          // Set value to terrain height at mouse position
          GridInfo info;
          getGridInfo(mMouseBrush->getGridPoint(), info);
          mSetHeightVal = info.mHeight;
          mBrushChanged = true;
          return;
       }
     
       mMousePlane.set( mMousePos, Point3F(0,0,1) );
       mMouseDown = true;
     
       mSelectionLocked = false;
     
       mouseLock();
       mMouseDownSeq++;
       mUndoSel = new Selection;
       mCurrentAction->process(mMouseBrush, event, true, TerrainAction::Begin);
       // process on ticks - every 30th of a second.
       Sim::postEvent(this, new TerrainProcessActionEvent(mMouseDownSeq), Sim::getCurrentTime() + 30);
     
    }

     

    now i just have to get it running :)


    if you can help me please answer 8)



    Greetings

    Robert

×
×
  • Create New...