[SOLVED][2.1] ManualObject multicolor line

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Feanor16
Halfling
Posts: 46
Joined: Tue Feb 18, 2014 10:49 pm

[SOLVED][2.1] ManualObject multicolor line

Post by Feanor16 » Wed Jan 25, 2017 3:49 pm

Hi,
i'm trying to make a line using ManualObject. but the simple line display several colours:
Image

this is my code:

Code: Select all

    Ogre::ManualObject * ManualObject;
    ManualObject = Node_->sceneNode()->getCreator()->createManualObject(Ogre::SCENE_DYNAMIC);

    ManualObject->begin("DbRed", Ogre::OT_LINE_LIST); //Datablock DbRed works
    ManualObject->colour(0,0,0); // tested but doesn't work
    ManualObject->setStatic(false);

    ManualObject->position(0.0, 0.0, 1.0);
    ManualObject->position(0.0,  0.0, -1.0);
    ManualObject->line(0,1);

    ManualObject->end();
  
    Node_->attachObject(ManualObject);
someone knows what happen?

thank you
Last edited by Feanor16 on Thu Jan 26, 2017 11:41 am, edited 1 time in total.
0 x

Feanor16
Halfling
Posts: 46
Joined: Tue Feb 18, 2014 10:49 pm

Re: [2.1] ManualObject multicolor line

Post by Feanor16 » Thu Jan 26, 2017 11:40 am

Problem Solved: the V2 ManualObject doesn't works with a Pbs Datablock. It works perfectly with Unlit Datablock.

Code: Select all

  Ogre::HlmsUnlit *hlmsUnlitMaterials = static_cast<Ogre::HlmsUnlit*>(hlmsManager->getHlms(Ogre::HLMS_UNLIT));
  Ogre::HlmsUnlitDatablock *UnlitDatablock;
  Ogre::String datablockUnlitName = "UnlitColour";

  UnlitDatablock = static_cast<Ogre::HlmsUnlitDatablock*>(hlmsUnlitMaterials->createDatablock(
                                                     datablockUnlitName,
                                                     datablockUnlitName,
                                                     Ogre::HlmsMacroblock(),
                                                     Ogre::HlmsBlendblock(),
                                                     Ogre::HlmsParamVec() ) );

  UnlitDatablock->setUseColour(true);
  UnlitDatablock->setColour(Ogre::ColourValue(1,0,0));
0 x

al2950
OGRE Expert User
OGRE Expert User
Posts: 1193
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 74

Re: [SOLVED][2.1] ManualObject multicolor line

Post by al2950 » Thu Jan 26, 2017 1:34 pm

This was most likely caused because you did not specify any normals or tangents which are required to calculate any lighting.

Also please note Manual Object really should not be used at all, and was added back to 2.1 due to community pressure to help with porting, but is much more limited. However it is highly recommended to generate vertex buffers yourself, it is much easier than it was in 1.x. Check out the samples "CustomRenderable" & "DynamicGeometry"
0 x

Post Reply