Esempio n. 1
0
//----------------------------------------------------------
//void ofxObject::draw(float *_matrix){
void ofxObject::draw(ofxObjectMaterial *iMaterial, float *iMatrix, int iSelect, bool iDrawAlone)
{
	//if(id == 1) printf("i am a circle %f - %f, %f, %f\n", ofGetElapsedTimef(), color.r, color.g, color.b);
  
	//call idle whether or not the object is shown
	//PEND: this might have to move down, so it doesn't get called multiple times
	//idle(ofGetElapsedTimef());
  
  
	if(shown) {
		
		//printf("ofxObject::draw()\n");
		if(!iDrawAlone){
			float *mat = updateMatrix(iMatrix);
			ofxObjectMaterial *m = updateMaterial(iMaterial);	//v4.0
      
			predraw();
      
			if ((iSelect == OF_RENDER_TRANSPARENT) && !hasTransparency()) {
				//Don't render — Transparent render pass, but this object is opaque
			}else if ((iSelect == OF_RENDER_OPAQUE) && hasTransparency()) {
				//Don't render — Opaque render pass, but this object is transparent
			}else if ((iSelect != OF_RENDER_ONTOP) && renderOntop) {
				//Don't render — Regular pass, but this is an on top object
			}else {
				//Render!
				render();
				//for (unsigned int i = 0; i < children.size(); i++)
        //children[i]->draw(m, mat, iSelect);
			}
			//v4.0 - to get alpha inheritance working
			for (unsigned int i = 0; i < children.size(); i++)
				children[i]->draw(m, mat, iSelect);
      
			postdraw();
		}
		else{
			//iDrawAlone is true — just draw this object (no children)
			//PEND idle of children won't get called for these objects! live with it or fix it
			//v4.0 (moving children draw loop above might have fixed it)
			predraw();
			render();
			postdraw();
		}
	}
	
}
Esempio n. 2
0
int ofxObject::collectNodes(int iSelect, ofxObject *iNodes[], int iNumber, int iMax)
{
	int curNode = iNumber;
  
	if (iNumber >= iMax) {
		printf("ofxObject::collectNodes() cannot render more than %d objects.\n", iMax);
		return curNode;
	}
  
	// v2.25 - default - we are not sorted.
	sortedObjectsWindowZ = 0;
	isSortedObject = false;
  
	if (shown) {
		if ((iSelect == OF_RENDER_TRANSPARENT) && !hasTransparency()) {
			// Skip it — looking for transparent objects, but this one is opaque
		}
		else if	((iSelect == OF_RENDER_OPAQUE) && hasTransparency()) {
			// Skip it — looking for opaque objects, but this one is transparent
		}
		else if ((iSelect == OF_RENDER_ONTOP) && (!renderOntop)) {
			// Skip it - looking for on-top objects, but this is regular
		}
		else {
			// this is an object we want to add to the list
			iNodes[iNumber] = (ofxObject *)this;
			curNode++;
      
			if (!renderOntop) isSortedObject = true;
		}
    
		if (isSortedObject) sortedObjectsWindowZ = getWindowCoords().z;
		//continue down the tree
		for (unsigned int i = 0; i < children.size(); i++) {
			curNode = children[i]->collectNodes(iSelect, iNodes, curNode, iMax);
		}
	}
  
	return curNode;
}
Esempio n. 3
0
double IfcGeom::Material::transparency() const { if (hasTransparency()) return *style->Transparency(); else return 0; }
Esempio n. 4
0
bool BaseSurfaceOSystem::finishLoad() {
	BaseImage *image = new BaseImage();
	if (!image->loadFile(_filename)) {
		delete image;
		return false;
	}

	_width = image->getSurface()->w;
	_height = image->getSurface()->h;

	bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G');
	if (isSaveGameGrayscale) {
		warning("grayscaleConversion not yet implemented");
		// FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); TODO
	}

	// no alpha, set color key
	/*  if (surface->format.bytesPerPixel != 4)
	        SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/

	// convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?)
	// Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow.
	_surface->free();
	delete _surface;

	bool needsColorKey = false;
	bool replaceAlpha = true;
	if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) {
		_surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette());
		needsColorKey = true;
		replaceAlpha = false;
	} else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) {
		_surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette());
		needsColorKey = true;
	} else if (image->getSurface()->format.bytesPerPixel >= 3 && image->getSurface()->format != g_system->getScreenFormat()) {
		_surface = image->getSurface()->convertTo(g_system->getScreenFormat());
		if (image->getSurface()->format.bytesPerPixel == 3) {
			needsColorKey = true;
		}
	} else {
		_surface = new Graphics::Surface();
		_surface->copyFrom(*image->getSurface());
		if (_surface->format.aBits() == 0) {
			needsColorKey = true;
		}
	}
	
	if (needsColorKey) {
		TransparentSurface trans(*_surface);
		trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, replaceAlpha);
	}

	_hasAlpha = hasTransparency(_surface);
	_valid = true;

	_gameRef->addMem(_width * _height * 4);

	delete image;

	_loaded = true;

	return true;
}