コード例 #1
0
ファイル: transform_shape.cpp プロジェクト: CCChaos/RyzomCore
// ***************************************************************************
bool	CTransformShape::clip()
{
	H_AUTO( NL3D_TrShape_Clip );

	CClipTrav			&clipTrav= getOwnerScene()->getClipTrav();

	if(Shape)
	{
		// first test DistMax (faster).
		float maxDist = getDistMax();
		// if DistMax test enabled
		if(maxDist!=-1)
		{
			// Calc the distance
			float sqrDist = (clipTrav.CamPos - getWorldMatrix().getPos()).sqrnorm ();
			maxDist*=maxDist;

			// if dist > maxDist, skip
			if (sqrDist > maxDist)
			{
				// Ok, not shown
				return false;
			}
		}

		// Else finer clip with pyramid, only if needed
		if(clipTrav.ForceNoFrustumClip)
			return true;
		else
			return Shape->clip(clipTrav.WorldPyramid, getWorldMatrix());
	}
	else
		return false;
}
コード例 #2
0
ファイル: HierarchySubReferer.cpp プロジェクト: kniz/World
	type_result HierarchySubReferer::_render( D3DMATERIAL9& material )
	{
		_initializeMesh();
		//	main:
		//		DX9 바인딩:
		DX9& dx9 = getDependent();
		if( ! &dx9)
		{
			ALERT_ERROR(" : 디바이스 바인딩 실패로 중지");
			return RESULT_TYPE_ERROR;
		}
		LPDIRECT3DDEVICE9 device = dx9.getDevice();		
		//		월드좌표 갱신:
		D3DXMATRIX& world = getWorldMatrix();
		D3DXMATRIX origin;
		device->GetTransform(D3DTS_WORLD, &origin);
		device->SetTransform(D3DTS_WORLD, &world);

		device->SetRenderState(D3DRS_AMBIENT, 0xffffffff);

		//device->SetTexture(0, NULL);
		device->SetMaterial(&material);
		device->SetTexture(0, 0);
		if(_ball)
		{			
			_ball->DrawSubset(0);
		}

		//		자식과 선을 잇기:
		device->SetTransform(D3DTS_WORLD, &origin);

		_searchModuleSet(getConnector().getModuleCodeSetKey().getValue(), &ThisClass::_renderLineBetweenChild);			//		월드 좌표 복귀:
		return RESULT_SUCCESS;
	}
コード例 #3
0
ファイル: transform_shape.cpp プロジェクト: CCChaos/RyzomCore
// ***************************************************************************
void	CTransformShape::traverseLoadBalancingPass0()
{
	CLoadBalancingTrav		&loadTrav= getOwnerScene()->getLoadBalancingTrav();
	CSkeletonModel			*skeleton= getSkeletonModel();

	// World Model position
	const CVector		*modelPos;

	// If this isntance is binded or skinned to a skeleton, take the world matrix of this one as
	// center for LoadBalancing Resolution.
	if(skeleton)
	{
		// Take the root bone of the skeleton as reference (bone 0)
		// And so get our position.
		modelPos= &skeleton->Bones[0].getWorldMatrix().getPos();
	}
	else
	{
		// get our position from
		modelPos= &getWorldMatrix().getPos();
	}


	// Then compute distance from camera.
	float	modelDist= ( loadTrav.CamPos - *modelPos).norm();


	// Get the number of triangles this model use now.
	_FaceCount= getNumTriangles(modelDist);
	_LoadBalancingGroup->addNbFacesPass0(_FaceCount);
}
コード例 #4
0
ファイル: Shape.cpp プロジェクト: adamh/gnash-fork
bool
Shape::pointInShape(boost::int32_t x, boost::int32_t y) const
{
    SWFMatrix wm = getWorldMatrix();
    wm.invert();
    point lp(x, y);
    wm.transform(lp);
    
    // FIXME: if the shape contains non-scaled strokes
    //        we can't rely on boundary itself for a quick
    //        way out. Bounds supposedly already include
    //        thickness, so we might keep a flag telling us
    //        whether *non_scaled* strokes are present
    //        and if not still use the boundary check.
    // NOTE: just skipping this test breaks a corner-case
    //       in DrawingApiTest (kind of a fill-leakage making
    //       the collision detection find you inside a self-crossing
    //       shape).
    if (_def) {
        if (!_def->bounds().point_test(lp.x, lp.y)) return false;
        return _def->pointTestLocal(lp.x, lp.y, wm);
    }
    assert(_shape.get());
    
    if (!_shape->getBounds().point_test(lp.x, lp.y)) return false;
    return _shape->pointTestLocal(lp.x, lp.y, wm);

}
コード例 #5
0
ファイル: SceneManager.cpp プロジェクト: mink365/RacingEngine
void SceneManager::vist(const NodePtr &node)
{
    if (node->getEntity()->getTransform()->refreshFlags & Transform::RF_LOCAL_TRANSFORM) {
        this->sceneTransformUpdateBucket.push_back(node);
    }

    if (node->isVisible()) {
        auto renderElement = node->getComponent<RenderElement>();
        if (renderElement) {
            auto transform = node->getEntity()->getTransform();
            auto material = renderElement->getMaterial();
            auto mesh = renderElement->getMesh();
            this->renderManger.getRenderQueue().addRenderable(transform->getWorldMatrix(),
                                                              material, mesh->getMeshData(), material->getQueueID());
        } else if (node->getComponent<ui::ElementBatcher>()) {
            auto batcher = node->getComponent<ui::ElementBatcher>();

            batcher->Render();
        }

        for (auto& child : node->getChildren()) {
            this->vist(child);
        }
    }
}
コード例 #6
0
ファイル: lightnode.cpp プロジェクト: gaoyakun/atom3d
void ATOM_LightNode::updateLightParams (const ATOM_Matrix4x4f &projMatrix, const ATOM_Matrix4x4f &viewMatrix)
{
	if (_transformChanged)
	{
		_transformChanged =false;

		const ATOM_Matrix4x4f &worldMatrix = getWorldMatrix ();

		ATOM_Light::LightType type = _light->getLightType ();

		if (type == ATOM_Light::Point || type == ATOM_Light::Spot)
		{
			_light->setPosition (ATOM_Vector3f(worldMatrix.m30, worldMatrix.m31, worldMatrix.m32));
		}

		if (type == ATOM_Light::Directional || type == ATOM_Light::Spot)
		{
			_light->setDirection (worldMatrix.transformVector (ATOM_Vector3f(0.f, 0.f, 1.f)));
		}

		_light->setRange (getScale ());
	}

	//const ATOM_Vector4f &colorFactor = _useGlobalColorKeys ? ATOM_RenderSettings::getLightTimeFactor () : _colorKeys.getCurrentValue ();
	_light->setColor4f (_color);
}
コード例 #7
0
ファイル: CFShaderParamSet.cpp プロジェクト: uvbs/GameProject
	void ShaderParamSet::setupGlobalParam( IShaderParamInput* input , ShaderParamGroup& paramGroup )
	{
		for ( ShaderParamList::iterator iter( paramGroup.paramList.begin() ), 
			                            itEnd( paramGroup.paramList.end() );
			iter != itEnd ; ++iter )
		{
			switch( iter->content )
			{
			case SP_WORLD:
				input->setUniform( iter->varName.c_str() , getWorldMatrix() );
				break;
			case SP_VIEW :
				input->setUniform( iter->varName.c_str() , getViewMatrix() );
				break;
			case SP_PROJ :
				input->setUniform( iter->varName.c_str() , getProjectMatrix() );
				break;
			case SP_WORLD_INV :
				input->setUniform( iter->varName.c_str() , getInvWorldMatrix() );
				break;
			case SP_VIEW_PROJ :
				input->setUniform( iter->varName.c_str() , getViewProjMatrix() );
				break;
			case SP_WVP :
				input->setUniform( iter->varName.c_str() , getWVPMatrix() );
				break;
			case SP_WORLD_VIEW:
				input->setUniform( iter->varName.c_str() , getWorldViewMatrix() );
				break;
			//case SP_AMBIENT_LIGHT:
			//	input->setUniform( iter->varName.c_str() , scene->setAmbientLight() );
			}
		}
	}
コード例 #8
0
void CMyObject::drawSubset(IDirect3DDevice9* pd3dDevice, ULONG AttributeID, ID3DXEffect * effect, UINT numPass, D3DXMATRIX ViewProj) 
{
	ULONG * pAtrributeMap;
	ULONG nAttributeCount;
	//int wtf;

	if (m_useCustomAttribMap)//check if to use custom attributes for this object or the default ones used in mesh creation 
	{
		pAtrributeMap   = m_pCustomAtribbMap;
		nAttributeCount = m_customAtrribCount;
	}
	else
	{
		pAtrributeMap   = m_pMesh->getAtrributeMap();
		nAttributeCount = m_pMesh->getAttributeCount();
	}

	for (ULONG i = 0 ; i < nAttributeCount ; i++)
	{
		if (pAtrributeMap[i] == AttributeID)//check for the corresponding attribute in the attribute map
		{
			if (pd3dDevice)// if there was given a d3d device function should also set world transformation
			{
// 				pd3dDevice->SetTransform( D3DTS_WORLD, &getWorldMatrix() );
// 				pd3dDevice->SetFVF( m_pMesh->GetFVF() );
				//wtf = pd3dDevice->Release();
			}

			effect->SetMatrix(m_matWorldViewProjH, &(getWorldMatrix() * ViewProj) );
			effect->SetMatrix(m_matWorldH, &getWorldMatrix());

			D3DXMATRIX worldInverseTranspose;
			D3DXMatrixInverse(&worldInverseTranspose, 0, &getWorldMatrix());
			D3DXMatrixTranspose(&worldInverseTranspose, &worldInverseTranspose);
			effect->SetMatrix(m_matWorldTH, &worldInverseTranspose);
			//effect->SetMatrix("matWorldViewProj", &(getWorldMatrix() * ViewProj) );
			//effect->SetMatrix("matWorld", &getWorldMatrix());

			effect->BeginPass(numPass);

			m_pMesh->DrawSubset(i);//found the correct attribute draw it 

			effect->EndPass();
			break;//no need to keep scaning as we have found the attribute
		}
	}
}
コード例 #9
0
ファイル: Transformable.cpp プロジェクト: Meorw/spaceofroids
mat3f Transformable::getWorldNormalMatrix()
{
	mat4f w = getWorldMatrix();

	return mat3f(w.a, w.b, w.c,
				 w.e, w.f, w.g,
				 w.i, w.j, w.k);
}
コード例 #10
0
ファイル: RenderTargetD3D9.cpp プロジェクト: weimingtom/xgame
//矩阵变换
void	RenderTargetD3D9::setWorldMatrix(const Matrix4 & mtx)
{
    //if( m_RenderState.m_mtxWorld == mtx) return; //这种情况很少出现
    m_RenderState.m_mtxWorld = mtx;
    m_RenderState.m_mtxModelView = m_RenderState.m_mtxView * mtx;
    D3DXMATRIX mtxD3D;
    getWorldMatrix(mtxD3D);
    m_pRenderSystem->getD3D9Device()->getDevice()->SetTransform( D3DTS_WORLD, &mtxD3D);
}
コード例 #11
0
ファイル: CFShaderParamSet.cpp プロジェクト: uvbs/GameProject
	Matrix4 const& ShaderParamSet::getWorldViewMatrix()
	{
		if ( mDirtyBit & DIRTY_WORLD_VIEW )
		{
			mWorldView = getWorldMatrix() * getViewMatrix();
			mDirtyBit &= ~DIRTY_WORLD_VIEW;
		}
		return mWorldView;
	}
コード例 #12
0
 //-----------------------------------------------------------------------------
 const Matrix4& AutoParamDataSource::getInverseWorldMatrix(void) const
 {
     if (mInverseWorldMatrixDirty)
     {
         mInverseWorldMatrix = getWorldMatrix().inverseAffine();
         mInverseWorldMatrixDirty = false;
     }
     return mInverseWorldMatrix;
 }
コード例 #13
0
 //-----------------------------------------------------------------------------
 const Matrix4& AutoParamDataSource::getWorldViewMatrix(void) const
 {
     if (mWorldViewMatrixDirty)
     {
         mWorldViewMatrix = getViewMatrix().concatenateAffine(getWorldMatrix());
         mWorldViewMatrixDirty = false;
     }
     return mWorldViewMatrix;
 }
コード例 #14
0
 //-----------------------------------------------------------------------------
 const Affine3& AutoParamDataSource::getWorldViewMatrix(void) const
 {
     if (mWorldViewMatrixDirty)
     {
         mWorldViewMatrix = getViewMatrix() * getWorldMatrix();
         mWorldViewMatrixDirty = false;
     }
     return mWorldViewMatrix;
 }
コード例 #15
0
ファイル: GameObject.cpp プロジェクト: mrmoeman/GroupProject
// ZS-->16/03/2015 added Draw function
//ALEX OWEN - 10/04/15 - draw function now passes a world matrix instead of individual values. That
// way the gameobject can decide whether the world matrix needs to be recalculated or not
bool GameObject::Draw( ID3D11DeviceContext* device_context, ID3D11Buffer* world_const_buffer )
{
	if (m_display_object)
	{
		return m_display_object->Draw( device_context, world_const_buffer, getWorldMatrix() );
	}

	return false;
}
コード例 #16
0
void CMeshCoordinate::render(const Vec3D& vCoordShow)
{
	{
		init();
	}
	CRenderSystem& R = CRenderSystem::getSingleton();
	CGraphics& G=GetGraphics();

	R.setWorldMatrix(getWorldMatrix());

	R.SetShader("Coordinate1");
	SetMeshSource();
	draw();

	G.DrawLine3D(m_CoordLines[CLT_X].vBegin,m_CoordLines[CLT_X].vEnd,vCoordShow.x>0?COORD_SELECT_COLOR:COORD_X_COLOR);
	G.DrawLine3D(m_CoordLines[CLT_X_Y].vBegin,m_CoordLines[CLT_X_Y].vEnd,(vCoordShow.x>0&&vCoordShow.y>0)?COORD_SELECT_COLOR:COORD_X_COLOR);
	G.DrawLine3D(m_CoordLines[CLT_X_Z].vBegin,m_CoordLines[CLT_X_Z].vEnd,(vCoordShow.x>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_X_COLOR);

	G.DrawLine3D(m_CoordLines[CLT_Y].vBegin,m_CoordLines[CLT_Y].vEnd,vCoordShow.y>0?COORD_SELECT_COLOR:COORD_Y_COLOR);
	G.DrawLine3D(m_CoordLines[CLT_Y_X].vBegin,m_CoordLines[CLT_Y_X].vEnd,(vCoordShow.x>0&&vCoordShow.y>0)?COORD_SELECT_COLOR:COORD_Y_COLOR);
	G.DrawLine3D(m_CoordLines[CLT_Y_Z].vBegin,m_CoordLines[CLT_Y_Z].vEnd,(vCoordShow.y>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_Y_COLOR);

	G.DrawLine3D(m_CoordLines[CLT_Z].vBegin,m_CoordLines[CLT_Z].vEnd,vCoordShow.z>0?COORD_SELECT_COLOR:COORD_Z_COLOR);
	G.DrawLine3D(m_CoordLines[CLT_Z_X].vBegin,m_CoordLines[CLT_Z_X].vEnd,(vCoordShow.x>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_Z_COLOR);
	G.DrawLine3D(m_CoordLines[CLT_Z_Y].vBegin,m_CoordLines[CLT_Z_Y].vEnd,(vCoordShow.y>0&&vCoordShow.z>0)?COORD_SELECT_COLOR:COORD_Z_COLOR);


	R.SetShader("Coordinate2");
	if (vCoordShow.x>0&&vCoordShow.y>0)
	{
		//	G.fillQuad(Vec3D(0,0,0),m_CoordLines[CLT_X_Y].vBegin,m_CoordLines[CLT_X_Y].vEnd,m_CoordLines[CLT_Y_X].vBegin,COORD_PLANE_COLOR);
	}
	if (vCoordShow.y>0&&vCoordShow.z>0)
	{
		//	G.fillQuad(Vec3D(0,0,0),m_CoordLines[CLT_Y_Z].vBegin,m_CoordLines[CLT_Y_Z].vEnd,m_CoordLines[CLT_Z_Y].vBegin,COORD_PLANE_COLOR);
	}
	if (vCoordShow.z>0&&vCoordShow.x>0)
	{
		//	G.fillQuad(Vec3D(0,0,0),m_CoordLines[CLT_Z_X].vBegin,m_CoordLines[CLT_Z_X].vEnd,m_CoordLines[CLT_X_Z].vBegin,COORD_PLANE_COLOR);
	}

// 	R.SetBlendFunc(true);
// 	R.SetTextureColorOP(0,TBOP_MODULATE);
// 	R.SetTextureAlphaOP(0,TBOP_MODULATE);

	//int nFontHeight = GetTextRender().GetCharHeight();
	//Pos2D posScreen;
	//R.world2Screen(getWorldMatrix()*Vec3D(1.0f,0.0f,0.0f),posScreen);
	//GetTextRender().drawText(L"X",posScreen.x,posScreen.y-nFontHeight,vCoordShow.x>0?COORD_SELECT_COLOR:COORD_X_COLOR);

	//R.world2Screen(getWorldMatrix()*Vec3D(0.0f,1.0f,0.0f),posScreen);
	//GetTextRender().drawText(L"Y",posScreen.x,posScreen.y-nFontHeight,vCoordShow.y>0?COORD_SELECT_COLOR:COORD_Y_COLOR);

	//R.world2Screen(getWorldMatrix()*Vec3D(0.0f,0.0f,1.0f),posScreen);
	//GetTextRender().drawText(L"Z",posScreen.x,posScreen.y-nFontHeight,vCoordShow.z>0?COORD_SELECT_COLOR:COORD_Z_COLOR);
}
コード例 #17
0
ファイル: Transformable.cpp プロジェクト: Meorw/spaceofroids
vec3f Transformable::getWorldRight()
{
	mat4f w;
	vec4f v;

	w = getWorldMatrix();
	v = w.getCol(0);

	return v.xyz();
}
コード例 #18
0
ファイル: Transformable.cpp プロジェクト: Meorw/spaceofroids
vec3f Transformable::getWorldFront()
{
	mat4f w;
	vec4f v;

	w = getWorldMatrix();
	v = w.getCol(2);

	return - v.xyz();
}
コード例 #19
0
ファイル: C3DCamera.cpp プロジェクト: cn00/MJ
const Matrix& C3DCamera::getViewMatrix()
{
	if (_dirtyBits & CAMERA_DIRTY_VIEW)
	{
		getWorldMatrix().invert(&_view);
		_dirtyBits &= ~CAMERA_DIRTY_VIEW;
	}

	return _view;
}
コード例 #20
0
	//================================================================================
	//!	メソッド名	CSKIN_MESH::getWorldCenter
	//
	//	機能		ワールド座標系中心点を受け取る
	//	戻り値		ワールド座標系中心点
	//	更新		2007/12/08		<新規>
	//================================================================================
	VEC3
	CSKIN_MESH::getWorldCenter(void)
	{
	//	ワールド座標系中心点
		VEC3	aCenter;
	//	ワールド座標系の演算
		D3DXVec3TransformCoord(&aCenter, &sd_ptr->mesh->localCenter, getWorldMatrix());
	//	ワールド座標系中心点を返す
		return	aCenter;
	}
コード例 #21
0
ファイル: CFShaderParamSet.cpp プロジェクト: uvbs/GameProject
	Matrix4 const& ShaderParamSet::getInvWorldMatrix()
	{
		if ( mDirtyBit & DIRTY_INV_WORLD )
		{
			float det;
			getWorldMatrix().inverse( mInvWorld , det );
			mDirtyBit &= ~DIRTY_INV_WORLD;
		}
		return mInvWorld;
	}
コード例 #22
0
ファイル: Transformable.cpp プロジェクト: Meorw/spaceofroids
vec3f Transformable::getWorldPosition(
		vec3f pos
	)
{
	vec4f v = vec4f(pos.x, pos.y, pos.z, 1.0f);
	mat4f w = getWorldMatrix();

	v = w * v;

	return v.xyz();
}
コード例 #23
0
void ShadedModel::updateLightPositions() {
  if(hasAllLights) {
    mat4 mat = getWorldMatrix();
    std::vector<Light*>::iterator it;
    int index = 0;
    for(it = lights.begin(); it != lights.end(); it++) {
      prog->setUniform(mat * (*it)->getPosition(), "lights[%d].Position",
          index);
      index++;
    }
  }
}
コード例 #24
0
ファイル: Enemy.cpp プロジェクト: Philldomd/oopro
void Enemy::render(D3DXMATRIX& p_view, D3DXMATRIX& p_projection)
{
    m_device->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

    D3DXMATRIX worldViewProj = getWorldMatrix() * p_view * p_projection;

    m_model->m_vertexBuffer->apply(0);
    m_model->m_indexBuffer->apply(0);

    m_shader->setMatrix("g_mWorldViewProj", worldViewProj);

    D3D10_TECHNIQUE_DESC techDesc;
    m_shader->getTechnique()->GetDesc( &techDesc );
    for( UINT p = 0; p < techDesc.Passes; p++ )
    {
        m_shader->apply(p);
        m_device->DrawIndexed( m_model->m_size,0, 0);
    }

    m_volume->draw( getWorldMatrix(), p_view, p_projection );
}
コード例 #25
0
ファイル: Bitmap.cpp プロジェクト: BrandRegard/gnash
void
Bitmap::add_invalidated_bounds(InvalidatedRanges& ranges, bool force)
{
    if (!force && !invalidated()) return;

    ranges.add(m_old_invalidated_ranges);

    SWFRect bounds;
    bounds.expand_to_transformed_rect(getWorldMatrix(*this), getBounds()); 
    ranges.add(bounds.getRange());

}
コード例 #26
0
void
Video::add_invalidated_bounds(InvalidatedRanges& ranges, bool force)
{
    if (!force && !invalidated()) return; // no need to redraw

    ranges.add(m_old_invalidated_ranges);

    assert(m_def);

    SWFRect bounds;
    bounds.expand_to_transformed_rect(getWorldMatrix(*this), m_def->bounds());

    ranges.add(bounds.getRange());
}
コード例 #27
0
ファイル: tmip.cpp プロジェクト: Ojaswi/inviwo
void TMIP::process() {
    auto volumes = inport_.getData();

    if (volumes->empty()) {
        return;
    }

    auto firstVol = volumes->at(0);

    if (inport_.isChanged()) {
        const DataFormatBase* format = firstVol->getDataFormat();
        volume0_ = std::make_shared<Volume>(firstVol->getDimensions(), format);
        volume0_->setModelMatrix(firstVol->getModelMatrix());
        volume0_->setWorldMatrix(firstVol->getWorldMatrix());
        // pass on metadata
        volume0_->copyMetaDataFrom(*firstVol);
        volume0_->dataMap_ = firstVol->dataMap_;

        volume1_ = std::shared_ptr<Volume>(volume0_->clone());
    }

    int iterations = static_cast<int>(std::ceil(volumes->size() / static_cast<float>(maxSamplers_)));
    LogInfo(iterations);

    std::shared_ptr<Volume> readVol = volume0_;
    std::shared_ptr<Volume> writeVol = volume1_;
    int offset = 0;
    for (int i = 0; i < iterations; i++) {
        bool firstIT = i == 0;
        bool lastIT = i != 0 && iterations;
        
        auto startVolIT = volumes->begin() + offset + 1;
        
        if (firstIT) {
            auto endVolIT = volumes->begin() + offset + maxSamplers_;
            iteration(shader_, volumes->at(0), writeVol, startVolIT, endVolIT);
        }
        else if (!lastIT) {
            auto endVolIT = volumes->begin() + offset + maxSamplers_;
            iteration(shader_, readVol, writeVol, startVolIT, endVolIT);
        } else {
            iteration(shaderLast_, readVol, writeVol, startVolIT, volumes->end());
        }
        std::swap(readVol, writeVol);
        offset += maxSamplers_;
    }

    outport_.setData(readVol);
}
コード例 #28
0
	//================================================================================
	//!	メソッド名	CSKIN_MESH::draw
	//
	//	機能		描画
	//	機能概要	スキンメッシュの描画を行う
	//	引数		inDev			Direct3Dデバイス
	//	戻り値		TRUE			描画成功
	//				FALSE			描画失敗
	//	更新		2008/05/30		<追加>	コメント
	//================================================================================
	BOOL
	CSKIN_MESH::draw(CONST DEV inDev)
	{
	//	描画の無効性を調べて、無効の時
		if(	!getVisible())
		{
		//	描画失敗を返す
			return	FALSE;
		}

	//	モデルを前向きにする
		MAT16	matrix = (*getWorldMatrixInversed()) * (*getWorldMatrix());

		return	drawSkin(inDev, &matrix);
	}
コード例 #29
0
 //-----------------------------------------------------------------------------
 const Matrix4& AutoParamDataSource::getTextureWorldViewProjMatrix(size_t index) const
 {
     if (index < OGRE_MAX_SIMULTANEOUS_LIGHTS)
     {
         if (mTextureWorldViewProjMatrixDirty[index] && mCurrentTextureProjector[index])
         {
             mTextureWorldViewProjMatrix[index] = 
                 getTextureViewProjMatrix(index) * getWorldMatrix();
             mTextureWorldViewProjMatrixDirty[index] = false;
         }
         return mTextureWorldViewProjMatrix[index];
     }
     else
         return Matrix4::IDENTITY;
 }
コード例 #30
-1
ファイル: Ground.cpp プロジェクト: hipblip/OutdoorScene
/* Draws the ground according to the height map provided
 * @param void
 * @return void
 */
void Ground::draw() {
	Renderer::setShader(2);//set current shader to the ground shader
	glUseProgram(Renderer::getShader());

	glm::mat4 view = glm::lookAt(glm::vec3(0, 250, 1000), glm::vec3(0, 0, 0), glm::vec3(0.0f, 1.0f, 0.0f));
	glm::mat4 projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f);

	GLuint viewID = glGetUniformLocation(Renderer::getShader(), "viewMatrix");
	GLuint projID = glGetUniformLocation(Renderer::getShader(), "projectionMatrix");
	GLuint worldID = glGetUniformLocation(Renderer::getShader(), "worldMatrix");
	GLuint TextureID  = glGetUniformLocation(Renderer::getShader(), "myTextureSampler");
	GLuint hmScaleID = glGetUniformLocation(Renderer::getShader(), "scaleMatrix");

	glm::mat4 scaleMat = glm::scale(glm::mat4(1.f), hmScale);

	glUniformMatrix4fv(viewID, 1, GL_FALSE, &view[0][0]);
	glUniformMatrix4fv(projID, 1, GL_FALSE, &projection[0][0]);
	glUniformMatrix4fv(worldID, 1, GL_FALSE, &getWorldMatrix()[0][0]);
	glUniformMatrix4fv(hmScaleID, 1, GL_FALSE, &scaleMat[0][0]);
	
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, textureID);
	glUniform1i(TextureID, 0);

	glBindVertexArray(vertexArrayID);
	glEnable(GL_PRIMITIVE_RESTART);
	glPrimitiveRestartIndex(hmRows * hmCols);
	
	int iNumIndices = (hmRows-1)*hmCols*2 + hmRows-1;
	glDrawElements(GL_TRIANGLE_STRIP, iNumIndices, GL_UNSIGNED_INT, 0);
	//glDrawElements(GL_TRIANGLE_STRIP, HM_SIZE_X*(HM_SIZE_Y-1)*2+HM_SIZE_Y-2, GL_UNSIGNED_INT, 0);
}