change groundcover via script

There are no stupid questions, just stupid answers.
  • 1
  • 4
  • 5
  • 6
  • 7
  • 8
74 posts Page 6 of 8
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Mon Sep 18, 2017 6:01 pm
hi there,


here a little video of my try on changing groundcover with torque 3d:

https://www.youtube.com/watch?v=obYls7lnc-8

its not finished - just an idea from me.

what i need is to set the player to the position of the brush :)

thanks a lot!

greetings
Robert

PS: im not klicking anything - it shows the material automatically by code - im just moving around with the view ;)
JeffR
Steering Committee
Steering Committee
Posts: 757
Joined: Tue Feb 03, 2015 9:49 pm
 
by JeffR » Thu Sep 21, 2017 3:52 pm
Very nice, dude!
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Fri Sep 22, 2017 7:40 pm
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
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sat Sep 23, 2017 1:50 pm
Hi again,


okay it seems to do the job - but i have a littl Problem.

"SuperType": Ist kein Element von "Gui3DMouseEvent"

what does this mean?


Thank you very much!

Greetings Robert
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sat Sep 23, 2017 10:16 pm
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
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
  by subabrain » Sun Sep 24, 2017 2:05 pm
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
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sun Sep 24, 2017 6:15 pm
hi,

sorry but i have a little problem with this solution...
its only working with the active TerrainEditor ... :/

please help me ...

thanks and stay tuned!
Robert
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Mon Sep 25, 2017 6:05 pm
Hello Friends,

this is the last Post of getting the stuff to work - this is my solution to view:

https://youtu.be/mFWtS1sQfnE

If you need help - just ask ;)

Greetz
Robert
JeffR
Steering Committee
Steering Committee
Posts: 757
Joined: Tue Feb 03, 2015 9:49 pm
 
by JeffR » Mon Sep 25, 2017 7:36 pm
Sorry, I hadn't seen your message yesterday, though I'm glad you got it working!

If you can, I'd say go ahead and make a thread in the Resources area with your changes in case someone else wants a similar effect :)
subabrain
Posts: 134
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Mon Sep 25, 2017 8:06 pm
Hi,

yes i would do a little tutorial but first i have to modify it a little bit ;)

greetz
Robert
  • 1
  • 4
  • 5
  • 6
  • 7
  • 8
74 posts Page 6 of 8

Who is online

Users browsing this forum: No registered users and 2 guests