Replacement for mBounds.point

Expanding and utilizing the engine via C++.
4 posts Page 1 of 1
Posts: 25
Joined: Tue Mar 01, 2016 11:39 pm
by Tiel » Fri Dec 09, 2016 3:46 pm
A resource I'm trying to port has the lines
// projected point
	mPtScreen = mPtProj;

	// alignment offset
	mPtScreen += offsetAlign;

	// screen offset
	mPtScreen += mOffsetScreen;
	// setTrgPosition(mPtScreen);
Problem being mBounds is private as of a few years ago. I'm not even going to pretend I'm comfortable with C++, but from what I've gathered this last line is to set the position of the control via mBounds.point (which is the topleftcorner of a ctrl to the best of my knowledge, forgive my ignorance). So getExtent() or getBounds, the replacement for retrieving extents with mBounds, wouldn't exactly work here, as those are functions that return a value, not the other way around.

Getting to the point, is there a replacement for mBounds.point?
Posts: 957
Joined: Tue Feb 03, 2015 9:49 pm
by JeffR » Fri Dec 09, 2016 5:05 pm
If you're only trying to set the position of the gui control, you should be able to just call setPosition(mPtScreen);

if you poke through gui/core/guiControl.h, that's the header of the root gui object class, and that sucker has a ton of useful utility functions for doing basic stuff like this.

Lemme know if that doesn't work, but that should do what you need.
Posts: 25
Joined: Tue Mar 01, 2016 11:39 pm
by Tiel » Sat Dec 10, 2016 12:13 am
Okay, that seemed to please it.

Although, if I might go offtopic, I've also been trying to get this guy to work: ... ead/107847
// If we're mounted to them, don't give them anything!  
   ShapeBase* obj = this;  
      if((SceneObject*)obj->getObjectMount() == convex->getObject())  
         obj = obj->getObjectMount();
This displeases the compiler:

error C2440: '=' : cannot convert from 'SceneObject *' to 'ShapeBase *'

What I'm trying to do is mount staticshapes to an AIPlayer but it sounds like the collision's immobilizing them.
Posts: 957
Joined: Tue Feb 03, 2015 9:49 pm
by JeffR » Wed Dec 14, 2016 4:41 am
That'd be because getObjectMount() returns a sceneObject, which isn't necessarily a ShapeBase object.

You'll either want your initial ShapeBase* obj = this; to instead read SceneObject* obj = this;, so you can handle ANY scene object that may be mounted, or if you just assume the only things you'll be mounting are other ShapeBase objects, you can turn that last line into:

Code: Select all

obj = dynamic_cast<ShapeBase*>(obj->getObjectMount());
Which will try casting obj to a ShapeBase. If one of the mounted objects isn't a shapebase or derived from it, that approach could cause problems/crashes though, so be wary.
4 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests