void CoverArt::calcPositionOnScreen() { VisualActorGraphics::prepareCoverArtAction(); VisualStagePosition coverArtAssetPosition = this->coverArtAsset.getPosition(); coverArtAssetPosition.reset(); coverArtAssetPosition.horizontalAlignment = kCenterAligned; coverArtAssetPosition.verticalAlignment = kMiddleAligned; coverArtAssetPosition.minMarginBottom = (double)VisualDataStore::getValueInt(VisualConfiguration::kTrackInfoTextureHeight) + 5.0; coverArtAssetPosition.minMarginBottomUnit = kPixel; coverArtAssetPosition.minMarginTop = 5; coverArtAssetPosition.minMarginTopUnit = kPixel; coverArtAssetPosition.minMarginLeft = 5; coverArtAssetPosition.minMarginLeftUnit = kPixel; coverArtAssetPosition.minMarginRight = 5; coverArtAssetPosition.minMarginRightUnit = kPixel; this->coverArtAsset.setPosition(coverArtAssetPosition); VisualStageBox* coverArtAssetBox = this->coverArtAsset.getBox(); coverArtAssetBox->update(); // VisualStageBox only updates automatically on value changed, after canvas reshape event we have to update manually (before calculating scaleFactor) coverArtAssetBox->setScalingBehaviour(kPreserveAspectRatio); this->coverArtAsset.generateVertexChain(kFrontVertexChain); VisualActorGraphics::finishCoverArtAction(); }
uint16 TrackTitle::getTrackInfoTextureHeightInPixels() { uint16 heightOfTrackInfoTextureInPixels = 0; VisualStageBox* trackInfoAssetBox = this->trackInfoAsset.getBox(); VisualCamera& aCamera = this->trackInfoAsset.getCamera(); heightOfTrackInfoTextureInPixels = VisualActorGraphics::yCoordToPixel(trackInfoAssetBox->getTopCoord(), aCamera) - VisualActorGraphics::yCoordToPixel(trackInfoAssetBox->getBottomCoord(), aCamera); return heightOfTrackInfoTextureInPixels; }
void Beatlight::calcPositionOnScreen() { VisualStagePosition beatlightAssetPosition = this->beatlightAsset.getPosition(); beatlightAssetPosition.reset(); beatlightAssetPosition.horizontalAlignment = kRightAligned; beatlightAssetPosition.verticalAlignment = kTopAligned; beatlightAssetPosition.minMarginBottom = 5; beatlightAssetPosition.minMarginBottomUnit = kPixel; beatlightAssetPosition.minMarginTop = 20; beatlightAssetPosition.minMarginTopUnit = kPixel; beatlightAssetPosition.minMarginLeft = 5; beatlightAssetPosition.minMarginLeftUnit = kPixel; beatlightAssetPosition.minMarginRight = 20; beatlightAssetPosition.minMarginRightUnit = kPixel; this->beatlightAsset.setPosition(beatlightAssetPosition); VisualStageBox* beatlightAssetBox = this->beatlightAsset.getBox(); beatlightAssetBox->update(); // VisualStageBox only updates automatically on value changed, after canvas reshape event we have to update manually (before calculating scaleFactor) beatlightAssetBox->setScalingBehaviour(kPreserveAspectRatio); this->beatlightAsset.generateVertexChain(kFrontVertexChain); }
void CoverArt::prepareCoverAction() { VisualActorGraphics::enableDepthTest(); double distance = this->coverArtAsset.getCamera().getMaxFarPos() - this->coverArtAsset.getCamera().getMaxNearPos(); double distanceCenter = distance / 2.0 * -1.0; VisualStageBox* coverArtAssetBox = this->coverArtAsset.getBox(); double stageBoxDepth = coverArtAssetBox->getCoordDepth(); VisualActorGraphics::translateMatrix(0.0, 0.0, distanceCenter - this->coverArtAsset.getCamera().getMaxNearPos() - (stageBoxDepth / 2.0)); }
double CoverArt::calcCoordDepth() { VisualStageBox* coverArtAssetBox = this->coverArtAsset.getBox(); double ratio = 0.0; VisualCamera aCamera; aCamera.setPerspectiveProjection(3.0); CoordSize3D size = aCamera.getSize(); if (size.width > size.height) { ratio = coverArtAssetBox->getUnscaledCoordWidth() / size.width; } else { ratio = coverArtAssetBox->getUnscaledCoordHeight() / size.height; } double zCoordAmount = size.depth; return zCoordAmount * ratio; }
void CoverArt::clear() { VisualStageBox* coverArtAssetBox = this->coverArtAsset.getBox(); coverArtAssetBox->setContentPixelWidth(0); coverArtAssetBox->setContentPixelHeight(0); VisualStagePosition coverArtAssetPosition = this->coverArtAsset.getPosition(); coverArtAssetPosition.reset(); this->coverArtAsset.setPosition(coverArtAssetPosition); this->coverArtAsset.removeAnimations(); this->coverArtAsset.setOpacityValue(0.0); }
void TrackTitle::clear() { VisualStageBox* trackInfoAssetBox = this->trackInfoAsset.getBox(); trackInfoAssetBox->setContentPixelWidth(0); trackInfoAssetBox->setContentPixelHeight(0); VisualStagePosition trackInfoAssetPosition = this->trackInfoAsset.getPosition(); trackInfoAssetPosition.reset(); this->trackInfoAsset.setPosition(trackInfoAssetPosition); this->trackInfoAsset.removeAnimations(); this->trackInfoAsset.setOpacityValue(0.0); }
void Beatlight::addSpotlightImage() { VisualImage spotlightImage; spotlightImage.initWithResource(SPOTPNG); /* VisualFile* inputFile = VisualFile::createWithUserDesktopDirectory(); VisualString inputFileName = VisualString("spot.png"); inputFile->appendFileName(inputFileName); //spotlightImage.initWithFile(*inputFile); spotlightImage.initWithContentsOfFile(*inputFile); delete(inputFile); */ //VisualString url("http://www.imagomat.de/images/coverversion/screen_mac.png"); //VisualImage* spotlightImage = VisualImage::createWithURL(url); if (!spotlightImage.isEmpty()) { this->beatlightAsset.setImage(spotlightImage); VisualStageBox* beatlightAssetBox = this->beatlightAsset.getBox(); beatlightAssetBox->setContentPixelWidth(spotlightImage.getWidth()); beatlightAssetBox->setContentPixelHeight(spotlightImage.getHeight()); /* VisualFile outputFile; outputFile.initWithUserDesktopDirectory(); VisualString aFileName = VisualString("vizKitBeatlightImage.png"); outputFile.appendFileName(aFileName); OSStatus status = spotlightImage.writeToFile(outputFile); if (status != noErr) { printf("err %ld in Beatlight::addSpotlightImage()\n", status); } */ this->calcPositionOnScreen(); VisualAnimation pulsateAnimation(kAnimatedOpacity); UInt32 durationInMilliseconds = 550; pulsateAnimation.setDurationInMilliseconds(durationInMilliseconds); pulsateAnimation.setLoopMode(kMirroredLoop, kInfiniteRepetition); this->beatlightAsset.addAnimation(pulsateAnimation); } }
void CoverArt::makeImageOfCover() { if (VisualDataStore::getNumberOfCoverArtworksOfCurrentTrack() > 0) { VisualImage* coverArtImage = VisualActorGraphics::createCoverArtImage(); /* VisualImage* coverArtImage = new VisualImage; VisualFile* inputFile = VisualFile::createWithUserDesktopDirectory(); VisualString inputFileName = VisualString("spot.png"); inputFile->appendFileName(inputFileName); coverArtImage->initWithFile(*inputFile); delete(inputFile); */ //VisualString url("http://www.imagomat.de/images/coverversion/screen_mac.png"); //VisualImage* coverArtImage = VisualImage::createWithURL(url); if (coverArtImage != NULL) { //VisualConvolutionFilter aConvolutionFilter(VisualConvolutionFilter::kEmboss); //coverArtImage->applyConvolutionFilter(aConvolutionFilter); /* VisualFile outputFile; outputFile.initWithUserDesktopDirectory(); VisualString aFileName = VisualString("vizKitCoverArtImage.png"); outputFile.appendFileName(aFileName); OSStatus status = coverArtImage->writeToFile(outputFile); if (status != noErr) { printf("err %ld in CoverArt::makeImageOfCover()\n", status); } */ this->coverArtAsset.setImage(*coverArtImage); VisualStageBox* coverArtAssetBox = this->coverArtAsset.getBox(); coverArtAssetBox->setContentPixelWidth(coverArtImage->getWidth()); coverArtAssetBox->setContentPixelHeight(coverArtImage->getHeight()); VisualActorGraphics::releaseCoverArtImage(&coverArtImage); } } }
void Beatlight::reshape() { VisualCamera aCamera; aCamera.setOrthographicProjection(); this->beatlightAsset.setCamera(aCamera); VisualStagePosition beatlightAssetPosition = this->beatlightAsset.getPosition(); beatlightAssetPosition.reset(); VisualStageBox* beatlightAssetBox = this->beatlightAsset.getBox(); //double coordDepth = this->calcCoordDepth(); //coverArtAssetPosition.depthAlignment = kDepthCenterAligned; //coverArtAssetBox->setCoordDepth(coordDepth); beatlightAssetPosition.horizontalAlignment = kLeftAligned; beatlightAssetPosition.verticalAlignment = kBottomAligned; beatlightAssetPosition.verticalCoordOffset = VisualActorGraphics::yPixelToCoord(220, aCamera); this->beatlightAsset.setPosition(beatlightAssetPosition); beatlightAssetBox->update(); // VisualStageBox only updates automatically on value changed, after canvas reshape event we have to update manually (before calculating scaleFactor) beatlightAssetBox->setScalingBehaviour(kPreserveAspectRatio); VisualVertex* aVertex = NULL; beatlightAssetBox->initializeVertexChain(this->vertexChainId); aVertex = beatlightAssetBox->createVertex(0.0, 1.0, 0.5, 0.0, 1.0); beatlightAssetBox->addVertexToChain(this->vertexChainId, aVertex); aVertex = beatlightAssetBox->createVertex(0.0, 0.0, 0.5, 0.0, 0.0); beatlightAssetBox->addVertexToChain(this->vertexChainId, aVertex); aVertex = beatlightAssetBox->createVertex(1.0, 0.0, 0.5, 1.0, 0.0); beatlightAssetBox->addVertexToChain(this->vertexChainId, aVertex); aVertex = beatlightAssetBox->createVertex(1.0, 1.0, 0.5, 1.0, 1.0); beatlightAssetBox->addVertexToChain(this->vertexChainId, aVertex); }
UInt32* VisualTextureContainer::getRectPixels(const UInt16 format, const UInt16 type) { UInt32* pixels = NULL; UInt32* prevPixels = NULL; char errStr[512]; double scaleFactor = 1.0; UInt8 numberOfBytesPerChannel = 0; UInt8 numberOfChannels = 0; // channel == color resp. alpha channel UInt8 numberOfBytesPerPixel = 0; UInt32 numberOfBytesPerRow = 0; if ((format == kGL_RGBA) || (format == kGL_BGRA)) { numberOfChannels = 4; } else { sprintf(errStr, "unknown format %d in file: %s (line: %d) [%s])", format, __FILE__, __LINE__, __FUNCTION__); writeLog(errStr); return pixels; } if ((type == kGL_UNSIGNED_INT_8_8_8_8_REV) || (type == kGL_UNSIGNED_INT_8_8_8_8) || (type == kGL_UNSIGNED_BYTE)) { numberOfBytesPerChannel = 1; // // 1 byte (== 8 bits) per color/channel } else { sprintf(errStr, "unknown type %d in file: %s (line: %d) [%s])", type, __FILE__, __LINE__, __FUNCTION__); writeLog(errStr); return pixels; } numberOfBytesPerPixel = numberOfBytesPerChannel * numberOfChannels; numberOfBytesPerRow = numberOfBytesPerPixel * this->textureWidth; VisualStageBox stageBox; VisualStagePosition position; position.horizontalAlignment = kLeftAligned; position.verticalAlignment = kBottomAligned; stageBox.setVisualStagePosition(position); stageBox.setContentPixelWidth(this->getImageWidth()); stageBox.setContentPixelHeight(this->getImageHeight()); VertexChain aVertexChain; Vertex* topLeftFrontVertex = new Vertex; topLeftFrontVertex->vertexPosition.xPos = stageBox.getLeftCoord() * scaleFactor; topLeftFrontVertex->vertexPosition.yPos = stageBox.getTopCoord() * scaleFactor; topLeftFrontVertex->vertexPosition.zPos = stageBox.getFrontPosition(); topLeftFrontVertex->vertexColor.r = 1.0f; topLeftFrontVertex->vertexColor.g = 1.0f; topLeftFrontVertex->vertexColor.b = 1.0f; topLeftFrontVertex->vertexColor.a = 1.0f; topLeftFrontVertex->texCoordPosition.sPos = 0.0f; topLeftFrontVertex->texCoordPosition.tPos = this->getTextureLogicalHeight(); aVertexChain.push_back(topLeftFrontVertex); Vertex* bottomLeftFrontVertex = new Vertex; bottomLeftFrontVertex->vertexPosition.xPos = stageBox.getLeftCoord() * scaleFactor; bottomLeftFrontVertex->vertexPosition.yPos = stageBox.getBottomCoord() * scaleFactor; bottomLeftFrontVertex->vertexPosition.zPos = stageBox.getFrontPosition(); bottomLeftFrontVertex->vertexColor.r = 1.0f; bottomLeftFrontVertex->vertexColor.g = 1.0f; bottomLeftFrontVertex->vertexColor.b = 1.0f; bottomLeftFrontVertex->vertexColor.a = 1.0f; bottomLeftFrontVertex->texCoordPosition.sPos = 0.0f; bottomLeftFrontVertex->texCoordPosition.tPos = 0.0f; aVertexChain.push_back(bottomLeftFrontVertex); Vertex* bottomRightFrontVertex = new Vertex; bottomRightFrontVertex->vertexPosition.xPos = stageBox.getRightCoord() * scaleFactor; bottomRightFrontVertex->vertexPosition.yPos = stageBox.getBottomCoord() * scaleFactor; bottomRightFrontVertex->vertexPosition.zPos = stageBox.getFrontPosition(); bottomRightFrontVertex->vertexColor.r = 1.0f; bottomRightFrontVertex->vertexColor.g = 1.0f; bottomRightFrontVertex->vertexColor.b = 1.0f; bottomRightFrontVertex->vertexColor.a = 1.0f; bottomRightFrontVertex->texCoordPosition.sPos = this->getTextureLogicalWidth(); bottomRightFrontVertex->texCoordPosition.tPos = 0.0f; aVertexChain.push_back(bottomRightFrontVertex); Vertex* topRightFrontVertex = new Vertex; topRightFrontVertex->vertexPosition.xPos = stageBox.getRightCoord() * scaleFactor; topRightFrontVertex->vertexPosition.yPos = stageBox.getTopCoord() * scaleFactor; topRightFrontVertex->vertexPosition.zPos = stageBox.getFrontPosition(); topRightFrontVertex->vertexColor.r = 1.0f; topRightFrontVertex->vertexColor.g = 1.0f; topRightFrontVertex->vertexColor.b = 1.0f; topRightFrontVertex->vertexColor.a = 1.0f; topRightFrontVertex->texCoordPosition.sPos = this->getTextureLogicalWidth(); topRightFrontVertex->texCoordPosition.tPos = this->getTextureLogicalHeight(); aVertexChain.push_back(topRightFrontVertex); VisualGraphics* theVisualGraphics = VisualGraphics::getInstance(); // read previous pixels if ((format == kGL_RGBA) || (format == kGL_BGRA)) { prevPixels = (UInt32*)calloc((numberOfBytesPerRow / numberOfBytesPerPixel) * this->textureHeight, numberOfBytesPerPixel); } theVisualGraphics->readPixels(stageBox.getLeftCoord(), stageBox.getBottomCoord(), this->textureWidth, this->textureHeight, &prevPixels, format, type); // draw current texture theVisualGraphics->drawTexture(this->textureName, &aVertexChain, this->getUseRectExtension(), kReplace); // read pixels of current texture if ((format == kGL_RGBA) || (format == kGL_BGRA)) { pixels = (UInt32*)calloc((numberOfBytesPerRow / numberOfBytesPerPixel) * this->textureHeight, numberOfBytesPerPixel); } theVisualGraphics->readPixels(stageBox.getLeftCoord(), stageBox.getBottomCoord(), this->textureWidth, this->textureHeight, &pixels, format, type); // restore previous pixels theVisualGraphics->drawPixels(&prevPixels, stageBox.getLeftCoord(), stageBox.getBottomCoord(), this->textureWidth, this->textureHeight, format, type); for (VertexChainIterator chainIt = aVertexChain.begin(); chainIt != aVertexChain.end(); chainIt++) { delete *chainIt; *chainIt = NULL; } aVertexChain.clear(); free(prevPixels); return pixels; }
void CoverArt::reshape() { VisualCamera aCamera; aCamera.setPerspectiveProjection(3.0); this->coverArtAsset.setCamera(aCamera); VisualStagePosition coverArtAssetPosition = this->coverArtAsset.getPosition(); coverArtAssetPosition.reset(); VisualStageBox* coverArtAssetBox = this->coverArtAsset.getBox(); double coordDepth = this->calcCoordDepth(); coverArtAssetPosition.depthAlignment = kDepthCenterAligned; coverArtAssetBox->setCoordDepth(coordDepth); coverArtAssetPosition.horizontalAlignment = kCenterAligned; coverArtAssetPosition.verticalAlignment = kMiddleAligned; coverArtAssetPosition.minMarginBottom = (double)VisualDataStore::getValueInt(VisualDataStore::kTrackInfoTextureHeight) + 5.0; coverArtAssetPosition.minMarginBottomUnit = kPixel; coverArtAssetPosition.minMarginTop = 5; coverArtAssetPosition.minMarginTopUnit = kPixel; coverArtAssetPosition.minMarginLeft = 5; coverArtAssetPosition.minMarginLeftUnit = kPixel; coverArtAssetPosition.minMarginRight = 5; coverArtAssetPosition.minMarginRightUnit = kPixel; this->coverArtAsset.setPosition(coverArtAssetPosition); coverArtAssetBox->update(); // VisualStageBox only updates automatically on value changed, after canvas reshape event we have to update manually (before calculating scaleFactor) coverArtAssetBox->setScalingBehaviour(kPreserveAspectRatio); VisualVertex* aVertex = NULL; coverArtAssetBox->initializeVertexChain(this->vertexChainId); aVertex = coverArtAssetBox->createVertex(0.0, 1.0, 0.5, 0.0, 1.0); coverArtAssetBox->addVertexToChain(this->vertexChainId, aVertex); aVertex = coverArtAssetBox->createVertex(0.0, 0.0, 0.5, 0.0, 0.0); coverArtAssetBox->addVertexToChain(this->vertexChainId, aVertex); aVertex = coverArtAssetBox->createVertex(1.0, 0.0, 0.5, 1.0, 0.0); coverArtAssetBox->addVertexToChain(this->vertexChainId, aVertex); aVertex = coverArtAssetBox->createVertex(1.0, 1.0, 0.5, 1.0, 1.0); coverArtAssetBox->addVertexToChain(this->vertexChainId, aVertex); }
void TrackTitle::reshape() { VisualCamera aCamera; aCamera.setOrthographicProjection(); this->trackInfoAsset.setCamera(aCamera); VisualStageBox* trackInfoAssetBox = this->trackInfoAsset.getBox(); trackInfoAssetBox->setScalingBehaviour(kPreserveAspectRatio); VisualStagePosition trackInfoAssetPosition = this->trackInfoAsset.getPosition(); trackInfoAssetPosition.reset(); trackInfoAssetPosition.horizontalAlignment = kCenterAligned; trackInfoAssetPosition.verticalAlignment = kBottomAligned; this->trackInfoAsset.setPosition(trackInfoAssetPosition); VisualVertex* aVertex = NULL; trackInfoAssetBox->initializeVertexChain(this->vertexChainId); VertexColor aVertexColor; for (uint8 i = 0; i < 4; i++) { switch (i) { case 0: aVertexColor.r = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopLeftRed); aVertexColor.g = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopLeftGreen); aVertexColor.b = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopLeftBlue); aVertexColor.a = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopLeftAlpha); aVertexColor.red = aVertexColor.r; aVertexColor.green = aVertexColor.g; aVertexColor.blue = aVertexColor.b; aVertexColor.alpha = aVertexColor.a; aVertex = trackInfoAssetBox->createVertex(0.0, 1.0, 0.0, 0.0, 1.0, aVertexColor); trackInfoAssetBox->addVertexToChain(this->vertexChainId, aVertex); break; case 1: aVertexColor.r = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomLeftRed); aVertexColor.g = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomLeftGreen); aVertexColor.b = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomLeftBlue); aVertexColor.a = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomLeftAlpha); aVertexColor.red = aVertexColor.r; aVertexColor.green = aVertexColor.g; aVertexColor.blue = aVertexColor.b; aVertexColor.alpha = aVertexColor.a; aVertex = trackInfoAssetBox->createVertex(0.0, 0.0, 0.0, 0.0, 0.0, aVertexColor); trackInfoAssetBox->addVertexToChain(this->vertexChainId, aVertex); break; case 2: aVertexColor.r = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomRightRed); aVertexColor.g = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomRightGreen); aVertexColor.b = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomRightBlue); aVertexColor.a = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorBottomRightAlpha); aVertexColor.red = aVertexColor.r; aVertexColor.green = aVertexColor.g; aVertexColor.blue = aVertexColor.b; aVertexColor.alpha = aVertexColor.a; aVertex = trackInfoAssetBox->createVertex(1.0, 0.0, 0.0, 1.0, 0.0, aVertexColor); trackInfoAssetBox->addVertexToChain(this->vertexChainId, aVertex); break; case 3: aVertexColor.r = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopRightRed); aVertexColor.g = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopRightGreen); aVertexColor.b = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopRightBlue); aVertexColor.a = VisualPreferences::getValue(VisualPreferences::kTrackInfoTextureColorTopRightAlpha); aVertexColor.red = aVertexColor.r; aVertexColor.green = aVertexColor.g; aVertexColor.blue = aVertexColor.b; aVertexColor.alpha = aVertexColor.a; aVertex = trackInfoAssetBox->createVertex(1.0, 1.0, 0.0, 1.0, 1.0, aVertexColor); trackInfoAssetBox->addVertexToChain(this->vertexChainId, aVertex); break; default: writeLog("ERR: switch case unknown"); } } char trackLayoutPos[128]; sprintf(trackLayoutPos, "top: %f, left: %f, bottom: %f, right: %f", trackInfoAssetBox->getTopCoord(), trackInfoAssetBox->getLeftCoord(), trackInfoAssetBox->getBottomCoord(), trackInfoAssetBox->getRightCoord()); setProcessInfo("TrackLayout", trackLayoutPos); }