[Solved]How to create RibbonTrail without create MovableObject Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 1

[Solved]How to create RibbonTrail without create MovableObject

Post by niubaty » Thu Jan 10, 2019 2:36 pm

Ogre Version: 1.10
Operating System: win10
Render System: GL3+

This is the original sample code:

Code: Select all

mSwordTrail = (RibbonTrail*)sceneMgr->createMovableObject("RibbonTrail", &params);
I'm using Ogre python binding, which means I do not know how to change MovableObject to RibbonTrail in python way.
I tried to do it this way

Code: Select all

class SwordTrail(Ogre.MovableObject,Ogre.RibbonTrail):
    def __init__(self,name,scn_mgr,numberOfChains,maxElements):
        Ogre.RibbonTrail.__init__(self,name,maxElements,numberOfChains)
        Ogre.MovableObject.__init__(self,name)
and do not work out

Code: Select all

Traceback (most recent call last):
  File "tmp.py", line 672, in <module>
    app.initApp()
  File "tmp.py", line 658, in setup
    self.char=sinbad(self.cam)
  File "tmp.py", line 44, in __init__
    self.setupBody(cam.getSceneManager())
  File "tmp.py", line 67, in setupBody
    self.swordtrail=SwordTrail("RibbonTrail",scn_mgr,2,80)
  File "tmp.py", line 17, in __init__
    Ogre.MovableObject.__init__(self)
TypeError: Cannot create new instances of type 'SwordTrail'
So, is there any ways to bypass that sample code(create a movableobject first and convert to RibbonTrail)
Last edited by niubaty on Mon Jan 14, 2019 3:36 am, edited 1 time in total.
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 835
Joined: Sun Mar 30, 2014 2:51 pm
x 147
Contact:

Re: How to create RibbonTrail without create MovableObject

Post by paroj » Thu Jan 10, 2019 4:36 pm

sceneMgr->createRibbonTrail
0 x

niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 1

Re: How to create RibbonTrail without create MovableObject

Post by niubaty » Fri Jan 11, 2019 2:40 am

paroj wrote:
Thu Jan 10, 2019 4:36 pm
sceneMgr->createRibbonTrail
if you create a RibbonTrail object , you can not use the setVisible() Method of MovableObject

Code: Select all

        self.swordtrail=scn_mgr.createRibbonTrail('RibbonTrail')
        self.swordtrail.setMaxChainElements(80)
        self.swordtrail.setNumberOfChains(2)
        self.swordtrail.setMaterialName('Examples/LightRibbonTrail')
        self.swordtrail.setVisible(True)

Code: Select all

Traceback (most recent call last):
  File "tmp.py", line 677, in <module>
    app.initApp()
  File "tmp.py", line 663, in setup
    self.char=sinbad(self.cam)
  File "tmp.py", line 45, in __init__
    self.setupBody(cam.getSceneManager())
  File "tmp.py", line 75, in setupBody
    self.swordtrail.setVisible(True)
AttributeError: 'Ogre.RibbonTrail' object has no attribute 'setVisible'
0 x

niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 1

Re: How to create RibbonTrail without create MovableObject

Post by niubaty » Fri Jan 11, 2019 2:57 am

This is all the method of Ogre.RibbonTrail

Code: Select all

['TCD_U', 'TCD_V', '__class__', '__cmp__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__hex__', '__init__', '__int__', '__le__', '__long__', '__lt__', '__ne__', '__new__', '__oct__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_timeUpdate', '_updateCustomGpuParameter', '_updateRenderQueue', 'acquire', 'addChainElement', 'addNode', 'append', 'clearAllChains', 'clearChain', 'disown', 'getBoundingBox', 'getBoundingRadius', 'getCastsShadows', 'getChainElement', 'getChainIndexForNode', 'getColourChange', 'getCustomParameter', 'getDynamic', 'getInitialColour', 'getInitialWidth', 'getLights', 'getMaterial', 'getMaterialName', 'getMaxChainElements', 'getMovableType', 'getNodeIterator', 'getNumChainElements', 'getNumWorldTransforms', 'getNumberOfChains', 'getOtherTextureCoordRange', 'getPolygonModeOverrideable', 'getRenderOperation', 'getRenderSystemData', 'getSquaredViewDepth', 'getTechnique', 'getTextureCoordDirection', 'getTrailLength', 'getUseIdentityProjection', 'getUseIdentityView', 'getUseTextureCoords', 'getUseVertexColours', 'getUserObjectBindings', 'getWidthChange', 'getWorldTransforms', 'hasCustomParameter', 'next', 'nodeDestroyed', 'nodeUpdated', 'own', 'postRender', 'preRender', 'removeChainElement', 'removeCustomParameter', 'removeNode', 'setColourChange', 'setCustomParameter', 'setDynamic', 'setFaceCamera', 'setInitialColour', 'setInitialWidth', 'setMaterialName', 'setMaxChainElements', 'setNumberOfChains', 'setOtherTextureCoordRange', 'setPolygonModeOverrideable', 'setRenderSystemData', 'setTextureCoordDirection', 'setTrailLength', 'setUseIdentityProjection', 'setUseIdentityView', 'setUseTextureCoords', 'setUseVertexColours', 'setWidthChange', 'this', 'thisown', 'updateChainElement', 'visitRenderables']
It seems that do not have the MovableObject Methods
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 835
Joined: Sun Mar 30, 2014 2:51 pm
x 147
Contact:

Re: How to create RibbonTrail without create MovableObject

Post by paroj » Fri Jan 11, 2019 12:28 pm

thats a bug in the bindings. will push a fix.
0 x

niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 1

Re: How to create RibbonTrail without create MovableObject

Post by niubaty » Fri Jan 11, 2019 1:38 pm

I may know why.
Let's experiment, We expect this way:
This is the ex.h

Code: Select all

#ifndef _EX_
#define _EX_
#include <iostream>
using namespace std;
class EX{
public:
void setVisible();
};
void EX::setVisible(){
cout<<"movable stuff"<<endl;
}
#endif
This is the ex2.h

Code: Select all

#include "ex.h"
class EX2 : public EX{
public:
void RibbionStuff();
};
void EX2::RibbionStuff(){
cout<<"RibbonStuff"<<endl;
}
we write ex2.i for swig and compile the python module:
This is the ex2.i

Code: Select all

%module ex2
%{
#include "ex.h"
#include "ex2.h"
%}
%include "ex.h"
%include "ex2.h"

Code: Select all

swig -c++ -python ex2.i
F:\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe -mdll -O -Wall -ID:\Python27\include -ID:\Python27\PC -c ex2_wrap.cxx -o build\temp.win-amd64-2.7\Release\ex2_wrap.o -DMS_WIN64
F:\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe -shared -s build\temp.win-amd64-2.7\Release\ex2_wrap.o build\temp.win-amd64-2.7\Release\_ex2.def -LD:\Python27\libs -LD:\Python27\PCbuild\amd64 -LD:\Python27\PC\VS9.0\amd64 -lpython27 -lmsvcr90 -o build\lib.win-amd64-2.7\_ex2.pyd -DMS_WIN64
copy build\lib.win-amd64-2.7\_ex2.pyd _ex2.pyd
Let's test the result:

Code: Select all

Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
>>> import ex2
>>> e=ex2.EX2()
>>> dir(e)
['RibbionStuff', '__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__swig_getmethods__', '__swig_setmethods__', '__weakref__', '_s', 'setVisible', 'this']
setVisible() and RibbonStuff() are available.

Now let's switch the sequence of %include "ex.h" and %include "ex2.h" in ex2.i
This is the wrong ex.i

Code: Select all

%module ex2
%{
#include "ex.h"
#include "ex2.h"
%}
%include "ex2.h"
%include "ex.h"
We generate ex2_wrap.cxx and recompile again.
After the similar compile process before,now we test:

Code: Select all

Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
>>> import ex2
>>> e=ex2.EX2()
>>> dir(e)
['RibbionStuff', '__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__swig_getmethods__', '__swig_setmethods__', '__weakref__', 'this']
See? The method setVisible is missing!
And Original Ogre.i is:

Code: Select all

    %include "OgreBillboardChain.h"
        %include "OgreRibbonTrail.h"
    %include "OgreBillboardSet.h"
%include "OgreShadowCaster.h"
%include "OgreMovableObject.h"
    %include "OgreMovablePlane.h"
    %ignore Ogre::Light::setPosition;
    %ignore Ogre::Light::getPosition;
So the class of RibbonTrail missing its parent class method. We should move the child class header after the parent class header and recompile the source code.
0 x

niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 1

Re: How to create RibbonTrail without create MovableObject

Post by niubaty » Fri Jan 11, 2019 1:42 pm

paroj wrote:
Fri Jan 11, 2019 12:28 pm
thats a bug in the bindings. will push a fix.
Please push the fix to 1.10 by the way. I can not compile the 1.11 successfully with mingw on windows.
Thank you! :D :D :D
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 835
Joined: Sun Mar 30, 2014 2:51 pm
x 147
Contact:

Re: How to create RibbonTrail without create MovableObject

Post by paroj » Sat Jan 12, 2019 12:31 am

1.10 is EOL, so no sorry. The fix is quite easy to backport though: https://github.com/OGRECave/ogre/pull/1044

Also take a look at the MinGW patches here: https://github.com/OGRECave/ogre/issues/820 Maybe they can help you in getting it running.
0 x

niubaty
Kobold
Posts: 27
Joined: Thu Jan 10, 2019 2:19 pm
x 1

Re: How to create RibbonTrail without create MovableObject

Post by niubaty » Mon Jan 14, 2019 3:35 am

It seems that moving ShadowCaster and MovableObject header only is not enough.
The OgreNode.h also should move before OgreRibbonTrail because RibbonTrail also inherit from Ogre::Node::Listener

Code: Select all

%include "OgreRenderable.h"
%include "OgreShadowCaster.h"
%include "OgreMovableObject.h"
%include "OgreNode.h"
%include "OgreBillboardChain.h"
%include "OgreRibbonTrail.h"


I recompile the sdk and it worked
0 x

Post Reply