Beispiel #1
0
AmbientLight::AmbientLight()
{
	setRenderQueueGroup(Ogre::RENDER_QUEUE_2);

	// Render op setup
	mRenderOp.vertexData = new Ogre::VertexData();
	mRenderOp.indexData = 0;
	GeomUtils::createQuad(mRenderOp.vertexData);
	mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_STRIP; 
	mRenderOp.useIndexes = false; 

	// Set bounding box (pretty much infinite)
	setBoundingBox(Ogre::AxisAlignedBox(-10000,-10000,-10000,10000,10000,10000));
	mRadius = 15000;

	// Ambient lighting material
	mMatPtr = Ogre::MaterialManager::getSingleton().getByName("Render/AmbientLight");
	assert(mMatPtr.isNull() == false);
	mMatPtr->load();
	
	// Explicitly bind samplers for OpenGL
	if (Ogre::Root::getSingleton().getRenderSystem()->getName().find("OpenGL 3+") != Ogre::String::npos)
	{
		mMatPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("Tex0", 0);
		mMatPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("Tex1", 1);
		mMatPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("Tex2", 2);
	}
}
Beispiel #2
0
Blob::Blob(const cv::Rect_<float>& bb, ObjectState state, ApplicationContext* context)
: mObjectBoundingBox(bb)
, mState(state)
, mContext(context)
{
	setBoundingBox(bb);
}
Beispiel #3
0
void SceneGraph::recomputeBoundingBox() 
{
	Node	*node;
	float	center[3];
	float	size[3];

	BoundingBox bbox;

	for (node=getNodes(); node; node=node->nextTraversal()) {
		if (node->isGroupingNode()) {
			GroupingNode *gnode = (GroupingNode *)node;
			gnode->getBoundingBoxCenter(center);
			gnode->getBoundingBoxSize(size);
			bbox.addBoundingBox(center, size);
		}
		else if (node->isGeometryNode()) { 
			GeometryNode *gnode = (GeometryNode *)node; 
			gnode->getBoundingBoxCenter(center); 
			gnode->getBoundingBoxSize(size); 
			bbox.addBoundingBox(center, size); 
		} 
	}

	setBoundingBox(&bbox);
}
void ColorChange::setup() {  
  INFO("Creating a ColorChange ...");

  if(colorMask & BLUE)
      color = "FlatBlue";
  else if(colorMask & GREEN)
    color = "FlatGreen";
  else if(colorMask & RED)
    color = "FlatRed";
  else if(colorMask & GREY)
    color = "FlatGrey";
  
  colorChange = ObjectPtr(new Object(
                   LoadManager::getMesh("cube.obj"),
                   MaterialManager::getMaterial(color)));

  RenderEngine::getRenderElement("regular")->addObject(colorChange);

  colorChange->scale(glm::vec3(.5, .5, .5));
  colorChange->translate(position);

    
  setCollisionID(16);
  setCollideWithID(2);
  setCanCollide(true);

  setBoundingBox(BoundingBox(glm::vec3(.5f,.5f,.5f), glm::vec3(-.5f,-.5f,-.5f)));
  getBoundingBox()->setPosition(position);
}
void ServicesDbReader::setConfiguration(const Settings& conf)
{
  ConfigOptions configOptions(conf);
  setMaxElementsPerMap(configOptions.getMaxElementsPerPartialMap());
  setUserEmail(configOptions.getServicesDbReaderEmail());
  setBoundingBox(configOptions.getConvertBoundingBox());
}
Beispiel #6
0
//------------------------------------------------------------------------------
// TriMesh implementation
bool TriMesh::loadFile(QString fileName, size_t /*maxVertexCount*/)
{
    // maxVertexCount is ignored - not sure there's anything useful we can do
    // to respect it when loading a mesh...
    PlyLoadInfo info;
    if (!loadPlyFile(fileName, info))
        return false;
    setFileName(fileName);
    V3d offset = V3d(info.offset[0], info.offset[1], info.offset[2]);
    setOffset(offset);
    setCentroid(getCentroid(offset, info.verts));
    setBoundingBox(getBoundingBox(offset, info.verts));
    m_verts.swap(info.verts);
    m_colors.swap(info.colors);
    m_texcoords.swap(info.texcoords);
    m_triangles.swap(info.triangles);
    m_edges.swap(info.edges);
    if (!info.textureFileName.isEmpty())
    {
        QImage image;
        if (image.load(info.textureFileName))
            m_texture.reset(new Texture(image));
        else
            g_logger.warning("Could not load texture %s for model %s", info.textureFileName, fileName);
    }
    //makeSmoothNormals(m_normals, m_verts, m_triangles);
    //makeEdges(m_edges, m_triangles);
    return true;
}
Beispiel #7
0
Trundler::Trundler(int blockX, int blockY, Field *field)
  : Enemy(TRUNDLER, field), dir(TRUNDLE_RIGHT), inAir(false), yvel(0),
    yvelTimer(TRUNDLER_FALL_DELAY)
{
  moveAbs(blockX * 32, blockY * 32);
  setBoundingBox(22, 25, 3, 3);
}
Beispiel #8
0
RenderObjectPtr
MeshRenderComponent::buildRenderObject(MeshPropertyPtr mesh, RenderBufferPtr buffer) noexcept
{
	auto material = this->getMaterial(mesh->getMaterialID());
	if (material)
	{
		auto renderObject = std::make_shared<RenderMesh>();
		renderObject->setRenderBuffer(buffer);
		renderObject->setBoundingBox(mesh->getBoundingBox());
		renderObject->setRenderListener(this);

		renderObject->setMaterial(material);

		renderObject->setCastShadow(this->getCastShadow());
		renderObject->setReceiveShadow(this->getReceiveShadow());

		renderObject->setLayer(this->getGameObject()->getLayer());

		renderObject->setTransform(this->getGameObject()->getTransform());
		renderObject->setTransformInverse(this->getGameObject()->getTransformInverse());
		renderObject->setTransformInverseTranspose(this->getGameObject()->getTransformInverseTranspose());

		return renderObject;
	}

	return nullptr;
}
/**
 * @brief cwCaptureViewport::updateBoundingBox
 *
 * This will update the bounding box for the viewport capture.
 *
 * This is useful for displaying annotation, and interactions ontop of the item
 * in qml.
 */
void cwCaptureViewport::updateBoundingBox()
{
    QTransform transform = previewItem()->transform();
    QRectF paperRect = previewItem()->boundingRect();
    QRectF boundingBoxRect = transform.mapRect(paperRect);
    setBoundingBox(boundingBoxRect);
}
Beispiel #10
0
//-------------------------------------------------------------------------------------
//sets the actual corners of the box
void SelectionBox::setCorners(float left, float top, float right, float bottom)
{
    /** Set the coordinate\n
     *  first change the coordinate to -1~1\n
     *  draw the rectangle line\n
	*/
	left = left * 2 - 1;
	right = right * 2 - 1;
	top = 1 - top * 2;
	bottom = 1 - bottom * 2;
	
  	std::cout << "4......drawing\n";
	std::cout << "left:" << left << std::endl;
	std::cout << "right:" << right << std::endl;
	std::cout << "bottom:" << bottom << std::endl;
	std::cout << "top:" << top << std::endl;

	clear();
	begin("",Ogre::RenderOperation::OT_LINE_STRIP);
		position(left, top, -1);
		position(right, top, -1);
		position(right, bottom, -1);
		position(left, bottom, -1);
		position(left, top, -1);
	end();

	setBoundingBox(Ogre::AxisAlignedBox::BOX_INFINITE);
}
Beispiel #11
0
	AmbientLight::AmbientLight()
	{
		setRenderQueueGroup(RENDER_QUEUE_2);

		mRenderOp.vertexData = new VertexData();
		mRenderOp.indexData = 0;

		GeomUtils::createQuad(mRenderOp.vertexData);

		mRenderOp.operationType = RenderOperation::OT_TRIANGLE_STRIP; 
		mRenderOp.useIndexes = false; 

		// Set bounding
		setBoundingBox(AxisAlignedBox(-10000,-10000,-10000,10000,10000,10000));
		mRadius = 15000;

		mMatPtr = MaterialManager::getSingleton().getByName("DeferredShading/AmbientLight");
		assert(mMatPtr.isNull()==false);
		mMatPtr->load();

		//This shader needs to be aware if its running under OpenGL or DirectX.
		//Real depthFactor = (Root::getSingleton().getRenderSystem()->getName() ==
		//    "OpenGL Rendering Subsystem") ? 2.0 : 1.0;
		//mMatPtr->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant(
		//        "depthFactor", depthFactor);
	}
Beispiel #12
0
   void EffectBillboardChain::updateBoundingBox()
   {
       if (mChainElementList.size() < 2)
          return;

       Ogre::Real width = mChainElementList[0].width;
       Vector3 widthVector = Vector3(width, width, width);
       const Vector3& position = mChainElementList[0].position;
       Vector3 minimum = position - widthVector;
       Vector3 maximum = position + widthVector;

       for (unsigned int i = 1; i < mChainElementList.size(); i++)
       {
         // Update the bounds of the bounding box
          Ogre::Real width = mChainElementList[i].width;
          Vector3 widthVector = Vector3(width, width, width);
          const Vector3& position = mChainElementList[i].position;

          minimum.makeFloor(position - widthVector);
          maximum.makeCeil(position + widthVector);
       }

       // Set the current bounding box
       setBoundingBox(AxisAlignedBox(minimum, maximum));

       // Set the current radius
       mRadius = Math::Sqrt(std::max(minimum.squaredLength(), maximum.squaredLength()));
   }
Beispiel #13
0
void geode::getBounds(Matrix4 m) {
	m.identity();
	m.scale(2, 2, 2);
	for (int i = 0; i < 4; i++) {
		if (m.get(0, i) < min.x) {
			min.x = m.get(0, i);
		}

		if (m.get(0, i) > max.x) {
			max.x = m.get(0, i);
		}

		if (m.get(1, i) < min.y) {
			min.y = m.get(1, i);
		}

		if (m.get(1, i) > max.y) {
			max.y = m.get(1, i);
		}

		if (m.get(2, i) < min.z) {
			min.z = m.get(2, i);
		}

		if (m.get(2, i) > max.z) {
			max.z = m.get(2, i);
		}
	}

	setBoundingBox(min, max);
}
//==============================================================================
void DrawableText::refreshFromValueTree (const ValueTree& tree, ComponentBuilder&)
{
    ValueTreeWrapper v (tree);
    setComponentID (v.getID());

    const RelativeParallelogram newBounds (v.getBoundingBox());
    const RelativeCoordinate newFontHeight (v.getFontHeight());
    const RelativeCoordinate newFontHScale (v.getFontHorizontalScale());
    const Colour newColour (v.getColour());
    const Justification newJustification (v.getJustification());
    const String newText (v.getText());
    const Font newFont (v.getFont());

    if (text != newText || font != newFont || justification != newJustification
         || colour != newColour || bounds != newBounds
         || newFontHeight != fontHeight || newFontHScale != fontHScale)
    {
        setBoundingBox (newBounds);
        setFontHeight (newFontHeight);
        setFontHorizontalScale (newFontHScale);
        setColour (newColour);
        setFont (newFont, false);
        setJustification (newJustification);
        setText (newText);
    }
}
//==============================================================================
void DrawableImage::refreshFromValueTree (const ValueTree& tree, ComponentBuilder& builder)
{
    const ValueTreeWrapper controller (tree);
    setComponentID (controller.getID());

    const float newOpacity = controller.getOpacity();
    const Colour newOverlayColour (controller.getOverlayColour());

    Image newImage;
    const var imageIdentifier (controller.getImageIdentifier());


    jassert (builder.getImageProvider() != 0 || imageIdentifier.isVoid()); // if you're using images, you need to provide something that can load and save them!

    if (builder.getImageProvider() != nullptr)
        newImage = builder.getImageProvider()->getImageForIdentifier (imageIdentifier);

    const RelativeParallelogram newBounds (controller.getBoundingBox());

    if (bounds != newBounds || newOpacity != opacity
         || overlayColour != newOverlayColour || image != newImage)
    {
        repaint();
        opacity = newOpacity;
        overlayColour = newOverlayColour;

        if (image != newImage)
            setImage (newImage);

        setBoundingBox (newBounds);
    }
}
 void PlanetFilter::initRenderOp() {    
     mRenderOp.operationType = RenderOperation::OT_TRIANGLE_STRIP;
     mRenderOp.useIndexes = FALSE;
     mRenderOp.vertexData = new VertexData();
     
     setBoundingBox(AxisAlignedBox(Vector3(-getBoundingRadius()), Vector3(getBoundingRadius())));
 }
Beispiel #17
0
void ofxLSystem::build(){
    //check if axiom, rules and theta are ok,
    // if not, define some default
    try {
        validateInput(axiom, rulesContainer, theta);
    } catch (ofxLSInputError& e) {
        ofLogError(e.what());
        theta = 25.00;
        axiom = "F";
        rulesContainer = {"F -> F[+F][-F]"};
    }
    //clear the mesh
    mesh.clear();

    // setup the turtle, the sentences and the geometry
    setMeshMode(geometry);
    turtle.setup(stepLength, stepWidth, theta, geometry, randomYRotation, scaleWidth, resolution, textureRepeat);
    const vector<string> sentences =
        ofxLSystemGrammar::buildSentences(rulesContainer, depth, axiom, constants);

    // populate the mesh
    turtle.generate(mesh, sentences.back(), depth);
    getMesh().clear();
    getMesh().append(mesh);
    setBoundingBox(turtle.getBuildedBoundingBox());
    getMesh().enableNormals();
}
Beispiel #18
0
   void AxisRenderable::drawLine(const Ogre::Vector3 &v1, const Ogre::Vector3 &v2, const Ogre::ColourValue &c1, const Ogre::ColourValue &c2,unsigned int lineCount)
   {
      assert(lineCount >= 0 && lineCount < m_max_line_count && m_locked_data);
      if(lineCount<0 || lineCount >= m_max_line_count || !m_locked_data)
      {
         return;
      }

      Ogre::Real *pPos = m_locked_data;

      pPos = (Ogre::Real *)((unsigned int)(pPos) + 6*lineCount*sizeof(Ogre::Real) + 2*lineCount*sizeof(unsigned int));
      *pPos++ = v1.x;
      *pPos++ = v1.y;
      *pPos++ = v1.z;
      Ogre::Root::getSingleton().convertColourValue(c1,((Ogre::uint32 *)pPos));
      pPos = (Ogre::Real *)((unsigned int)(pPos) + sizeof(unsigned int));
      *pPos++ = v2.x;
      *pPos++ = v2.y;
      *pPos++ = v2.z;
      Ogre::Root::getSingleton().convertColourValue(c2,((Ogre::uint32 *)pPos));

      mBox.merge(v1);
      mBox.merge(v2);

      mRenderOp.vertexData->vertexCount = 3 * 2;
      mRenderOp.vertexData->vertexStart = 0;
  
      setBoundingBox(mBox);
   }
void DrawableComposite::ValueTreeWrapper::resetBoundingBoxToContentArea (UndoManager* undoManager)
{
    const RelativeRectangle content (getContentArea());

    setBoundingBox (RelativeParallelogram (RelativePoint (content.left, content.top),
                                           RelativePoint (content.right, content.top),
                                           RelativePoint (content.left, content.bottom)), undoManager);
}
void DrawableComposite::resetBoundingBoxToContentArea()
{
    const RelativeRectangle content (getContentArea());

    setBoundingBox (RelativeParallelogram (RelativePoint (content.left, content.top),
                                           RelativePoint (content.right, content.top),
                                           RelativePoint (content.left, content.bottom)));
}
Beispiel #21
0
Entity::Entity(EntityType type) {
	this->loc = cv::Point(0, 0);
	this->type = type;
	msLastSeen = 0;
	isInFrame = false;

	setBoundingBox();
}
Beispiel #22
0
RedSpark::RedSpark(int blockX, int blockY)
  : Collidable(RED_SPARK)
{
  setBoundingBox(32, 20, 0, 6);
  moveAbs(blockX * 32, blockY * 32);
  type = CT_REDSPARK;
  collidableBlocksMarker = false;
}
Beispiel #23
0
bool Player::onSimCollisionImageQuery (SimCollisionImageQuery *query)
{
	query->count = 1;
	query->image[0] = &collisionImage;
	setBoundingBox();
	collisionImage.transform = getTransform();
	return true;
}
Beispiel #24
0
Shape::Shape(ShapeType shapeType, double x, double y, double w, double h, double angle) :
    m_shapeType(shapeType), m_label(0), m_fontSize(5)
{
	setBoundingBox(x, y, w, h);
	QTransform transform;
	transform.rotate(angle);
	setTransform(transform);
}
Beispiel #25
0
void SimFire::updateBBox(const Point3F & p)
{
   Box3F box;
   box = bbox;
   box.fMin += p;
   box.fMax += p;
   setBoundingBox(box);
}
Beispiel #26
0
	void Obstacle::setOrigin(Point newOrigin){origin = newOrigin;
			setBoundingBox(	origin.x-spaceDimensions.x,
						origin.x+spaceDimensions.x,
						origin.y-spaceDimensions.y,
						origin.y+spaceDimensions.y,
						origin.z-spaceDimensions.z,
						origin.x+spaceDimensions.z);
				}
Beispiel #27
0
Entity::Entity(cv::Point loc, EntityType type, int timeMS) {
	this->loc = loc;
	this->type = type;
	msLastSeen = timeMS;
	isInFrame = true;

	setBoundingBox();
}
Beispiel #28
0
GuiDrawable::GuiDrawable(std::string n, 
			 int x, int y, int w, int h) {
  name = n;
  setBoundingBox(x,y,w,h);

  standardFont.load("Courier-Sans.ttf", 28);
  smallFont.load("Courier-Sans.ttf", 18);
}
Beispiel #29
0
 void Cylinder::assemble() {
   // Add Bottom.
   addObject(new Disc(Point3(0,y0,0),radius,Vector3(0,-1,0)));
   // Add Top.
   addObject(new Disc(Point3(0,y1,0),radius,Vector3(0,1,0)));
   // Add Sides.
   addObject(new OpenCylinder(radius,y0,y1));
   setBoundingBox();
 }
Beispiel #30
0
void MicroTileArray::updateBoundingBox(BoundingBox &boundingBox, byte x0, byte y0, byte x1, byte y1) {
	if (!isBoundingBoxEmpty(boundingBox)) {
		x0 = MIN(TileX0(boundingBox), x0);
		y0 = MIN(TileY0(boundingBox), y0);
		x1 = MAX(TileX1(boundingBox), x1);
		y1 = MAX(TileY1(boundingBox), y1);
	}
	setBoundingBox(boundingBox, x0, y0, x1, y1);
}