change groundcover via script

There are no stupid questions, just stupid answers.
  • 1
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
74 posts Page 5 of 8
Bloodknight
Posts: 94
Joined: Tue Feb 03, 2015 8:58 pm
by Bloodknight » Mon Jul 24, 2017 12:58 am
look for TerrainEditor::autoMaterialLayer in terrainEditor.cpp, this shows how to paint the terrain via code.
subabrain
Posts: 126
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sun Sep 10, 2017 9:59 am
Hello Guys,

sorry for the long delay but i dont get it :/

i tried all things - to manipulate the c++ methods and try to search for solutions but i dont get it!

i now get it to execute c++ functions with torque 3d but they dont get it to run -> for example:

---------------------------------------------------------------------------------------------------------------------------

grass.cpp

#include "grass.h"
#include "console/simBase.h"
#include "console/console.h"
#include "gui/worldEditor/terrainEditor.h"
#include "gui/worldEditor/terrainActions.h"

IMPLEMENT_CONOBJECT(grass);

void grass::set_grass()
{

TerrainEditor *edit = new TerrainEditor();

edit->autoMaterialLayer(-10000, 10000, 0, 90, 100);

}


---------------------------------------------------------------------------------------------------------------------------


grass.h

#ifndef _SIMBASE_H_  
#include "console/simBase.h"
#include "gui/worldEditor/terrainEditor.h"
#endif

class grass : public SimObject

private:
typedef SimObject Parent;

public:
grass() { grass::set_grass(); }
virtual ~grass() {}
virtual void set_grass();

DECLARE_CONOBJECT(grass);
};

---------------------------------------------------------------------------------------------------------------------------

And the TorqueScript:
grass.cs

function grasses() {

%obj = new grass();
%obj.set_grass();

}


---------------------------------------------------------------------------------------------------------------------------

okay - but i just need to now how i can paint the material on a certain position :roll:

please help me - thx a lot!


Greetings - Robert!
subabrain
Posts: 126
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Wed Sep 13, 2017 5:16 pm
Duion wrote:Then it will probably be in the C++ source code.
I looked it up for you and it may be this one:
https://github.com/GarageGames/Torque3D ... #L197-L247


i think this is the key - but how to execute this method?

i tried to make an instance and all the method ... but whats with the arguments?

please help me -.-


Greetz
Robert
Duion
Posts: 832
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Thu Sep 14, 2017 10:50 am
The arguments are named, you pass them along when you use the function.
If you miss arguments you usually get an error message like "invalid number of arguments got 2 expected 3" etc.
If you use debug mode in Visual Studio you can even see the data that is passed along with the function.
JeffR
Steering Committee
Steering Committee
Posts: 755
Joined: Tue Feb 03, 2015 9:49 pm
 
by JeffR » Thu Sep 14, 2017 4:18 pm
If that's the whole code for your object, you still need a consoleMethod definition so the script system knows what the function is

Similar to [ur=]https://github.com/GarageGames/Torque3D/blob/development/Engine/source/T3D/shapeBase.cpp#L4936-L4947lthis,[/url] you would do something like:

DefineEngineMethod( grass, set_grass, void, (),,
"@Paints some grass.\n\n" )
{
object->set_grass();
}


What this does, is informs the script engine that objects of the 'grass' class have a function called set_grass() that can be called. When it's called, the above is executed by the script engine. So it'll take object(which is automatically the class of the first argument in the DefineEngineMethod function - in this case, "grass" - and then we call set_grass for it.

2 minor nitpicks from your examples I spotted(just to encourage good habits ;) ) you wouldn't want to have the grass::set_grass() call in the constructor. The method isn't static for one thing. Secondly, set_grass doesn't need to be virtual unless you plan to have classes inherit from grass and also have their own set_grass() function. You can leave that as a regular old function, since we'll be calling it through the DefineEngineMethod stuff :)
subabrain
Posts: 126
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Thu Sep 14, 2017 10:23 pm
Hello,

first - thanks alot for your help - i did the steps you told.
Its working like you said. but how can i get these arguments in the method:

void PaintMaterialAction::process(Selection * sel, const Gui3DMouseEvent &, bool selChanged, Type)

?

Okay - gn8 ;)

Greetz Robert
subabrain
Posts: 126
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Fri Sep 15, 2017 10:39 pm
Hello Friends,

okay now i found something useful

http://abighole.hngamers.com/terrainDeformer.zip

i hope i get it with this one ;)

greetz
Robert :D
Azaezel
Posts: 384
Joined: Tue Feb 03, 2015 9:50 pm
 
by Azaezel » Sat Sep 16, 2017 1:20 am
You won't. The terrain has undergone 3 revisions since then. Though the general principles do still apply.
subabrain
Posts: 126
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sat Sep 16, 2017 9:47 am
Hi,

omg - what shall i do now?

sorry for penetrating you but i am at the end of my knowledge :?

please help!


greetings
Robert
subabrain
Posts: 126
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sun Sep 17, 2017 2:46 pm
Hello,

i have a plan now - i let you know if its ready ;)

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

Who is online

Users browsing this forum: No registered users and 1 guest