void GenericEntityNode::_applyTransformation()
{
	if (getType() == TRANSFORM_PRIMITIVE)
	{
		m_contained.revertTransform();

		m_contained.translate(getTranslation());
		m_contained.rotate(getRotation());

		m_contained.freezeTransform();
	}
}
void GenericEntityNode::_onTransformationChanged()
{
	if (getType() == TRANSFORM_PRIMITIVE)
	{
		m_contained.revertTransform();

		m_contained.translate(getTranslation());
		m_contained.rotate(getRotation());

		m_contained.updateTransform();
	}
}
Exemple #3
0
int	Shape::getHeight(bool rotated)
{
	if(rotated)
		return mBoundingBox.bottom - mBoundingBox.top;
	else	{
		float rotation = getRotation();
		rotate(-rotation);
		int height = mBoundingBox.bottom - mBoundingBox.top;
		rotate(rotation);
		return height;
	}
}
Exemple #4
0
void Sphere3DOverlay::render(RenderArgs* args) {
    if (!_visible) {
        return; // do nothing if we're not visible
    }

    const int SLICES = 15;
    float alpha = getAlpha();
    xColor color = getColor();
    const float MAX_COLOR = 255.0f;
    glm::vec4 sphereColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);

    auto batch = args->_batch;

    if (batch) {
        Transform transform;
        transform.setTranslation(_position);
        transform.setRotation(_rotation);
        transform.setScale(_dimensions);

        batch->setModelTransform(transform);
        DependencyManager::get<GeometryCache>()->renderSphere(*batch, 1.0f, SLICES, SLICES, sphereColor, _isSolid);
    } else {
        glDisable(GL_LIGHTING);
        
        glm::vec3 position = getPosition();
        glm::vec3 center = getCenter();
        glm::vec3 dimensions = getDimensions();
        glm::quat rotation = getRotation();

        float glowLevel = getGlowLevel();
        Glower* glower = NULL;
        if (glowLevel > 0.0f) {
            glower = new Glower(glowLevel);
        }

        glPushMatrix();
            glTranslatef(position.x, position.y, position.z);
            glm::vec3 axis = glm::axis(rotation);
            glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
            glPushMatrix();
                glm::vec3 positionToCenter = center - position;
                glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
                glScalef(dimensions.x, dimensions.y, dimensions.z);
                DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES, sphereColor, _isSolid);
            glPopMatrix();
        glPopMatrix();
        
        if (glower) {
            delete glower;
        }
    }

}
Exemple #5
0
int Shape::getWidth(bool rotated)
{
	if(rotated)
		return mBoundingBox.right - mBoundingBox.left;
	else	{
		float rotation = getRotation();
		rotate(-rotation);
		int width =  mBoundingBox.right - mBoundingBox.left;
		rotate(rotation);
		return width;
	}
}
void EclassModelNode::_onTransformationChanged()
{
	if (getType() == TRANSFORM_PRIMITIVE)
	{
		_revertTransform();

		translate(getTranslation());
		rotate(getRotation());

		updateTransform();
	}
}
void EclassModelNode::_applyTransformation()
{
	if (getType() == TRANSFORM_PRIMITIVE)
	{
		_revertTransform();

		translate(getTranslation());
		rotate(getRotation());

		_freezeTransform();
	}
}
Exemple #8
0
//------------------------------------------------
void ofxBox2dRect::draw() {
	
	if(body == NULL) {
		return;	
	}
    
    ofPushMatrix();
    ofTranslate(ofxBox2dBaseShape::getPosition());
    ofRotateDeg(getRotation());
    mesh.draw(ofGetFill()==OF_FILLED?OF_MESH_FILL:OF_MESH_WIREFRAME);
    ofPopMatrix();
    
    /*
    const b2Transform& xf = body->GetTransform();
    ofPolyline shape;
    for (b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext()) {
        b2PolygonShape* poly = (b2PolygonShape*)f->GetShape();
        if(poly) {
            for(int i=0; i<poly->m_count; i++) {
                b2Vec2 pt = b2Mul(xf, poly->m_vertices[i]);
                shape.addVertex(worldPtToscreenPt(pt));
            }
        }
    }
    shape.close();
    shape.draw();*/


    // update the polyline
    // getRectangleShape();
    /*
    ofPath path;
    for (int i=0; i<shape.size(); i++) {
        if(i==0)path.moveTo(shape[i]);
        else path.lineTo(shape[i]);
    }
    
    // draw the path
    path.setColor(ofGetStyle().color);
    path.setFilled(ofGetStyle().bFill);
    path.draw();
    
    // are we sleeping
    if(isSleeping()) {
        ofPushStyle();
        ofEnableAlphaBlending();
        path.setColor(ofColor(255, 100));
        path.setFilled(true);
        path.draw();
        ofPopStyle();
    }
	*/
}
Exemple #9
0
void Graphics::update(double deltaTime)
{
	auto camera = scene.getActiveCamera();
	if (camera != nullptr)
	{
		auto rotation = camera->getRotation();
		//rotation.y -= 1.0f;
		camera->setRotation(rotation);
	}

	gui.update(deltaTime);
}
void PlayerVitalityParticle::render(double edt) {
    Engine::VideoSystem *videoSystem =
        Engine::Core::getInstance()->getVideoSystem();
    
    setBlendMode();
    videoSystem->bindTexture("Particles");

    double size = getSize();
    double opacity = getOpacity();
    double rotation = getRotation();
    int texture = getTexture();

    double pw = 1.0 / TEX_IMAGE_PARTICLE_WIDTH;
    double ph = 1.0 / TEX_IMAGE_PARTICLE_HEIGHT;

    double particleWidth = 8.0 * pw;
    double particleHeight = 8.0 * ph;

    int row = texture / 12;
    int col = texture % 12;

    double hOffset = col * (particleWidth + 2.0 * pw) + pw;
    double vOffset = 1.0 - ((row + 1) * (particleHeight + 2.0 * ph)) + ph;

    glColor4f(1.0f, 1.0f, 0.0f, opacity);

    glPushMatrix();
    glTranslatef(pos.x, pos.y, 0.0f);
    glRotatef(rotation, 0.0f, 0.0f, 1.0f);

    glBegin(GL_TRIANGLE_STRIP);

    glTexCoord2f(hOffset + particleWidth, vOffset);
    glVertex3f( 0.5 * size, -0.5 * size, 0.0f);

    glTexCoord2f(hOffset + particleWidth, vOffset + particleHeight);
    glVertex3f( 0.5 * size,  0.5 * size, 0.0f);

    glTexCoord2f(hOffset, vOffset);
    glVertex3f(-0.5 * size, -0.5 * size, 0.0f);

    glTexCoord2f(hOffset, vOffset + particleHeight);
    glVertex3f(-0.5 * size,  0.5 * size, 0.0f);

    glEnd();

    glPopMatrix();

    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void RenderableZoneEntityItem::render(RenderArgs* args) {
    if (_drawZoneBoundaries) {
        switch (getShapeType()) {
            case SHAPE_TYPE_COMPOUND: {
                updateGeometry();
                
                if (_model && _model->isActive()) {
                    PerformanceTimer perfTimer("zone->renderCompound");
                    glPushMatrix();
                    _model->renderInScene(getLocalRenderAlpha(), args);
                    glPopMatrix();
                }
                break;
            }
            case SHAPE_TYPE_BOX:
            case SHAPE_TYPE_SPHERE: {
                PerformanceTimer perfTimer("zone->renderPrimitive");
                glm::vec3 position = getPosition();
                glm::vec3 center = getCenter();
                glm::vec3 dimensions = getDimensions();
                glm::quat rotation = getRotation();
                
                glm::vec4 DEFAULT_COLOR(1.0f, 1.0f, 1.0f, getLocalRenderAlpha());
                
                glPushMatrix(); {
                    glTranslatef(position.x, position.y, position.z);
                    glm::vec3 axis = glm::axis(rotation);
                    glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
                    glPushMatrix(); {
                        glm::vec3 positionToCenter = center - position;
                        glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
                        glScalef(dimensions.x, dimensions.y, dimensions.z);
                        
                        auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
                        
                        if (getShapeType() == SHAPE_TYPE_SPHERE) {
                            const int SLICES = 15;
                            const int STACKS = 15;
                            deferredLightingEffect->renderWireSphere(0.5f, SLICES, STACKS, DEFAULT_COLOR);
                        } else {
                            deferredLightingEffect->renderWireCube(1.0f, DEFAULT_COLOR);
                        }
                    } glPopMatrix();
                } glPopMatrix();
                break;
            }
            default:
                // Not handled
                break;
        }
    }
}
Exemple #12
0
void Camera::render()
{
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    Quaternion<float> tmpQuat(getRotation());
    tmpQuat.inverse();
    static float *floatBuffer = new float[16];
    QuatUtil::store(tmpQuat, floatBuffer);
    glMultMatrixf(floatBuffer);
    Vector3<float> eye = getPosition();
    glTranslatef(-eye.x, -eye.y, -eye.z);
}
    void SceneObject::attachCamera( CameraPtr cam )
    {
        AssertMsg( cam->getFunctionality() == Camera::kFunc_FPS, "Cannot attach non-FPS cameras" );
		AssertMsg( mFPSCamera, "missing information about how to attach the camera" );
        mCamera = cam;
        mCamera->setTarget(mFPSCamera->target + getPosition());
        if (mCamera && mFPSCamera)
        {
            mFPSCamera->UpdatePosition(this, mCamera, getPosition());
            mFPSCamera->UpdateRotation(this, mCamera, getRotation());
        }

    }
void ImageBox::draw() 
{
	ofxBox2dRect::draw();
	ofPushMatrix();
		ofEnableAlphaBlending();
		ofTranslate(getPosition().x, getPosition().y, 0);
		ofRotate(getRotation());
			image.setAnchorPercent(0.5, 0.5);
			//Weird part B: I have to scale the image back up
			image.draw(0, 0, getWidth()*2, getHeight()*2);
		ofDisableAlphaBlending();
	ofPopMatrix();
}
void BlackHole::drawOnRadar(sf::RenderTarget& window, sf::Vector2f position, float scale, bool long_range)
{
    sf::Sprite object_sprite;
    textureManager.setTexture(object_sprite, "blackHole.png");
    object_sprite.setRotation(getRotation());
    object_sprite.setPosition(position);
    float size = getRadius() * scale / object_sprite.getTextureRect().width * 2;
    object_sprite.setScale(size, size);
    object_sprite.setColor(sf::Color(64, 64, 255));
    window.draw(object_sprite);
    object_sprite.setColor(sf::Color(0, 0, 0));
    window.draw(object_sprite);
}
Exemple #16
0
void Shot::display() {
    
    ofPushMatrix();
    ofTranslate(getPosition());
    ofRotateZ(getRotation());
    ofSetColor(color);
    ofFill();
    //    image->draw(0,0, width, height);
//    ofRect(0, 0, width, height);
    ofCircle(0, 0, getRadius());
    ofPopMatrix();
    
}
Exemple #17
0
void NSpriteComponent::save(pugi::xml_node& node, std::string const& name)
{
    pugi::xml_node n = node.append_child(name.c_str());
    if (mTexture != "")
    {
        n.append_attribute("texture") = mTexture.c_str();
        n.append_attribute("rect") = NString::toString(mSprite.getTextureRect()).c_str();
    }
    n.append_attribute("pos") = NString::toString(getPosition()).c_str();
    n.append_attribute("ori") = NString::toString(getOrigin()).c_str();
    n.append_attribute("sca") = NString::toString(getScale()).c_str();
    n.append_attribute("rot") = getRotation();
}
Exemple #18
0
void Bird::draw(sf::RenderTarget &target, sf::RenderStates states) const {
	sf::Sprite cur(frames[curFrame]);
	
	float elapsed = ((paused ? pausedTime : timer.getElapsedTime()) -
	                 skippedTime).asSeconds();
	
	float dy = started ? 0.0f : 6.0f * sinf(8.0f * elapsed);
	
	cur.setPosition(startingPos.x, pos + dy);
	cur.setRotation(-getRotation() * RAD2DEG);
	
	target.draw(cur, states);
}
void RenderableZoneEntityItem::changeProperties(Lambda setNewProperties) {
    QString oldShapeURL = getCompoundShapeURL();
    glm::vec3 oldPosition = getPosition(), oldDimensions = getDimensions();
    glm::quat oldRotation = getRotation();
    
    setNewProperties();
    
    if (oldShapeURL != getCompoundShapeURL()) {
        if (_model) {
            delete _model;
        }
        
        _model = getModel();
        _needsInitialSimulation = true;
        _model->setURL(getCompoundShapeURL(), QUrl(), true, true);
    }
    if (oldPosition != getPosition() ||
        oldRotation != getRotation() ||
        oldDimensions != getDimensions()) {
        _needsInitialSimulation = true;
    }
}
Exemple #20
0
void cModel::initialise(glm::vec3 mdlPosition, glm::vec3 mdlRotation, glm::vec3 mdlScale, glm::vec3 mdlDirection, float mdlSpeed, bool mdlIsActive)
{
	setPosition(mdlPosition);
	setRotation(mdlRotation);
	setScale(mdlScale);
	setDirection(mdlDirection);
	setSpeed(mdlSpeed);
	setIsActive(mdlIsActive);
	m_Dimensions.s_mdldepth = 0.0f;
	m_Dimensions.s_mdlheight = 0.0f;
	m_Dimensions.s_mdlWidth = 0.0f;
	m_mdlRadius = m_Dimensions.s_mdldepth / 2;
	glm::vec3 mdlPos = getPosition();
	GLfloat mdlRot = getRotation().x;
	glRotatef(mdlRot, 1.0f, 0.0f, 0.0f);
	mdlRot = getRotation().y;
	glRotatef(mdlRot, 0.0f, 1.0f, 0.0f);
	mdlRot = getRotation().z;
	glRotatef(mdlRot, 0.0f, 0.0f, 1.0f);
	glTranslatef(mdlPosition.x, mdlPosition.y, mdlPosition.z);
	OutputDebugString("Initialising model \n");
}
Exemple #21
0
/** Updates the graphics model. Mainly set the graphical position to be the
 *  same as the physics position, but uses offsets to position and rotation
 *  for special gfx effects (e.g. skidding will turn the karts more).
 *  \param offset_xyz Offset to be added to the position.
 *  \param rotation Additional rotation.
 */
void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
                              const btQuaternion& rotation)
{
    Vec3 xyz=getXYZ()+offset_xyz;
    m_node->setPosition(xyz.toIrrVector());
    btQuaternion r_all = getRotation()*rotation;
    if(btFuzzyZero(r_all.getX()) && btFuzzyZero(r_all.getY()-0.70710677f) &&
       btFuzzyZero(r_all.getZ()) && btFuzzyZero(r_all.getW()-0.70710677f)   )
        r_all.setX(0.000001f);
    Vec3 hpr;
    hpr.setHPR(r_all);
    m_node->setRotation(hpr.toIrrHPR());
}   // updateGraphics
//------------------------------------------------
void ofxBox2dCircle::draw() {
	
	if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
	ofCircle(0, 0, radius);
	ofSetColor(0);
	ofLine(0, 0, radius, 0);
	ofPopMatrix();
	
}
Exemple #23
0
int main()
{
    int a, b, c, d;
    int totalAngle;
    while(true)
    {
        scanf("%d %d %d %d", &a, &b, &c, &d);
        if(a == 0 && b == 0 && c == 0 && d == 0)
        {
            break;
        }

        totalAngle = 720;
        totalAngle += getRotation(a, b, true);
        totalAngle += 360;
        totalAngle += getRotation(b, c, false);
        totalAngle += getRotation(c, d, true);
                
        printf("%d\n", totalAngle);
    }

}
void QSpaceNavigatorClient::update()
{
	SpaceNavigatorClient::update();
	if (_unconsumedData)
	{
		_unconsumedData = false;
		double x, y, z, rx, ry, rz;
		getTranslation(x, y, z);
		getRotation(rx, ry, rz);
		//emit updated(x, y, z, rx, ry, rz);
		emit translated(x, y, z);
	}
}
Exemple #25
0
void Asteroid::drawOnRadar(sf::RenderTarget& window, sf::Vector2f position, float scale, bool long_range)
{
    sf::Sprite object_sprite;
    textureManager.setTexture(object_sprite, "RadarBlip.png");
    object_sprite.setRotation(getRotation());
    object_sprite.setPosition(position);
    object_sprite.setColor(sf::Color(255, 200, 100));
    float size = getRadius() * scale / object_sprite.getTextureRect().width * 2;
    if (size < 0.2)
        size = 0.2;
    object_sprite.setScale(size, size);
    window.draw(object_sprite);
}
Exemple #26
0
 void Transform::onDuplicate( Component* dst )
 {
     if( !dst )
         return;
     Component::onDuplicate( dst );
     if( !XeCore::Common::IRtti::isDerived< Transform >( dst ) )
         return;
     Transform* c = (Transform*)dst;
     c->setPosition( getPosition() );
     c->setRotation( getRotation() );
     c->setScale( getScale() );
     c->setMode( getMode() );
 }
Exemple #27
0
void setRotation(float _radians, float _duration, EaseType _e) {

    float radians_start = getRotation();

    // Ease over the smallest angular distance needed
    float radians_delta = glm::mod(_radians - radians_start, (float)TWO_PI);
    if (radians_delta > PI) { radians_delta -= TWO_PI; }
    _radians = radians_start + radians_delta;

    auto cb = [=](float t) { setRotationNow(ease(radians_start, _radians, t, _e)); };
    setEase(EaseField::rotation, { _duration, cb });

}
Exemple #28
0
bool TextEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
                     bool& keepSearching, OctreeElementPointer& element, float& distance, 
                     BoxFace& face, glm::vec3& surfaceNormal,
                     void** intersectedObject, bool precisionPicking) const {
    glm::vec3 dimensions = getDimensions();
    glm::vec2 xyDimensions(dimensions.x, dimensions.y);
    glm::quat rotation = getRotation();
    glm::vec3 position = getPosition() + rotation * 
            (dimensions * (getRegistrationPoint() - ENTITY_ITEM_DEFAULT_REGISTRATION_POINT));

    // FIXME - should set face and surfaceNormal
    return findRayRectangleIntersection(origin, direction, rotation, position, xyDimensions, distance);
}
Exemple #29
0
bool Tank::command(enumOrder order)
{
	float stepX = 0.0f;
	float stepY = 0.0f;
	float fRotation = getRotation();

	switch (order)
	{
	case cmdNothing:
		break;
	case cmdGoUP:
		stepY = 1.0f;
		fRotation = 0.0f;
		break;
	case cmdGoDown:
		stepY = -1.0f;
		fRotation = 180.0f;
		break;
	case cmdGoLeft:
		stepX = -1.0f;
		fRotation = 270.0f;
		break;
	case cmdGoRight:
		stepX = 1.0f;
		fRotation = 90.0f;
		break;
	case cmdFire:
		//调用子弹开火
		return mBullet->fire();
	default:
		break;
	}

	//根据运行方向旋转坦克
	setRotation(fRotation);

	CCRect rect = this->boundingBox();
	mMovedRect = CCRectMake(rect.getMinX() + stepX,
		rect.getMinY() + stepY, rect.size.width, rect.size.height);
	//检测地图上的碰撞
	if (!mTileMapInfo->collisionTest(mMovedRect))
	{
		IsBlock = false;
		return true;
	}
	//如果碰撞了就不要移动,设置为阻塞状态
	mMovedRect = rect;
	IsBlock = true;

	return false;
}
Exemple #30
0
void Aircraft::updateTexts()
{
	mHealthDisplay->setString(toString(getHitpoints()) + " HP");
	mHealthDisplay->setPosition(0.f, 50.f);
	mHealthDisplay->setRotation(-getRotation());

	if (mMissileDisplay)
	{
		if (mMissileAmmo == 0)
			mMissileDisplay->setString("");
		else
			mMissileDisplay->setString("M: " + toString(mMissileAmmo));
	}
}