[2.1] BillboardChain and RibbonTrail
-
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
[2.1] BillboardChain and RibbonTrail
Is anybody else successfully using these classes in 2.1? Any ideas what is needed to get them showing?
I found this post from 2015, with al2950 having the same issue: http://www.ogre3d.org/forums/viewtopic. ... 12#p515902 but no solution is mentioned in the thread.
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] BillboardChain and RibbonTrail
What's the code you're using to create and display those BillboardChain or RibbonTrails?
-
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
Re: [2.1] BillboardChain and RibbonTrail
Thanks for adding it to your TODO. I might need to look into it myself to get it working sooner though, since you really have a lot on your list.
I might clean up our code and post it later, but I do not suspect the issue is there at the moment (I hope I will not end up eating these words, simpler things have gone wrong before ), since it basically just creates the ribbon trail and assigns the datablock, and sets it up to track another scene node.
Since you have a lot of experience debugging these things, do you have any pointers regarding what might go wrong?
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] BillboardChain and RibbonTrail
The first thing that comes to mind is that Billboards are a special snowflake that work best when you set the hlms datablock by name and not by pointer. If you search on our forums the explanation of why is this will be there (hint: it's technical debt)
-
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
Re: [2.1] BillboardChain and RibbonTrail
-
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
Re: [2.1] BillboardChain and RibbonTrail
1. They are never added to mRenderables
2. BillboardChain::preRender is never called, so its vertex buffers are never updated.
The patch below fixes (1):
Code: Select all
diff -r 04f7437fcbb8 OgreMain/src/OgreBillboardChain.cpp
--- a/OgreMain/src/OgreBillboardChain.cpp Mon Oct 17 19:32:28 2016 -0300
+++ b/OgreMain/src/OgreBillboardChain.cpp Sat Nov 05 17:21:12 2016 +0100
@@ -718,9 +718,13 @@
if (mIndexData->indexCount > 0)
{
+ if (mRenderables.empty())
+ mRenderables.push_back(this);
//TODO: RENDER QUEUE
//queue->addRenderable(this, mRenderQueueID, mRenderQueuePriority);
}
+ else
+ mRenderables.clear();
}
//-----------------------------------------------------------------------
void BillboardChain::getRenderOperation(RenderOperation& op, bool casterPass)
Code: Select all
diff -r 04f7437fcbb8 OgreMain/src/OgreSceneManager.cpp
--- a/OgreMain/src/OgreSceneManager.cpp Mon Oct 17 19:32:28 2016 -0300
+++ b/OgreMain/src/OgreSceneManager.cpp Sat Nov 05 17:21:12 2016 +0100
@@ -1272,6 +1272,7 @@
while( itRend != enRend )
{
+ (*itRend)->preRender(this, mDestRenderSystem);
mRenderQueue->addRenderableV1( i, casterPass, *itRend, *itor );
++itRend;
}
Code: Select all
diff -r 04f7437fcbb8 Samples/2.0/ApiUsage/AnimationTagPoint/AnimationTagPointGameState.cpp
--- a/Samples/2.0/ApiUsage/AnimationTagPoint/AnimationTagPointGameState.cpp Mon Oct 17 19:32:28 2016 -0300
+++ b/Samples/2.0/ApiUsage/AnimationTagPoint/AnimationTagPointGameState.cpp Sat Nov 05 17:17:03 2016 +0100
@@ -9,6 +9,7 @@
#include "OgreMeshManager.h"
#include "OgreMesh2.h"
#include "OgreMeshManager2.h"
+#include "OgreBillboardChain.h"
#include "Animation/OgreSkeletonInstance.h"
#include "Animation/OgreTagPoint.h"
@@ -129,6 +130,24 @@
camera->setPosition( Ogre::Vector3( 0, 2.5, 4 ) );
TutorialGameState::createScene01();
+
+ Ogre::SceneNode* chainNode = sceneManager->getRootSceneNode()->createChildSceneNode();
+ chainNode->setPosition(Ogre::Vector3(0, 0, 0));
+ chainNode->setOrientation(Ogre::Quaternion(1, 0, 0, 0));
+
+ Ogre::v1::BillboardChain * chain = sceneManager->createBillboardChain();
+
+ chain->setDynamic(true);
+ chain->setNumberOfChains(1);
+ chain->setUseVertexColours(true);
+ chain->setMaxChainElements(5);
+
+ for (int i = 0; i < 5; ++i)
+ chain->addChainElement(0, Ogre::v1::BillboardChain::Element(Ogre::Vector3(0.5 * i, 0, 0), 0.1, 0.2 * i, Ogre::ColourValue(1,0,0,1), Ogre::Quaternion()));
+
+ chainNode->attachObject(chain);
+ chain->setVisible(true);
+
}
//-----------------------------------------------------------------------------------
void AnimationTagPointGameState::update( float timeSinceLast )
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] BillboardChain and RibbonTrail
I tried to create a ribbon trail for the Stickman's hand, but it appears there are more bugs in RibbonTrail. They all seem like they could be silly like this one though, haven't looked very further into it. One of them was a mCachedTransformOutOfDate assert. While calling _getDerivedPositionUpdated would fix it, I would have to check if doing that would cause slowdowns if many ribbon trails are used. Very likely _getDerivedPosition is just being called too early and needs to be moved.
Thanks for the fix!
-
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
Re: [2.1] BillboardChain and RibbonTrail
Hmm. RibbonTrail worked for me after my BillboardChain fixes.
EDIT: Shadows don't seem to work with BillboardChain, only a couple loose triangles appear to get drawn into the shadow buffer. I seem to remember that they used to be reoriented towards the shadow camera when rendered from that vantage point. Is that functionality still intact?
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.1] BillboardChain and RibbonTrail
I'm also trying to get RibbonTrail working, but no matter what unlit material I use, i get the exception:
Code: Select all
OGRE EXCEPTION(1:InvalidStateException): Renderable must have at least 2 coordinates in UV set #0. Either change the mesh, or change the UV source settings
Code: Select all
hlms LightRibbonTrail unlit
{
diffuse_map ribbonband.png #2
scene_blend add
depth_write off
cull_mode none
}
Code: Select all
this->ribbonTrail->setDatablockOrMaterialName("LightRibbonTrail", "Unlit");
this->ribbonTrail->setUseVertexColours(true);
Did someone manage to get ribbon trail working?
Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
- Kohedlo
- Orc
- Posts: 435
- Joined: Fri Nov 27, 2009 3:34 pm
- Location: Ukraine, Sumy
- x 32
- Contact:
Re: [2.1] BillboardChain and RibbonTrail
this is ribbon trail on 2.1 and code.
Code: Select all
p->ribbon = Ogre::Root::getSingletonPtr()->getSceneManager(CfgManager::getSingleton().main_scene_manager_name)->createRibbonTrail();
Ogre::Root::getSingletonPtr()->getSceneManager(CfgManager::getSingleton().main_scene_manager_name)
->getRootSceneNode()->attachObject(p->ribbon);
// sN->attachObject(p->ribbon);
p->ribbon->setTrailLength(p->setTrailLength);
//p->ribbon->setMaxChainElements(p->maxElements);
p->ribbon->setInitialColour(0, p->col.r, p->col.g, p->col.b);
p->ribbon->setColourChange(0, p->colourChange.r, p->colourChange.g, p->colourChange.b, p->colourChange.a);
p->ribbon->setInitialWidth(0, p->width);
p->ribbon->setDatablock(p->material);
p->ribbon->setWidthChange(0,p->widthDeltaPerSecond);
p->ribbon->addNode(sN);
void I_SCENE::UpdateRibbonTrail(std::string Name) // and update that currently need
{
IParticle* p = GetParticle(Name);
if(p->partycleType == 4)
p->ribbon->_timeUpdate(IEngine::getSingleton().timeSinceLastFrame);
}
current project: Imperial Game Engine 2.5
- Kohedlo
- Orc
- Posts: 435
- Joined: Fri Nov 27, 2009 3:34 pm
- Location: Ukraine, Sumy
- x 32
- Contact:
Re: [2.1] BillboardChain and RibbonTrail
Code: Select all
hlms RibbonTrail unlit
{
lighting off
scene_blend add
depth_write off
diffuse_map ribbonband.png
}
current project: Imperial Game Engine 2.5
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.1] BillboardChain and RibbonTrail
I will take a look at it.
Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.1] BillboardChain and RibbonTrail
I checked you code with mine, and its similiar. But as soon as I set the datablock for the ribbon trail, I get the error:
Code: Select all
OGRE EXCEPTION(1:InvalidStateException): Renderable must have at least 2 coordinates in UV set #0. Either change the mesh, or change the UV source settings in HlmsUnlit::calculateHashForPreCreate
Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Halfling
- Posts: 68
- Joined: Sun May 11, 2014 7:55 pm
- Location: Poland
- x 21
Re: [2.1] BillboardChain and RibbonTrail
I had the same problem. I solved this by setting datablock later - at least frame later after creating and initializing ribbon trail.Lax wrote: ↑Wed Jan 31, 2018 6:16 pmDo you have an idea how to fix this?Code: Select all
OGRE EXCEPTION(1:InvalidStateException): Renderable must have at least 2 coordinates in UV set #0. Either change the mesh, or change the UV source settings in HlmsUnlit::calculateHashForPreCreate
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.1] BillboardChain and RibbonTrail
I tried that out, but that did not work.
Can you post your unlit material code, maybe something is wrong with my ribbon trail definition?
Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Halfling
- Posts: 68
- Joined: Sun May 11, 2014 7:55 pm
- Location: Poland
- x 21
Re: [2.1] BillboardChain and RibbonTrail
Material code was already mentioned. I didn't add anything new:
Code: Select all
hlms LightRibbonTrail unlit
{
lighting off
depth_write off
scene_blend add
// diffuse 1.0 0.0 0.0 1.0
diffuse_map ribbonband.png
}
Code: Select all
Ogre::SceneNode* chainNode = BModule::m->sceneManager->getRootSceneNode()->createChildSceneNode();
chainNode->setPosition(Ogre::Vector3(0, 0, 0));
chainNode->setOrientation(Ogre::Quaternion(1, 0, 0, 0));
mSwordTrail = BModule::m->sceneManager->createRibbonTrail();
mSwordTrail->setName("RibbonTrail");
mSwordTrail->setDynamic(true);
mSwordTrail->setNumberOfChains(1);
mSwordTrail->setUseVertexColours(true);
mSwordTrail->setMaxChainElements(80);
mSwordTrail->setUseTextureCoords(true);
mSwordTrail->setFaceCamera(false, Ogre::Vector3::UNIT_Y);
mSwordTrail->setTrailLength(20);
// mSwordTrail->setDatablock("LightRibbonTrail");
// mSwordTrail->setTextureCoordDirection(Ogre::v1::BillboardChain::TCD_V);
for (int i = 0; i < 1; ++i) {
mSwordTrail->setInitialColour(i, 1.0, 1.0, 1.0, 1.0);
mSwordTrail->setColourChange(i, 1.25, 1.25, 1.25, 1.25);
mSwordTrail->setWidthChange(i, 0.0);
mSwordTrail->setInitialWidth(i, 1.0);
}
chainNode->attachObject(mSwordTrail);
Code: Select all
mSwordTrail->addNode(node);
mSwordTrail->setVisible(true);
mSwordTrail->setDatablock("LightRibbonTrail");
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.1] BillboardChain and RibbonTrail
Ok thanks for the tip. Now the error message is gone.nd later (next frame in ::frameRenderingQueued method)
But I still see no ribbon trail. I added the same values for the ribbontrail as you have.
I have still no clue why that ribbon trail will not work
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Halfling
- Posts: 68
- Joined: Sun May 11, 2014 7:55 pm
- Location: Poland
- x 21
Re: [2.1] BillboardChain and RibbonTrail
Can you see ribbontrail without texture? Set white colour in material (black material will be fully transparent) like below:
Code: Select all
hlms LightRibbonTrail unlit
{
lighting off
depth_write off
scene_blend add
diffuse 1.0 1.0 1.0 1.0
}
Code: Select all
// mSwordTrail->setFaceCamera(false, Ogre::Vector3::UNIT_Y);