コード例 #1
0
ファイル: Sound.cpp プロジェクト: TheRyaz/c_reading
void Sound::update( float dt, float timeScale )
{
	assert( m_sb );

	// nothing to update?
	if ( m_paused || dt*timeScale <= Float::MIN_VALUE )
		return;

	// update playing speed
	int freq = (int)( (float)m_format.samplesPerSec() * timeScale );
	if ( freq < 100 )
		freq = 100;
	else if ( freq > 100000 )
		freq = 100000;
	if ( m_sb->frequency() != freq )
		m_sb->setFrequency( freq );

	// update 3D properties
	if ( SoundBuffer::USAGE_CONTROL3D & m_sb->usageFlags() )
	{
		// update tm
		Matrix4x4 tm = worldTransform();
		m_sb->setTransform( tm );
	}

	// update fading
	if ( m_fadeTime > 0.f )
	{
		m_fade += dt / m_fadeTime;
		if ( m_fade > 1.f )
			m_fade = 1.f;
	}

	// update (fading) state
	switch ( m_state )
	{
	case STATE_STOP:
		break;

	case STATE_PLAY:
		break;

	case STATE_FADEIN:
		assert( m_fadeTime > Float::MIN_VALUE );
		m_sb->setVolume( getDrvVolume( interpVolume(m_fade,-100.f,m_vol) ) );
		if ( m_fade >= 1.f )
			m_state = STATE_PLAY;
		break;

	case STATE_FADEOUT:
		assert( m_fadeTime > Float::MIN_VALUE );
		m_sb->setVolume( getDrvVolume( interpVolume(m_fade,m_vol,-100.f) ) );
		if ( m_fade >= 1.f )
			stop();
		break;
	}

	// commit changes to device
	m_sb->commit();
}
コード例 #2
0
ファイル: Camera.cpp プロジェクト: TheRyaz/c_reading
void Camera::updateCachedTransforms()
{
	m_worldToCamera = worldTransform().inverse();
	m_view = viewTransform();
	m_projection = projectionTransform();
	m_viewProjection = viewProjectionTransform();
}
コード例 #3
0
ファイル: SceneGraph.cpp プロジェクト: tapio/Wendy
void Node::enqueue(render::Scene& scene, const Camera& camera) const
{
  if (m_renderable)
    m_renderable->enqueue(scene, camera, worldTransform());

  for (auto c : m_children)
    c->enqueue(scene, camera);
}
コード例 #4
0
ファイル: WPainter.C プロジェクト: nkabir/wt
void WPainter::drawPie(const WRectF& rectangle, int startAngle, int spanAngle)
{
    WTransform oldTransform = WTransform(worldTransform());

    translate(rectangle.center().x(), rectangle.center().y());
    scale(1., rectangle.height() / rectangle.width());

    WPainterPath path(WPointF(0.0, 0.0));
    path.arcTo(0.0, 0.0, rectangle.width() / 2.0,
               startAngle / 16., spanAngle / 16.);
    path.closeSubPath();

    drawPath(path);

    setWorldTransform(oldTransform);
}
コード例 #5
0
ファイル: reEnemy.cpp プロジェクト: ZhaoJie1987/Radial-Engine
void reEnemy::messageProcess( reMessageDispatcher* sender, reMessage* message )
{	
	switch (message->id)
	{
	case reM_MOUSE_PRESS:
		{
			reMouseMessage* mouseMessage = (reMouseMessage*)message;
			reVec3 dir = glm::normalize(mouseMessage->dir);
			reVec3 p(0,1,0);
			target = mouseMessage->p + mouseMessage->dir*(glm::dot(p, mouseMessage->p)/glm::dot(p, -mouseMessage->dir));
			reVec3 d = (mouseMessage->p.y / -dir.y) * dir + mouseMessage->p;
			assert(glm::length(d-target) < 0.1f);
		}
		break;
	case reM_TIMER:
		{
			reVec4 pos = worldTransform().matrix * reVec4(0,0,0,1);
			reVec3 dir = target - reVec3(pos);
			if (glm::length(dir)>.5f)
			{
				dir = glm::normalize(dir);
				body->btBody->applyCentralForce(toBullet(dir)*1000);
			}
			else
			{
				dir = -fromBullet(body->btBody->getLinearVelocity());
				body->btBody->applyCentralForce(toBullet(dir)*100);				
			}
			reVec3 v = fromBullet(body->btBody->getLinearVelocity());
			reNode* node = (reNode*)children->objectByName("model");
			reAnimator* animator = node->children->findObject<reAnimator>();
			if (glm::length(v) > 0.001f)
			{
				float angle = atan2(v.x, v.z);				
				node->transform(reTransform(glm::rotate(reMat4(), glm::degrees(angle), reVec3(0,1,0))));				
				animator->play((reSequence*)node->objectByName("walk"), .3);
				animator->stopAnimation("idle", .3);
			}
			else
			{
				animator->play((reSequence*)node->objectByName("idle"), .3);
				animator->stopAnimation("walk", .3);
			}
		}
		break;
	}
}
コード例 #6
0
void DecalComponent::updateInternal()
{
	Mat4 worldTransform(m_trf);

	Mat4 viewMat = worldTransform.getInverse();

	Mat4 projMat = Mat4::calculateOrthographicProjectionMatrix(m_sizes.x() / 2.0f,
		-m_sizes.x() / 2.0f,
		m_sizes.y() / 2.0f,
		-m_sizes.y() / 2.0f,
		FRUSTUM_NEAR_PLANE,
		m_sizes.z());

	static const Mat4 biasMat4(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);

	m_biasProjViewMat = biasMat4 * projMat * viewMat;
}
コード例 #7
0
void rePTerrain::updateHeightmap()
{
	reVec3 center = worldTransform().position();
	center.y = 0;
	body->readTransform();
	reVec3 offset3 = center - reVec3(collisionCols*collisionWidth/2, 0, collisionRows*collisionHeight/2);
	reVec4 offset(offset3.x, offset3.y, offset3.z, 0);
	int i=0;
	for ( size_t y=0; y<collisionRows+1; y++)
	{
		for ( size_t x = 0; x<collisionCols+1; x++)		
		{
			reVec4 pos = reVec4(x*collisionWidth, 0, y*collisionHeight, 0) + offset;
			heightmap[i] = calculateVertex(pos).y;
			i+=1;
		}
	}
}
コード例 #8
0
ファイル: WPainter.C プロジェクト: nkabir/wt
void WPainter::drawChord(const WRectF& rectangle, int startAngle, int spanAngle)
{
    WTransform oldTransform = WTransform(worldTransform());

    translate(rectangle.center().x(), rectangle.center().y());
    scale(1., rectangle.height() / rectangle.width());

    double start = startAngle / 16.;
    double span = spanAngle / 16.;

    WPainterPath path;
    path.arcMoveTo(0, 0, rectangle.width()/2., start);
    path.arcTo(0, 0, rectangle.width()/2., start, span);
    path.closeSubPath();

    drawPath(path);

    setWorldTransform(oldTransform);
}
コード例 #9
0
void rePlayer::messageProcess( reMessageDispatcher* sender, reMessage* message )
{
	reVec3 deltaAngle(0,0,0);
	float rs = .5f;
	switch (message->id)
	{
	case reM_TIMER:
		if (model())
		{
			reVec3 dirZ = reVec3(model()->worldTransform().matrix * reVec4(0,0,-1, 0));
			reVec3 dirX = reVec3(model()->worldTransform().matrix * reVec4(1,0,0, 0));

			if (reRadial::shared()->input()->keyStates['W'])
			{			
				body->btBody->applyCentralForce(toBullet(dirZ * 50.0f));
			}
			if (reRadial::shared()->input()->keyStates['S'])
			{
				body->btBody->applyCentralForce(toBullet(dirZ * -50.0f));
			}
			if (reRadial::shared()->input()->keyStates[' '])
			{			
				body->btBody->applyCentralForce(toBullet(dirX * 1.0f));
				//reVec4 f = worldTransform().matrix * reVec4(0,-200,0,0);
				//btVector3 bf(f.x, f.y, f.z);
				//body->btBody->applyCentralForce(bf);
			}
			if (reRadial::shared()->input()->keyStates['A'])
			{
				reVec3 v = reVec3(glm::rotate(reMat4(), rs, reVec3(0,1,0)) * reVec4(fromBullet(body->btBody->getLinearVelocity()), 0));
				body->btBody->setLinearVelocity(toBullet(v));								
				model()->transform(glm::rotate(reMat4(), rs, reVec3(0,1,0)) * model()->transform().matrix);
				//body->btBody->applyCentralForce(toBullet(f));
			}
			if (reRadial::shared()->input()->keyStates['D'])
			{
				reVec3 v = reVec3(glm::rotate(reMat4(), -rs, reVec3(0,1,0)) * reVec4(fromBullet(body->btBody->getLinearVelocity()), 0));
				body->btBody->setLinearVelocity(toBullet(v));
				model()->transform(glm::rotate(reMat4(), -rs, reVec3(0,1,0)) * model()->transform().matrix);
				//deltaAngle += reVec3(0,-1,0);
				//model()->transform(glm::rotate(reMat4(), -1.0f, reVec3(0,1,0)) * model()->transform().matrix);
			}
			reVec3 pos = worldTransform().position();
			camera->lookAt(pos);
			light->lookAt(pos);
			if (pos.y < calculateVertex(reVec4(pos,1)).y)
			{
				//__debugbreak();
			}
			break;
		}
	}
	
	if (glm::length(fromBullet(body->btBody->getLinearVelocity())))
	{				
		reVec3 dir = glm::normalize(fromBullet(body->btBody->getLinearVelocity()));
		if (!dir.z)
		{
			return;
		}
		float yaw = dir.z < 0 ? glm::atan(dir.x / dir.z) : M_PI - glm::atan(dir.x / -dir.z);
		float pitch = glm::atan(dir.y / abs(dir.z));
		reMat4 y(glm::rotate(reMat4(), glm::degrees(yaw), reVec3(0,1,0)));
		reMat4 p(glm::rotate(reMat4(), glm::degrees(pitch), reVec3(1,0,0)));		
		model()->children->at(0)->transform(p);
		reVec3 da = reVec3(0, glm::degrees(yaw), 0) - camera->lookAngles();
		camera->lookAngles(camera->lookAngles() + da / 5.0f );
	}
}
コード例 #10
0
ファイル: Camera.cpp プロジェクト: TheRyaz/c_reading
Matrix4x4 Camera::viewProjectionTransform() const
{
	Matrix4x4 view = worldTransform().inverse();
	return projectionTransform() * view;
}
コード例 #11
0
ファイル: Camera.cpp プロジェクト: TheRyaz/c_reading
Matrix4x4 Camera::viewTransform() const
{
	return worldTransform().inverse();
}
コード例 #12
0
void
TransformNode::cacheLastWorldTransform() const
{
    _lastWorldTransformProperty->set(worldTransform());
}
コード例 #13
0
ファイル: Camera.cpp プロジェクト: RWTHmediTEC/Carna
void Camera::updateWorldTransform()
{
    Spatial::updateWorldTransform();
    myViewTransform = worldTransform().inverse();
}
コード例 #14
0
ファイル: node.cpp プロジェクト: argontus/3S3K3D
const Matrix4x4 Node::modelToWorldMatrix() const
{
    return toMatrix4x4(worldTransform());
}
コード例 #15
0
ファイル: DirectLight.cpp プロジェクト: TheRyaz/c_reading
Vector3 DirectLight::worldDirection() const
{
	const Matrix4x4& wt = worldTransform();
	return Vector3( wt(0,2), wt(1,2), wt(2,2) );
}
コード例 #16
0
ファイル: scenegraph.cpp プロジェクト: amaula/ode-0.12
Vec3 SceneNode::worldPos() const
{
    Matrix wx;
    worldTransform(wx);
    return wx.translation();
}
コード例 #17
0
ファイル: SceneGraph.cpp プロジェクト: tapio/Wendy
void Node::update()
{
  if (m_camera)
    m_camera->setTransform(worldTransform());
}