Getting/Setting with GeDialog
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/04/2011 at 11:19, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;---------
Hi,I'm having a problem with the get method in C++ and the GeDialog class.
Most people are using the .res way of creating dialogs. So I'm having a hard time learning how to use the AddGizmo type of dialogs wit C++.Here's my code:
This works fine
Bool myDialog::CreateLayout(void) { AddSlider(MySlider, BFH_SCALEFIT); return TRUE; }
This works fine
Bool myDialog::InitValues(void) { SetReal(MySlider, 0.0,1,1e3,1.0); return TRUE; }
This Is where I'm stuck --I don't know how to get the values from my gizmo's
Bool myDialog::Command(LONG id,const BaseContainer &msg) { Real slidervalue = GetReal(MySlider); // <---This is wrong GePrint(RealToString(slidervalue)); return TRUE; }
Can anyone show me the proper way to get the values from of a gizmo?
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/04/2011 at 11:53, xxxxxxxx wrote:
hello you have to filter by id valus passed by commad ....
switch (id)
{
case YourSliderID:
Real value;
GetReal(YourSliderID,value);
break;
}Franz
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/04/2011 at 15:02, xxxxxxxx wrote:
Ah ha!
So that's what they meant by: GetReal(MyID, value); in the SDK.
I didn't understand what they were trying to say. I thought they were telling me to put the actual value in there. And that made no sense to me, because If I knew the value, I wouldn't be using the Getter in the first place.The way you wrote it. I can now see clearly that what they meant was to create and use an empty variable to hold the value that the getter finds.
Thanks!
-ScottA -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/04/2011 at 06:42, xxxxxxxx wrote:
You can tell that "value" is used to pass a value back to you, because it's a reference (recognizable from the "&").
Bool GetReal(const GadgetPtr& id, Real& value) const
Otherwise, it would either not be a reference, or it would be const Real & value.
Cheers,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/04/2011 at 08:29, xxxxxxxx wrote:
Thanks Jack.
I understand how pointers and references work in theory ( they access the memory address of the variables. And they can be use to get around scope limitations).
But when using them in practice with the C4d SDK I'm still rather lost about them most of the time.For example.
Right now I'm trying to convert my Coffee code that moves an object by all of it's points. Because that way I can rotate it and it will always move where it's being pointed.**Working Coffee code** main(doc,op) { var mtx= op->GetMl();//get object's local matrix var move = mtx->GetMulP(vector(0,0,2));//move object by 2 in Z axis a->SetV0(move);//grab the object and execute the move op->SetMl(mtx);// EventAdd();// runs even if timeline is stopped } **C++ version with pointer errors** Matrix mtx = op->GetMl();//<--No errors Vector move = mtx->GetMulP(Vector(0,0,2)); <--- mtx Error: expression must have a pointer type mtx->SetV0(move); // <--- mtx Error: expression must have a pointer type op->SetMl(mtx); //<--- No errors
I'm stuck because I really don't understand how to use pointers properly related to the C4D SDK.
The pointer tutorials on the net all talk about the abstract theory(which I think I understand) of pointers.
But what I really need is an explanation of how they work specifically for the C4D SDK code.
Not the abstract explanations I see on the net.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/04/2011 at 10:58, xxxxxxxx wrote:
mtx isn't a pointer but an instance. Use '.' instead of '->':
**C++ version with pointer errors** Matrix mtx = op->GetMl();//<--No errors Vector move = mtx.GetMulP(Vector(0,0,2)); <--- mtx No Errors mtx.SetV0(move); // <--- mtx No Errors op->SetMl(mtx); //<--- No errors
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/04/2011 at 12:05, xxxxxxxx wrote:
Thanks Robert,
It seems that GetMulP is a Coffee only function. And handling matrices is done differently with Python and C++.
I don't think I'll be able to figure out how to do things like multiplying a matrix and moving object points in global and local space from what's in the C++ SDK.
I was just starting to get comfortable with matrix manipulation in Coffee. Then the game changed on me and Python & C++ became the preferred languages to use in C4D.
Now I've got to start all over again from scratch.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/04/2011 at 12:12, xxxxxxxx wrote:
Vector move = Vector(0.0,0.0,2.0) * mtx;
mtx.off = move;C4D uses pre-multiplication for matrices so you'll want operations to be done right to left (to do an ScaleRotateTranslate operation, for instance) :
Matrix xform = MatrixMove() * MatrixRot() * MatrixScale();
As you see there are 'operators' set up for matrix math such as multiplication of matrices or matrix to vector. '!' inverts a matrix:
Matrix m;
Matrix inverse = !m; -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/04/2011 at 12:35, xxxxxxxx wrote:
Oh cool!
Thanks a lot for taking the time to explain that to me Robert. Got it working now.
I'm sure I'll probably still get stuck from time to time with converting my other examples. But at least you've got me started in the right direction.Thanks
-ScottA