Exemplo n.º 1
0
bool OGL2_Renderer::Init()
{
	if( glewInit() != GLEW_OK  )
	{
		PRINTF( "Failed to initialize GLEW\n" );
		return false;
	}

	glEnable( GL_CULL_FACE );
	glEnable( GL_ALPHA_TEST );
	glEnable( GL_TEXTURE_2D );

	memset( &rconf, 1, sizeof( rconf ) );

	currentTexture = 123123;

	rconf.flags = 0;
	rconf.blendEnabled = true; // just to turn it off

	SetCulling( 0 );
	SetCulling( CULL_FRONT );
	SetDepthTest( DEPTH_DISABLED );
	SetDepthTest( DEPTH_LESS_EQUAL );
	SetAlphaTest( 0 );
	SetAlphaTest( 1 );
	SetAlphaTest( 0 );
	SetBlending( 0, 0 );
	SetBlending( BLEND_ONE, BLEND_ONE );
	SetBlending( 0, 0 );
//	glEnable( GL_DEPTH_TEST );
//	glDepthFunc( GL_LEQUAL );

	p_MainShader = PrecacheShader( "main" );
	p_MenuBgShader = PrecacheShader( "menubg" );

	PrecacheImage( "bear", 1024, 512, false );
	PrecacheImage( "pipe", 256, 128, false );
	PrecacheImage( "grass", 1024, 512, false );
	PrecacheImage( "dirt", 512, 512, false );
	PrecacheImage( "finish", 512, 256, false );

	PrecacheModel( "pipe_1" );
	PrecacheModel( "pipe_2" );
	PrecacheModel( "pipe_3" );
	PrecacheModel( "pipe_4" );
	PrecacheModel( "pipe_5" );
	PrecacheModel( "pipe_6" );
	PrecacheModel( "finish" );
	PrecacheModel( "bear" );
	PrecacheModel( "terrain" );

	p_Ortho->Init();

	return true;
}
Exemplo n.º 2
0
/**
 * Copy this material from another.
 */
void vtMaterial::CopyFrom(vtMaterial *pFrom)
{
	SetDiffuse1(pFrom->GetDiffuse());
	SetSpecular1(pFrom->GetSpecular());
	SetAmbient1(pFrom->GetAmbient());
	SetEmission1(pFrom->GetEmission());

	SetCulling(pFrom->GetCulling());
	SetLighting(pFrom->GetLighting());

//	SetTexture(pFrom->GetTexture());
	SetTransparent(pFrom->GetTransparent());
}
/**
\brief	Sets up the graphics for the joint.

\detail This base joint class sets up a default ball graphics object. A few of the joint
classes do not have any special graphics associated with them, so simply knowing where the joint
is located is enough, and a ball to define that position is sufficient. This base code creates
that graphics so that each derived class does not have to. If a joint does need special 
graphics then just override this function and define it yourself, but do not call this base method.

\author	dcofer
\date	4/15/2011
**/
void VsJoint::SetupGraphics()
{
	//Setup Vs pointers to child and parent.
	m_lpVsParent = dynamic_cast<VsRigidBody *>(m_lpThisJoint->Parent());
	if(!m_lpVsParent)
		THROW_ERROR(Vs_Err_lUnableToConvertToVsRigidBody, Vs_Err_strUnableToConvertToVsRigidBody);

	m_lpVsChild = dynamic_cast<VsRigidBody *>(m_lpThisJoint->Child());
	if(!m_lpVsChild)
		THROW_ERROR(Vs_Err_lUnableToConvertToVsRigidBody, Vs_Err_strUnableToConvertToVsRigidBody);

	//The parent osg object for the joint is actually the child rigid body object.
	m_osgParent = ParentOSG();
	osg::ref_ptr<osg::Group> osgChild = ChildOSG();

	if(m_osgParent.valid())
	{
		//Add the parts to the group node.
		CStdFPoint vPos(0, 0, 0), vRot(VX_PI/2, 0, 0); 
		vPos.Set(0, 0, 0); vRot.Set(0, VX_PI/2, 0); 
		
		m_osgJointMT = new osg::MatrixTransform();
		m_osgJointMT->setMatrix(SetupMatrix(vPos, vRot));

		m_osgNode = m_osgJointMT.get();

		//Create the sphere.
		CreateJointGraphics();

		BuildLocalMatrix();

		SetAlpha();
		SetCulling();
		SetVisible(m_lpThisMI->IsVisible());

		//Add it to the scene graph.
		m_osgParent->addChild(m_osgRoot.get());

		//Set the position with the world coordinates.
		Physics_UpdateAbsolutePosition();

		//We need to set the UserData on the OSG side so we can do picking.
		//We need to use a node visitor to set the user data for all drawable nodes in all geodes for the group.
		osg::ref_ptr<VsOsgUserDataVisitor> osgVisitor = new VsOsgUserDataVisitor(this);
		osgVisitor->traverse(*m_osgMT);
	}
}