Jump to content

  • Log In with Google      Sign In   
  • Create Account

TiagoCosta

Member Since 26 Nov 2008
Online Last Active Today, 09:58 AM

Posts I've Made

In Topic: what's the principle behind the shader debugger?

Yesterday, 12:22 PM

Renderdoc is open source and includes a shader debugger. Might be a good starting point for you.


In Topic: particles system in HLSL & renderMonkey

Yesterday, 03:48 AM

Post screenshots...


In Topic: how to make a 3D Objbect move in circle?

19 October 2014 - 08:45 AM

Use the modified function I wrote on reply #4 getPositionInSphereD3D.


In Topic: how to make a 3D Objbect move in circle?

19 October 2014 - 08:29 AM

You're resetting the angle to 0 every update, that's why it doesn't change. Move angle to the class definition and only initialize it to 0 in the constructor.
 

class Lazer
{
    [...]
    float angle;
};

Laser::Laser() : angle(0.0f)
{
    [...]
}

void Lazer::UpdateLazer(float dt)
{
    angle += dt*D3DX_PI / 4; //rotate 45 degrees per seconds

    [...]
}

In Topic: how to make a 3D Objbect move in circle?

19 October 2014 - 07:49 AM

image001.gif
 
Follow this image. p is the radius, θ (theta) azimuthal angle, and φ (phi) polar angle.
The angles are in radians.
 
So if you want the object to move in a circle on the xy-plane:
Set the φ to π/2 (pi/2) and update θ each frame:
 



void Object::UpdateObject(float dt)
{
    angle += dt*PI/4; //rotate 45 degrees per seconds

    if(angle > 2*PI)
       angle -= 2*PI;

    ObjectPos = getPositionInSphere(sphere_center, radius, angle ,PI/2);
    D3DXMatrixTranslation(&matTrans, ObjectPos.x, ObjectPos.y, ObjectPos.z);

    [...]
}

EDIT #1: 

BTW, you might have to switch the coordinates in the function getPositionInSphere if you're using a different coordinate system.
 
For the typical D3D left-hand coordinate system:

Vector3 getPositionInSphereD3D(Vector3 sphere_center, float radius, float theta, float phi)
{
    return Vector3(sphere_center.x + radius * sin(phi) * sin(theta),
                   sphere_center.y + radius * cos(phi),
                   sphere_center.z + radius * sin(phi) * cos(theta));
}

 
EDIT #2:
 
Since you only want to move in a circle (phi is constant PI/2), the function turns into polar coordinates:
 

Vector3 getPositionInCircleD3D(Vector3 sphere_center, float radius, float theta)
{
    return Vector3(sphere_center.x + radius * sin(theta),
                   sphere_center.y,
                   sphere_center.z + radius * cos(theta));
}

PARTNERS