Beispiel #1
0
// Write AxisBlock keywords
bool UChromaSession::writeAxisBlock(LineParser& parser, Axes& axes, int axis)
{
	parser.writeLineF("    %s %i\n", UChromaSession::viewPaneKeyword(UChromaSession::AxisBlockKeyword), axis);
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::AutoScaleKeyword), Axes::autoScaleMethod(axes.autoScale(axis)));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::AutoTicksKeyword), stringBool(axes.autoTicks(axis)));
	parser.writeLineF("      %s %f\n", UChromaSession::axisKeyword(UChromaSession::FirstTickKeyword), axes.tickFirst(axis));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::FractionalPositioningKeyword), stringBool(axes.positionIsFractional(axis)));
	parser.writeLineF("      %s %s %s %s\n", UChromaSession::axisKeyword(UChromaSession::GridLinesKeyword), stringBool(axes.gridLinesMajor(axis)), stringBool(axes.gridLinesMinor(axis)), stringBool(axes.gridLinesFull(axis)));
	LineStyle style = axes.gridLineMajorStyle(axis);
	parser.writeLineF("      %s %f '%s' %f %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::GridLineMajorStyleKeyword), style.width(), LineStipple::stipple[style.stipple()].name, style.colour().redF(), style.colour().greenF(), style.colour().blueF(), style.colour().alphaF());
	style = axes.gridLineMinorStyle(axis);
	parser.writeLineF("      %s %f '%s' %f %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::GridLineMinorStyleKeyword), style.width(), LineStipple::stipple[style.stipple()].name, style.colour().redF(), style.colour().greenF(), style.colour().blueF(), style.colour().alphaF());
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::InvertKeyword), stringBool(axes.inverted(axis)));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::LabelAnchorKeyword), TextPrimitive::textAnchor(axes.labelAnchor(axis)));
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::LabelOrientationKeyword), axes.labelOrientation(axis).x, axes.labelOrientation(axis).y, axes.labelOrientation(axis).z);
	parser.writeLineF("      %s %f %f\n", UChromaSession::axisKeyword(UChromaSession::LimitsKeyword), axes.min(axis), axes.max(axis));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::LogarithmicKeyword), stringBool(axes.logarithmic(axis)));
	parser.writeLineF("      %s %i\n", UChromaSession::axisKeyword(UChromaSession::MinorTicksKeyword), axes.minorTicks(axis));
	NumberFormat fmt = axes.numberFormat(axis);
	parser.writeLineF("      %s '%s' %i %s %s\n", UChromaSession::axisKeyword(UChromaSession::NumberFormatKeyword), NumberFormat::formatType(fmt.type()), fmt.nDecimals(), stringBool(fmt.useUpperCaseExponent()), stringBool(fmt.forcePrecedingPlus()));
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::PositionFractionalKeyword), axes.positionFractional(axis).x, axes.positionFractional(axis).y, axes.positionFractional(axis).z);
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::PositionRealKeyword), axes.positionReal(axis).x, axes.positionReal(axis).y, axes.positionReal(axis).z);
	parser.writeLineF("      %s %f\n", UChromaSession::axisKeyword(UChromaSession::StretchKeyword), axes.stretch(axis));
	parser.writeLineF("      %s %f\n", UChromaSession::axisKeyword(UChromaSession::TickDeltaKeyword), axes.tickDelta(axis));
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::TickDirectionKeyword), axes.tickDirection(axis).x, axes.tickDirection(axis).y, axes.tickDirection(axis).z);
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::TitleAnchorKeyword), TextPrimitive::textAnchor(axes.titleAnchor(axis)));
	parser.writeLine(QString("      ")+UChromaSession::axisKeyword(UChromaSession::TitleKeyword)+" '"+axes.title(axis)+"'\n");
	parser.writeLineF("      %s %f %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::TitleOrientationKeyword), axes.titleOrientation(axis).x, axes.titleOrientation(axis).y, axes.titleOrientation(axis).z, axes.titleOrientation(axis).w);
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::VisibleAxisKeyword), stringBool(axes.visible(axis)));
	parser.writeLineF("    %s\n", UChromaSession::axisKeyword(UChromaSession::EndAxisKeyword));

	return true;
}
Beispiel #2
0
void GCodeLibrary::parseAxes(const js::Arguments &args, Axes &axes,
                             bool incremental) {
  for (const char *axis ="xyzabcuvw"; *axis; axis++) {
    string name = string(1, *axis);
    if (args.has(name)) axes.set(*axis, args.getNumber(name) +
                                 (incremental ? axes.get(*axis) : 0));
  }
}
Beispiel #3
0
// Update and send primitive
void TargetPrimitive::updateAndSendPrimitive(const Axes& axes, bool forceUpdate, bool pushAndPop, const QOpenGLContext* context)
{
	// Check collection validity
	if (!Collection::objectValid(collection_, "collection in TargetPrimitive::updateAndSendPrimitive")) return;

	// Check whether the primitive for this collection needs updating
	bool upToDate = true;
	if (forceUpdate) upToDate = false;
	else if (primitiveAxesUsedAt_ != axes.displayVersion()) upToDate = false;
	else if (primitiveColourUsedAt_ != collection_->colourVersion()) upToDate = false;
	else if (primitiveDataUsedAt_ != collection_->dataVersion()) upToDate = false;
	else if (primitiveStyleUsedAt_ != collection_->displayStyleVersion()) upToDate = false;

	// If the primitive is out of date, recreate it's data.
	if (!upToDate)
	{
		// Recreate primitive depending on current style
		switch (collection_->displayStyle())
		{
			case (Collection::LineXYStyle):
				Surface::constructLineXY(primitive_, axes, collection_->displayAbscissa(), collection_->displayData(), collection_->colourScale());
				break;
			case (Collection::LineZYStyle):
				Surface::constructLineZY(primitive_, axes, collection_->displayAbscissa(), collection_->displayData(), collection_->colourScale());
				break;
			case (Collection::GridStyle):
				Surface::constructGrid(primitive_, axes, collection_->displayAbscissa(), collection_->displayData(), collection_->colourScale());
				break;
			case (Collection::SurfaceStyle):
			case (Collection::UnlitSurfaceStyle):
				Surface::constructFull(primitive_, axes, collection_->displayAbscissa(), collection_->displayData(), collection_->colourScale());
				break;
			default:
				printf("Internal Error: Display style %i not accounted for in TargetPrimitive::updateAndSendPrimitive().\n", collection_->displayStyle());
				break;
		}

		// Pop old primitive instance (unless flagged not to)
		if ((!pushAndPop) && (primitive_.nInstances() != 0)) primitive_.popInstance(context);
	
		// Push a new instance to create the new display list / vertex array
		primitive_.pushInstance(context);
	}

	// Send primitive
	sendToGL();

	// Pop current instance (if flagged)
	if (pushAndPop) primitive_.popInstance(context);

	// Store version points for the up-to-date primitive
	primitiveAxesUsedAt_ = axes.displayVersion();
	primitiveColourUsedAt_ = collection_->colourVersion();
	primitiveDataUsedAt_ = collection_->dataVersion();
	primitiveStyleUsedAt_ = collection_->displayStyleVersion();

	return;
}
Beispiel #4
0
Move::Move(MoveType type, const Axes &start, const Axes &end, real startTime,
           unsigned tool, real feed, real speed, unsigned line) :
  Segment3R(start.getXYZ(), end.getXYZ()), type(type),
  start(start), end(end), tool(tool), feed(feed), speed(speed), line(line),
  dist(start.distance(end)), time(feed ? dist / feed * 60 : 0),
  startTime(startTime) {

  // TODO fix rapid feed time

  if (type != MoveType::MOVE_RAPID && !feed)
    THROW("Cutting move with zero feed");
}
Beispiel #5
0
Move::Move(MoveType type, const Axes &start, const Axes &end, real startTime,
           unsigned tool, real feed, real speed, unsigned line) :
  Segment3R(start.getXYZ(), end.getXYZ()), type(type),
  start(start), end(end), tool(tool), feed(feed), speed(speed), line(line),
  dist(start.distance(end)), time(dist / feed * 60), startTime(startTime) {

  if (!feed) {
    time = 0;

    static bool warned = false;
    if (!warned) {
      LOG_WARNING("Zero feed");
      warned = true;
    }
  }
}
Beispiel #6
0
// Construct full surface representation of data
void Surface::constructFull(PrimitiveList& primitiveList, const Axes& axes, const Array<double>& displayAbscissa, List<DisplayDataSet>& displayData, ColourScale colourScale)
{
	// Forget all data in current primitives
	primitiveList.forgetAll();

	// Get extents of displayData to use based on current axes limits
	Vec3<int> minIndex, maxIndex;
	if (!calculateExtents(axes, displayAbscissa, displayData, minIndex, maxIndex)) return;
	int nZ = (maxIndex.z - minIndex.z) + 1;

	// Copy and transform abscissa values (still in data space) into axes coordinates
	Array<double> x(displayAbscissa, minIndex.x, maxIndex.x);
	axes.transformX(x);
	int nX = x.nItems();

	// Check for specific actions when we have a low number of display datasets
	if (nZ == 1)
	{
		// Special case, if there is exactly one dataset, draw a standard XY line surface instead
		constructLineXY(primitiveList, axes, displayAbscissa, displayData, colourScale);
		return;
	}
	if (nX == 1)
	{
		// Special case, if there is exactly one dataset, draw a standard XY line surface instead
		constructLineZY(primitiveList, axes, displayAbscissa, displayData, colourScale);
		return;
	}

	// Resize primitive list so it's large enough for our needs
	primitiveList.reinitialise(nZ-1, false, GL_TRIANGLES, true);

	// Temporary variables
	Array< Vec3<double> > normA, normB;
	Array<double> yA, yB, yC;
	Array<DisplayDataSet::DataPointType> typeA, typeB, typeC;
	Array< Vec4<GLfloat> > colourA, colourB;
	QColor colour;
	double zA, zB, zC;
	Vec3<double> nrm(0.0, 1.0, 0.0);

	// Construct first slice data and set initial min/max values
	yA.copy(displayData[minIndex.z]->y(), minIndex.x, maxIndex.x);
	typeA.copy(displayData[minIndex.z]->yType(), minIndex.x, maxIndex.x);
	axes.transformY(yA, typeA);
	zA = axes.transformZ(displayData[minIndex.z]->z());
	if ((minIndex.z+1) <= maxIndex.z)	// Safety check - this should always be true because of the checks above
	{
		yB.copy(displayData[minIndex.z+1]->y(), minIndex.x, maxIndex.x);
		typeB.copy(displayData[minIndex.z+1]->yType(), minIndex.x, maxIndex.x);
		axes.transformY(yB, typeB);
		zB = axes.transformZ(displayData[minIndex.z+1]->z());
	}
	constructSurfaceStrip(x, yA, zA, axes, normA, colourA, colourScale, yC, 0.0, yB, zB);

	// Create triangles in strips between the previous and target Y/Z values
	int nBit, nPlusOneBit, totalBit;
	int vertexAn = -1, vertexBn = -1, vertexAnPlusOne = -1, vertexBnPlusOne = -1;
	Primitive* currentPrimitive = primitiveList[0];
	for (int index = minIndex.z+1; index <=maxIndex.z; ++index)
	{
		// Grab next data (if we are not at the end of the index range)
		if (index < maxIndex.z)
		{
			yC.copy(displayData[index+1]->y(), minIndex.x, maxIndex.x);
			typeC.copy(displayData[index+1]->yType(), minIndex.x, maxIndex.x);
			axes.transformY(yC, typeC);
			zC = axes.transformZ(displayData[index+1]->z());
		}
		else yC.clear();

		// Construct data for current slice
		constructSurfaceStrip(x, yB, zB, axes, normB, colourB, colourScale, yA, zA, yC, zC);

		// Use a simple bit to quickly determine which triangles to draw, given possible lack of datapoints in slices
		//
		//			n	n+1	n	n+1
		//	Slice A		4-------1	4-------1	0 = Both	5 = None
		//			| ....TR|	|TL.... |	1 = BL		6 = None
		//			|   ....|	|....   |	2 = TL		7 = None
		//			|BL   ..|	|..   BR|	3 = None	8 = TR
		//	Slice B		8-------2	8-------2	4 = BR		9+= None

		// Set initial bit, and generate initial vertices
		nBit = 0;
		if (typeA.value(0) == DisplayDataSet::NoPoint)
		{
			nBit += 4;
			vertexAn = -1;
		}
		else vertexAn = currentPrimitive->defineVertex(x.value(0), yA.value(0), zA, normA[0], colourA[0]);
		if (typeB.value(0) == DisplayDataSet::NoPoint)
		{
			nBit += 8;
			vertexBn = -1;
		}
		else vertexBn = currentPrimitive->defineVertex(x.value(0), yB.value(0), zB, normB[0], colourB[0]);

		for (int n=0; n<nX-1; ++n)
		{
			// Construct bit for n+1
			nPlusOneBit = 0;
			if (typeA.value(n+1) == DisplayDataSet::NoPoint) nPlusOneBit += 1;
			if (typeB.value(n+1) == DisplayDataSet::NoPoint) nPlusOneBit += 2;
			totalBit = nBit + nPlusOneBit;

			// Reset indices for current (n+1) column
			vertexAnPlusOne = -1;
			vertexBnPlusOne = -1;

			// Add triangles for this quadrant
			if (totalBit == 0)
			{
				// Draw both
				if (vertexAn == -1) vertexAn = currentPrimitive->defineVertex(x.value(n), yA.value(n), zA, normA[n], colourA[n]);
				if (vertexBn == -1) vertexBn = currentPrimitive->defineVertex(x.value(n), yB.value(n), zB, normB[n], colourB[n]);
				vertexAnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yA.value(n+1), zA, normA[n+1], colourA[n+1]);
				vertexBnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yB.value(n+1), zB, normB[n+1], colourB[n+1]);
				currentPrimitive->defineIndices(vertexAn, vertexAnPlusOne, vertexBnPlusOne);
				currentPrimitive->defineIndices(vertexAn, vertexBn, vertexBnPlusOne);
			}
			else if (totalBit == 1)
			{
				// Bottom left corner only
				if (vertexAn == -1) vertexAn = currentPrimitive->defineVertex(x.value(n), yA.value(n), zA, normA[n], colourA[n]);
				if (vertexBn == -1) vertexBn = currentPrimitive->defineVertex(x.value(n), yB.value(n), zB, normB[n], colourB[n]);
				vertexBnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yB.value(n+1), zB, normB[n+1], colourB[n+1]);
				currentPrimitive->defineIndices(vertexAn, vertexBnPlusOne, vertexBn);
			}
			else if (totalBit == 2)
			{
				// Top left corner only
				if (vertexAn == -1) vertexAn = currentPrimitive->defineVertex(x.value(n), yA.value(n), zA, normA[n], colourA[n]);
				if (vertexBn == -1) vertexBn = currentPrimitive->defineVertex(x.value(n), yB.value(n), zB, normB[n], colourB[n]);
				vertexAnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yA.value(n+1), zA, normA[n+1], colourA[n]);
				currentPrimitive->defineIndices(vertexAn, vertexAnPlusOne, vertexBn);
			}
			else if (totalBit == 4)
			{
				// Bottom right corner only
				if (vertexBn == -1) vertexBn = currentPrimitive->defineVertex(x.value(n), yB.value(n), zB, normB[n], colourB[n]);
				vertexAnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yA.value(n+1), zA, normA[n+1], colourA[n+1]);
				vertexBnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yB.value(n+1), zB, normB[n+1], colourB[n+1]);
				currentPrimitive->defineIndices(vertexAnPlusOne, vertexBnPlusOne, vertexBn);
			}
			else if (totalBit == 8)
			{
				// Top right corner only
				if (vertexAn == -1) vertexAn = currentPrimitive->defineVertex(x.value(n), yA.value(n), zA, normA[n], colourA[n]);
				vertexAnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yA.value(n+1), zA, normA[n+1], colourA[n+1]);
				vertexBnPlusOne = currentPrimitive->defineVertex(x.value(n+1), yB.value(n+1), zB, normB[n+1], colourB[n+1]);
				currentPrimitive->defineIndices(vertexAn, vertexAnPlusOne, vertexBnPlusOne);
			}

			// Store new nBit for next index
			nBit = nPlusOneBit*4;
			vertexAn = vertexAnPlusOne;
			vertexBn = vertexBnPlusOne;
		}

		// Shuffle data backwards...
		yA = yB;
		zA = zB;
		typeA = typeB;
		normA = normB;
		colourA = colourB;
		yB = yC;
		zB = zC;
		typeB = typeC;
		
		// Increment primitive pointer
		currentPrimitive = currentPrimitive->next;
	}
}
Beispiel #7
0
// Construct grid surface representation of data
void Surface::constructGrid(PrimitiveList& primitiveList, const Axes& axes, const Array<double>& displayAbscissa, List<DisplayDataSet>& displayData, ColourScale colourScale)
{
    // Forget all data in current primitives
    primitiveList.forgetAll();

    // Get extents of displayData to use based on current axes limits
    Vec3<int> minIndex, maxIndex;
    if (!calculateExtents(axes, displayAbscissa, displayData, minIndex, maxIndex)) return;
    int nZ = (maxIndex.z - minIndex.z) + 1;

    // Copy and transform abscissa values (still in data space) into axes coordinates
    Array<double> x(displayAbscissa, minIndex.x, maxIndex.x);
    axes.transformX(x);
    int nX = x.nItems();
    if (nX < 2) return;

    // Decide how large to make VertexChunks in Primitives
    // We will consider multiple slices at once in order to take most advantage of the post-transform cache
    // forming (abscissa.nItems()/(cacheSize-1)+1) Primitives (we divide by (cacheSize-1) because we will force an overlap
    // of one gridpoint between adjacent strips).
    const int cacheSize = 12;
    int nPrimitives = x.nItems()/(cacheSize-1) + 1;

    // Get some values from axes so we can calculate colours properly
    bool yLogarithmic = axes.logarithmic(1);
    double yStretch = axes.stretch(1);

    // Reinitialise primitive list
    primitiveList.reinitialise(nPrimitives, true, GL_LINES, true);

    // Temporary variables
    int n, offset = 0, i, nLimit, nMax;
    Vec4<GLfloat> colour;
    Vec3<double> nrm(0.0, 1.0, 0.0);
    Array<double> y;
    Array<DisplayDataSet::DataPointType> yType;

    DisplayDataSet** slices = displayData.array();
    Primitive* currentPrimitive = primitiveList[0];
    int verticesA[cacheSize], verticesB[cacheSize];
    double z;

    // Loop over abscissa indices
    while (offset <= x.nItems())
    {
        // Set nLimit to ensure we don't go beyond the end of the data arrays
        nLimit = std::min(cacheSize, x.nItems()-offset);

        // Loop over remaining displayData
        for (int slice = minIndex.z; slice <= maxIndex.z; ++slice)
        {
            // Grab arrays
            y.copy(slices[slice]->y(), minIndex.x+offset, minIndex.x+offset+nLimit-1);
            yType.copy(slices[slice]->yType(), minIndex.x+offset, minIndex.x+offset+nLimit-1);
            axes.transformY(y, yType);
            z = axes.transformZ(slices[slice]->z());

            // Generate vertices for this row
            for (n=0; n<nLimit; ++n)
            {
                i = offset+n;
                if (yType.value(n) != DisplayDataSet::NoPoint)
                {
                    // A value exists here, so define a vertex
                    colourScale.colour(yLogarithmic ? pow(10.0, y.value(n) / yStretch) : y.value(n) / yStretch, colour);
                    verticesB[n] = currentPrimitive->defineVertex(x.value(i), y.value(n), z, nrm, colour);

                    // If the previous vertex on this row also exists, draw a line here
                    if ((n != 0) && (verticesB[n-1] != -1)) currentPrimitive->defineIndices(verticesB[n-1], verticesB[n]);
                }
                else verticesB[n] = -1;
            }

            // Draw lines across slices (if slice != 0)
            if (slice != 0)
            {
                nMax = (maxIndex.z-slice) > 1 ? nLimit-1 : nLimit;
                for (n=0; n<nMax; ++n)
                {
                    if ((verticesA[n] != -1) && (verticesB[n] != -1)) currentPrimitive->defineIndices(verticesA[n], verticesB[n]);
                }
            }

            // Store current vertices for next pass
            for (n=0; n<cacheSize; ++n) verticesA[n] = verticesB[n];
        }

        // Move to next primitive and increase offset
        currentPrimitive = currentPrimitive->next;
        offset += cacheSize-1;
    }
}
void ColoredCubeApp::initApp()
{

    D3DApp::initApp();
    //input->initialize(getMainWnd(), false);
    //audio->initialize();

    float boxScale = 0.5f;
    float collisionFixFactor = 1.1f;
    currentBullet = 0;
    explosionTimer = 0;
    explosionRunning = false;
    shotRelease = true;

    // increments when you run into a cube // just for now
    score = 0;
    mAxes.init(md3dDevice, 1.0f);
    mEnemy.init(md3dDevice, .5f, RED);
    mPlayer.init(md3dDevice, .5f, BLUE);
    mBullet.init(md3dDevice, .25f, D3DXCOLOR(0.0f, 1.0f, 0.0f, 0.0f));
    particleBox.init(md3dDevice, .01f, GREEN);
    particleBox2.init(md3dDevice, .04f, RED);
    starBox.init(md3dDevice, 0.05f, WHITE);
    //mBox.init(md3dDevice, boxScale);
    mLine.init(md3dDevice, 1.0f);
    //mTriangle.init(md3dDevice, 1.0f);
    //mQuad.init(md3dDevice, 10.0f);
    mQuad.init(md3dDevice, 0.0f);

    gameObject1.init(&mPlayer, sqrt(2.0f), Vector3(6,.5,0), Vector3(0,0,0), 5.0f,1.0f);
    //gameObject1.init(&mBox, sqrt(2.0f), Vector3(6,.5,0), Vector3(0,0,0), 5000.0f,1.0f);
    gameObject1.setRadius(gameObject1.getRadius()*boxScale*collisionFixFactor);

    int step = 2;
    for (int i = 0; i < MAX_NUM_ENEMIES; i++)
    {
        enemyObjects[i].init(&mEnemy, sqrt(2.0), Vector3(-5,.5,step*i - 3.8), Vector3(1,0,0), 8.0f, 1);
        //enemyObjects[i].init(&mBox, sqrt(2.0), Vector3(-5,.5,step*i - 3.8), Vector3(1,0,0), 3000.0f, 1);
        enemyObjects[i].setRadius(enemyObjects[i].getRadius()*boxScale * collisionFixFactor);
        enemyObjects[i].setInActive();
    }

    for (int i = 0; i < MAX_NUM_BULLETS; i++)
    {
        playerBullets[i].init(&mBullet, 0.5f, Vector3(0,0,0), Vector3(-12,0,0), 0.0f, 1);
        playerBullets[i].setInActive();
    }

    for (int i = 0; i < MAX_NUM_EXP_PARTICLES; i++)
    {

        if(i%5 == 0)particles[i].init(&particleBox2, 0.5f, Vector3(0,0,0), Vector3(0,0,0), 7000.0f, 1);
        else particles[i].init(&particleBox, 0.5f, Vector3(0,0,0), Vector3(0,0,0), 7000.0f, 1);
        particles[i].setInActive();
    }

    for (int i = 0; i < MAX_NUM_STARS; i++)
    {
        stars[i].init(&starBox, 0.5f, Vector3(0,0,0), Vector3(0,0,0), 7000.0f, 1);
        stars[i].setActive();
    }

    buildFX();
    buildVertexLayouts();

    audio = new Audio();

    if (*WAVE_BANK != '\0' && *SOUND_BANK != '\0')  // if sound files defined
    {
        if (!audio->initialize()) {

        }

        /*if( FAILED( hr = audio->initialize() ) )
        {
        if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) )
        throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system because media file not found."));
        else
        throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system."));
        }*/
    }

    enemyBuffer.resetClock();
    shotBuffer.resetClock();
    gameTimer.resetClock();


    D3DXVECTOR3 pos(10.0f, 2.0f, 0.0f);
    D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
    D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);

    //Camera Object
    camera.init(pos, Vector3(0,0,0), Vector3(0,0,0));
    camera.setPerspective();
    // camera
    cameraPos = pos;

    audio->playCue(BKG);

    //Places stars in scene
    placeStars();
}