sphere.mesh

48 views
Skip to first unread message

KUMAR SIDDHANT

unread,
Jun 29, 2013, 2:42:27 PM6/29/13
to python-ogre...@googlegroups.com
how to change the radius in sphere.mesh to a knowing value....say 250 units.???

dermont

unread,
Jun 29, 2013, 7:15:12 PM6/29/13
to python-ogre...@googlegroups.com
There are a couple of ways you can do this, try using the entities bounding box, taking into account the padding factor and current scenode scale.

There is probably an easier way of doing this and I haven't tested the code, if you still encounter problems let us know.

    def _scaleEntity(self, entity, scale):

        node = entity.getParentSceneNode()
        #worldboundingbox = entity.getWorldBoundingBox(True).getSize()
        worldboundingbox = entity.getBoundingBox().getSize()*node._getDerivedScale()
        ## avoid rounding errors, default is 0.01
        padfactor = "%.4f" % (ogre.MeshManager.getSingleton().getBoundsPaddingFactor())
        ## get half extents without padding factor
        halfextents = worldboundingbox /(1.0 + 2*float(padfactor)) / 2.0
        node.setScale(node._getDerivedScale() *(scale/halfextents))

    def _createScene(self):
        .....
        radius = 25
        self._scaleEntity(entity, ogre.Vector3(radius,radius,radius))

KUMAR SIDDHANT

unread,
Jun 29, 2013, 10:06:45 PM6/29/13
to python-ogre...@googlegroups.com
Yeah dermont...this code works...thanks a lot!!!

Kumar Siddhant
BTech 3rd year undergraduate
Electrical Engineering Dept.
NIT Rourkela
Reply all
Reply to author
Forward
0 new messages