Ejemplo n.º 1
0
    ColorNode()
        : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
    {
        setGeometry(&m_geometry);

        QSGSimpleMaterial<State> *material = Shader::createMaterial();
        material->setFlag(QSGMaterial::Blending);
        setMaterial(material);
        setFlag(OwnsMaterial);
    }
Ejemplo n.º 2
0
bool GuiMaterialCtrl::onWake()
{
   if ( !Parent::onWake() )
      return false;

   setActive( true );
   setMaterial( mMaterialName );

   return true;
}
Ejemplo n.º 3
0
void bench( float shrink ) {
    setMaterial( &benchMats );

    glPushMatrix();
    glTranslatef(0, 0, -shrink*BENCH_DEPTH);
    box(shrink*BENCH_WIDTH, shrink*BENCH_HEIGHT, shrink*BENCH_DEPTH);
    glPopMatrix();

    box(shrink*BENCH_WIDTH, shrink*BENCH_HEIGHT/2, shrink*BENCH_DEPTH);
}
Ejemplo n.º 4
0
PlotNode2D::PlotNode2D():
    m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0)
{
    m_geometry.setDrawingMode(GL_LINE_STRIP);
    m_geometry.setLineWidth(1);
    //m_geometry.setVertexDataPattern(QSGGeometry::DynamicPattern);

    setGeometry(&m_geometry);
    setMaterial(&m_material);
}
Ejemplo n.º 5
0
void drawHandle ()
{
	int i;
	glPushMatrix();
		glTranslatef(0, 0, -0.5);
		setMaterial(plasticDiffuse, plasticSpecular, plasticShininess);
		gluCylinder(qobj, 0.1, 0.1, 1.0, 12, 1);
		glTranslatef(0.0, 0.0, 1.0);
		if (robotMode == BADASS) {
			setMaterial(beaterDiffuse, beaterSpecular, beaterShininess);
			//glColor3f(0.8, 0.8, 0.8);
			gluCylinder(qobj, 0.02, 0.02, 1.0, 12, 1);
			for (i = 0; i < 4; i++) {
				glPushMatrix();
					glTranslatef(0, 0, 0.5);
					glRotatef(90.0*i + beaterAngle, 0.0, 0.0, 1.0);
					/*
					glBegin(GL_LINE_STRIP);
						glVertex3f(0.0, 0.0, 0.5);
						glVertex3f(0.1, 0.0, 0.6);
						glVertex3f(0.1, 0.0, 0.9);
						glVertex3f(0.0, 0.0, 1.0);
					glEnd();
					*/
					glPushMatrix();
						glTranslatef(0.1, 0.0, 0.1);
						gluCylinder(qobj, 0.01, 0.01, 0.3, 12, 1);
					glPopMatrix();
					glPushMatrix();
						glRotatef(45, 0, 1, 0);
						gluCylinder(qobj, 0.01, 0.01, 0.1*sqrtf(2), 12, 1);
					glPopMatrix();
					glPushMatrix();
						glTranslatef(0.1, 0, 0.4);
						glRotatef(-45, 0, 1, 0);
						gluCylinder(qobj, 0.01, 0.01, 0.1*sqrtf(2), 12, 1);
					glPopMatrix();
				glPopMatrix();
			}
		}
	glPopMatrix();
}
Ejemplo n.º 6
0
//! deletes all textures
void CNullDriver::deleteAllTextures()
{
	// we need to remove previously set textures which might otherwise be kept in the
	// last set material member. Could be optimized to reduce state changes.
	setMaterial(SMaterial());

	for (u32 i=0; i<Textures.size(); ++i)
		Textures[i].Surface->releaseRef();

	Textures.clear();
}
Ejemplo n.º 7
0
FORCEINLINE void TVoxelData::initializeMaterial() {
	const int s = voxel_num * voxel_num * voxel_num;
	material_data = new unsigned short[s];
	for (auto x = 0; x < voxel_num; x++) {
		for (auto y = 0; y < voxel_num; y++) {
			for (auto z = 0; z < voxel_num; z++) {
				setMaterial(x, y, z, base_fill_mat);
			}
		}
	}
}
Ejemplo n.º 8
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.º 9
0
NxLine::NxLine( OperationType opType, bool UseVertexColour ) : mUseVertexColour(UseVertexColour)
{
	initialize(opType,false);
	setMaterial("BaseWhiteNoLighting");
	mDirty = true;
	setRenderQueueGroup( RENDER_QUEUE_OVERLAY - 1);

	// animation spline
	mAnimSpline = new SimpleSpline();
	mAnimSpline->setAutoCalculate(true);
}
Ejemplo n.º 10
0
SGPolyLineNode::SGPolyLineNode( const QVector<QPointF>& points ) noexcept :
    QSGGeometryNode{}
{
    setFlag( QSGNode::OwnedByParent, true );
    try {
        _material = new qgl::SGPolyLineAAMaterial{};
        setFlag( QSGNode::OwnsMaterial );
        setMaterial( _material );
        markDirty( QSGNode::DirtyMaterial );
    } catch (...) { }
    createGeometry(points);
}
Ejemplo n.º 11
0
 void DynamicLines::setColor(Ogre::ColourValue color)
 {
     // color-coded id
     unsigned int matIndex = ((unsigned int)(color.r) << 24) +
                             ((unsigned int)(color.g) << 16) +
                             ((unsigned int)(color.b) << 8) +
                             ((unsigned int)(color.a));
     Ogre::String matName = "DL" + Ogre::StringConverter::toString(matIndex);
     Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().createOrRetrieve(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME).first.staticCast<Ogre::Material>();
     materialPtr->setAmbient(color);
     setMaterial(matName);
 }
Ejemplo n.º 12
0
void
display(void)
{
  if (useSpecularTexture && needsLightUpdate) {
    setMaterial(MAT_GEN_SPECULAR_TEXTURE);
    needsLightUpdate = GL_FALSE;
  }
  redraw();
  glFlush();
  glutSwapBuffers();
  checkErrors();
}
Ejemplo n.º 13
0
QSGNinePatchNode::QSGNinePatchNode()
    : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0)
    , m_horizontalTileMode(QSGBorderImage::Stretch)
    , m_verticalTileMode(QSGBorderImage::Stretch)
    , m_dirtyGeometry(false)
    , m_mirror(false)
{
    setOpaqueMaterial(&m_material);
    setMaterial(&m_materialO);
    setGeometry(&m_geometry);
    m_geometry.setDrawingMode(GL_TRIANGLES);
}
Ejemplo n.º 14
0
AddChain::Node::Node(std::vector<QPointF> pts)
    : m_geometry({{2, GL_FLOAT}}, pts.size() + 1, sizeof(QVector2D)) {
  setMaterial(&m_material);
  setGeometry(&m_geometry);

  m_geometry.setDrawingMode(GL_LINE_STRIP);
  QVector2D* array = m_geometry.vertexData<QVector2D>();
  for (size_t i = 0; i < pts.size(); i++)
    array[i] = QVector2D(pts[i].x(), pts[i].y());
  array[pts.size()] = array[pts.size() - 1];
  m_geometry.updateVertexData();
}
Ejemplo n.º 15
0
QgsPhongMaterialWidget::QgsPhongMaterialWidget( QWidget *parent )
  : QWidget( parent )
{
  setupUi( this );

  setMaterial( QgsPhongMaterialSettings() );

  connect( btnDiffuse, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed );
  connect( btnAmbient, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed );
  connect( btnSpecular, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed );
  connect( spinShininess, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPhongMaterialWidget::changed );
}
Ejemplo n.º 16
0
TextSprite::TextSprite(MaterialPtr material, const std::string &text, FontPtr font, PropertiesPtr	properties)
	: Sprite(), _text(text), _font(font)
{
	// Create geometry
	createGeometry();

	// Add atlas texture to the material
	material->setTexture(bRenderer::DEFAULT_SHADER_UNIFORM_CHARACTER_MAP(), font->getAtlas());

	setMaterial(material);
	setProperties(properties);
}
Ejemplo n.º 17
0
Player::Player(Updatable* parent) : PatternAnimation(parent, NULL, textureResources.get("character"),
				Vector2ui(0, 0), Vector2ui(0, 0), Vector2ui(118, 99), Vector2ui(3, 1), 3, 10), m_shots(NULL), m_nbShots(0), m_orientation(AHEAD), m_currentWeapon(NULL)
{
	m_updateFocus = false;
	m_currentWeapon = new MachineGun(this, NULL);
	m_weapons.add("MachineGun", m_currentWeapon);
	m_currentWeapon = new ShotGun(this, NULL);
	m_weapons.add("ShotGun", m_currentWeapon);
	setMaterial(&m_textureMaterial);
	scale(glm::vec3(0.22, 0.15, 1.0));
	setPositionOrigin(glm::vec3(0.5, 0.5, 0.0), true);
}
Ejemplo n.º 18
0
void flag::drawObject() {

    GLenum errCode;
    const GLubyte *errString;

    //glPushMatrix();
    //glLoadIdentity();
    setTranslate();
    setRotate();
    if(colorMode == _glColor) {
        glEnable(GL_COLOR_MATERIAL);
        setColor();
    } else {
        glDisable(GL_COLOR_MATERIAL);
    }
    setScale();

    //qDebug() << "Drawing object\n";

    glBindTexture(GL_TEXTURE_2D,textureId);
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 8" << errCode;
    }
    setMaterial();
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 9" << errCode;
    }
    glBegin(GL_TRIANGLES);
    for(int i = 0; i < vertices.size();i++) {
        glNormal3f(normals.at(i).x(), normals.at(i).y(), normals.at(i).z());
        glTexCoord2f(textures.at(i).x(), textures.at(i).y());
        glVertex3f(vertices.at(i).x(), vertices.at(i).y(), vertices.at(i).z());
    }
    glEnd();
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 10" << errCode;
    }
    glBindTexture(GL_TEXTURE_2D,0);
    if ((errCode = glGetError()) != GL_NO_ERROR) {
        errString = gluErrorString(errCode);
        qDebug() << "OpenGL Error: 11" << errCode;
    }
    //glPopMatrix();

    if(debug) {

        debug = false;
    }

}
Ejemplo n.º 19
0
    std::shared_ptr<MeshRenderer> Scene::createPlane(GameObject *gameObject){
        if (!gameObject) {
            gameObject = createGameObject("Plane");
        }
        auto meshRenderer = gameObject->addComponent<MeshRenderer>();
        auto mesh = make_shared<Mesh>();
        mesh->setMeshData(MeshFactory::createPlaneData());
        meshRenderer->setMesh(mesh);

        Material* mat = Project::createMaterial("assets/shaders/diffuse.shader");
        meshRenderer->setMaterial(mat);
        return meshRenderer;
    }
Ejemplo n.º 20
0
// Specify the values of a sphere struct in the fragment shader
void setSphere(GLuint shaderProgram, const char *sphereName, Vec3 point, float radius, Material mat)
{
    char sphereMember[30];
    strcpy(sphereMember, sphereName);
    strcat(sphereMember, ".center");    
    glUniform3f(glGetUniformLocation(shaderProgram, sphereMember), point[0], point[1], point[2]);
    
    strcpy(sphereMember, sphereName);
    strcat(sphereMember, ".radius");
    glUniform1f(glGetUniformLocation(shaderProgram, sphereMember), radius);

    setMaterial(shaderProgram, sphereName, mat);
}
Ejemplo n.º 21
0
BackgroundNode::BackgroundNode(const QColor &color)
    : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0)
{
    setGeometry(&m_geometry);
    m_geometry.setLineWidth(1);
    m_geometry.setDrawingMode(GL_TRIANGLE_STRIP);
//    setFlag(QSGNode::OwnsGeometry);

    QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
    material->setColor(color);
    setMaterial(material);
    setFlag(QSGNode::OwnsMaterial);
}
Ejemplo n.º 22
0
    /*! \todo move all except the default shader to config file
    */
    void iMaterialResourceFactory::initDefaultMaterial()
    {
        _defaultID = createMaterial();
        getMaterial(_defaultID)->setName("IgorDefault");
        getMaterial(_defaultID)->addShaderSource("default.vert", iShaderObjectType::Vertex);
        getMaterial(_defaultID)->addShaderSource("default_directional_light.frag", iShaderObjectType::Fragment);
        getMaterial(_defaultID)->compileShader();
        getMaterial(_defaultID)->getRenderStateSet().setRenderState(iRenderState::Texture2D0, iRenderStateValue::Off);
        getMaterialGroup(_defaultID)->setOrder(iMaterial::RENDER_ORDER_DEFAULT);

        // set material to start with
        setMaterial(_defaultID);
    }
Ejemplo n.º 23
0
void setDiffuse(const QColor &diffuse)
{
    GLfloat diffuseMaterial[] = { static_cast<GLfloat>(diffuse.redF()),
                                  static_cast<GLfloat>(diffuse.greenF()),
                                  static_cast<GLfloat>(diffuse.blueF()),
                                  1.0f};

    setMaterial(NO_MATERIAL,
                diffuseMaterial,
                NO_MATERIAL,
                SHININESS_ZERO,
                NO_MATERIAL);
}
Ejemplo n.º 24
0
GObject::GObject(const char* identifier)
{
	this->identifier = identifier;
	intCounter = 0;
	floatCounter = 0.0f;
	ambientMaterial = new GLfloat[4];
	diffuseMaterial = new GLfloat[4];
	setMaterial(baseAmbientMaterial, baseDiffuseMaterial);

	position = new EDPoint(0.0f, 0.0f, 0.0f);

	setCallUpdate(emptyFunction);
}
Ejemplo n.º 25
0
//!
bool CTestSceneNode::set(ISceneNode* other)
{
	if (!other || this == other
			|| other->getSceneNodeType()!=ESNT_TEST_SCENE_NODE)
	{
		return false;
	}

	setPrimitiveType( ((ITestSceneNode*)other)->getPrimitiveType() );
	setMaterial(other->getMaterial(0));

	return true;
}
/*!
    Constructs a new simple texture node
 */
QSGSimpleTextureNode::QSGSimpleTextureNode()
    : QSGGeometryNode(*new QSGSimpleTextureNodePrivate)
    , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
{
    setGeometry(&m_geometry);
    setMaterial(&m_material);
    setOpaqueMaterial(&m_opaque_material);
    m_material.setMipmapFiltering(QSGTexture::None);
    m_opaque_material.setMipmapFiltering(QSGTexture::None);
#ifdef QSG_RUNTIME_DESCRIPTION
    qsgnode_set_description(this, QLatin1String("simpletexture"));
#endif
}
Ejemplo n.º 27
0
// on "init" you need to initialize your instance
bool MaterialLesson12::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(MaterialLesson12::menuCloseCallback, this));
    
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label

    // add "MathLesson1" splash screen"
    
    //create Sprite3D
    std::string filename = "res/Material/plane.c3t";
    auto sprite = Sprite3D::create(filename);
    sprite->setPosition(visibleSize.width/2 + origin.x, visibleSize.height/3 + origin.y);
    sprite->setScale(2);
    sprite->setRotation3D(Vec3(-70, 0, 0));
    addChild(sprite);
    
    auto material = Material::createWithFilename("res/Material/water.material");
    sprite->setMaterial(material);
    
    return true;
}
Ejemplo n.º 28
0
MapNode::MapNode(QGeoMap *map): QSGGeometryNode(),
        m_fbo(0),
        m_fboSurface(0),
        m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4),
        m_texture(0),
        m_map(map),
        m_initialized(false),
        m_dirtyFBO(false)
{
    setMaterial(&m_material);
    setOpaqueMaterial(&m_opaqueMaterial);
    setGeometry(&m_geometry);
    // setFlag(UsePreprocess);
}
Ejemplo n.º 29
0
void NS2DT3BT3::set(const Element* el)
{
   _nb_dof = 3;
   Init(el);
   setMaterial();
   Triang3 tr(_theElement);
   _area = tr.getArea();
   ElementNodeCoordinates();
   _dSh(1) = tr.DSh(1);
   _dSh(2) = tr.DSh(2);
   _dSh(3) = tr.DSh(3);
   eMat = 0;
   eRHS = 0;
}
Ejemplo n.º 30
0
void drawCube(GLfloat color[3], GLfloat ladoY,GLfloat ladoX,GLfloat ladoZ){
	glEnable(GL_LIGHTING);
	// crea un cubo con base en el plano XY y centrado en 0,0,0 de ladoX * ladoY * lado Z

	setMaterial(color);

	glPushMatrix();
		glTranslatef(0,0,ladoZ/2.0); // el centro de masa esta en la base del cubo, no en el centro
		glScalef(ladoX,ladoY,ladoZ);
		glutSolidCube(1);
	glPopMatrix();


}