Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches

Detailed Description

Move an element from the server by changing only its transformation.

One box stands still. Every 1.5 s the other is moved by SetTransMatrix(), which streams only the new matrix. The client moves the object it already has and rebuilds no geometry.

#include <ROOT/REveBox.hxx>
#include <TTimer.h>
#include <TMath.h>
using namespace ROOT::Experimental;
class REveTransMover : public TTimer {
// clang-format off
REveElement *fEl{nullptr};
int fStep{0};
// clang-format on
public:
REveTransMover(REveElement *el, Long_t ms) : TTimer(ms, kTRUE), fEl(el) {}
Bool_t Notify() override
{
t.SetPos(30.0 * TMath::Sin(0.4 * fStep), 0.0, 0.0);
fEl->SetTransMatrix(t.Array()); // a transformation-only change
++fStep;
Reset();
return kTRUE;
}
};
static REveBox *make_box(const char *name, Color_t col, Float_t a, Float_t z)
{
auto b = new REveBox(name);
b->SetMainColor(col);
b->SetMainTransparency(0);
// clang-format off
b->SetVertex(0, -a, -a, z - a); b->SetVertex(1, -a, a, z - a);
b->SetVertex(2, a, a, z - a); b->SetVertex(3, a, -a, z - a);
b->SetVertex(4, -a, -a, z + a); b->SetVertex(5, -a, a, z + a);
b->SetVertex(6, a, a, z + a); b->SetVertex(7, a, -a, z + a);
// clang-format on
return b;
}
void trans_update()
{
auto eveMng = REveManager::Create();
eveMng->AllowMultipleRemoteConnections(false, false);
auto still = make_box("Still", kCyan, 10, -20);
eveMng->GetEventScene()->AddElement(still);
auto mover = make_box("Mover", kMagenta, 10, 20);
// Give the box a transformation from the start, so the first stream already
// carries its matrix.
mover->InitMainTrans();
eveMng->GetEventScene()->AddElement(mover);
eveMng->Show();
(new REveTransMover(mover, 1500))->TurnOn();
}
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
short Color_t
Color number (short)
Definition RtypesCore.h:100
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
@ kMagenta
Definition Rtypes.h:66
@ kCyan
Definition Rtypes.h:66
char name[80]
Definition TGX11.cxx:142
3D box with arbitrary vertices (cuboid).
Base class for REveUtil visualization elements, providing hierarchy management, rendering control and...
RAII guard for locking Eve manager (ctor) and processing changes (dtor).
REveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:162
Bool_t Notify() override
Notify when timer times out.
Definition TTimer.cxx:148
Namespace for ROOT features in testing.
Definition TROOT.h:100
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:601
Author
Matevz Tadel

Definition in file trans_update.C.