Example #1
0
void TestApp::DrawSkeleton()
{
	// Draw the skeleton
		// Get all the toRoot transforms
		// for each transform, extract 41, 42, 43 as position 
		// draw AABB
		const std::vector<Math::Matrix>& toRootTransforms = mAnimationController.ToRootTransforms();
		// get vector of bones
		const std::vector<Bone*>& bones = mModel.mBones;

		Color RandColor((float)(rand()%100)/100, (float)(rand()%100)/100, (float)(rand()%100)/100, 1.0f );
		for(u32 i = 0; i < toRootTransforms.size(); ++i)
		{
			const Math::Matrix& mat = toRootTransforms[i];
			const Math::Vector3 center( mat._41, mat._42, mat._43 );
			
			//SimpleDraw::AddAABB(center, 0.01f, Color((float)(rand()%100)/100, (float)(rand()%100)/100, (float)(rand()%100)/100, 1.0f ));
			SimpleDraw::AddAABB(center, 0.02f, RandColor);

			for(u32 j = 0; j < bones[i]->children.size(); ++j)
			{
				const Math::Matrix& child = toRootTransforms[bones[i]->children[j]->index];
				const Math::Vector3 childCenter( child._41, child._42, child._43 );
				SimpleDraw::AddLine(center, childCenter, RandColor);
			}
			// draw bones to children
		}
}
    virtual void dialogClosed(const DialogWindowEventUnrecPtr e)
    {
        if(e->getOption() != DialogWindowEvent::DIALOG_OPTION_CANCEL)
        {
            //Create the Layer FieldContainer
            CreateFieldContainerCommandPtr CreateCommand = CreateFieldContainerCommand::create(e->getInput());

		    TheCommandManager->executeCommand(CreateCommand);

            //If the layer is a ColorLayer then give it a random color
            if(CreateCommand->getContainer()->getType() == ColorLayer::getClassType())
            {
                Color4f RandColor(RandomPoolManager::getRandomReal32(0.0f,1.0f),
                                  RandomPoolManager::getRandomReal32(0.0f,1.0f),
                                  RandomPoolManager::getRandomReal32(0.0f,1.0f),
                                  1.0f);

                dynamic_cast<ColorLayer*>(CreateCommand->getContainer())->setColor(RandColor);
            }


            //Set the background layer to use the newly create layer
            SetFieldValueCommandPtr SetFieldCommand = SetFieldValueCommand::create(SinglePtrFieldLabel,Component::BackgroundFieldId, boost::lexical_cast<std::string>(CreateCommand->getContainer()->getId()));

		    TheCommandManager->executeCommand(SetFieldCommand);
        }
    }
Example #3
0
void GlobulesSystem::AddRandomGlobule()
{
    Globule g;
    g.color = RandColor();
    g.radius = 0.01f + randf() * 0.1;
    g.r.x = g.radius + (1.0 - 2*g.radius) * randf();
    g.r.y = g.radius + (1.0 - 2*g.radius) * randf();
    g.v.x = -0.05 + 0.1 * randf();
    g.v.y = -0.05 + 0.1 * randf();

    globules.push_back(g);
}
Example #4
0
ST_RGB Graying::RandColor()
{
	ST_RGB rgb;
	RandColor(&rgb);
	return rgb;
}