Exemple #1
0
static VALUE Drawable_get_scale(VALUE vSelf) {
	// Get C++ object pointer from vSelf
	Drawable *pSelf;
	Data_Get_Struct(vSelf, Drawable, pSelf);
	float x = pSelf->GetScaleX();
	float y = pSelf->GetScaleY();
	VALUE vArr = rb_ary_new();
	rb_ary_push(vArr, rb_float_new(x));
	rb_ary_push(vArr, rb_float_new(y));
	return vArr;
}
void RenderingEngine::ClearExpired(){
    simnode<Drawable>* node = _drawables->head;
    while (node != NULL) {
        Drawable* d = node->data;
        if(d->IsExpired()){
            node = _drawables->removeAndGetNext(node, !d->PreserveExpired());
            continue;
        }
        node = node->next;
    }
}
Exemple #3
0
	void AiEngine::drawMapDrawables() const
	{
		MapDrawablesSet::const_iterator it;
		for (it = mapDrawables.begin(); it != mapDrawables.end(); it++)
		{
			mapCanvas.reset();

			Drawable *drawable = *it;
			drawable->draw(mapCanvas);
		}
	}
Exemple #4
0
	void AiEngine::drawScreenDrawables() const
	{
		ScreenDrawablesSet::const_iterator it;
		for (it = screenDrawables.begin(); it != screenDrawables.end(); it++)
		{
			screenCanvas.reset();

			Drawable *drawable = *it;
			drawable->draw(screenCanvas);
		}
	}
Drawable::Drawable (const Drawable& other)
    : Component (other.getName())
{
    setInterceptsMouseClicks (false, false);
    setPaintingIsUnclipped (true);

    setComponentID (other.getComponentID());
    setTransform (other.getTransform());

    if (auto* clipPath = other.drawableClipPath.get())
        setClipPath (clipPath->createCopy());
}
Exemple #6
0
bool Scene::DoesIntersect(const Ray &ray)
{
    for (std::vector<Drawable *>::const_iterator i = m_DrawableList.begin(); i != m_DrawableList.end(); i++) {
        Drawable *d = *i;

        if (d->Intersect(ray)) {
            return true;
        }
    }

    return false;
}
void GraphicsEngine::redo()
{
    if (!redoStack.empty())
    {
        Drawable *obj = redoStack.back();
        obj->load();
        objects.push_back(obj);
        std::stable_sort(objects.begin(), objects.end(), [](const Drawable* a, const Drawable* b) { return a->sortIndex() < b->sortIndex(); });
        redoStack.pop_back();
        undoStack.push_back(obj);
    }
}
Exemple #8
0
/**
 * \brief Destroys from Lua all drawable objects created
 * by this script.
 */
void LuaContext::destroy_drawables() {

  std::set<Drawable*>::iterator it;
  for (it = drawables.begin(); it != drawables.end(); ++it) {
    Drawable* drawable = *it;
    drawable->decrement_refcount();
    if (drawable->get_refcount() == 0) {
      delete drawable;
    }
  }
  drawables.clear();
  drawables_to_remove.clear();
}
Exemple #9
0
void StaticTrace_addTile(StaticTrace* self, Tile* tile, uint32_t x, uint32_t y)
{
	//if the position is correct
	if(x < self->nbCasesX && y < self->nbCasesY && tile)
	{
		//Add the tile
		self->tiles[x][y] = tile;

		//And set its position
		Drawable* tileDrawable = (Drawable*)tile;
		tileDrawable->setPosition(tileDrawable, self->padX + x*self->sizeX, self->padY + y*self->sizeY);
	}
}
Exemple #10
0
void TextDraw::SetText(
	Drawable & draw,
	const Font & font, const std::string & text,
	float x, float y, float scalex, float scaley,
	float r, float g, float b,
	VertexArray & output_array)
{
	RenderText(font, text, x, y, scalex, scaley, output_array);
	draw.SetTextures(font.GetFontTexture()->GetId());
	draw.SetVertArray(&output_array);
	draw.SetCull(false, false);
	draw.SetColor(r, g, b, 1.0);
}
Exemple #11
0
void BoxOctreeQuery::TestDrawables(Drawable** start, Drawable** end, bool inside)
{
    while (start != end)
    {
        Drawable* drawable = *start++;
        
        if ((drawable->GetDrawableFlags() & drawableFlags_) && (drawable->GetViewMask() & viewMask_))
        {
            if (inside || box_.IsInsideFast(drawable->GetWorldBoundingBox()))
                result_.Push(drawable);
        }
    }
}
Exemple #12
0
	/**
	* Draws an Image at the specified coordinates, with rotation and
	* scaling along both axes.
	* @param x The x-coordinate.
	* @param y The y-coordinate.
	* @param angle The amount of rotation.
	* @param sx The scale factor along the x-axis. (1 = normal).
	* @param sy The scale factor along the y-axis. (1 = normal).
	* @param ox The offset along the x-axis.
	* @param oy The offset along the y-axis.
	**/
	int w_draw(lua_State * L)
	{
		Drawable * drawable = luax_checktype<Drawable>(L, 1, "Drawable", GRAPHICS_DRAWABLE_T);
		float x = (float)luaL_optnumber(L, 2, 0.0f);
		float y = (float)luaL_optnumber(L, 3, 0.0f);
		float angle = (float)luaL_optnumber(L, 4, 0.0f);
		float sx = (float)luaL_optnumber(L, 5, 1.0f);
		float sy = (float)luaL_optnumber(L, 6, sx);
		float ox = (float)luaL_optnumber(L, 7, 0);
		float oy = (float)luaL_optnumber(L, 8, 0);
		drawable->draw(x, y, angle, sx, sy, ox, oy);
		return 0;
	}
Exemple #13
0
void Gameplay::Draw() {
	int activeAsteroids = 0;
	for(auto it = asteroids.begin(); it != asteroids.end(); ++it) {
		if(!(*it)->active)
			continue;
		activeAsteroids++;
		(*it)->fillInstanceData(asteroidDraw->instances);
	}
	if(activeAsteroids > 0) {
		asteroidDraw->setEffectTextures();
		asteroidDraw->drawInstanced(activeAsteroids);
	}

	for(auto it = sceneMgr->Begin(); it != sceneMgr->End(); ++it) {
		if(!(*it)->active)
			continue;
		(*it)->Draw();
	}

	laserDraw->setShader("laserEffect", "RenderLasers");
	laserDraw->draw();

	//draw glowy stuff
	resourceMgr->md3dImmediateContext->RSSetViewports(1, &resourceMgr->viewports["DScale2"]);
	resourceMgr->md3dImmediateContext->OMSetRenderTargets(1, &resourceMgr->renderTargets["DScale"], NULL);
	resourceMgr->md3dImmediateContext->ClearRenderTargetView(resourceMgr->renderTargets["DScale"], reinterpret_cast<const float*>(&Colors::Black));
	for(auto it = sceneMgr->Begin(); it != sceneMgr->End(); ++it) 
	{
		if(!(*it)->glow || !(*it)->active)
			continue;
		Drawable* temp = (*it)->GetComponent<Drawable>();
		if(temp)
		{
			temp->setShader("glowDraw", "RenderGlowy");
			temp->setEffectVariables();
			temp->setEffectTextures();
			(*it)->Draw();
			temp->setShader("betterPhongBump", "Render");
		}
	}
	laserDraw->setShader("glowDraw", "RenderGlowy");
	laserDraw->setEffectVariables();
	laserDraw->draw();
	laserDraw->points.clear();

	glow->setEffectVariables();
	glow->draw("DScale", "DScale2", "Pass2", "Original");

	closeButton->Draw( );
}
void DrawableBase::execSyncV(      FieldContainer    &oFrom,
                                        ConstFieldMaskArg  whichField,
                                        AspectOffsetStore &oOffsets,
                                        ConstFieldMaskArg  syncMode,
                                  const UInt32             uiSyncInfo)
{
    Drawable *pThis = static_cast<Drawable *>(this);

    pThis->execSync(static_cast<Drawable *>(&oFrom),
                    whichField,
                    oOffsets,
                    syncMode,
                    uiSyncInfo);
}
Exemple #15
0
void UpdateDrawablesWork(const WorkItem* item, unsigned threadIndex)
{
    const FrameInfo& frame = *(reinterpret_cast<FrameInfo*>(item->aux_));
    Drawable** start = reinterpret_cast<Drawable**>(item->start_);
    Drawable** end = reinterpret_cast<Drawable**>(item->end_);

    while (start != end)
    {
        Drawable* drawable = *start;
        if (drawable)
            drawable->Update(frame);
        ++start;
    }
}
Exemple #16
0
Drawable *Scene::getByTag(int tag) {
    
    std::vector<Drawable *>::iterator it;
    
    for(it = displayList.begin(); it < displayList.end(); ++it) {
        
        Drawable *drawable = (Drawable *) *it;
        if (drawable->getTag() == tag) {
            return drawable;
        }
    }
    
    return NULL;
}
Exemple #17
0
void Buffer::createFromDrawable(Drawable &obj) {
   shouldDelete = true;

   if (obj.getW() > 512 || obj.getH() > 512)
      throw RubyException(rb_eRuntimeError, "Drawable too big for a buffer.");

   int width = obj.getW();
   int height = obj.getH();
   img = oslCreateImage(width, height, OSL_IN_VRAM, OSL_PF_8888);
   if (!img) {
      img = oslCreateImage(width, height, OSL_IN_RAM, OSL_PF_8888);
      if (!img)
	 throw RubyException(rb_eRuntimeError, "Buffer could not be created");
   }
   else {
      Buffer::registerInVram(img);
   }

   OSL_IMAGE *old = oslGetDrawBuffer();
   setActual();

   obj.clearMove();
   obj.setPos(0, 0);
   obj.draw();
   obj.cancelMove();

   oslSetDrawBuffer(old);
}
Exemple #18
0
static VALUE Drawable_set_scale(VALUE vSelf, VALUE vScale) {
	// Get C++ object pointer from vSelf
	Drawable *pSelf;
	Data_Get_Struct(vSelf, Drawable, pSelf);
	if(ISNUM(vScale)) {
		float f = (float)NUM2DBL(vScale);
		pSelf->SetScale(f, f);
	} else if(IS(vScale, rb_cArray)) {
		float x = (float)NUM2DBL(rb_ary_entry(vScale, 0));
		float y = (float)NUM2DBL(rb_ary_entry(vScale, 1));
		pSelf->SetScale(x, y);
	} else
		rb_raise(rb_eTypeError, "wrong argument type(s)");
	return Qnil;
}
Exemple #19
0
bool Scene::DoesIntersect(const Ray &ray, double maxDistance)
{
    for (std::vector<Drawable *>::const_iterator i = m_DrawableList.begin(); i != m_DrawableList.end(); i++) {
        Drawable *d = *i;

        Vector3d pos;
        Vector3d normal;
        if (d->Intersect(ray, pos, normal)) {
            if ((ray.origin - pos).Length() < maxDistance)
                return true;
        }
    }

    return false;
}
Exemple #20
0
bool SpaceshipGame::drawScene(Node* node, void* cookie)
{
    Drawable* drawable = node->getDrawable();
    if (drawable)
    {
        // Transparent nodes must be drawn last (stage 1)
        bool isTransparent = (node == _glowNode);

        // Skip transparent objects for stage 0
        if ((!isTransparent && (int*)cookie == 0) || (isTransparent && (int*)cookie == (int*)1))
            drawable->draw();
    }

    return true;
}
Exemple #21
0
void Drawable::update(void) {
	Drawable* d = _children;

	if (_parent) {
		_abs_xy.x = _parent->_abs_xy.x + _rel_xy.x;
		_abs_xy.y = _parent->_abs_xy.y + _rel_xy.y;
	} else {
		_abs_xy.x = _rel_xy.x;
		_abs_xy.y = _rel_xy.y;
	}

	while (d) {
		d->update();
		d = d->_next;
	}
}
Image ProjectExporter::rescaleImageForIcon (Drawable& d, const int size)
{
    if (DrawableImage* drawableImage = dynamic_cast<DrawableImage*> (&d))
    {
        Image im = SoftwareImageType().convert (drawableImage->getImage());

        if (size == im.getWidth() && size == im.getHeight())
            return im;

        // (scale it down in stages for better resampling)
        while (im.getWidth() > 2 * size && im.getHeight() > 2 * size)
            im = im.rescaled (im.getWidth() / 2,
                              im.getHeight() / 2);

        Image newIm (Image::ARGB, size, size, true, SoftwareImageType());
        Graphics g (newIm);
        g.drawImageWithin (im, 0, 0, size, size,
                           RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false);
        return newIm;
    }

    Image im (Image::ARGB, size, size, true, SoftwareImageType());
    Graphics g (im);
    d.drawWithin (g, im.getBounds().toFloat(), RectanglePlacement::centred, 1.0f);
    return im;
}
Exemple #23
0
void arkanoid::Game::draw_object(Drawable &dr){
	if(dr.is_visible()){
		if(dr.d_id == 0){
			dr_counter++;
			dr.d_id = dr_counter;
			drawed.push_back(dr);
		}
		

		float xdiff = static_cast<float>(actual_max_col) / static_cast<float>(default_max_col);
		float ydiff = static_cast<float>(actual_max_row) / static_cast<float>(default_max_row);
		unsigned start_r = round(dr.d_start_row * ydiff);
		unsigned end_r = round(dr.d_end_row * ydiff);
		unsigned start_c = round(dr.d_start_col * xdiff);
		unsigned end_c = round(dr.d_end_col* xdiff);

		use_color(dr.d_color);

		for(unsigned i = start_r; i <= end_r; i++)
		{
			for(unsigned j = start_c; j <= end_c; j++)
			{
		
				mvprintw(i, j, "%c", dr.d_ch);
				refresh();
		
			}
		}
	}
}
	void capture(Graphics& gl, const Lens& cam, const Pose& pose, Drawable& draw) {
		validate();
		
		glPushAttrib(GL_ALL_ATTRIB_BITS);
		
		Vec3d pos = pose.pos();
		Vec3d ux, uy, uz; 
		pose.unitVectors(ux, uy, uz);
		mProjection = Matrix4d::perspective(90, 1, cam.near(), cam.far());
		
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFboId);
		for (int face=0; face<6; face++) {
			glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT+face);
			
			gl.viewport(0, 0, resolution(), resolution());
			gl.clearColor(clearColor());
			gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
			
			switch (face) {
				case 0:
					// GL_TEXTURE_CUBE_MAP_POSITIVE_X   
					mModelView = Matrix4d::lookAt(uz, uy, -ux, pos);
					break;
				case 1:
					// GL_TEXTURE_CUBE_MAP_NEGATIVE_X   
					mModelView = Matrix4d::lookAt(-uz, uy, ux, pos);
					break;
				case 2:
					// GL_TEXTURE_CUBE_MAP_POSITIVE_Y   
					mModelView = Matrix4d::lookAt(ux, -uz, uy, pos);
					break;
				case 3:
					// GL_TEXTURE_CUBE_MAP_NEGATIVE_Y   
					mModelView = Matrix4d::lookAt(ux, uz, -uy, pos);
					break;
				case 4:
					// GL_TEXTURE_CUBE_MAP_POSITIVE_Z   
					mModelView = Matrix4d::lookAt(ux, uy, uz, pos);
					break;
				default:
					// GL_TEXTURE_CUBE_MAP_NEGATIVE_Z   
					mModelView = Matrix4d::lookAt(-ux, uy, -uz, pos);
					break;
			}
			
			// apply camera transform:
			gl.pushMatrix(gl.PROJECTION);
			gl.loadMatrix(mProjection);
			gl.pushMatrix(gl.MODELVIEW);
			gl.loadMatrix(mModelView);
			
			draw.onDraw(gl);
			
			gl.popMatrix(gl.PROJECTION);
			gl.popMatrix(gl.MODELVIEW);
		}
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
		
		glPopAttrib();
	}
void Ball::check_paddle(Drawable paddle){
    if(this->intersect(paddle)){
        glm::vec2 paddle_loc = paddle.get_location();
        glm::vec2 paddle_dim = paddle.get_dimensions();
        //Calulate istance from center of paddle
        GLfloat distance = vertex.x - (paddle_loc.x + ((paddle_dim.x/2)));
        GLfloat percentage = distance/(paddle_dim.x);
    
        //Calculate new velocity
        glm::vec2 prev_velocity = this->velocity;
        velocity.x =  3 * percentage;
        velocity.y = -1*abs(velocity.y);
        
        //Normalize to maintain constant speed
       // velocity = glm::normalize(velocity)*glm::length(prev_velocity);                         
   }
}
Exemple #26
0
IntersectionData KDTree::closestIntersection(const vector<Drawable *> &objList, const ray &viewRay) {
    IntersectionData intersection;
    intersection.obj = NULL;
    intersection.time = std::numeric_limits<double>::max();

    double tmp_time;
    for(unsigned int i = 0; i < objList.size(); i++) {
        Drawable *object = objList[i];
        tmp_time = object->intersection(viewRay);
        if(tmp_time > EPSILON && tmp_time < intersection.time) {
            intersection.time = tmp_time;
            intersection.obj = object;
        }
    }

    return intersection;
}
Exemple #27
0
bool TerrainSample::drawScene(Node* node)
{
    Camera* camera = _scene->getActiveCamera();
    Drawable* drawable = node->getDrawable();
    if (dynamic_cast<Model*>(drawable))
    {
        if (!node->getBoundingSphere().intersects(camera->getFrustum()))
            return true;
    }
    if (drawable)
    {
        bool wireframe = (node == _sky) ? false : _wireframe;
        drawable->draw(wireframe);
    }

	return true;
}
Exemple #28
0
void Object_destroy(Drawable* drawable)
{
	Object* self = (Object*)drawable;
	uint32_t i, j;
	for(i=0; i < self->nbCasesX; i++)
	{
		for(j=0; j < self->nbCasesY; j++)
		{
			Drawable* tile = (Drawable*)(self->tiles[i][j]);
			if(tile != NULL)
				tile->destroy(tile);
		}
		free(self->tiles[i]);
	}
	free(self->tiles);
	free(self);
}
Exemple #29
0
static bool Cull(const Frustum & f, const Drawable & d)
{
	const float radius = d.GetRadius();
	Vec3 center = d.GetObjectCenter();
	d.GetTransform().TransformVectorOut(center[0], center[1], center[2]);
	for (int i = 0; i < 6; i++)
	{
		const float rd =
			f.frustum[i][0] * center[0] +
			f.frustum[i][1] * center[1] +
			f.frustum[i][2] * center[2] +
			f.frustum[i][3];
		if (rd <= -radius)
			return true;
	}
	return false;
}
Exemple #30
0
////////////////////////////////////////////////////////////
/// Draw something on the window
////////////////////////////////////////////////////////////
void RenderWindow::Draw(const Drawable& Object) const
{
    // Check whether we are called from the outside or from a previous call to Draw
    if (!myIsDrawing)
    {
        myIsDrawing = true;

        // Set our window as the current target for rendering
        if (SetActive())
        {
            // Save the current render states and set the SFML ones
            if (myPreserveStates)
            {
                GLCheck(glMatrixMode(GL_MODELVIEW));  GLCheck(glPushMatrix());
                GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glPushMatrix());
                GLCheck(glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT   | GL_ENABLE_BIT  |
                                     GL_TEXTURE_BIT      | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT));
                SetRenderStates();
            }

            // Set the window viewport and transform matrices
            GLCheck(glViewport(0, 0, GetWidth(), GetHeight()));
            GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glLoadMatrixf(myCurrentView->GetMatrix().Get4x4Elements()));
            GLCheck(glMatrixMode(GL_MODELVIEW));  GLCheck(glLoadIdentity());

            // Let the object draw itself
            Object.Draw(*this);

            // Restore render states
            if (myPreserveStates)
            {
                GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glPopMatrix());
                GLCheck(glMatrixMode(GL_MODELVIEW));  GLCheck(glPopMatrix());
                GLCheck(glPopAttrib());
            }
        }

        myIsDrawing = false;
    }
    else
    {
        // We are already called from a previous Draw : we don't need to set the states again, just draw the object
        Object.Draw(*this);
    }
}