void 
CTimeLineRendererInOpenGL::_TraversePoint(int iPointIndex, int iTraceIndex, float fX, float fY, float fZ, float fT)
{
	static list<int>::iterator liiParticleIterator;
	static VECTOR3 v3PrevPoint;
	static VECTOR3 v3PrevTangent;
	// ADD-BY-LEETEN 04/16/2010-BEGIN
	static float fPrevT;
	// ADD-BY-LEETEN 04/16/2010-END
	// ADD-BY-LEETEN 07/07/2010-BEGIN
	static VECTOR4 v4PrevColor;
	VECTOR4 v4Color = cColorScheme.V4GetColor();
	// ADD-BY-LEETEN 07/07/2010-END
	VECTOR3 v3Point(fX, fY, fZ);

	VECTOR3 v3Tangent = v3Point - v3PrevPoint;
	v3Tangent.Normalize();

	if( 0 < iPointIndex )
	{
		float fT0 = max(fPrevT, fMinTimeStep);
		float fT1 = min(fT, fMaxTimeStep);
		if( fT0 < fT1 )
		{
			float fMinCoeff = (fT0 - fPrevT)/(fT - fPrevT);
			float fMaxCoeff = (fT1 - fPrevT)/(fT - fPrevT);
			if( iPointIndex > 0 )
			{
				if( 1 == iPointIndex )
					pv4TexCoords.push_back(VECTOR4(v3Tangent[0], v3Tangent[1], v3Tangent[2], 1.0));
				else
					pv4TexCoords.push_back(VECTOR4(v3PrevTangent[0], v3PrevTangent[1], v3PrevTangent[2], 1.0));
				VECTOR3 v3PrevP = v3PrevPoint + fMinCoeff * (v3Point - v3PrevPoint);
				pv4Coords.push_back(VECTOR4(v3PrevP[0], v3PrevP[1], v3PrevP[2], 1.0));
				pv4Colors.push_back(v4PrevColor);

				pv4TexCoords.push_back(VECTOR4(v3Tangent[0], v3Tangent[1], v3Tangent[2], 1.0));
				VECTOR3 v3NextP = v3PrevPoint + fMaxCoeff * (v3Point - v3PrevPoint);
				pv4Coords.push_back(VECTOR4(v3NextP[0], v3NextP[1], v3NextP[2], 1.0));
				pv4Colors.push_back(v4Color);
			}
			iNrOfRenderedParticles++;
		}
	}
	fPrevT = fT;

	v3PrevPoint = v3Point;
	v3PrevTangent = v3Tangent;
	v4PrevColor = v4Color;
	cColorScheme._MoveToNextPoint();
}
Exemple #2
0
void compute_pathlines() 
{

  float from[3], to[3]; 

  from[0] = minLen[0];   from[1] = minLen[1];   from[2] = minLen[2]; 
  to[0] = maxLen[0];   to[1] = maxLen[1];   to[2] = maxLen[2]; 

  printf("generating seeds...\n"); 
  osuflow->SetRandomSeedPoints(from, to, 1000); 
  int nSeeds; 
  VECTOR3* seeds = osuflow->GetSeeds(nSeeds); 
  for (int i=0; i<nSeeds; i++) 
    printf(" seed no. %d : [%f %f %f]\n", i, seeds[i][0], 
	   seeds[i][1], seeds[i][2]); 

  sl_list.clear(); 

  float* tarray = new float[nSeeds]; 
  for (int i=0;i<nSeeds; i++) 
    tarray[i] = (float)(i % num_timesteps); 

  printf("compute streamlines..\n"); 
  osuflow->SetIntegrationParams(0.01f, 0.5f); 
  //  osuflow->GenPathLines(seeds, sl_list , FORWARD, nSeeds, 5000); 
  osuflow->GenPathLines(seeds, sl_list , FORWARD, nSeeds, 5000, tarray); 
  printf(" done integrations\n"); 
  printf("list size = %d\n", (int)sl_list.size()); 

	// ADD-BY-LEETEN 07/09/2010-BEGIN
	for(int i = 0; i < sl_list.size(); i++)
	{
		VECTOR4 v4Color;
		switch((i/2)%7)
		{
		case 0: v4Color = VECTOR4(1.0f, 0.0f, 0.0f, 1.0f);	break;
		case 1: v4Color = VECTOR4(0.0f, 1.0f, 0.0f, 1.0f);	break;
		case 2: v4Color = VECTOR4(0.0f, 0.0f, 1.0f, 1.0f);	break;
		case 3: v4Color = VECTOR4(1.0f, 1.0f, 0.0f, 1.0f);	break;
		case 4: v4Color = VECTOR4(1.0f, 0.0f, 1.0f, 1.0f);	break;
		case 5: v4Color = VECTOR4(0.0f, 1.0f, 1.0f, 1.0f);	break;
		case 6: v4Color = VECTOR4(1.0f, 1.0f, 1.0f, 1.0f);	break;
		}
		liv4Colors.push_back(v4Color);
	}
	// ADD-BY-LEETEN 07/09/2010-END
	cLineRenderer._Update();
}
Exemple #3
0
void compute_streamlines() 
{
	LOG("");

  float from[3], to[3]; 

  from[0] = minLen[0];   from[1] = minLen[1];   from[2] = minLen[2]; 
  to[0] = maxLen[0];   to[1] = maxLen[1];   to[2] = maxLen[2]; 

  printf("generating seeds...\n"); 
  osuflow->SetRandomSeedPoints(from, to, 200); 
  int nSeeds; 
  VECTOR3* seeds = osuflow->GetSeeds(nSeeds); 
  for (int i=0; i<nSeeds; i++) 
    printf(" seed no. %d : [%f %f %f]\n", i, seeds[i][0], 
	   seeds[i][1], seeds[i][2]); 

  sl_list.clear(); 

  printf("compute streamlines..\n"); 
  osuflow->SetIntegrationParams(1, 5); 
  osuflow->GenStreamLines(sl_list , BACKWARD_AND_FORWARD, 30, 0); 
  printf(" done integrations\n"); 
  OSUFlow::MergeBackwardAndForwardTraces(sl_list);	// ADD-BY-LEETEN 09/09/2012
    printf("list size = %d\n", (int)sl_list.size()); 

	// ADD-BY-LEETEN 07/07/2010-BEGIN
	for(int i = 0; i < sl_list.size(); i++)
	{
		VECTOR4 v4Color;
		// MOD-BY-LEETEN 09/09/2012-FROM:		switch((i/2)%7)
		switch(i%7)
		// MOD-BY-LEETEN 09/09/2012-END
		{
		case 0: v4Color = VECTOR4(1.0f, 0.0f, 0.0f, 1.0f);	break;
		case 1: v4Color = VECTOR4(0.0f, 1.0f, 0.0f, 1.0f);	break;
		case 2: v4Color = VECTOR4(0.0f, 0.0f, 1.0f, 1.0f);	break;
		case 3: v4Color = VECTOR4(1.0f, 1.0f, 0.0f, 1.0f);	break;
		case 4: v4Color = VECTOR4(1.0f, 0.0f, 1.0f, 1.0f);	break;
		case 5: v4Color = VECTOR4(0.0f, 1.0f, 1.0f, 1.0f);	break;
		case 6: v4Color = VECTOR4(1.0f, 1.0f, 1.0f, 1.0f);	break;
		}
		liv4Colors.push_back(v4Color);
	}
	// ADD-BY-LEETEN 07/07/2010-END
	cLineRenderer._Update();
}
void compute_streamlines() 
{
  srand (time(NULL));
	LOG("");

  float from[3], to[3]; 

  from[0] = minLen[0];   from[1] = minLen[1];   from[2] = minLen[2]; 
  to[0] = maxLen[0];   to[1] = maxLen[1];   to[2] = maxLen[2]; 

  printf("generating seeds...\n"); 
  osuflow->SetRandomSeedPoints(from, to, 500);
  int nSeeds; 
  VECTOR3* seeds = osuflow->GetSeeds(nSeeds); 
  for (int i=0; i<nSeeds; i++) 
    printf(" seed no. %d : [%f %f %f]\n", i, seeds[i][0], 
	   seeds[i][1], seeds[i][2]); 

  sl_list.clear(); 

  printf("compute streamlines..\n"); 
  osuflow->SetIntegrationParams(.001, .001);
  osuflow->GenStreamLines(sl_list , BACKWARD_AND_FORWARD, 2000, 0);
  int n = sl_list.size();
  printf(" done integrations\n"); 
  printf("list size = %d\n", n);

	// ADD-BY-LEETEN 07/07/2010-BEGIN
    for(int i = 0; i < n; i++)
	{
		VECTOR4 v4Color;
#if 0
		switch((i/2)%7)
		{
		case 0: v4Color = VECTOR4(1.0f, 0.0f, 0.0f, 1.0f);	break;
		case 1: v4Color = VECTOR4(0.0f, 1.0f, 0.0f, 1.0f);	break;
		case 2: v4Color = VECTOR4(0.0f, 0.0f, 1.0f, 1.0f);	break;
		case 3: v4Color = VECTOR4(1.0f, 1.0f, 0.0f, 1.0f);	break;
		case 4: v4Color = VECTOR4(1.0f, 0.0f, 1.0f, 1.0f);	break;
		case 5: v4Color = VECTOR4(0.0f, 1.0f, 1.0f, 1.0f);	break;
		case 6: v4Color = VECTOR4(1.0f, 1.0f, 1.0f, 1.0f);	break;
		}
#else
		switch((i/2)%10)
		{
		case 0: v4Color = VECTOR4(164.f/255.f, 196.f/255.f, 0.0f, 1.0f);	break;
		case 1: v4Color = VECTOR4(96.f/255.f, 169.f/255.f, 23.f/255.f, 1.0f);	break;
		case 2: v4Color = VECTOR4(0, 138.f/255.f, 0, 1.0f);	break;
		case 3: v4Color = VECTOR4(0, 171.f/255.f, 169.f/255.f, 1.0f);	break;
		case 4: v4Color = VECTOR4(27.f/255.f, 161.f/255.f, 226.f/255.f, 1.0f);	break;
		case 5: v4Color = VECTOR4(0, 80.f/255.f, 239.f/255.f, 1.0f);	break;
		case 6: v4Color = VECTOR4(106.f/255.f, 0, 1.f, 1.0f);	break;
		case 7: v4Color = VECTOR4(170.f/255.f, 0, 1.f, 1.0f);	break;
		case 8: v4Color = VECTOR4(244.f/255.f, 114.f/255.f, 208.f/255.f, 1.0f);	break;
		case 9: v4Color = VECTOR4(216.f/255.f, 0, 115.f/255.f, 1.0f);	break;
		}
#endif
		liv4Colors.push_back(v4Color);
	}
	// ADD-BY-LEETEN 07/07/2010-END
	cLineRenderer._Update();
}
VECTOR4 IRenderPipeline3D::mFunction_VertexLighting(const VECTOR3& vPosW, const VECTOR3& vNormalW)
{
	//---------For Each Vertex, Perform Gouraud Shading------------

	VECTOR4 outColor = { 0.0f,0.0f,0.0f,1.0f };

	//traverse every lights
	for (UINT i = 0;i < c_maxLightCount;++i)
	{
		if (mDirLight[i].mIsEnabled == TRUE)
		{
			//normalized light vector
			VECTOR3 unitIncomingLightVec = mDirLight[i].mDirection;
			unitIncomingLightVec.Normalize();

			//vector from current vertex to Camera(Eye),used when compute specular
			VECTOR3 toEye = mCameraPos - vPosW;
			toEye.Normalize();

			//unit vertex normal
			VECTOR3 unitNormal = vNormalW;
			unitNormal.Normalize();

			//Ambient Color
			VECTOR3 currentAmbient = mMaterial.ambient* mDirLight[i].mAmbientColor * mMaterial.diffuse;

			//diffuse Factor (first make sure that angle <normal,light> is less than PI/2
			VECTOR3 currentDiffuse = { 0,0,0 };
			VECTOR3 currentSpecular = { 0,0,0 };

			float diffuseFactor = mDirLight[i].mDiffuseIntensity*Math::Vec3_Dot((-1)*unitIncomingLightVec, unitNormal);
			if (diffuseFactor > 0.0f)
			{
				//diffuse color (eye pos independent)
				currentDiffuse = diffuseFactor * mDirLight[i].mDiffuseColor;

				//if Texture Mapping is disabled, then use pure diffuse color of material
				if (m_pTexture == nullptr)
				{
					//component-wise
					currentDiffuse = currentDiffuse* mMaterial.diffuse;
				}
				//else the color will be passed down to pixel shader to multiply by 
				//per-pixel sample diffuse color


				//Specular color - eye position dependent
				/*VECTOR3 unitOutgoingLightVec = Vec3_Reflect(unitIncomingLightVec, unitNormal);
				float specFactor =
					mDirLight[i].mSpecularIntensity *
					pow(max(Vec3_Dot(unitOutgoingLightVec, toEye), 0.0f), mMaterial.specularSmoothLevel);

				//Vector3 * vector3 means component-wise mult , return vec3(x1*x2,y1*y2,z1*z2)
				currentSpecular = specFactor* mMaterial.specular * mDirLight[i].mSpecularColor;*/

			}

			VECTOR3 outColor3 = currentAmbient+currentDiffuse+currentSpecular;
			outColor += VECTOR4(outColor3.x, outColor3.y, outColor3.z, 0.0f);
		}
	}

	return outColor;
}
void 
CLineAnimatorInOpenGL::_TraversePoint(int iPointIndex, int iTraceIndex, float fX, float fY, float fZ, float fT)
{
	static list<int>::iterator liiParticleIterator;
	static VECTOR3 v3PrevPoint;
	static VECTOR3 v3PrevTangent;
	// ADD-BY-LEETEN 07/07/2010-BEGIN
	static VECTOR4 v4PrevColor;
	VECTOR4 v4Color = cColorScheme.V4GetColor();
	// ADD-BY-LEETEN 07/07/2010-END
	VECTOR3 v3Point(fX, fY, fZ);

	if( 0 == iPointIndex )
	{
		for(liiParticleIterator  = liParticles.begin();		
			liiParticleIterator != liParticles.end() && *liiParticleIterator < 0;
			liiParticleIterator++)
			;
	}

	VECTOR3 v3Tangent = v3Point - v3PrevPoint;
	v3Tangent.Normalize();

	if( liiParticleIterator != liParticles.end() && iPointIndex == *liiParticleIterator )
	{
		#if	0	// MOD-BY-LEETEN 07/05/2010-FROM:
			if( iPointIndex > 0 )
			{
				if( 1 == iPointIndex )
					glTexCoord3fv(&v3Tangent[0]);
				else
					glTexCoord3fv(&v3PrevTangent[0]);
				glVertex3fv(&v3PrevPoint[0]);

				glTexCoord3fv(&v3Tangent[0]);
				glVertex3fv(&v3Point[0]);
			}
		#else	// MOD-BY-LEETEN 07/05/2010-TO:
		if( 1 == iPointIndex )
			pv4TexCoords.push_back(VECTOR4(v3Tangent[0], v3Tangent[1], v3Tangent[2], 1.0));
		else
			pv4TexCoords.push_back(VECTOR4(v3PrevTangent[0], v3PrevTangent[1], v3PrevTangent[2], 1.0));
		pv4Coords.push_back(VECTOR4(v3PrevPoint[0], v3PrevPoint[1], v3PrevPoint[2], 1.0));
		// ADD-BY-LEETEN 07/07/2010-BEGIN
		pv4Colors.push_back(v4PrevColor);
		// ADD-BY-LEETEN 07/07/2010-END

		pv4TexCoords.push_back(VECTOR4(v3Tangent[0], v3Tangent[1], v3Tangent[2], 1.0));
		pv4Coords.push_back(VECTOR4(v3Point[0], v3Point[1], v3Point[2], 1.0));
		// ADD-BY-LEETEN 07/07/2010-BEGIN
		pv4Colors.push_back(v4Color);
		// ADD-BY-LEETEN 07/07/2010-END
		#endif	// MOD-BY-LEETEN 07/05/2010-END
		liiParticleIterator++;
		iNrOfRenderedParticles++;
	}

	// ADD-BY-LEETEN 07/07/2010-BEGIN
	cColorScheme._MoveToNextPoint();

	v4PrevColor = v4Color;
	// ADD-BY-LEETEN 07/07/2010-END
	v3PrevPoint = v3Point;
	v3PrevTangent = v3Tangent;
}