• Create Account

# AhmedSaleh

Member Since 27 Nov 2001
Offline Last Active Mar 24 2014 03:18 AM

### In Topic: Projecting a Quad from light source and Normal Vector

17 March 2014 - 09:14 AM

Hi Kryzon,

I'm trying to translate the quad based on my how much my charterer has leaned towards the light direction. So I had the dot product between light direction and up vector, then I tried to use that value to scale up two vertices of a quad, but it doesn't work at all. When I stop lighting in the scene, I still get cosine angles from the dot product.

float leaningAngle = Mathf.Abs(Vector3.Dot(lightDir.normalized, mUp.GetVector3().normalized));
Global.Log("leaningAngle" + leaningAngle);

// leaning left
if (mLean > 0 && lerp < 0)
{
vertexLeftOffset = mLean; // squeeze left side
vertexRightOffset = leaningAngle; // extend the other side

}

// right leaning
if (mLean < 0 && lerp < 0)
{

vertexRightOffset = mLean; // squeeze right side quad
vertexLeftOffset = leaningAngle; // scale the shadow based on light's direction, left side

}

Vector3 vxPos1Top = pos + rot * (new Vector3(-offsetX + vertexLeftOffset, 0, offsetY) * scale); // 1,2 vertices or on its left
Vector3 vxPos2Top = pos + rot * (new Vector3(-offsetX + vertexLeftOffset, 0, -offsetY) * scale);
Vector3 vxPos3Top = pos + (mForward.GetVector3().normalized * mMiddleVerticesScale; // two middle vertices
Vector3 vxPos4Top = pos - (mForward.GetVector3().normalized * mMiddleVerticesScale;
Vector3 vxPos5Top = pos + rot * (new Vector3(offsetX + vertexRightOffset, 0, offsetY) * scale); // 5,6 vertices are on the right of the bikeer
Vector3 vxPos6Top = pos + rot * (new Vector3(offsetX + vertexRightOffset, 0, -offsetY) * scale);

### In Topic: Drawing a singular (or selection of) pixel(s) onto a screen using SDL2

13 March 2014 - 03:17 AM

This was my reference to write a software rasterizer:

http://joshbeam.com/articles/triangle_rasterization

### In Topic: Implementing bicycle audio

12 March 2014 - 08:31 AM

How about getting the reverse ? when the bike settles or decelerating? it should clicks in reverse ?
doesn't hear nice :/

clickCounter += mBiker.BikeRunner.Speed;

if (clickCounter < clickRate)
{
if (!mRunningSound.IsPlaying)
{
mRunningSound.Play();
}

clickCounter -= clickRate;
}

### In Topic: Implementing bicycle audio

12 March 2014 - 04:25 AM

That's really the idea of a basic wheel encoder, where you count the ticks of the wheel, correct?

What are your suggestions to make it better?

### In Topic: Implementing bicycle audio

11 March 2014 - 05:24 PM

would you tell me the idea in plain example ? the maths ?

I wanted to do if ( counter++>period) play, then make counter = 0;  is that wrong ?  why did you accumulate the speed then you subtract the rate from it ?

this is not linear operation correct?

PARTNERS