private void initializeView() { // create scene thread view = new LocalizerView(windowRedrawFreqMax, windowLeft, windowTop, windowWidth, windowHeight, false); view.setBackgroundColor(windowBackgroundColor.getRed(), windowBackgroundColor.getGreen(), windowBackgroundColor.getBlue()); // start the scene thread view.start(); }
public iParam clone() { ParamColor clone = new ParamColor(name, group, parentSet, desc, stdValue, options); clone.stdValue = stdValue; clone.minValue = minValue; clone.maxValue = maxValue; clone.value = new RGBColorFloat(value.getRed(), value.getGreen(), value.getBlue()); return(clone); }
protected override void render() { // load textures (if needed; done here because it should be from this thread/context) if (doLoadTextures > 0) { loadTextures(); } // check if fixation should be shown if (showFixation) { // set the fixation to white glColor3(1f, 1f, 1f); // set the text count int fixationTextWidth = fixationFont.getTextWidth("+"); fixationFont.printLine((int)((getContentWidth() - fixationTextWidth) / 2), (int)((getContentHeight() - fixationFont.height) / 2), "+"); } if (showCountDown >= 0) { // set the countdown to white glColor3(1f, 1f, 1f); // set the text count int countTextWidth = countdownFont.getTextWidth(showCountDown.ToString()); countdownFont.printLine((int)((getContentWidth() - countTextWidth) / 2), (int)((getContentHeight() - countdownFont.height) / 2), showCountDown.ToString()); } // draw the blocks if (showBlocks) { // set the blockcolor to white glColor3(1f, 1f, 1f); // loop through the blocks for (int i = 0; i < blocks.Count; ++i) { // skip block which are out of display if (blocks[i].x + blocks[i].width < 0) { continue; } if (blocks[i].x > getContentWidth()) { continue; } // bind the texture, also if it is 0 // (could use glEnable(GL_TEXTURE_2D) and glDisable(GL_TEXTURE_2D), but binding to zero for untextured block can be used as well) glBindTexture2D(blocks[i].texture); // draw the block glBeginTriangles(); // vertex 0 glTexCoord2(1.0f, 1.0f); glVertex3(blocks[i].x + blocks[i].width, blocks[i].y + blocks[i].height, 0.0f); glTexCoord2(1.0f, 0.0f); glVertex3(blocks[i].x + blocks[i].width, blocks[i].y, 0.0f); glTexCoord2(0.0f, 0.0f); glVertex3(blocks[i].x, blocks[i].y, 0.0f); //vertex 1 glTexCoord2(0.0f, 1.0f); glVertex3(blocks[i].x, blocks[i].y + blocks[i].height, 0.0f); glTexCoord2(1.0f, 1.0f); glVertex3(blocks[i].x + blocks[i].width, blocks[i].y + blocks[i].height, 0.0f); glTexCoord2(0.0f, 0.0f); glVertex3(blocks[i].x, blocks[i].y, 0.0f); glEnd(); } } // draw the cursor if (showCursor) { // set the cursor color, no texture if (cursorColorSetting == 2) // manual escape { glColor3(cursorEscapeColor.getRed(), cursorEscapeColor.getGreen(), cursorEscapeColor.getBlue()); } else if ((cursorColorSetting == 1) || (cursorColorSetting == 3 && cursorInCurrentBlock)) // manual hit or automatic { glColor3(cursorHitColor.getRed(), cursorHitColor.getGreen(), cursorHitColor.getBlue()); } else // other (manual miss) { glColor3(cursorMissColor.getRed(), cursorMissColor.getGreen(), cursorMissColor.getBlue()); } glBindTexture2D(0); // cursor polygon glBeginPolygon(); for (double i = 0; i < 2 * Math.PI; i += Math.PI / 24) { glVertex3(Math.Cos(i) * cursorRadius + cursorX, Math.Sin(i) * cursorRadius + cursorY, 0.0); } glEnd(); } // write the score text if (score > -1) { glColor3(1f, 1f, 1f); scoreFont.printLine(getContentWidth() - scoreFont.height * 9, 5, ("Score: " + score)); } // check if text should be shown if (showText.Length != 0) { // set the text to white glColor3(1f, 1f, 1f); // print the text textFont.printLine((getContentWidth() - showTextWidth) / 2, getContentHeight() / 2, showText); } // check if there is no signal if (showConnectionLost) { // set white color for drawing glColor3(1f, 1f, 1f); // print text int textWidth = textFont.getTextWidth("Lost connection with device"); textFont.printLine((int)((getContentWidth() - textWidth) / 2), (int)((getContentHeight()) / 4), "Lost connection with device"); // set texture glBindTexture2D(connectionLostTexture); // draw texture glBeginTriangles(); // vertex 0 glTexCoord2(0.0f, 0.0f); glVertex3((getContentWidth() - 200) / 2, (getContentHeight() - 200) / 2, 0.0f); glTexCoord2(1.0f, 0.0f); glVertex3((getContentWidth() - 200) / 2 + 200, (getContentHeight() - 200) / 2, 0.0f); glTexCoord2(1.0f, 1.0f); glVertex3((getContentWidth() - 200) / 2 + 200, (getContentHeight() - 200) / 2 + 200, 0.0f); //vertex 1 glTexCoord2(0.0f, 0.0f); glVertex3((getContentWidth() - 200) / 2, (getContentHeight() - 200) / 2, 0.0f); glTexCoord2(1.0f, 1.0f); glVertex3((getContentWidth() - 200) / 2 + 200, (getContentHeight() - 200) / 2 + 200, 0.0f); glTexCoord2(0.0f, 1.0f); glVertex3((getContentWidth() - 200) / 2, (getContentHeight() - 200) / 2 + 200, 0.0f); glEnd(); } }
public void setTargetMissColor(RGBColorFloat color) { targetMissColorR = color.getRed(); targetMissColorG = color.getGreen(); targetMissColorB = color.getBlue(); }
public void setCursorMissColor(RGBColorFloat color) { cursorMissColorR = color.getRed(); cursorMissColorG = color.getGreen(); cursorMissColorB = color.getBlue(); }
public void initBlockSequence(List <int> inTargetSequence, List <List <float> > inTargets) { // wait until the textures are loaded before continuing while (doLoadTextures > 0) { Thread.Sleep(50); } // lock for textures events (thread safety) lock (textureLock) { // int i = 0; // clear all block sequence information for (i = 0; i < blocks.Count; ++i) { blocks[i].texture = 0; } blocks.Clear(); // set the block variables nothing currentBlock = noBlock; cursorInCurrentBlock = false; // loop through the targets in the sequence float startX = 0; for (i = 0; i < inTargetSequence.Count; ++i) { // calculate the block height and y position (based on percentages) float height = getContentHeight() * (inTargets[1][inTargetSequence[i]] / 100.0f); float y = getContentHeight() * (inTargets[0][inTargetSequence[i]] / 100.0f) - height / 2.0f; // calculate the block width (based on sec) float widthSec = inTargets[2][inTargetSequence[i]]; float widthPixels = (float)getContentWidth() / ((float)getContentWidth() / blockSpeed) * widthSec; // set the start position startX -= widthPixels; // create the color (decomposes the 24-bit integer into seperate RGB components RGBColorFloat color = new RGBColorFloat((int)inTargets[3][inTargetSequence[i]]); // create a block object MultiClicksBlock block = new MultiClicksBlock(startX, y, widthPixels, height, color.getRed(), color.getGreen(), color.getBlue()); // set the block texture (initialized to 0 = no texture) if (inTargetSequence[i] < (int)blockTextures.Count) { block.texture = blockTextures[inTargetSequence[i]]; } // add block for display blocks.Add(block); } } }