Example #1
0
	TransformNode::TransformNode(Renderer& rend)
		: SceneNode(rend)
	{
		setTranslate(0, 0, 0);
		setRotate(0, 0, 0);
		setScale(1, 1, 1);
	}
Matr4::Matr4(const Vect4& xAxis, const Vect4& yAxis, const Vect4& zAxis, const Vect4& translate)
{
   memset(_elems, 0, sizeof(_elems));
   setAxisX(xAxis);
   setAxisY(yAxis);
   setAxisZ(zAxis);
   setTranslate(translate);
}
Example #3
0
// Mouse Wheel Click Drag
void GuiMaterialPreview::onMiddleMouseDragged(const GuiEvent &event)
{
   if (mMouseState != Panning)
   {
      return;
   }
   Point2I delta = event.mousePoint - mLastMousePoint;
   mLastMousePoint = event.mousePoint;
   setTranslate(event.modifier, delta.x, delta.y);
}
Matr4::Matr4(const Vect4& rotVect, const Vect4& transVect, const Vect4& scaleVect)
{
   memset(_elems, 0, sizeof(_elems));
   setTranslate(transVect);

   rotateX(rotVect[0]);
   rotateY(rotVect[1]);
   rotateZ(rotVect[2]);

   scale(scaleVect);
}
Example #5
0
void flag::drawObject() {

    GLenum errCode;
    const GLubyte *errString;

    //glPushMatrix();
    //glLoadIdentity();
    setTranslate();
    setRotate();
    if(colorMode == _glColor) {
        glEnable(GL_COLOR_MATERIAL);
        setColor();
    } else {
        glDisable(GL_COLOR_MATERIAL);
    }
    setScale();

    //qDebug() << "Drawing object\n";

    glBindTexture(GL_TEXTURE_2D,textureId);
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 8" << errCode;
    }
    setMaterial();
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 9" << errCode;
    }
    glBegin(GL_TRIANGLES);
    for(int i = 0; i < vertices.size();i++) {
        glNormal3f(normals.at(i).x(), normals.at(i).y(), normals.at(i).z());
        glTexCoord2f(textures.at(i).x(), textures.at(i).y());
        glVertex3f(vertices.at(i).x(), vertices.at(i).y(), vertices.at(i).z());
    }
    glEnd();
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 10" << errCode;
    }
    glBindTexture(GL_TEXTURE_2D,0);
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 11" << errCode;
    }
    //glPopMatrix();

    if(debug) {

        debug = false;
    }

}
Example #6
0
bool
TerrainGrass::createObject(TerrainMapPtr map) noexcept
{
	auto mesh = std::make_shared<ray::MeshProperty>();

	for (auto& it : map->getEntrys())
	{
		if (it.empty() || it.instanceID != _grass->getInstance())
			continue;

		if (it.y <= 0)
			continue;

		VisiableFaces faces;
		int total = this->visiable(map, it, faces);
		if (total)
		{
			int dx = it.x << 1;
			int dy = it.y << 1;
			int dz = it.z << 1;

			this->makeCube(mesh, faces, dx, dy, dz, 1);
		}
	}

	if (mesh->getNumVertices())
	{
		int mx, my, mz;
		map->getPosition(mx, my, mz);

		int size = map->size();

		int offsetX = mx * size << 1;
		int offsetY = my * size << 1;
		int offsetZ = mz * size << 1;

		auto gameObject = _grassObject->clone();
		gameObject->setName(ray::format("chunk_%d_%d_%d") % offsetX % offsetY % offsetZ);
		gameObject->setTranslate(ray::Vector3(offsetX, offsetY, offsetZ));
		gameObject->getComponent<ray::MeshComponent>()->setMesh(mesh);

		auto rigidbody = std::make_shared<ray::PhysicsBodyComponent>();
		gameObject->addComponent(rigidbody);
		gameObject->addComponent(std::make_shared<ray::PhysicsMeshComponent>());

		_object = gameObject;

		return true;
	}

	return false;
}
Example #7
0
CMatrix::CMatrix(const float *quat,const float *pos)
{
	if ( quat )
	{
		CQuaternion q(quat);
		q.toMatrix(*this);
	}
	else
	{
		identity();
	}
	if ( pos ) setTranslate(pos);
}
Example #8
0
void MMSLabelWidget::updateFromThemeClass(MMSLabelWidgetClass *themeClass) {

    // update widget-specific settings
    if (themeClass->isSlidable())
        setSlidable(themeClass->getSlidable());
    if (themeClass->isSlideSpeed())
        setSlideSpeed(themeClass->getSlideSpeed());
    if (themeClass->isTranslate())
        setTranslate(themeClass->getTranslate());

    // update base text-specific settings
    MMSTEXTBASE_UPDATE_FROM_THEME_CLASS(this, themeClass);

    // update general widget settings
    MMSWidget::updateFromThemeClass(&(themeClass->widgetClass));
}
	bool UIElement::Load(TiXmlNode* x_RootNode){
		//Check it has a base
		TiXmlNode* xNode;
		TiXmlElement * xInfoElement;
		TiXmlNode* xBase = x_RootNode->FirstChild("base");
		if (!xBase){
			Logger::Log("Could not find 'info' Node. \n");
			return false;
		}
		xInfoElement = xBase->ToElement();

	//Define all the BASE variables
		char* buffer;
		buffer = (char*)xInfoElement->Attribute("location");

		if (std::strcmp(buffer,"TOP_LEFT") == 0){
			lPivot = Location::TOP_LEFT;
		}else if (std::strcmp(buffer,"TOP_CENTER") == 0){
			lPivot = Location::TOP_CENTER;
		}else if (std::strcmp(buffer,"TOP_RIGHT") == 0){
			lPivot = Location::TOP_RIGHT;
		}else if (std::strcmp(buffer,"CENTER_LEFT") == 0){
			lPivot = Location::CENTER_LEFT;
		}else if (std::strcmp(buffer,"CENTER_CENTER") == 0){
			lPivot = Location::CENTER_CENTER;
		}else if (std::strcmp(buffer,"CENTER_RIGHT") == 0){
			lPivot = Location::CENTER_RIGHT;
		}else if (std::strcmp(buffer,"BOTTOM_LEFT") == 0){
			lPivot = Location::BOTTOM_LEFT;
		}else if (std::strcmp(buffer,"BOTTOM_CENTER") == 0){
			lPivot = Location::BOTTOM_CENTER;
		}else if (std::strcmp(buffer,"BOTTOM_RIGHT") == 0){
			lPivot = Location::BOTTOM_RIGHT;
		}

		xNode = xBase->FirstChild("Colour");
		if (!xNode){Logger::Log("Could not find 'Colour' Node. \n");return false;}
		xInfoElement = xNode->ToElement();
		glm::vec4 Colour(0);
		xInfoElement->QueryFloatAttribute("r",&Colour.r);
		xInfoElement->QueryFloatAttribute("g",&Colour.g);
		xInfoElement->QueryFloatAttribute("b",&Colour.b);
		xInfoElement->QueryFloatAttribute("a",&Colour.a);
		setColour(Colour);

		xNode = xBase->FirstChild("Position");
		if (!xNode){Logger::Log("Could not find 'Position' Node. \n");return false;}
		xInfoElement = xNode->ToElement();
		glm::vec3 Position(0);
		float Offset = 0;
		xInfoElement->QueryFloatAttribute("x",&Position.x);
		xInfoElement->QueryFloatAttribute("y",&Position.y);
		xInfoElement->QueryFloatAttribute("z",&Position.z);
		xInfoElement->QueryFloatAttribute("o",&Offset);
		setOffset(Offset);
		setTranslate(Position);

		xNode = xBase->FirstChild("Rotation");
		if (!xNode){Logger::Log("Could not find 'Rotation' Node. \n");return false;}
		xInfoElement = xNode->ToElement();
		float Rotation;
		xInfoElement->QueryFloatAttribute("r",&Rotation);
		setRotation(Rotation);

		xNode = xBase->FirstChild("Scale");
		if (!xNode){Logger::Log("Could not find 'Scale' Node. \n");return false;}
		xInfoElement = xNode->ToElement();
		glm::vec2 Scale(0);
		xInfoElement->QueryFloatAttribute("x",&Scale.x);
		xInfoElement->QueryFloatAttribute("y",&Scale.y);
		setScale(Scale);

		xNode = xBase->FirstChild("Size");
		if (!xNode){Logger::Log("Could not find 'Size' Node. \n");return false;}
		xInfoElement = xNode->ToElement();
		glm::vec2 Size(0);
		xInfoElement->QueryFloatAttribute("x",&Size.x);
		xInfoElement->QueryFloatAttribute("y",&Size.y);
		setScale(Size);

		return true;
	}
Example #10
0
bool
TerrainTree::createObject(TerrainMapPtr map) noexcept
{
	auto woods = std::make_shared<ray::MeshProperty>();
	auto leafs = std::make_shared<ray::MeshProperty>();

	for (auto& it : map->getEntrys())
	{
		if (it.empty())
			continue;

		if (it.instanceID != _wood->getInstance() &&
			it.instanceID != _leaf->getInstance())
			continue;

		VisiableFaces faces;
		int total = this->visiable(map, it, faces);
		if (total)
		{
			int dx = it.x << 1;
			int dy = it.y << 1;
			int dz = it.z << 1;

			if (it.instanceID == _wood->getInstance())
				this->makeCube(woods, faces, dx, dy, dz, 1);

			if (it.instanceID == _leaf->getInstance())
				this->makeCube(leafs, faces, dx, dy, dz, 1);
		}
	}

	int mx, my, mz;
	map->getPosition(mx, my, mz);

	int size = map->size();

	int offsetX = mx * size << 1;
	int offsetY = my * size << 1;
	int offsetZ = mz * size << 1;

	if (woods->getNumVertices())
	{
		auto gameObject = _woodObject->clone();
		gameObject->setName(ray::format("chunk_wood_%d_%d_%d") % offsetX % offsetY % offsetZ);
		gameObject->setTranslate(ray::Vector3(offsetX, offsetY, offsetZ));
		gameObject->getComponent<ray::MeshComponent>()->setMesh(woods);

		auto rigidbody = std::make_shared<ray::PhysicsBodyComponent>();
		gameObject->addComponent(rigidbody);
		gameObject->addComponent(std::make_shared<ray::PhysicsMeshComponent>());

		_objects.push_back(gameObject);
	}

	if (leafs->getNumVertices())
	{
		auto gameObject = _leafObject->clone();
		gameObject->setName(ray::format("chunk_leaf_%d_%d_%d") % offsetX % offsetY % offsetZ);
		gameObject->setTranslate(ray::Vector3(offsetX, offsetY, offsetZ));
		gameObject->getComponent<ray::MeshComponent>()->setMesh(leafs);

		auto rigidbody = std::make_shared<ray::PhysicsBodyComponent>();
		gameObject->addComponent(rigidbody);
		gameObject->addComponent(std::make_shared<ray::PhysicsMeshComponent>());

		_objects.push_back(gameObject);
	}

	if (!_objects.empty())
		return true;

	return false;
}
Example #11
0
void Transformable::setTranslate(
		vec3f	v
	)
{
	setTranslate(v.x, v.y, v.z);
}
Example #12
0
Matrix4::Matrix4(const Vector3& trans)
{
	setTranslate(trans);
}
Example #13
0
Matr4::Matr4(const Vect4& pos)
{
  *this = Identity;
  setTranslate(pos);
}