buw::vector2d OpenInfraPlatform::Infrastructure::VerticalAlignmentElement2DArc::Rotate(const double angle, const vector2d& v) const
{
	return buw::vector2d(
		std::cos(angle) * v.x() - std::sin(angle) * v.y(),
		std::sin(angle) * v.x() + std::cos(angle) * v.y()
	);
}
예제 #2
0
	float footholdtree::nextground(bool left, vector2d pos)
	{
		//return getgroundbelow(pos);

		short nextid = -1;
		if (left && pos.x() < ground.horizontal.x())
		{
			nextid = ground.prev;
		}
		else if (!left && pos.x() > ground.horizontal.y())
		{
			nextid = ground.next;
		}

		if (nextid > 0)
		{
			ground = footholds[nextid];

			if (ground.isfloor())
			{
				return static_cast<float>(ground.vertical.x());
			}
			else
			{
				float step = static_cast<float>((ground.vertical.y() - ground.vertical.x())) / (ground.horizontal.y() - ground.horizontal.x());
				return static_cast<float>(ground.vertical.x() + (step * (pos.x() - ground.horizontal.x())));
			}
		}
		else
		{
			return getgroundbelow(pos);
		}
	}
예제 #3
0
	mesodrop::mesodrop(short o, animation* ani, int own, vector2d pos, vector2d dst, char type, bool pld)
	{
		oid = o;
		anim = ani;
		owner = own;
		pickuptype = type;
		playerdrop = pld;

		fx = static_cast<float>(pos.x());
		fy = static_cast<float>(pos.y());

		updatefht();

		dalpha = 1.0f;
		alpha = 1.0f;
		moved = 0.0f;

		if (pos == dst)
		{
			state = DST_FLOATING;
			vspeed = 0;
			hspeed = 0;
			basey = fy;
		}
		else
		{
			state = DST_DROPPED;
			vspeed = -6.0f;
			hspeed = static_cast<float>(dst.x() - pos.x()) / 16;
		}
	}
예제 #4
0
float vector2d::operator * (vector2d vec) const {
	/*!	\brief Calculates the scalar product of the object it is called on and the vector in the argument and returns the result.
	 *	\param vec vector2d to multiply with.
	 *	\return The scalar product.
	 */
	return ((_x * vec.getX()) + (_y * vec.getY()));
}
예제 #5
0
vector2d vector2d::operator - (vector2d vec) const {
	/*!	\brief Substracts the vector from the argument from this vector and returns the result.
	 *	\param vec Vector to substract.
	 *	\return The difference.
	 */
	vector2d tmp(_x - vec.getX(), _y - vec.getY());
	return tmp;
}
예제 #6
0
vector2d vector2d::operator + (vector2d vec) const {
	/*!	\brief Adds the vector from the argument to this vector and returns the result.
	 *	\param vec Vector to add.
	 *	\return The sum.
	 */
	vector2d tmp(_x + vec.getX(), _y + vec.getY());
	return tmp;
}
예제 #7
0
vector2d vector2d::operator += (vector2d vec) {
	/*!	\brief Adds the vector in the argument and returns the sum.
	 *	\param vec The vektor2d to add.
	 *	\return The resulting vector2d.
	 */
	 _x += vec.getX();
	 _y += vec.getY();
	 
	 return *this;
}
예제 #8
0
vector2d vector2d::operator -= (vector2d vec) {
	/*!	\brief Substracts the vector in the argument and returns the result.
	 *	\param vec vektor2d to substract.
	 *
	 *	\return The resulting vector2d.
	 */
	 _x -= vec.getX();
	 _y -= vec.getY();
	 
	 return *this;
}
예제 #9
0
	float footholdtree::getgroundbelow(vector2d pos)
	{
		foothold ret;
		float ycomp = 65536;
		pos = pos - vector2d(0, 5);
		for (map<short, foothold>::iterator ftit = footholds.begin(); ftit != footholds.end(); ftit++)
		{
			if (ftit->second.horizontal.contains(pos.x()))
			{
				float y;
				if (ftit->second.isfloor())
				{
					y = static_cast<float>(ftit->second.vertical.x());
				}
				else
				{
					float step = static_cast<float>((ftit->second.vertical.y() - ftit->second.vertical.x())) / (ftit->second.horizontal.y() - ftit->second.horizontal.x());
					y = static_cast<float>(ftit->second.vertical.x() + (step * (pos.x() - ftit->second.horizontal.x())));
				}

				if (ycomp > y && y > pos.y())
				{
					ret = ftit->second;
					ycomp = y;
				}
			}
		}

		ground = ret;
		return ycomp;
		

		/*int closest = lowestg;
		pos = pos - vector2d(0, 5);

		for (vector<map<short, short>>::iterator pfit = platforms.begin(); pfit != platforms.end(); ++pfit)
		{
			if (pfit->count(pos.x()))
			{
				int py = pfit->at(pos.x());

				if (py <= closest && py >= pos.y())
				{
					closest = py;
				}
			}
		}

		return static_cast<float>(closest);*/
	}
예제 #10
0
bool vector2d::operator!=(const vector2d& other)
{
	int i = 0;

	if (afData[0] == other.x())
	{
		i++;
	}
	if (afData[1] == other.y())
	{
		i++;
	}
	return i != 2;
}
예제 #11
0
int main()
{
    device = createDevice(EDT_OPENGL, dimension2d<u32>(screenWidth, screenHeight), 16,
                                          false, false, false, 0);
    if (!device)
        return 1;

    IVideoDriver* driver = device->getVideoDriver();

    MyEventReceiver receiver;
    device->setEventReceiver(&receiver);

    image = driver->getTexture("/home/fuyajun/Documents/irrlicht-1.7.2/media/fireball.bmp");

    position.set(0,0);
    direction.set(1,1);

    u32 then = device->getTimer()->getTime();

    while (device->run())
    {
        const u32 now = device->getTimer()->getTime();
        const f32 deltaTime = (f32)(now - then);
        then = now;

        update(deltaTime);

        driver->beginScene(true, true, SColor(255,255,255,255));

        driver->draw2DImage(image, position2d<s32>((s32)position.X, (s32)position.Y), rect<s32>(0, 0, 32, 32), 0, SColor(255, 255, 255, 255), true);

        driver->endScene();

        core::stringw str = L"x: ";
        str += target.X;
        str += ", y: ";
        str += target.Y;
        str += ", posX: ";
        str += position.X;
        str += ", posY: ";
        str += position.Y;

        device->setWindowCaption(str.c_str());
    }

    device->drop();

    return 0;
}
예제 #12
0
	void TextWrapperGL::draw(vector2d<int32_t> pos) const
	{
		const FontsFT* fonts = LocatorGL::getfonts();
		if (false)
		{
			const FT_Face* fontface = fonts->getfont(font);
			if (*fontface)
			{
				float x = static_cast<float>(pos.x());
				float y = static_cast<float>(pos.y());

				//glBlendFunc(GL_SRC_ALPHA, GL_ZERO);

				for (size_t i = 0; i < str.size(); i++)
				{
					int8_t ch = str[i];
					FT_GlyphSlot g = (*fontface)->glyph; 
					
					FT_UInt  glyph_index = FT_Get_Char_Index(*fontface, ch);

					if (FT_Load_Glyph(*fontface, glyph_index, FT_LOAD_DEFAULT) == FT_Err_Ok)
					{
						if (FT_Render_Glyph(g, FT_RENDER_MODE_NORMAL) == FT_Err_Ok)
						{
							glBindTexture(GL_TEXTURE_2D, texture);
							glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, g->bitmap.width, g->bitmap.rows, 0, GL_RED, GL_UNSIGNED_BYTE, g->bitmap.buffer);

							x += g->advance.x >> 6;
						}
					}
				}

				/*glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

				GLfloat left = pos.x();
				GLfloat right = pos.x() + x;
				GLfloat top = y;
				GLfloat bottom = y + 14;

				glBegin(GL_QUADS);
				glTexCoord2f(0, 0); glVertex3f(left, top, 0);
				glTexCoord2f(0, 1); glVertex3f(left, bottom, 0);
				glTexCoord2f(1, 1); glVertex3f(right, bottom, 0);
				glTexCoord2f(1, 0); glVertex3f(right, top, 0);
				glEnd();*/
			}
		}
예제 #13
0
	int32_t Footholdtree::getlwall(vector2d<int32_t> pos) const
	{
		int32_t ret = walls.x();
		vector2d<int32_t> ver = vector2d<int32_t>(pos.y() - 80, pos.y() - 20);
		for (map<uint16_t, Foothold>::const_iterator ftit = footholds.begin(); ftit != footholds.end(); ++ftit)
		{
			Foothold fh = ftit->second;
			if (fh.getver().overlaps(ver) && fh.iswall())
			{
				int32_t x = fh.getl();
				if (x > ret && x <= pos.x())
				{
					ret = x;
				}
			}
		}
		return ret;
	}
예제 #14
0
	void imagecache::draw(imgcontext ict, size_t id, D2D1_RECT_F r, float alpha, float xscale, float yscale, vector2d center)
	{
		target->SetTransform(
			D2D1::Matrix3x2F::Scale(
			D2D1::Size(xscale, yscale),
			D2D1::Point2F(
			static_cast<float>(center.x()),
			static_cast<float>(center.y())
			)));

		draw(ict, id, r, alpha);

		target->SetTransform(
			D2D1::Matrix3x2F::Scale(
			D2D1::Size(1.0f, 1.0f),
			D2D1::Point2F(
			static_cast<float>(center.x()),
			static_cast<float>(center.y())
			)));
	}
예제 #15
0
	foothold footholdtree::getbelow(vector2d pos)
	{
		foothold ret;
		float comp = 65536;
		pos = pos - vector2d(0, 10);

		for (map<short, foothold>::iterator ftit = footholds.begin(); ftit != footholds.end(); ftit++)
		{
			foothold fh = ftit->second;

			if (fh.hcontains(pos.x()))
			{
				float y = fh.resolvex(pos.x());

				if (comp > y && y > pos.y())
				{
					ret = fh;
					comp = y;
				}
			}
		}

		return ret;
	}
예제 #16
0
    virtual bool OnEvent(const SEvent& event)
    {
        if (event.EventType == EET_MOUSE_INPUT_EVENT)
        {
            if (event.MouseInput.isLeftPressed())
            {
                target.X = (f32)event.MouseInput.X;
                target.Y = (f32)event.MouseInput.Y;

                direction = target - position;
                direction.normalize();//方向向量
            }
        }
        return false;
    }
예제 #17
0
	void BitmapWrapperD2D::draw(rectangle2d<int32_t> rect, float_t xscale, float_t yscale, vector2d<int32_t> center, float_t alpha) const
	{
		ID2D1BitmapRenderTarget* target = Graphics::locator.gettarget();
		if (target)
		{
			bool transform = (xscale != 1.0f) || (yscale != 1.0f);

			if (transform)
			{
				target->SetTransform(
					D2D1::Matrix3x2F::Scale(
					D2D1::Size(xscale, yscale),
					D2D1::Point2F(
					static_cast<FLOAT>(center.x()),
					static_cast<FLOAT>(center.y())
					)));
			}

			if (source)
			{
				D2D_RECT_F r = D2D1::RectF((FLOAT)rect.l(), (FLOAT)rect.t(), (FLOAT)rect.r(), (FLOAT)rect.b());
				target->DrawBitmap(source, r, alpha);
			}

			if (transform)
			{
				target->SetTransform(
					D2D1::Matrix3x2F::Scale(
					D2D1::Size(1.0f, 1.0f),
					D2D1::Point2F(
					static_cast<FLOAT>(center.x()),
					static_cast<FLOAT>(center.y())
					)));
			}
		}
	}
예제 #18
0
		void draw(size_t id, rectangle2d<int16_t> rect, float xscale, 
			float yscale, vector2d<int16_t> center, float alpha) {

			if (!available(id))
				return;

			GLfloat left = center.x() + xscale * (rect.l() - center.x());
			GLfloat right = center.x() + xscale * (rect.r() - center.x());
			GLfloat top = center.y() + yscale * (rect.t() - center.y());
			GLfloat bottom = center.y() + yscale * (rect.b() - center.y());

			glBindTexture(GL_TEXTURE_2D, bitmaps[id]);
			glBegin(GL_QUADS);
			glTexCoord2f(0, 0); glVertex3f(left, top, 0);
			glTexCoord2f(0, 1); glVertex3f(left, bottom, 0);
			glTexCoord2f(1, 1); glVertex3f(right, bottom, 0);
			glTexCoord2f(1, 0); glVertex3f(right, top, 0);
			glEnd();
		}
예제 #19
0
vector2d vector2d::multiply(const vector2d& other) const
{
	vector2d multiply(afData[0] * other.x(), afData[1] * other.y());
	return multiply;
}
예제 #20
0
vector2d vector2d::add(const vector2d& other) const
{
	vector2d add(afData[0] + other.x(), afData[1] + other.y());
	return add;
}
예제 #21
0
vector2d vector2d::subtract(const vector2d& other) const
{
	vector2d subtract(afData[0] - other.x(), afData[1] - other.y());
	return subtract;
}
예제 #22
0
float vector2d::crossProduct(const vector2d& other) const
{
	float crossProduct = (afData[0] * other.y() - afData[1] * other.x());
	return crossProduct;
}
예제 #23
0
float vector2d::angle(const vector2d& other) const
{
	float angle = cos(dotProduct(other) / other.magnitude() * sqrt(afData[0] * afData[0] + afData[1] * afData[1]));
	return angle;
}
예제 #24
0
void vector2d::set(vector2d vector)
{
	afData[0] = vector.x();
	afData[1] = vector.y();
}
예제 #25
0
	bool vector2d::operator != (vector2d v)
	{
		return a != v.x() || b != v.y();
	}
예제 #26
0
bool vector2d::operator==(const vector2d& other)
{
	return afData[0] == other.x() && afData[1] == other.y();
}
예제 #27
0
	bool vector2d::operator == (vector2d v)
	{
		return a == v.x() && b == v.y();
	}
예제 #28
0
	void Player::setposition(vector2d<int32_t> pos)
	{
		phobj.fx = static_cast<float>(pos.x());
		phobj.fy = static_cast<float>(pos.y());
	}
예제 #29
0
	vector2d vector2d::operator / (vector2d v)
	{
		int x = (v.x() == 0) ? 1 : v.x();
		int y = (v.y() == 0) ? 1 : v.y();
		return vector2d(a / x, b / y);
	}
예제 #30
0
float vector2d::dotProduct(const vector2d& other) const
{
	float dotProduct = (afData[0] * other.x()) + (afData[1] * other.y());
	return dotProduct;
}