Beispiel #1
0
void Flasher::UpdateMesh()
{
   const float height = (m_d.m_height + m_ptable->m_tableheight)*m_ptable->m_BG_scalez[m_ptable->m_BG_current_set];
   const float movx = minx + (maxx - minx)*0.5f;
   const float movy = miny + (maxy - miny)*0.5f;

   Matrix3D tempMatrix, TMatrix;
   TMatrix.RotateZMatrix(ANGTORAD(m_d.m_rotZ));
   tempMatrix.RotateYMatrix(ANGTORAD(m_d.m_rotY));
   tempMatrix.Multiply(TMatrix, TMatrix);
   tempMatrix.RotateXMatrix(ANGTORAD(m_d.m_rotX));
   tempMatrix.Multiply(TMatrix, TMatrix);

   tempMatrix.SetTranslation(m_d.m_vCenter.x,m_d.m_vCenter.y,height);
   tempMatrix.Multiply(TMatrix, tempMatrix);

   TMatrix.SetTranslation(
       -movx, //-m_d.m_vCenter.x,
       -movy, //-m_d.m_vCenter.y,
       0.f);
   tempMatrix.Multiply(TMatrix, tempMatrix);

   Vertex3D_TexelOnly *buf;
   dynamicVertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::DISCARDCONTENTS);

   for (unsigned int i = 0; i < numVertices; i++)
   {
      Vertex3D_TexelOnly vert = vertices[i];
      tempMatrix.MultiplyVector(vert, vert);
      buf[i] = vert;
   }

   dynamicVertexBuffer->unlock();
}
Beispiel #2
0
void Spinner::GetHitShapes(vector<HitObject*> &pvho)
{
   const float height = m_ptable->GetSurfaceHeight(m_d.m_szSurface, m_d.m_vCenter.x, m_d.m_vCenter.y);
   const float h = m_d.m_height + 30.0f;

   const float angleMin = min(m_d.m_angleMin, m_d.m_angleMax); // correct angle inversions
   const float angleMax = max(m_d.m_angleMin, m_d.m_angleMax);

   m_d.m_angleMin = angleMin;
   m_d.m_angleMax = angleMax;

   HitSpinner * const phitspinner = new HitSpinner(this, height);
   m_phitspinner = phitspinner;

   pvho.push_back(phitspinner);

   if (m_d.m_fShowBracket)
   {
      /*add a hit shape for the bracket if shown, just in case if the bracket spinner height is low enough so the ball can hit it*/
      const float halflength = m_d.m_length * 0.5f + (m_d.m_length*0.1875f);
      const float radangle = ANGTORAD(m_d.m_rotation);
      const float sn = sinf(radangle);
      const float cs = cosf(radangle);

      HitCircle *phitcircle;
      phitcircle = new HitCircle(Vertex2D(m_d.m_vCenter.x + cs*halflength, m_d.m_vCenter.y + sn*halflength), m_d.m_length*0.075f, height + m_d.m_height, height + h);
      pvho.push_back(phitcircle);

      phitcircle = new HitCircle(Vertex2D(m_d.m_vCenter.x - cs*halflength, m_d.m_vCenter.y - sn*halflength), m_d.m_length*0.075f, height + m_d.m_height, height + h);
      pvho.push_back(phitcircle);
   }
}
Beispiel #3
0
STDMETHODIMP Spinner::put_AngleMax(float newVal)
{
   if (g_pplayer)
   {
      if (m_d.m_angleMin != m_d.m_angleMax)	// allow only if in limited angle mode
      {
         if (newVal > m_d.m_angleMax) newVal = m_d.m_angleMax;
         else if (newVal < m_d.m_angleMin) newVal = m_d.m_angleMin;

         newVal = ANGTORAD(newVal);

         if (m_phitspinner->m_spinnerMover.m_angleMin < newVal)  // Min is smaller???
            m_phitspinner->m_spinnerMover.m_angleMax = newVal;   //yes set new max
         else m_phitspinner->m_spinnerMover.m_angleMin = newVal; //no set new minumum
      }
      else return S_FAIL;
   }
   else
   {
      STARTUNDO
         m_d.m_angleMax = newVal;
      STOPUNDO
   }

   return S_OK;
}
Beispiel #4
0
STDMETHODIMP Spinner::put_AngleMin(float newVal)
{
   if (g_pplayer)
   {
      if (m_d.m_angleMin != m_d.m_angleMax)	// allow only if in limited angle mode
      {
         if (newVal > m_d.m_angleMax) newVal = m_d.m_angleMax;
         else if (newVal < m_d.m_angleMin) newVal = m_d.m_angleMin;

         newVal = ANGTORAD(newVal);

         if (m_phitspinner->m_spinnerMover.m_angleMax > newVal)  // max is bigger
            m_phitspinner->m_spinnerMover.m_angleMin = newVal;   //then set new minumum
         else m_phitspinner->m_spinnerMover.m_angleMax = newVal; //else set new max
      }
      else return S_FAIL;
   }
   else
   {
      STARTUNDO
         m_d.m_angleMin = newVal;
      STOPUNDO
   }
   return S_OK;
}
Beispiel #5
0
void Bumper::Render(Sur * const psur)
{
   psur->SetBorderColor(RGB(0, 0, 0), false, 0);
   psur->SetFillColor(-1);
   psur->SetObject(this);
   psur->SetObject(NULL);
   const float radangle = ANGTORAD(m_d.m_orientation - 90.f);
   const float sn = sinf(radangle);
   const float cs = cosf(radangle);

   const float x1 = m_d.m_vCenter.x - cs*(m_d.m_radius + 10.f);
   const float y1 = m_d.m_vCenter.y - sn*(m_d.m_radius + 10.f);
   const float x2 = m_d.m_vCenter.x + cs*(m_d.m_radius + 10.f);
   const float y2 = m_d.m_vCenter.y + sn*(m_d.m_radius + 10.f);
   psur->Ellipse(x1, y1, 10.0f);
   psur->Ellipse(x2, y2, 10.0f);
   psur->Ellipse(m_d.m_vCenter.x, m_d.m_vCenter.y, m_d.m_radius*1.5f);
   psur->Ellipse(m_d.m_vCenter.x, m_d.m_vCenter.y, m_d.m_radius);

   if (g_pvp->m_fAlwaysDrawLightCenters)
   {
      psur->Line(m_d.m_vCenter.x - 10.0f, m_d.m_vCenter.y, m_d.m_vCenter.x + 10.0f, m_d.m_vCenter.y);
      psur->Line(m_d.m_vCenter.x, m_d.m_vCenter.y - 10.0f, m_d.m_vCenter.x, m_d.m_vCenter.y + 10.0f);
   }
}
Beispiel #6
0
void Bumper::PreRender(Sur * const psur)
{
   psur->SetBorderColor(-1, false, 0);

   psur->SetObject(this);
   const float radangle = ANGTORAD(m_d.m_orientation);
   const float sn = sinf(radangle);
   const float cs = cosf(radangle);

   const float x1 = m_d.m_vCenter.x - cs*(m_d.m_radius + 10.f);
   const float y1 = m_d.m_vCenter.y - sn*(m_d.m_radius + 10.f);
   const float x2 = m_d.m_vCenter.x + cs*(m_d.m_radius + 10.f);
   const float y2 = m_d.m_vCenter.y + sn*(m_d.m_radius + 10.f);
   psur->Ellipse(x1, y1, 10.0f);
   psur->Ellipse(x2, y2, 10.0f);

   if (m_ptable->m_renderSolid)
   {
      const Material * const mat = m_ptable->GetMaterial(m_d.m_szCapMaterial);
      psur->SetFillColor(mat->m_cBase);
   }
   else
      psur->SetFillColor(-1);

   psur->Ellipse(m_d.m_vCenter.x, m_d.m_vCenter.y, m_d.m_radius*1.5f);
   if (m_ptable->m_renderSolid)
   {
      const Material * const mat = m_ptable->GetMaterial(m_d.m_szBaseMaterial);
      psur->SetFillColor(mat->m_cBase);
   }
   else
      psur->SetFillColor(-1);

   psur->Ellipse(m_d.m_vCenter.x, m_d.m_vCenter.y, m_d.m_radius);
}
Beispiel #7
0
void ISelect::Rotate(float ang, Vertex2D *pvCenter)
{
   GetIEditable()->MarkForUndo();

   Vertex2D vCenter;
   GetCenter(&vCenter);

   const float sn = sinf(ANGTORAD(ang));
   const float cs = cosf(ANGTORAD(ang));

   const float dx = vCenter.x - pvCenter->x;
   const float dy = vCenter.y - pvCenter->y;

   vCenter.x = pvCenter->x + cs*dx - sn*dy;
   vCenter.y = pvCenter->y + cs*dy + sn*dx;
   PutCenter(&vCenter);
}
Beispiel #8
0
HitSpinner::HitSpinner(Spinner * const pspinner, const float height)
{
	m_spinneranim.m_pspinner = pspinner;

	const float halflength = pspinner->m_d.m_length * 0.5f;

	const float radangle = ANGTORAD(pspinner->m_d.m_rotation);
	const float sn = sinf(radangle);
	const float cs = cosf(radangle);

	m_lineseg[0].m_rcHitRect.zlow = height;
	m_lineseg[0].m_rcHitRect.zhigh = height + 50.0f;
	m_lineseg[1].m_rcHitRect.zlow = height;
	m_lineseg[1].m_rcHitRect.zhigh = height + 50.0f;

	m_lineseg[0].m_pfe = NULL;
	m_lineseg[1].m_pfe = NULL;

	m_lineseg[0].v2.x = pspinner->m_d.m_vCenter.x + cs*(halflength + (float)PHYS_SKIN); //oversize by the ball radius
	m_lineseg[0].v2.y = pspinner->m_d.m_vCenter.y + sn*(halflength + (float)PHYS_SKIN); //this will prevent clipping
	m_lineseg[0].v1.x = pspinner->m_d.m_vCenter.x - cs*(halflength + (float)PHYS_SKIN); //through the edge of the
	m_lineseg[0].v1.y = pspinner->m_d.m_vCenter.y - sn*(halflength + (float)PHYS_SKIN); //spinner

	m_lineseg[1].v1.x = m_lineseg[0].v2.x;
	m_lineseg[1].v1.y = m_lineseg[0].v2.y;
	m_lineseg[1].v2.x = m_lineseg[0].v1.x;
	m_lineseg[1].v2.y = m_lineseg[0].v1.y;

	m_lineseg[0].CalcNormal();
	m_lineseg[1].CalcNormal();

	m_spinneranim.m_angleMax = ANGTORAD(pspinner->m_d.m_angleMax);
	m_spinneranim.m_angleMin = ANGTORAD(pspinner->m_d.m_angleMin);

	m_spinneranim.m_angle = clamp(0.0f, m_spinneranim.m_angleMin, m_spinneranim.m_angleMax);
	m_spinneranim.m_anglespeed = 0;
    // compute proper damping factor for physics framerate
    m_spinneranim.m_damping = powf(pspinner->m_d.m_antifriction, (float)PHYS_FACTOR);

	m_spinneranim.m_elasticity = pspinner->m_d.m_elasticity;
	m_spinneranim.m_fVisible = pspinner->m_d.m_fVisible;	
}
Beispiel #9
0
STDMETHODIMP Flipper::RotateToStart() // return to park 
{
   if (m_phitflipper)
   {
      const float startAng =  ANGTORAD(m_d.m_StartAngle);		
      m_phitflipper->m_flipperanim.m_EnableRotateEvent = -1;
      m_phitflipper->m_flipperanim.SetSolenoidState(false);
   }

   return S_OK;
}
Beispiel #10
0
STDMETHODIMP Flipper::RotateToEnd() //power stroke to hit ball
{
   if (m_phitflipper)
   {
      const float endAng = ANGTORAD(m_d.m_EndAngle);
      m_phitflipper->m_flipperanim.m_EnableRotateEvent = 1;
      m_phitflipper->m_flipperanim.SetSolenoidState(true);
   }

   return S_OK;
}
Beispiel #11
0
void Spinner::RenderSetup()
{
   if (!m_d.m_fVisible)
      return;

   RenderDevice * const pd3dDevice = g_pplayer->m_pin3d.m_pd3dPrimaryDevice;

   const float height = m_ptable->GetSurfaceHeight(m_d.m_szSurface, m_d.m_vCenter.x, m_d.m_vCenter.y)*m_ptable->m_BG_scalez[m_ptable->m_BG_current_set];
   m_posZ = height + m_d.m_height;

   if (bracketIndexBuffer)
      bracketIndexBuffer->release();
   bracketIndexBuffer = pd3dDevice->CreateAndFillIndexBuffer(spinnerBracketNumFaces, spinnerBracketIndices);

   if (bracketVertexBuffer)
      bracketVertexBuffer->release();
   pd3dDevice->CreateVertexBuffer(spinnerBracketNumVertices, 0, MY_D3DFVF_NOTEX2_VERTEX, &bracketVertexBuffer);

   fullMatrix.RotateZMatrix(ANGTORAD(m_d.m_rotation));

   Vertex3D_NoTex2 *buf;
   bracketVertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::WRITEONLY);
   for (int i = 0; i < spinnerBracketNumVertices; i++)
   {
      Vertex3Ds vert(spinnerBracket[i].x, spinnerBracket[i].y, spinnerBracket[i].z);
      vert = fullMatrix.MultiplyVector(vert);
      buf[i].x = vert.x*m_d.m_length + m_d.m_vCenter.x;
      buf[i].y = vert.y*m_d.m_length + m_d.m_vCenter.y;
      buf[i].z = vert.z*m_d.m_length*m_ptable->m_BG_scalez[m_ptable->m_BG_current_set] + m_posZ;

      vert = Vertex3Ds(spinnerBracket[i].nx, spinnerBracket[i].ny, spinnerBracket[i].nz);
      vert = fullMatrix.MultiplyVectorNoTranslate(vert);
      buf[i].nx = vert.x;
      buf[i].ny = vert.y;
      buf[i].nz = vert.z;

      buf[i].tu = spinnerBracket[i].tu;
      buf[i].tv = spinnerBracket[i].tv;
   }
   bracketVertexBuffer->unlock();

   if (plateIndexBuffer)
      plateIndexBuffer->release();
   plateIndexBuffer = pd3dDevice->CreateAndFillIndexBuffer(spinnerPlateNumFaces, spinnerPlateIndices);

   if (plateVertexBuffer)
      plateVertexBuffer->release();
   pd3dDevice->CreateVertexBuffer(spinnerPlateNumVertices, USAGE_DYNAMIC, MY_D3DFVF_NOTEX2_VERTEX, &plateVertexBuffer);

   vertexBuffer_spinneranimangle = -FLT_MAX;
   UpdatePlate(NULL);
}
Beispiel #12
0
HitGate::HitGate(Gate * const pgate, const float height)
{
    m_pgate = pgate;
    const float halflength = pgate->m_d.m_length * 0.5f;

    const float radangle = ANGTORAD(pgate->m_d.m_rotation);
    const float sn = sinf(radangle);
    const float cs = cosf(radangle);

    m_lineseg[0].m_hitBBox.zlow = height;
    m_lineseg[0].m_hitBBox.zhigh = height + (float)(2.0*PHYS_SKIN);
    m_lineseg[1].m_hitBBox.zlow = height;
    m_lineseg[1].m_hitBBox.zhigh = height + (float)(2.0*PHYS_SKIN);

    m_lineseg[0].m_ObjType = eGate;
    m_lineseg[1].m_ObjType = eGate;

    m_lineseg[0].v2.x = pgate->m_d.m_vCenter.x + cs*(halflength + (float)PHYS_SKIN); //oversize by the ball radius
    m_lineseg[0].v2.y = pgate->m_d.m_vCenter.y + sn*(halflength + (float)PHYS_SKIN); //this will prevent clipping
    m_lineseg[0].v1.x = pgate->m_d.m_vCenter.x - cs*(halflength + (float)PHYS_SKIN); //through the edge of the
    m_lineseg[0].v1.y = pgate->m_d.m_vCenter.y - sn*(halflength + (float)PHYS_SKIN); //spinner

    m_lineseg[1].v1.x = m_lineseg[0].v2.x;
    m_lineseg[1].v1.y = m_lineseg[0].v2.y;
    m_lineseg[1].v2.x = m_lineseg[0].v1.x;
    m_lineseg[1].v2.y = m_lineseg[0].v1.y;

    m_lineseg[0].CalcNormal();
    m_lineseg[1].CalcNormal();

    m_gateMover.m_angleMin = pgate->m_d.m_angleMin;
    m_gateMover.m_angleMax = pgate->m_d.m_angleMax;

    m_gateMover.m_friction = pgate->m_d.m_friction;
    m_gateMover.m_fVisible = pgate->m_d.m_fVisible;

    m_gateMover.m_angle = m_gateMover.m_angleMin;
    m_gateMover.m_anglespeed = 0.0f;
    m_gateMover.m_damping = powf(pgate->m_d.m_damping, (float)PHYS_FACTOR); //0.996f;
    m_gateMover.m_gravityfactor = pgate->m_d.m_gravityfactor;

    m_gateMover.m_pgate = pgate;
    m_gateMover.m_fOpen = false;
    m_gateMover.m_forcedMove = false;
    m_twoWay = false;
}
Beispiel #13
0
HitGate::HitGate(Gate * const pgate, const float height)
{
	m_pgate = pgate;
    const float halflength = pgate->m_d.m_length * 0.5f;

    const float radangle = ANGTORAD(pgate->m_d.m_rotation);
    const float sn = sinf(radangle);
    const float cs = cosf(radangle);

    m_lineseg[0].m_rcHitRect.zlow = height;
    m_lineseg[0].m_rcHitRect.zhigh = height + 50.0f;
    m_lineseg[1].m_rcHitRect.zlow = height;
    m_lineseg[1].m_rcHitRect.zhigh = height + 50.0f;

    m_lineseg[0].m_pfe = NULL;
    m_lineseg[1].m_pfe = NULL;

    m_lineseg[0].v2.x = pgate->m_d.m_vCenter.x + cs*(halflength + (float)PHYS_SKIN); //oversize by the ball radius
    m_lineseg[0].v2.y = pgate->m_d.m_vCenter.y + sn*(halflength + (float)PHYS_SKIN); //this will prevent clipping
    m_lineseg[0].v1.x = pgate->m_d.m_vCenter.x - cs*(halflength + (float)PHYS_SKIN); //through the edge of the
    m_lineseg[0].v1.y = pgate->m_d.m_vCenter.y - sn*(halflength + (float)PHYS_SKIN); //spinner

    m_lineseg[1].v1.x = m_lineseg[0].v2.x;
    m_lineseg[1].v1.y = m_lineseg[0].v2.y;
    m_lineseg[1].v2.x = m_lineseg[0].v1.x;
    m_lineseg[1].v2.y = m_lineseg[0].v1.y;

    m_lineseg[0].CalcNormal();
    m_lineseg[1].CalcNormal();

	m_gateanim.m_angleMin = pgate->m_d.m_angleMin;
	m_gateanim.m_angleMax = pgate->m_d.m_angleMax;

	m_gateanim.m_friction = pgate->m_d.m_friction;
	m_gateanim.m_fVisible = pgate->m_d.m_fVisible;	

	m_gateanim.m_angle = m_gateanim.m_angleMin;
	m_gateanim.m_anglespeed = 0;

	m_gateanim.m_pgate = pgate;
	m_gateanim.m_fOpen = false;
    m_twoWay=false;
}
Beispiel #14
0
void Spinner::UpdatePlate(Vertex3D_NoTex2 * const vertBuffer)
{
   // early out in case still same rotation
   if (m_phitspinner->m_spinnerMover.m_angle == vertexBuffer_spinneranimangle)
       return;

   vertexBuffer_spinneranimangle = m_phitspinner->m_spinnerMover.m_angle;

   Matrix3D _fullMatrix;
   Matrix3D rotzMat, rotxMat;

   _fullMatrix.SetIdentity();
   rotxMat.RotateXMatrix(-m_phitspinner->m_spinnerMover.m_angle);
   rotxMat.Multiply(_fullMatrix, _fullMatrix);
   rotzMat.RotateZMatrix(ANGTORAD(m_d.m_rotation));
   rotzMat.Multiply(_fullMatrix, _fullMatrix);

   Vertex3D_NoTex2 *buf;
   if (vertBuffer == NULL)
      plateVertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::DISCARDCONTENTS);
   else
      buf = vertBuffer;

   for (int i = 0; i < spinnerPlateNumVertices; i++)
   {
      Vertex3Ds vert(spinnerPlate[i].x, spinnerPlate[i].y, spinnerPlate[i].z);
      vert = _fullMatrix.MultiplyVector(vert);
      buf[i].x = vert.x*m_d.m_length + m_d.m_vCenter.x;
      buf[i].y = vert.y*m_d.m_length + m_d.m_vCenter.y;
      buf[i].z = vert.z*m_d.m_length*m_ptable->m_BG_scalez[m_ptable->m_BG_current_set] + m_posZ;

      vert = Vertex3Ds(spinnerPlate[i].nx, spinnerPlate[i].ny, spinnerPlate[i].nz);
      vert = _fullMatrix.MultiplyVectorNoTranslate(vert);
      buf[i].nx = vert.x;
      buf[i].ny = vert.y;
      buf[i].nz = vert.z;

      buf[i].tu = spinnerPlate[i].tu;
      buf[i].tv = spinnerPlate[i].tv;
   }
   if (vertBuffer == NULL)
      plateVertexBuffer->unlock();
}
Beispiel #15
0
void Spinner::UIRenderPass2(Sur * const psur)
{
   psur->SetLineColor(RGB(0, 0, 0), false, 3);
   psur->SetObject(this);

   float halflength = m_d.m_length * 0.5f;

   const float radangle = ANGTORAD(m_d.m_rotation);
   const float sn = sinf(radangle);
   const float cs = cosf(radangle);

   psur->Line(m_d.m_vCenter.x + cs*halflength, m_d.m_vCenter.y + sn*halflength,
      m_d.m_vCenter.x - cs*halflength, m_d.m_vCenter.y - sn*halflength);

   psur->SetLineColor(RGB(0, 0, 0), false, 1);
   psur->SetObject(this);

   psur->Line(m_d.m_vCenter.x + cs*halflength, m_d.m_vCenter.y + sn*halflength,
      m_d.m_vCenter.x - cs*halflength, m_d.m_vCenter.y - sn*halflength);
}
Beispiel #16
0
void Flipper::PreRender(Sur * const psur)
{
   const float anglerad = ANGTORAD(m_d.m_StartAngle);
   //const float anglerad2 = ANGTORAD(m_d.m_EndAngle);

   m_d.m_FlipperRadius = m_d.m_FlipperRadiusMax;

   psur->SetFillColor(m_ptable->RenderSolid() ? RGB(192,192,192) : -1);
   psur->SetBorderColor(-1,false,0);
   psur->SetLineColor(RGB(0,0,0), false, 0);

   Vertex2D vendcenter;
   Vertex2D rgv[4];
   SetVertices(m_d.m_Center.x, m_d.m_Center.y, anglerad, &vendcenter, rgv, m_d.m_BaseRadius, m_d.m_EndRadius);

   psur->SetObject(this);

   psur->Polygon(rgv, 4);
   psur->Ellipse(m_d.m_Center.x, m_d.m_Center.y, m_d.m_BaseRadius);
   psur->Ellipse(vendcenter.x, vendcenter.y, m_d.m_EndRadius);
}
Beispiel #17
0
void Bumper::RenderBlueprint(Sur *psur, const bool solid)
{
   if (solid)
      psur->SetFillColor(BLUEPRINT_SOLID_COLOR);
   else
      psur->SetFillColor(-1);
   psur->SetBorderColor(RGB(0, 0, 0), false, 0);
   psur->SetObject(this);
   psur->SetObject(NULL);
   const float radangle = ANGTORAD(m_d.m_orientation - 90.f);
   const float sn = sinf(radangle);
   const float cs = cosf(radangle);

   const float x1 = m_d.m_vCenter.x - cs*(m_d.m_radius + 10.f);
   const float y1 = m_d.m_vCenter.y - sn*(m_d.m_radius + 10.f);
   const float x2 = m_d.m_vCenter.x + cs*(m_d.m_radius + 10.f);
   const float y2 = m_d.m_vCenter.y + sn*(m_d.m_radius + 10.f);
   psur->Ellipse(x1, y1, 10.0f);
   psur->Ellipse(x2, y2, 10.0f);
   psur->Ellipse(m_d.m_vCenter.x, m_d.m_vCenter.y, m_d.m_radius*1.5f);
   psur->Ellipse(m_d.m_vCenter.x, m_d.m_vCenter.y, m_d.m_radius);
}
Beispiel #18
0
void Flipper::GetHitShapes(Vector<HitObject> * const pvho)
{
   if(m_d.m_OverridePhysics)
   {
	     char tmp[256];
 		 m_d.m_OverrideMass = 0.15f;
	     sprintf_s(tmp,256,"FlipperPhysicsMass%d",m_d.m_OverridePhysics-1);
         HRESULT hr = GetRegStringAsFloat("Player", tmp, &m_d.m_OverrideMass);
         if (hr != S_OK)
            m_d.m_OverrideMass = 0.15f;

		 m_d.m_OverrideStrength = 3.f;
	     sprintf_s(tmp,256,"FlipperPhysicsStrength%d",m_d.m_OverridePhysics-1);
         hr = GetRegStringAsFloat("Player", tmp, &m_d.m_OverrideStrength);
         if (hr != S_OK)
            m_d.m_OverrideStrength = 3.f;

 		 m_d.m_OverrideElasticity = 0.55f;
	     sprintf_s(tmp,256,"FlipperPhysicsElasticity%d",m_d.m_OverridePhysics-1);
         hr = GetRegStringAsFloat("Player", tmp, &m_d.m_OverrideElasticity);
         if (hr != S_OK)
            m_d.m_OverrideElasticity = 0.55f;
		 
		 m_d.m_OverrideReturnStrength = 0.09f;
	     sprintf_s(tmp,256,"FlipperPhysicsReturnStrength%d",m_d.m_OverridePhysics-1);
         hr = GetRegStringAsFloat("Player", tmp, &m_d.m_OverrideReturnStrength);
         if (hr != S_OK)
            m_d.m_OverrideReturnStrength = 0.09f;

		 m_d.m_OverrideElasticityFalloff = 0.43f;
	     sprintf_s(tmp,256,"FlipperPhysicsElasticityFalloff%d",m_d.m_OverridePhysics-1);
         hr = GetRegStringAsFloat("Player", tmp, &m_d.m_OverrideElasticityFalloff);
         if (hr != S_OK)
            m_d.m_OverrideElasticityFalloff = 0.43f;

  		 m_d.m_OverrideFriction = 0.8f;
	     sprintf_s(tmp,256,"FlipperPhysicsFriction%d",m_d.m_OverridePhysics-1);
         hr = GetRegStringAsFloat("Player", tmp, &m_d.m_OverrideFriction);
         if (hr != S_OK)
            m_d.m_OverrideFriction = 0.8f;

		 m_d.m_OverrideCoilRampUp = 0.f;
	     sprintf_s(tmp,256,"FlipperPhysicsCoilRampUp%d",m_d.m_OverridePhysics-1);
         hr = GetRegStringAsFloat("Player", tmp, &m_d.m_OverrideCoilRampUp);
         if (hr != S_OK)
            m_d.m_OverrideCoilRampUp = 0.f;
   }

   //

   const float height = m_ptable->GetSurfaceHeight(m_d.m_szSurface, m_d.m_Center.x, m_d.m_Center.y);

   if (m_d.m_FlipperRadiusMin > 0.f && m_d.m_FlipperRadiusMax > m_d.m_FlipperRadiusMin)
   {
      m_d.m_FlipperRadius = m_d.m_FlipperRadiusMax - (m_d.m_FlipperRadiusMax - m_d.m_FlipperRadiusMin) * m_ptable->m_globalDifficulty;
      m_d.m_FlipperRadius = max(m_d.m_FlipperRadius, m_d.m_BaseRadius - m_d.m_EndRadius +0.05f);
   }
   else m_d.m_FlipperRadius = m_d.m_FlipperRadiusMax;

   const float strength = m_d.m_OverridePhysics ? m_d.m_OverrideStrength : m_d.m_strength;
   const float return_ratio = m_d.m_OverridePhysics ? m_d.m_OverrideReturnStrength : m_d.m_return;
   const float mass = m_d.m_OverridePhysics ? m_d.m_OverrideMass : m_d.m_mass;

   HitFlipper * const phf = new HitFlipper(m_d.m_Center, m_d.m_BaseRadius, m_d.m_EndRadius,
	   m_d.m_FlipperRadius, ANGTORAD(m_d.m_StartAngle), ANGTORAD(m_d.m_EndAngle), height, height + m_d.m_height,
       strength, mass, return_ratio);

   phf->m_elasticity = m_d.m_OverridePhysics ? m_d.m_OverrideElasticity : m_d.m_elasticity;
   phf->SetFriction(m_d.m_OverridePhysics ? m_d.m_OverrideFriction : m_d.m_friction);
   phf->m_scatter = m_d.m_scatter;

   const float coil_ramp_up = m_d.m_OverridePhysics ? m_d.m_OverrideCoilRampUp : m_d.m_rampUp;

   if (coil_ramp_up <= 0.f)
       phf->m_flipperanim.m_torqueRampupSpeed = 1e6f; // set very high for instant coil response
   else
       phf->m_flipperanim.m_torqueRampupSpeed = strength / coil_ramp_up;

   phf->m_flipperanim.m_EnableRotateEvent = 0;
   phf->m_pfe = NULL;

   phf->m_flipperanim.m_fEnabled = m_d.m_fEnabled;
   phf->m_flipperanim.m_fVisible = m_d.m_fVisible;

   pvho->AddElement(phf);
   phf->m_pflipper = this;
   phf->m_flipperanim.m_pflipper = this;
   m_phitflipper = phf;	
}
Beispiel #19
0
void IHaveDragPoints::RotatePoints(float ang, Vertex2D *pvCenter, const bool useElementCenter)
{
   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   if (useElementCenter)
   {
      /* Don't use the pvCenter anymore! pvCenter is the mouse position when rotating is activated.
      Because the mouse position (rotation center) isn't shown in the editor use the element's center returned by GetPointCenter() */
      const float centerx = newcenter.x;
      const float centery = newcenter.y;

      const float sn = sinf(ANGTORAD(ang));
      const float cs = cosf(ANGTORAD(ang));

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = pdp1->m_v.x - centerx;
         const float dy = pdp1->m_v.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         pdp1->m_v.x = centerx + dx2;
         pdp1->m_v.y = centery + dy2;
      }
   }
   else
   {
      const float centerx = pvCenter->x;
      const float centery = pvCenter->y;

      const float sn = sinf(ANGTORAD(ang));
      const float cs = cosf(ANGTORAD(ang));

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = pdp1->m_v.x - centerx;
         const float dy = pdp1->m_v.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         pdp1->m_v.x = centerx + dx2;
         pdp1->m_v.y = centery + dy2;
      }

      // Move object center as well (if rotating around object center,
      // this will have no effect)
      {
         const float dx = newcenter.x - centerx;
         const float dy = newcenter.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         newcenter.x = centerx + dx2;
         newcenter.y = centery + dy2;
         PutPointCenter(&newcenter);
      }
   }
   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Beispiel #20
0
void Flipper::Render(Sur * const psur)
{
   const float anglerad = ANGTORAD(m_d.m_StartAngle);
   const float anglerad2 = ANGTORAD(m_d.m_EndAngle);

   Vertex2D vendcenter;
   Vertex2D rgv[4];
   SetVertices(m_d.m_Center.x, m_d.m_Center.y, anglerad, &vendcenter, rgv, m_d.m_BaseRadius, m_d.m_EndRadius);

   psur->SetFillColor(m_ptable->RenderSolid() ? RGB(192,192,192) : -1);
   psur->SetBorderColor(-1,false,0);
   psur->SetLineColor(RGB(0,0,0), false, 0);

   psur->SetObject(this);

   psur->Line(rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
   psur->Line(rgv[2].x, rgv[2].y, rgv[3].x, rgv[3].y);

   psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_BaseRadius, rgv[0].x, rgv[0].y, rgv[3].x, rgv[3].y);
   psur->Arc(vendcenter.x, vendcenter.y, m_d.m_EndRadius, rgv[2].x, rgv[2].y, rgv[1].x, rgv[1].y);

   SetVertices(m_d.m_Center.x, m_d.m_Center.y, anglerad2, &vendcenter, rgv, m_d.m_BaseRadius, m_d.m_EndRadius);

   psur->SetLineColor(RGB(128,128,128), true, 0);

   psur->Line(rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
   psur->Line(rgv[2].x, rgv[2].y, rgv[3].x, rgv[3].y);

   psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_BaseRadius, rgv[0].x, rgv[0].y, rgv[3].x, rgv[3].y);
   psur->Arc(vendcenter.x, vendcenter.y, m_d.m_EndRadius, rgv[2].x, rgv[2].y, rgv[1].x, rgv[1].y);

   rgv[0].x = m_d.m_Center.x + sinf(anglerad) * (m_d.m_FlipperRadius+m_d.m_EndRadius);
   rgv[0].y = m_d.m_Center.y - cosf(anglerad) * (m_d.m_FlipperRadius+m_d.m_EndRadius);

   rgv[1].x = m_d.m_Center.x + sinf(anglerad2) * (m_d.m_FlipperRadius+m_d.m_EndRadius);
   rgv[1].y = m_d.m_Center.y - cosf(anglerad2) * (m_d.m_FlipperRadius+m_d.m_EndRadius);

   if (m_d.m_EndAngle < m_d.m_StartAngle)
      psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_FlipperRadius+m_d.m_EndRadius
      , rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
   else psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_FlipperRadius+m_d.m_EndRadius
      , rgv[1].x, rgv[1].y, rgv[0].x, rgv[0].y);

   if (m_d.m_FlipperRadiusMin > 0.f && m_d.m_FlipperRadiusMax > m_d.m_FlipperRadiusMin)
   {
      m_d.m_FlipperRadius = (m_ptable->m_globalDifficulty > 0.f) ? m_d.m_FlipperRadiusMin : m_d.m_FlipperRadiusMax;
      m_d.m_FlipperRadius = max(m_d.m_FlipperRadius, m_d.m_BaseRadius - m_d.m_EndRadius +0.05f);
   }
   else return;

   if (m_d.m_FlipperRadius != m_d.m_FlipperRadiusMax)
   {
      SetVertices(m_d.m_Center.x, m_d.m_Center.y, anglerad, &vendcenter, rgv, m_d.m_BaseRadius, m_d.m_EndRadius);

      psur->SetObject(this);

      psur->Line(rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
      psur->Line(rgv[2].x, rgv[2].y, rgv[3].x, rgv[3].y);

      psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_BaseRadius, rgv[0].x, rgv[0].y, rgv[3].x, rgv[3].y);
      psur->Arc(vendcenter.x, vendcenter.y, m_d.m_EndRadius, rgv[2].x, rgv[2].y, rgv[1].x, rgv[1].y);

      SetVertices(m_d.m_Center.x, m_d.m_Center.y, anglerad2, &vendcenter, rgv, m_d.m_BaseRadius, m_d.m_EndRadius);

      psur->SetLineColor(RGB(128,128,128), true, 0);

      psur->Line(rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
      psur->Line(rgv[2].x, rgv[2].y, rgv[3].x, rgv[3].y);

      psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_BaseRadius, rgv[0].x, rgv[0].y, rgv[3].x, rgv[3].y);
      psur->Arc(vendcenter.x, vendcenter.y, m_d.m_EndRadius, rgv[2].x, rgv[2].y, rgv[1].x, rgv[1].y);

      rgv[0].x = m_d.m_Center.x + sinf(anglerad) * (m_d.m_FlipperRadius+m_d.m_EndRadius);
      rgv[0].y = m_d.m_Center.y - cosf(anglerad) * (m_d.m_FlipperRadius+m_d.m_EndRadius);

      rgv[1].x = m_d.m_Center.x + sinf(anglerad2) * (m_d.m_FlipperRadius+m_d.m_EndRadius);
      rgv[1].y = m_d.m_Center.y - cosf(anglerad2) * (m_d.m_FlipperRadius+m_d.m_EndRadius);

      if (m_d.m_EndAngle < m_d.m_StartAngle)
         psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_FlipperRadius+m_d.m_EndRadius
         , rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
      else psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_FlipperRadius+m_d.m_EndRadius
         , rgv[1].x, rgv[1].y, rgv[0].x, rgv[0].y);

      m_d.m_FlipperRadius = m_d.m_FlipperRadiusMax - (m_d.m_FlipperRadiusMax - m_d.m_FlipperRadiusMin) * m_ptable->m_globalDifficulty;
      m_d.m_FlipperRadius = max(m_d.m_FlipperRadius, m_d.m_BaseRadius - m_d.m_EndRadius +0.05f);

      SetVertices(m_d.m_Center.x, m_d.m_Center.y, anglerad, &vendcenter, rgv, m_d.m_BaseRadius, m_d.m_EndRadius);

      psur->SetObject(this);

      psur->Line(rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
      psur->Line(rgv[2].x, rgv[2].y, rgv[3].x, rgv[3].y);

      psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_BaseRadius, rgv[0].x, rgv[0].y, rgv[3].x, rgv[3].y);
      psur->Arc(vendcenter.x, vendcenter.y, m_d.m_EndRadius, rgv[2].x, rgv[2].y, rgv[1].x, rgv[1].y);

      SetVertices(m_d.m_Center.x, m_d.m_Center.y, anglerad2, &vendcenter, rgv, m_d.m_BaseRadius, m_d.m_EndRadius);

      psur->SetLineColor(RGB(128,128,128), true, 0);

      psur->Line(rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
      psur->Line(rgv[2].x, rgv[2].y, rgv[3].x, rgv[3].y);

      psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_BaseRadius, rgv[0].x, rgv[0].y, rgv[3].x, rgv[3].y);
      psur->Arc(vendcenter.x, vendcenter.y, m_d.m_EndRadius, rgv[2].x, rgv[2].y, rgv[1].x, rgv[1].y);

      rgv[0].x = m_d.m_Center.x + sinf(anglerad) * (m_d.m_FlipperRadius+m_d.m_EndRadius);
      rgv[0].y = m_d.m_Center.y - cosf(anglerad) * (m_d.m_FlipperRadius+m_d.m_EndRadius);

      rgv[1].x = m_d.m_Center.x + sinf(anglerad2) * (m_d.m_FlipperRadius+m_d.m_EndRadius);
      rgv[1].y = m_d.m_Center.y - cosf(anglerad2) * (m_d.m_FlipperRadius+m_d.m_EndRadius);

      if (m_d.m_EndAngle < m_d.m_StartAngle)
         psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_FlipperRadius+m_d.m_EndRadius
         , rgv[0].x, rgv[0].y, rgv[1].x, rgv[1].y);
      else psur->Arc(m_d.m_Center.x, m_d.m_Center.y, m_d.m_FlipperRadius+m_d.m_EndRadius
         , rgv[1].x, rgv[1].y, rgv[0].x, rgv[0].y);
   }

   m_d.m_FlipperRadius = m_d.m_FlipperRadiusMax;
}
Beispiel #21
0
void Flipper::RenderSetup(RenderDevice* pd3dDevice)
{
    const unsigned long numVertices= 108*2; //*2 for flipper plus rubber
    // 12 + 16 + 32 + 16 + 32
    _ASSERTE(m_phitflipper);
    Pin3D * const ppin3d = &g_pplayer->m_pin3d;

    const float height = m_ptable->GetSurfaceHeight(m_d.m_szSurface, m_d.m_Center.x, m_d.m_Center.y);

    const float anglerad = ANGTORAD(m_d.m_StartAngle);
    const float anglerad2 = ANGTORAD(m_d.m_EndAngle);

    if (vertexBuffer)
		vertexBuffer->release();
    pd3dDevice->CreateVertexBuffer(numVertices, 0, MY_D3DFVF_NOTEX2_VERTEX, &vertexBuffer);

    // 18 + 3*14 + 3*14 + 6*16*2 = 294
    // first 6 quads: top/front/back sides (no bottom)
    // next 14 tris:  base top cap
    // next 14 tris:  end top cap
    // next 16 quads: base mantle
    // next 16 quads: end mantle
    static WORD idx[numIndices]={0,1,2,0,2,3, 4,5,6,4,6,7, 8,9,10,8,10,11 };
    for( int i=0;i<14;i++ )
    {
        idx[18 + i*3  ] = 12;
        idx[18 + i*3+1] = 12+i+1;
        idx[18 + i*3+2] = 12+i+2;

        idx[60 + i*3  ] = 60;
        idx[60 + i*3+1] = 60+i+1;
        idx[60 + i*3+2] = 60+i+2;
    }

    for(int i=0;i<16;i++ )
    {
        const WORD o = 2 * i;

        idx[102 + i*6  ] = 28 + o;
        idx[102 + i*6+1] = 28 + (o+1)%32;
        idx[102 + i*6+2] = 28 + (o+2)%32;
        idx[102 + i*6+3] = 28 + (o+1)%32;
        idx[102 + i*6+4] = 28 + (o+3)%32;
        idx[102 + i*6+5] = 28 + (o+2)%32;

        idx[102 + 96 + i*6  ] = 76 + o;
        idx[102 + 96 + i*6+1] = 76 + (o+1)%32;
        idx[102 + 96 + i*6+2] = 76 + (o+2)%32;
        idx[102 + 96 + i*6+3] = 76 + (o+1)%32;
        idx[102 + 96 + i*6+4] = 76 + (o+3)%32;
        idx[102 + 96 + i*6+5] = 76 + (o+2)%32;
    }

    if (indexBuffer)
        indexBuffer->release();

	// not necessary to reorder
	/*WORD* tmp = reorderForsyth(idx,numIndices/3,numVertices);
    if(tmp != NULL)
    {
       memcpy(idx,tmp,numIndices*sizeof(WORD));
       delete [] tmp;
    }*/
    indexBuffer = pd3dDevice->CreateAndFillIndexBuffer(numIndices, idx);

    Vertex3D_NoTex2 *buf;
    vertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::WRITEONLY);

    // Render just the flipper (in standard position, angle=0)
    RenderAtThickness(pd3dDevice, 0.0f, height, m_d.m_BaseRadius - (float)m_d.m_rubberthickness, m_d.m_EndRadius - (float)m_d.m_rubberthickness, m_d.m_height, buf);

    // Render just the rubber.
    if (m_d.m_rubberthickness > 0)
        RenderAtThickness(pd3dDevice, 0.0f, height + (float)m_d.m_rubberheight, m_d.m_BaseRadius, m_d.m_EndRadius, (float)m_d.m_rubberwidth, buf+108);

    vertexBuffer->unlock();
}
Beispiel #22
0
void Bumper::ExportMesh(FILE *f)
{
   char name[MAX_PATH];
   char subObjName[MAX_PATH];
   WideCharToMultiByte(CP_ACP, 0, m_wzName, -1, name, MAX_PATH, NULL, NULL);


   m_baseHeight = m_ptable->GetSurfaceHeight(m_d.m_szSurface, m_d.m_vCenter.x, m_d.m_vCenter.y) * m_ptable->m_BG_scalez[m_ptable->m_BG_current_set];
   m_fullMatrix.RotateZMatrix(ANGTORAD(m_d.m_orientation));

   if (m_d.m_fBaseVisible)
   {
      Vertex3D_NoTex2 *base = new Vertex3D_NoTex2[bumperBaseNumVertices];
      strcpy_s(subObjName, name);
      strcat_s(subObjName, "Base");
      WaveFrontObj_WriteObjectName(f, subObjName);

      GenerateBaseMesh(base);
      WaveFrontObj_WriteVertexInfo(f, base, bumperBaseNumVertices);
      const Material * mat = m_ptable->GetMaterial(m_d.m_szBaseMaterial);
      WaveFrontObj_WriteMaterial(m_d.m_szBaseMaterial, NULL, mat);
      WaveFrontObj_UseTexture(f, m_d.m_szBaseMaterial);
      WaveFrontObj_WriteFaceInfoList(f, bumperBaseIndices, bumperBaseNumFaces);
      WaveFrontObj_UpdateFaceOffset(bumperBaseNumVertices);
      delete[] base;
   }
   if (m_d.m_fRingVisible)
   {
      Vertex3D_NoTex2 *ring = new Vertex3D_NoTex2[bumperRingNumVertices];
      strcpy_s(subObjName, name);
      strcat_s(subObjName, "Ring");
      WaveFrontObj_WriteObjectName(f, subObjName);

      GenerateRingMesh(ring);
      WaveFrontObj_WriteVertexInfo(f, ring, bumperRingNumVertices);
      WaveFrontObj_WriteFaceInfoList(f, bumperRingIndices, bumperRingNumFaces);
      WaveFrontObj_UpdateFaceOffset(bumperRingNumVertices);
      delete[] ring;
   }
   if (m_d.m_fSkirtVisible)
   {
      Vertex3D_NoTex2 *socket = new Vertex3D_NoTex2[bumperSocketNumVertices];
      strcpy_s(subObjName, name);
      strcat_s(subObjName, "Socket");
      WaveFrontObj_WriteObjectName(f, subObjName);

      GenerateSocketMesh(socket);
      WaveFrontObj_WriteVertexInfo(f, socket, bumperSocketNumVertices);
      const Material * mat = m_ptable->GetMaterial(m_d.m_szSkirtMaterial);
      WaveFrontObj_WriteMaterial(m_d.m_szSkirtMaterial, NULL, mat);
      WaveFrontObj_UseTexture(f, m_d.m_szSkirtMaterial);
      WaveFrontObj_WriteFaceInfoList(f, bumperSocketIndices, bumperSocketNumFaces);
      WaveFrontObj_UpdateFaceOffset(bumperSocketNumVertices);
      delete[] socket;
   }
   if (m_d.m_fCapVisible)
   {
      Vertex3D_NoTex2 *cap = new Vertex3D_NoTex2[bumperCapNumVertices];
      strcpy_s(subObjName, name);
      strcat_s(subObjName, "Cap");
      WaveFrontObj_WriteObjectName(f, subObjName);

      GenerateCapMesh(cap);
      WaveFrontObj_WriteVertexInfo(f, cap, bumperCapNumVertices);
      const Material * const mat = m_ptable->GetMaterial(m_d.m_szCapMaterial);
      WaveFrontObj_WriteMaterial(m_d.m_szCapMaterial, NULL, mat);
      WaveFrontObj_UseTexture(f, m_d.m_szCapMaterial);
      WaveFrontObj_WriteFaceInfoList(f, bumperCapIndices, bumperCapNumFaces);
      WaveFrontObj_UpdateFaceOffset(bumperCapNumVertices);
      delete[] cap;
   }
}
Beispiel #23
0
void Bumper::RenderSetup(RenderDevice* pd3dDevice)
{
   m_d.m_time_msec = g_pplayer->m_time_msec;

   m_baseHeight = m_ptable->GetSurfaceHeight(m_d.m_szSurface, m_d.m_vCenter.x, m_d.m_vCenter.y) * m_ptable->m_BG_scalez[m_ptable->m_BG_current_set];

   const float scalez = m_d.m_radius*m_d.m_heightScale*2.0f*m_ptable->m_BG_scalez[m_ptable->m_BG_current_set];

   m_fullMatrix.RotateZMatrix(ANGTORAD(m_d.m_orientation));
   if (m_d.m_fBaseVisible)
   {
      if (m_baseIndexBuffer)
         m_baseIndexBuffer->release();
      m_baseIndexBuffer = pd3dDevice->CreateAndFillIndexBuffer(bumperBaseNumFaces, bumperBaseIndices);

      if (m_baseVertexBuffer)
         m_baseVertexBuffer->release();
      pd3dDevice->CreateVertexBuffer(bumperBaseNumVertices, 0, MY_D3DFVF_NOTEX2_VERTEX, &m_baseVertexBuffer);


      Vertex3D_NoTex2 *buf;
      m_baseVertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::WRITEONLY);
      GenerateBaseMesh(buf);
      m_baseVertexBuffer->unlock();
   }

   if (m_d.m_fSkirtVisible)
   {
      if (m_socketIndexBuffer)
         m_socketIndexBuffer->release();
      m_socketIndexBuffer = pd3dDevice->CreateAndFillIndexBuffer(bumperSocketNumFaces, bumperSocketIndices);

      if (m_socketVertexBuffer)
         m_socketVertexBuffer->release();
      pd3dDevice->CreateVertexBuffer(bumperSocketNumVertices, 0, MY_D3DFVF_NOTEX2_VERTEX, &m_socketVertexBuffer);

      Vertex3D_NoTex2 *buf;
      m_socketVertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::WRITEONLY);
      GenerateSocketMesh(buf);
      m_socketVertexBuffer->unlock();
   }

   if (m_d.m_fRingVisible)
   {
      m_ringTexture.CreateFromResource(IDB_RINGENVMAP);

      if (m_d.m_szRingMaterial[0] != '\0')
      {
         m_ringMaterial = *(m_ptable->GetMaterial(m_d.m_szRingMaterial));
      }
      else
      {
         Material default_material;
         m_ringMaterial = default_material;
         m_ringMaterial.m_cBase = 0xFFFFFFFF; //!! set properly
         m_ringMaterial.m_cGlossy = 0;
         m_ringMaterial.m_bIsMetal = true;
      }

      if (m_ringIndexBuffer)
         m_ringIndexBuffer->release();
      m_ringIndexBuffer = pd3dDevice->CreateAndFillIndexBuffer(bumperRingNumFaces, bumperRingIndices);

      if (m_ringVertexBuffer)
         m_ringVertexBuffer->release();
      pd3dDevice->CreateVertexBuffer(bumperRingNumVertices, USAGE_DYNAMIC, MY_D3DFVF_NOTEX2_VERTEX, &m_ringVertexBuffer);

      m_ringVertices = new Vertex3D_NoTex2[bumperRingNumVertices];
      GenerateRingMesh(m_ringVertices);

      Vertex3D_NoTex2 *buf;
      m_ringVertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::DISCARDCONTENTS);
      memcpy(buf, m_ringVertices, bumperRingNumVertices*sizeof(Vertex3D_NoTex2));
      m_ringVertexBuffer->unlock();
   }

   if (m_d.m_fCapVisible)
   {
      m_capTexture.CreateFromResource(IDB_BUMPERCAP);

      if (m_capIndexBuffer)
         m_capIndexBuffer->release();
      m_capIndexBuffer = pd3dDevice->CreateAndFillIndexBuffer(bumperCapNumFaces, bumperCapIndices);

      if (m_capVertexBuffer)
         m_capVertexBuffer->release();
      pd3dDevice->CreateVertexBuffer(bumperCapNumVertices, 0, MY_D3DFVF_NOTEX2_VERTEX, &m_capVertexBuffer);

      Vertex3D_NoTex2 *buf;
      m_capVertexBuffer->lock(0, 0, (void**)&buf, VertexBuffer::WRITEONLY);
      GenerateCapMesh(buf);
      m_capVertexBuffer->unlock();
   }

}
Beispiel #24
0
void Spinner::ExportMesh(FILE *f)
{
   char name[MAX_PATH];
   char subObjName[MAX_PATH];
   WideCharToMultiByte(CP_ACP, 0, m_wzName, -1, name, MAX_PATH, NULL, NULL);
   std::vector<Vertex3D_NoTex2> transformedVertices;
   vector<HitObject*> dummyHitObj;

   const float height = m_ptable->GetSurfaceHeight(m_d.m_szSurface, m_d.m_vCenter.x, m_d.m_vCenter.y)*m_ptable->m_BG_scalez[m_ptable->m_BG_current_set];
   m_posZ = height + m_d.m_height;

   GetHitShapes(dummyHitObj);

   if (m_d.m_fShowBracket)
   {
      strcpy_s(subObjName, name);
      strcat_s(subObjName, "Bracket");
      WaveFrontObj_WriteObjectName(f, subObjName);

      fullMatrix.RotateZMatrix(ANGTORAD(m_d.m_rotation));

      transformedVertices.resize(spinnerBracketNumVertices);

      for (int i = 0; i < spinnerBracketNumVertices; i++)
      {
         Vertex3Ds vert(spinnerBracket[i].x, spinnerBracket[i].y, spinnerBracket[i].z);
         vert = fullMatrix.MultiplyVector(vert);
         transformedVertices[i].x = vert.x*m_d.m_length + m_d.m_vCenter.x;
         transformedVertices[i].y = vert.y*m_d.m_length + m_d.m_vCenter.y;
         transformedVertices[i].z = vert.z*m_d.m_length*m_ptable->m_BG_scalez[m_ptable->m_BG_current_set] + m_posZ;

         vert = Vertex3Ds(spinnerBracket[i].nx, spinnerBracket[i].ny, spinnerBracket[i].nz);
         vert = fullMatrix.MultiplyVectorNoTranslate(vert);
         transformedVertices[i].nx = vert.x;
         transformedVertices[i].ny = vert.y;
         transformedVertices[i].nz = vert.z;

         transformedVertices[i].tu = spinnerBracket[i].tu;
         transformedVertices[i].tv = spinnerBracket[i].tv;
      }
      WaveFrontObj_WriteVertexInfo(f, transformedVertices.data(), spinnerBracketNumVertices);

      const Material * mat = m_ptable->GetMaterial(m_d.m_szMaterial);
      WaveFrontObj_WriteMaterial(m_d.m_szMaterial, NULL, mat);
      WaveFrontObj_UseTexture(f, m_d.m_szMaterial);
      WaveFrontObj_WriteFaceInfoList(f, spinnerBracketIndices, spinnerBracketNumFaces);
      WaveFrontObj_UpdateFaceOffset(spinnerBracketNumVertices);

      transformedVertices.clear();
   }

   transformedVertices.resize(spinnerPlateNumVertices);
   vertexBuffer_spinneranimangle = -FLT_MAX;
   UpdatePlate(transformedVertices.data());

   strcpy_s(subObjName, name);
   strcat_s(subObjName, "Plate");
   WaveFrontObj_WriteObjectName(f, subObjName);

   WaveFrontObj_WriteVertexInfo(f, transformedVertices.data(), spinnerPlateNumVertices);
   WaveFrontObj_WriteFaceInfoList(f, spinnerPlateIndices, spinnerPlateNumFaces);
   WaveFrontObj_UpdateFaceOffset(spinnerPlateNumVertices);
   transformedVertices.clear();
}