Ejemplo n.º 1
0
 void SceneWidget::selectLightingMode (const std::string& mode)
 {
     if (mode=="day")
         setLighting (&mLightingDay);
     else if (mode=="night")
         setLighting (&mLightingNight);
     else if (mode=="bright")
         setLighting (&mLightingBright);
 }
Ejemplo n.º 2
0
void setShaders()
{
	MapObject Tiles = getTileBuffer();
	ImportObj Tee = getTeeBuffer();
	ImportObj Cup = getCupBuffer();
	ImportObj Walls = getWallsBuffer();
	ImportObj Pointer = getPointer();
	GLuint program = LoadShaders("vshader5.glsl", "fshader5.glsl");
	shadertemp = program;
	glUseProgram(program);
	GLuint vPosition, vNormal;

	//Set lighting
	setLighting(program);

	// Retrieve transformation uniform variable locations
	ModelView = glGetUniformLocation(program, "ModelView");
	Projection = glGetUniformLocation(program, "Projection");

	glGenVertexArrays(6, vao);

	BindShader(vao[0], program, Tiles.Vertices, Tiles.Normals, Tiles.Indices);
	BindShader(vao[1], program, Tee.Vertices, Tee.Normals, Tee.Indices);
	BindShader(vao[2], program, Cup.Vertices, Cup.Normals, Cup.Indices);
	BindShader(vao[3], program, GolfBall.Model.Vertices, GolfBall.Model.Normals, GolfBall.Model.Indices);
	BindShader(vao[4], program, Walls.Vertices, Walls.Normals, Walls.Indices);
	BindShader(vao[5], program, Pointer.Vertices, Pointer.Normals, Pointer.Indices);
}
Ejemplo n.º 3
0
void GLWidget::paintGL()
{
    // ---- Drawing all opaques objects (here, mainly lines) ----
    glDepthMask(GL_TRUE);
    
    // Clear the window and buffers
    glClearColor(settings_->backgroundColor_r(),
                 settings_->backgroundColor_g(),
                 settings_->backgroundColor_b(),
                 1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Initialize the view and lighting
    setCameraPositionAndOrientation();
    setLighting();

    // Set material (this is required for the 3D vew)
    // XXX this shouldn't be done here
    setMaterial(material_);
    glEnable(GL_COLOR_MATERIAL);

    // Draw scene
    currentGLWidget_ = this;
    drawScene();
    currentGLWidget_ = 0;
}
Ejemplo n.º 4
0
    SceneWidget::SceneWidget(QWidget *parent)
        : QWidget(parent)
        , mWindow(NULL)
        , mCamera(NULL)
        , mSceneMgr(NULL), mNavigation (0), mLighting (0), mUpdate (false)
        , mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
        , mKeyRollLeft (false), mKeyRollRight (false)
        , mFast (false), mDragging (false), mMod1 (false)
        , mFastFactor (4) /// \todo make this configurable
        , mDefaultAmbient (0, 0, 0, 0), mHasDefaultAmbient (false)
    {
        setAttribute(Qt::WA_PaintOnScreen);
        setAttribute(Qt::WA_NoSystemBackground);

        setFocusPolicy (Qt::StrongFocus);

        mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);

        mSceneMgr->setAmbientLight (Ogre::ColourValue (0,0,0,1));

        mCamera = mSceneMgr->createCamera("foo");

        mCamera->setPosition (300, 0, 0);
        mCamera->lookAt (0, 0, 0);
        mCamera->setNearClipDistance (0.1);
        mCamera->setFarClipDistance (30000);
        mCamera->roll (Ogre::Degree (90));

        setLighting (&mLightingDay);

        QTimer *timer = new QTimer (this);

        connect (timer, SIGNAL (timeout()), this, SLOT (update()));
        timer->start (20); /// \todo make this configurable
    }
Ejemplo n.º 5
0
void display(void) {
	++FrameCount;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	eye=Vec3( dist * cos( theta ) * (cos( phi )), dist * sin( theta ) * (cos( phi )), dist * sin( phi ) );
	setLighting();
    setCamera();
	float EYE[]={eye.x,eye.y,eye.z};
 
    glUseProgram(ProgramID);
    glUniformMatrix4fv(projMatrixLoc,  1, false, projMatrix);
    glUniformMatrix4fv(viewMatrixLoc,  1, false, viewMatrix);
	glUniform4fv(LightPosLoc, 1, LightPosition);
	glUniform4fv(LightDifLoc, 1, DiffuseLight);
	glUniform4fv(LightAmbLoc, 1, AmbientLight);
	glUniform4fv(LightSpecLoc, 1, SpecularLight);
	glUniform3fv(eyeLoc, 1, EYE);
 
    glBindVertexArray(VAO);
	if(MODE==0){
		glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
		glDrawElements(GL_TRIANGLES,3*model->nf,GL_UNSIGNED_INT,(GLvoid*)0);
	}
	else if(MODE==1){
		glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
		glDrawElements(GL_TRIANGLES,3*model->nf,GL_UNSIGNED_INT,(GLvoid*)0);

	}
	else if(MODE==2){
		glUniform3f(cLoc,0,0,0);
		glDrawElements(GL_POINTS,3*model->nf,GL_UNSIGNED_INT,(GLvoid*)0);
	}


    glutSwapBuffers();
}
Ejemplo n.º 6
0
void GodRaysSampler::prepare(SoftwareRenderer *renderer) {
    setCameraLocation(renderer->getCameraLocation());
    setLighting(renderer->getLightingManager());
    setAltitudes(renderer->getScenery()->getTerrain()->getHeightInfo().min_height,
                 renderer->getCloudsRenderer()->getHighestAltitude());
    renderer->getScenery()->getAtmosphere()->childGodRays()->copy(definition);
    reset();
}
Ejemplo n.º 7
0
void lightShader::beginRender()
{
	shader.setShaderActive(true);
	setLighting();
	setMaterial();
    shader.setUniformVariable3f("cLightPosition", LightPosition[0], LightPosition[1], LightPosition[2]);
	glActiveTexture(GL_TEXTURE0);
	
}
Ejemplo n.º 8
0
SceneWidget::SceneWidget(Resource::SceneManager* sceneManager, QWidget *parent, Qt::WindowFlags f)
    : RenderWidget(parent, f)
    , mSceneManager(sceneManager)
    , mLighting(NULL)
    , mHasDefaultAmbient(false)
{
    // we handle lighting manually
    mView->setLightingMode(osgViewer::View::NO_LIGHT);

    setLighting(&mLightingDay);
}
Ejemplo n.º 9
0
void displayObject()
{
    setMaterial();
    setLighting();
    setViewport();
    setCamera();
    //startDrawing
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    sate();//memanggil fungsi menggambar objek sate
    glFlush();//mengirim semua objek untuk dirender
}
Ejemplo n.º 10
0
SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget *parent, Qt::WindowFlags f)
    : RenderWidget(parent, f)
    , mResourceSystem(resourceSystem)
    , mLighting(NULL)
    , mHasDefaultAmbient(false)
{
    // we handle lighting manually
    mView->setLightingMode(osgViewer::View::NO_LIGHT);

    setLighting(&mLightingDay);
}
Ejemplo n.º 11
0
CGameCamera::CGameCamera()
{
	m_targetObject = NULL;
	m_objectType = CGameObject::CameraObject;

#ifdef GSEDITOR
	m_cameraMesh = NULL;
#endif

	ISceneManager *smgr = getIView()->getSceneMgr();

	// save old camera
	ICameraSceneNode *oldCam = smgr->getActiveCamera();

	// create new camera
	m_camera = smgr->addCameraSceneNode();		
	m_camera->setFOV( core::degToRad(60.0f) );
	m_camera->setFarValue( 8000.0f );
	m_camera->grab();	
	
	core::vector3df	pos(0,0,0);
	setPosition( pos );

	core::vector3df target(1,0,0);
	setTarget( target );

#ifdef GSEDITOR	
	CColladaMeshComponent *comp = new CColladaMeshComponent( this );
	comp->loadFromFile( getIView()->getPath("data/editor/camera.dae") );
	addComponent( comp );
	setLighting( false );

	m_cameraMesh = m_node;	
	m_cameraMesh->setVisible( true );	

	ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_cameraMesh );
	m_cameraMesh->setTriangleSelector(selector);
	selector->drop();
#endif

	// set camera node
	m_node = m_camera;

	// restore camera
	smgr->setActiveCamera( oldCam );
		
	m_animator = NULL;

#ifndef GSGAMEPLAY
	setEditorCamera();
#else
	setFreeCamera();
#endif
}
Ejemplo n.º 12
0
void Mesh::EnableSpecialFX(){
  draw_sequence=MESH_SPECIAL_FX_ONLY;
  setEnvMap(GFXFALSE);
  setLighting (GFXTRUE);
  if (orig) {
    orig->draw_sequence=MESH_SPECIAL_FX_ONLY;
    orig->blendSrc = orig->blendDst= ONE;
    orig->setEnvMap( GFXFALSE);
    orig->setLighting (GFXTRUE);
  }
  blendSrc=ONE;
  blendDst=ONE;
}
Ejemplo n.º 13
0
// ***************************************************************************
void			CMaterial::initUnlit()
{
	setShader(Normal);
	setLighting(false);
	setColor(CRGBA(255,255,255,255));
	for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++)
		setTexture((uint8)i ,NULL);
	setZBias(0);
	setZFunc(lessequal);
	setZWrite(true);
	setBlend(false);
	setAlphaTestThreshold(0.5f);
}
Ejemplo n.º 14
0
/*
    Afficher les deux lumieres
*/
void drawLights()
{
	/*
 	** AJOUTER CODE ICI
 	**
	** Dessine chaque lumiere en utilisant sa composante diffuse
	** comme couleur.  Utilisez la commande "glutSolideSphere" pour afficher
	** les lumieres.

	**
	** Vous devez desactiver l'eclairage et le remettre dans son
	** etat inital ensuite
	*/
	if(glIsEnabled(GL_LIGHTING) == GL_TRUE)
	{
		glDisable(GL_LIGHTING);
		for (int i = 0; i < 2; i++) {

			glPushMatrix();

			glDisable(gLights[i].lightID);
			if(gLights[i].on)
			{
				setLighting(gLights[i]);	
				glEnable(gLights[i].lightID);
			}

			glTranslated(gLights[i].position[0], gLights[i].position[1], gLights[i].position[2]);
			glColor4fv(gLights[i].diffuse);
			glutSolidSphere(8,20,20);

			glPopMatrix();
		}
		glEnable(GL_LIGHTING);
	}
	else
	{
		for (int i = 0; i < 2; i++) {

			glPushMatrix();
			
			glTranslated(gLights[i].position[0], gLights[i].position[1], gLights[i].position[2]);
			glColor4fv(gLights[i].diffuse);
			glutSolidSphere(8,20,20);

			glPopMatrix();
		}
	}
}
void displayObject()
{
setMaterial();
setLighting();
setViewport();
setCamera();

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
kubus();
prisma();
teko();
bola();
cone();
donat();
glFlush();
}
Ejemplo n.º 16
0
Archivo: main.cpp Proyecto: hef/shader
void display()
{
	glClearColor(0.0,0.0,0.0,1.0);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	//gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

	setLighting();

	shader.bind();
	cube();
	shader.unbind();

	//glutSwapBuffers();
	SDL_GL_SwapBuffers();
	angle += 0.1f;
}
void MapgenSinglenode::makeChunk(BlockMakeData *data)
{
	// Pre-conditions
	assert(data->vmanip);
	assert(data->nodedef);
	assert(data->blockpos_requested.X >= data->blockpos_min.X &&
		data->blockpos_requested.Y >= data->blockpos_min.Y &&
		data->blockpos_requested.Z >= data->blockpos_min.Z);
	assert(data->blockpos_requested.X <= data->blockpos_max.X &&
		data->blockpos_requested.Y <= data->blockpos_max.Y &&
		data->blockpos_requested.Z <= data->blockpos_max.Z);

	this->generating = true;
	this->vm   = data->vmanip;
	this->ndef = data->nodedef;

	v3s16 blockpos_min = data->blockpos_min;
	v3s16 blockpos_max = data->blockpos_max;

	// Area of central chunk
	v3s16 node_min = blockpos_min * MAP_BLOCKSIZE;
	v3s16 node_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);

	blockseed = getBlockSeed2(node_min, data->seed);

	MapNode n_node(c_node);

	for (s16 z = node_min.Z; z <= node_max.Z; z++)
	for (s16 y = node_min.Y; y <= node_max.Y; y++) {
		u32 i = vm->m_area.index(node_min.X, y, z);
		for (s16 x = node_min.X; x <= node_max.X; x++) {
			if (vm->m_data[i].getContent() == CONTENT_IGNORE)
				vm->m_data[i] = n_node;
			i++;
		}
	}

	// Add top and bottom side of water to transforming_liquid queue
	updateLiquid(&data->transforming_liquid, node_min, node_max);

	// Set lighting
	if ((flags & MG_LIGHT) && set_light == LIGHT_SUN)
		setLighting(LIGHT_SUN, node_min, node_max);

	this->generating = false;
}
Ejemplo n.º 18
0
SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget *parent, Qt::WindowFlags f)
    : RenderWidget(parent, f)
    , mResourceSystem(resourceSystem)
    , mLighting(NULL)
    , mHasDefaultAmbient(false)
{
    // we handle lighting manually
    mView->setLightingMode(osgViewer::View::NO_LIGHT);

    setLighting(&mLightingDay);

    mResourceSystem->getSceneManager()->setParticleSystemMask(Mask_ParticleSystem);

    /// \todo make shortcut configurable
    QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
    connect (focusToolbar, SIGNAL (activated()), this, SIGNAL (focusToolbarRequest()));
}
Ejemplo n.º 19
0
void display(void) {

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  glEnable(GL_LIGHTING); 
  glEnable(GL_LIGHT0);

  setLighting();
  setMaterial();

  glTranslatef(0.0, 0.0, transZ);
  //glRotatef(rotY, 0.0, 1.0, 0.0);

  glutSolidTeapot(1);

  glutSwapBuffers();
}
Ejemplo n.º 20
0
//-----------------------------------------------------------------------------
//* Initialize 
//! Initializes OpenGL. 
//
//! @param fullscreen   will render scene in fullscreen if true
//! @param width        width of window or width of screen resolution
//! @param height       height of window or height of screen resolution
//! @param bitDepth     bitDepth to use
//! @param refreshRate  refresh frequency to use
//! @param vSync        limits frame rate to the monitor's refresh frequency
//! @param hideCursor   hides mouse coursor if true
//-----------------------------------------------------------------------------
bool OpenGLManager::initialize(bool fullscreen, int width, int height, int bitDepth, int refreshRate, bool vSync, bool hideCursor)
{
    m_width       = width;
    m_height      = height;
    m_bitDepth    = bitDepth;
    m_refreshRate = refreshRate;
    m_fullscreen  = fullscreen;
    m_renderingCallback = NULL;
    //Set OpenGL Settings
    setClearColor(0.0f, 0.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

    //Set render states
    setCullMode(false, true);
    setTextureing2D(false);
    setLighting(false);

    return true;
}
Ejemplo n.º 21
0
int main(int argc, char** argv)
{
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowPosition(200,50);
	glutInitWindowSize(winWidth,winHeight);
	main_window = glutCreateWindow("Nick Barnes - Homework 6");

	glutDisplayFunc(drawScene);
	glutMouseFunc(mouseFunc);
	glutMotionFunc(motionFunc);
	glutKeyboardFunc(keyFunc);
	glutIdleFunc(idleFunc);
	glutReshapeFunc(resizeScene);

	setLighting();
	//gluiCode();
	glEnable(GL_TEXTURE_2D);
	LoadGLTextures();
    glShadeModel(GL_SMOOTH);
	glEnable(GL_DEPTH_TEST);
	glutMainLoop();
}
Ejemplo n.º 22
0
void GLWidget::initializeGL(){
    //glewInit();
    glEnable( GL_DEPTH_TEST);
    glFrontFace( GL_CCW);
    glShadeModel( GL_SMOOTH);
    glEnable( GL_NORMALIZE);
    setLighting( true);
    init3dEng();
    setQuaternion( 1);
    //m_trackBalls = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Plane);
    m_trackBalls = TrackBall(0.0f, QVector3D(0, 1, 0), TrackBall::Sphere);

    //-- sun Light
    sun1.isOn = true;
    sun1.mat.ambi.set( .3, .3, .3, 1.);
    sun1.mat.diff.set( .7, .7, .7, 1.);
    sun1.pos.set( -.5, 1, .5, 0.);
    sun2.isOn = true;
    sun2.mat.ambi.set( .3, .3, .3, 1.);
    sun2.mat.diff.set( .7, .7, .7, 1.);
    sun2.pos.set(  .5, -1, -.5, 0.);

    //-- bulb Light
    bulb.isOn = false;
    bulb.mat.ambi.set( .3, .3, .3, 1.);
    bulb.mat.diff.set( .7, .7, .7, 1.);
    bulb.mat.spec.set( 1., 1., 1., 1.);
    bulb.att.set( 1.0, .01, .0003);

    Texture2d *tex;
    GLubyte *textureImage; //added by sai
     tex = loadBMP( "lap.bmp");
    //bool success = loadPngImage("lap.png",256,256,true,&textureImage);
    //tex = loadBMP( "tex3.bmp");
    //stoma.Load3ds( "stomach.3ds");
    stoma.LoadBIN("mesh.bin");
    stoma.smooth = 1;
     stoma.bindTexture( tex);
    //stoma.bindTexture(&textureImage);
    //stoma.rotate( -90, 0, 0);
    //stoma.scale( Vector3f( .3, .3, .3));
    //stoma.scale( Vector3f( .003, .003, .003));
    stoma.col.set( .6, .6, .2);
    stoma.calcBoundingCube();
    stoma.calcGraph();
    //glTranslatef(0,-160.0,0.0);
stoma.drawGraph();
    skele.Load3ds( "skeleton.3ds");
    skele.smooth = 1;
    skele.col.set( .7, .7, .7);
    skele.calcBoundingCube();
    //stoma += -((skele.cubeBoundMin+skele.cubeBoundMax)/2.0);
    stoma += -((stoma.cubeBoundMin+stoma.cubeBoundMax)/2.0);
    skele += -((skele.cubeBoundMin+skele.cubeBoundMax)/2.0);
    skele.updateDisplayList();
    stoma.lap();
    stoma.saveBIN( "mappedmesh.bin");
    //tex = loadBMP( "lapatlas.bmp");
    //stoma.bindTexture( tex);

    stoma.updateDisplayList();
    skele.isHidden = true;

    model.LoadBIN( "mesh.bin");
    model.col.set( .8, .4, .4);
    model.scale( Vector3f(.1));
    model.calcBoundingCube();
    model += -((model.cubeBoundMin+model.cubeBoundMax)/2.0);
    model.updateDisplayList();
    model.isHidden = true;

    m_mouseClick = 0;
    camS = 0.1;
    camM = 1.0;				// camera zoom
    camT = 0.0; camP = 0.0; // camera theta and phi
    aspectRatio = 1.0;
    freeCam.pos.set( 45., 0., 0.);
    //freeCam.pos.set( 0., 0., -50.);
    freeCam.cnear = 0.01;
    freeCam.cfar = 2000.0;
    freeCam.ang = 45.0/camM;
    freeCam.eye.set( 0., 0., 0.);
    //freeCam.eye = freeCam.pos + Vector3f( sin(camP)*cos(camT), sin(camT), cos(camP)*cos(camT));

    printf("Done\n");
}
Ejemplo n.º 23
0
//--------------------------------------------------------------
// draw the view
void mgDX9Display::drawView()
{
  mg_d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
      D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

  // if too early, do nothing
  if (m_theApp == NULL)
    return;

  mg_d3dDevice->BeginScene();

  D3DXMatrixIdentity(&m_state->m_worldMatrix);

  // render sky (before light and fog, or we can't see sky)
  D3DXMATRIX eyeMatrix;
  toD3DMatrix(m_eyeMatrix, eyeMatrix);
  m_state->m_viewMatrix = eyeMatrix;

  mg_d3dDevice->SetTransform(D3DTS_PROJECTION, &m_state->m_projMatrix);
  mg_d3dDevice->SetTransform(D3DTS_WORLD, &m_state->m_worldMatrix);
  mg_d3dDevice->SetTransform(D3DTS_VIEW, &m_state->m_viewMatrix);

  // set defaults
  setMatColor(0.5, 0.5, 0.5);
  setLighting(false);

  m_theApp->drawSky();

  // set up for world object rendering
  D3DXMatrixIdentity(&m_state->m_worldMatrix);
  mg_d3dDevice->SetTransform(D3DTS_PROJECTION, &m_state->m_projMatrix);
  mg_d3dDevice->SetTransform(D3DTS_WORLD, &m_state->m_worldMatrix);

  // set up view transform
  D3DXMATRIX translate;
  D3DXMatrixTranslation(&translate, (FLOAT) -m_eyePt.x, (FLOAT) -m_eyePt.y, (FLOAT) -m_eyePt.z);
  D3DXMatrixMultiply(&m_state->m_viewMatrix, &translate, &eyeMatrix);

  mg_d3dDevice->SetTransform(D3DTS_VIEW, &m_state->m_viewMatrix);

  frustumBuildPlanes();

  setLightAndFog();

  // set defaults
  setMatColor(0.5, 0.5, 0.5);
  setLighting(true);
  setZEnable(true);
  setTransparent(false);

  // tell the app the draw the view
  m_theApp->drawView();

  // set up for front plane rendering.  screen coordinates.
  D3DXMATRIX identity;
  D3DXMatrixIdentity(&identity);
  mg_d3dDevice->SetTransform(D3DTS_PROJECTION, &identity);
  mg_d3dDevice->SetTransform(D3DTS_WORLD, &identity);

  D3DXMATRIX scaling;
  D3DXMatrixScaling(&scaling, 2.0f/(FLOAT) m_graphicsWidth, -2.0f/(FLOAT) m_graphicsHeight, 1.0f);
  D3DXMatrixTranslation(&translate, -0.5f * (FLOAT) m_graphicsWidth, -0.5f * (FLOAT) m_graphicsHeight, 0.0f);
  D3DXMatrixMultiply(&m_state->m_viewMatrix, &translate, &scaling);
  mg_d3dDevice->SetTransform(D3DTS_VIEW, &m_state->m_viewMatrix);

  // turn off quality texture filtering.  for overlay, we want the actual pixels
  mg_d3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
  mg_d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
  mg_d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);

  // set defaults for overlay
  setMatColor(1.0, 1.0, 1.0);
  setLighting(false);
  setZEnable(false);

  // tell the app to draw its overlay
  m_theApp->drawOverlay();

  // draw the cursor, if enabled
  if (m_cursorEnabled)
    drawCursor();

  // turn texture filtering back on
  mg_d3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
  mg_d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC);
  mg_d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
  mg_d3dDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, 2); // m_state->m_deviceCaps.MaxAnisotropy);

  mg_d3dDevice->EndScene();
}
Ejemplo n.º 24
0
void drawObjects(void)
{

	int x, y;
	float float_x, float_y, float_xb, float_yb;

	glTranslatef(transZ, 0.0, -transX);
	glRotatef(xrot, 0.0, 1.0, 0.0);
	//glRotatef(-yrot, 0.0, 1.0, 0.0);

	// Ground
	//glColor4f(0.3f,0.3f,0.3f,1);
	//glEnable( GL_TEXTURE_2D );
	//glBindTexture( GL_TEXTURE_2D, tex );
	glBegin(GL_QUADS);
	//glTexCoord2f(0, 0);
	glColor4f(0.54f,0.27f,0.07f,1);
	glVertex3f(-35,-5,-35);
	//glTexCoord2f(1, 0);
	glColor4f(0.54f,0.27f,0.07f,1);
	glVertex3f(-35,-5, 15);
	//glTexCoord2f(1, 1);
	glColor4f(0.54f,0.27f,0.07f,1);
	glVertex3f( 15,-5, 15);
	//glTexCoord2f(0, 1);
	glColor4f(0.54f,0.27f,0.07f,1);
	glVertex3f( 15,-5,-35);
	
	//glTexCoord2f(0, 0);
	glColor4f(0.5f,0.5f,0.0f,1);
	glVertex3f(-35,12,-35);
	//glTexCoord2f(1, 0);
	glColor4f(0.5f,0.5f,0.0f,1);
	glVertex3f(-35,12, 15);
	glColor4f(0.5f,0.5f,0.0f,1);
	//glTexCoord2f(1, 1);
	glColor4f(0.5f,0.5f,0.0f,1);
	glVertex3f( -35,-5, 15);
	//glTexCoord2f(0, 1);
	glColor4f(0.5f,0.5f,0.0f,1);
	glVertex3f( -35,-5,-35);

	glEnd();

	glPushMatrix();
	glTranslatef(0,-2.5,-16);
	glColor4f(0.9f,0.9f,0.9f,1);
	glMatrixMode(GL_TEXTURE);
	glActiveTextureARB(GL_TEXTURE7);
	glPushMatrix();
	glTranslatef(0,-2.5,-16);
	glutSolidCube(4);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	glPushMatrix();
	glUseProgram(shaderProgram);
	setLighting();
	setMaterial();
	glTranslatef(-20,-2.5,-20);
	glRotatef(-90, 1.0, 0.0, 0.0);
	glRotatef(90, 0.0, 0.0, 1.0);
	glMatrixMode(GL_TEXTURE);
	glActiveTextureARB(GL_TEXTURE7);
	glPushMatrix();
	glTranslatef(-20,-2.5,-20);
	glutSolidCube(4);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	//endTranslate();
	glUseProgram(0);
	
	glPushMatrix();
	glUseProgram(shaderProgram);
	setLighting();
	setMaterial();
	glTranslatef(0,0,-5);
	glRotatef(-90, 1.0, 0.0, 0.0);
	glRotatef(90, 0.0, 0.0, 1.0);
	glMatrixMode(GL_TEXTURE);
	glActiveTextureARB(GL_TEXTURE7);
	glPushMatrix();
	glTranslatef(0,0,-5);
	glutSolidSphere(2,25,25);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	//endTranslate();
	glUseProgram(0);

	
	glPushMatrix();
	glUseProgram(shaderProgram);
	setLighting();
	setMaterial();
	glTranslatef(-20,7,-10);
	
	glMatrixMode(GL_TEXTURE);
	glActiveTextureARB(GL_TEXTURE7);
	glPushMatrix();
	glTranslatef(-20,7,-10);
	glBegin(GL_QUADS);
	for( x = 0; x < 44; x++ )
	{
		for( y = 0; y < 44; y++ )
		{
			float_x = float(x)/44.0f;
			float_y = float(y)/44.0f;
			float_xb = float(x+1)/44.0f;
			float_yb = float(y+1)/44.0f;

			//glTexCoord2f( float_x, float_y);
			//glColor4f(1.0, 0.0, 0.0, 1.0);
			glVertex3f( points[x][y][0], points[x][y][1], points[x][y][2] );

//			glTexCoord2f( float_x, float_yb );
			//glColor4f(0.0, 1.0, 0.0, 1.0);
			glVertex3f( points[x][y+1][0], points[x][y+1][1], points[x][y+1][2] );

//			glTexCoord2f( float_xb, float_yb );
			//glColor4f(0.0, 0.0, 1.0, 1.0);
			glVertex3f( points[x+1][y+1][0], points[x+1][y+1][1], points[x+1][y+1][2] );

//			glTexCoord2f( float_xb, float_y );
			//glColor4f(1.0, 1.0, 0.0, 1.0);
			glVertex3f( points[x+1][y][0], points[x+1][y][1], points[x+1][y][2] );
		}
	}
	glEnd();
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	if( wiggle_count == 2 )
	{
		for( y = 0; y < 45; y++ )
		{
			hold=points[0][y][2];
			for( x = 0; x < 44; x++)
			{
				points[x][y][2] = points[x+1][y][2];
			}
			points[44][y][2]=hold;
		}
		wiggle_count = 0;
	}

	wiggle_count++;


	// Instead of calling glTranslatef, we need a custom function that also maintain the light matrix
	//startTranslate(0,10,-16);
	glUseProgram(0);

	glPushMatrix();
	glUseProgram(shaderProgram);
	setMaterial2();
	setLighting2();
	glTranslatef(-15.5,-5,-10);
	glRotatef(-90, 1.0, 0.0, 0.0);
	glRotatef(90, 0.0, 0.0, 1.0);
	glMatrixMode(GL_TEXTURE);
	glActiveTextureARB(GL_TEXTURE7);
	glPushMatrix();
	glTranslatef(-15.5,-5,-10);
	GLUquadric *quadratic = gluNewQuadric();
	gluCylinder(quadratic, 0.75f, 0.75f, 17.0f, 10.0f, 10.0f);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glUseProgram(0);


	glPushMatrix();
	glUseProgram(shaderProgram);
	setMaterial3();
	setLighting3();
	glTranslatef(-15.5,12,-10);
	glRotatef(-90, 1.0, 0.0, 0.0);
	glRotatef(90, 0.0, 0.0, 1.0);
	glMatrixMode(GL_TEXTURE);
	glActiveTextureARB(GL_TEXTURE7);
	glPushMatrix();
	glTranslatef(-15.5,12,-10);
	glutSolidSphere(1,25,25);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glUseProgram(0);	


	glPushMatrix();
	glUseProgram(toonProgram);
	setMaterial3();
	setLighting3();
	glTranslatef(-10,-2.5,-30);
	//glRotatef(-90, 1.0, 0.0, 0.0);
	//glRotatef(90, 0.0, 0.0, 1.0);
	glMatrixMode(GL_TEXTURE);
	glActiveTextureARB(GL_TEXTURE7);
	glPushMatrix();
	glTranslatef(-10,-5,-30);
	glutSolidTorus(1.5, 2.0, 10.0, 50.0);
	//glutSolidTeapot(4);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glUseProgram(0);
}
Ejemplo n.º 25
0
void Renderer::render(const shared_ptr<Scene>& _scene, bool _withNames, bool _fastDraw){
	if(!initDone || _scene->glDirty || (_scene->gl && _scene->gl->dirty)){
		init(_scene);
		_scene->glDirty=false;
		if(_scene->gl) _scene->gl->dirty=false;
	}
	assert(initDone);

	switch(fast){
		case FAST_ALWAYS: fastDraw=true; break;
		case FAST_UNFOCUSED: fastDraw=_fastDraw; break;
		case FAST_NEVER: fastDraw=false; break;
	}

	// make a copy to see if it were true the whole time
	bool wasSetRefNow(setRefNow);

	withNames=_withNames; // used in many methods
	if(withNames) glNamedObjects.clear();

	// acquire shared_ptr to scene
	{ scene=_scene; }

	// smuggle scene and ourselves into GLViewInfo for use with GlRep and field functors
	viewInfo.scene=scene.get();
	viewInfo.renderer=this;

	setClippingPlanes();
	setLighting();
	drawPeriodicCell();

	fieldDispatcher.scene=scene.get(); fieldDispatcher.updateScenePtr();

	for(auto& f: scene->fields){
		fieldDispatcher(f,&viewInfo);
	}

	if(engines){
		for(const auto& e: scene->engines){
			if(!e || e->dead) continue; // !e should not happen, but make sure
			glScopedName name(viewInfo,e,shared_ptr<Node>());
			e->render(viewInfo);
		}
	}

	for(const shared_ptr<GlExtraDrawer>& d: extraDrawers){
		if(!d || d->dead) continue;
		glPushMatrix();
			d->scene=scene.get();
			d->render();
		glPopMatrix();
	}
	
	// if ref positions were set the whole time, unset here, it is done for all nodes
	if(setRefNow && wasSetRefNow){ setRefNow=false; }

	if(withNames) cerr<<"render(withNames==true) done, "<<glNamedObjects.size()<<" objects inserted"<<endl;

	// release the shared_ptr; must be GIL-protected since descruction of Python-constructed object without GIL causes crash
	{ GilLock lock; scene.reset(); }


}
Ejemplo n.º 26
0
void			CMaterial::initLighted()
{
	initUnlit();
	setLighting(true);
}