Click here to Skip to main content
15,888,984 members
Home / Discussions / Article Writing
   

Article Writing

 
GeneralRe: Simple Text Based Machine Tutorial Needed Pin
Sebastián Benítez23-Dec-03 3:40
Sebastián Benítez23-Dec-03 3:40 
GeneralUtilityLibrary Pin
GlennDeBacker29-Nov-03 15:18
GlennDeBacker29-Nov-03 15:18 
GeneralRe: UtilityLibrary Pin
J. Dunlap29-Nov-03 17:17
J. Dunlap29-Nov-03 17:17 
GeneralSyntaxEditor Pin
Thommy Mewes25-Nov-03 13:35
Thommy Mewes25-Nov-03 13:35 
GeneralRe: SyntaxEditor Pin
Niels Penneman8-Jan-04 10:54
Niels Penneman8-Jan-04 10:54 
GeneralRe: SyntaxEditor Pin
Werdna15-Feb-04 17:00
Werdna15-Feb-04 17:00 
Generalopengl rotation Pin
Member 70457324-Nov-03 5:34
Member 70457324-Nov-03 5:34 
GeneralRe: opengl rotation Pin
suiram4025-Nov-03 8:16
suiram4025-Nov-03 8:16 
I have these excerpts from my code:
Is little bit more complicated:


WM_CREATE:
GetWindowRect(hMainWnd, &rw);
pc.x = (rw.right-rw.left)/2;
pc.y = (rw.bottom-rw.top)/2;
SetCursorPos(pc.x,pc.y);



#define BLOCKRANGE(a) if(a < - PIPE2-EPSILON) a =-
(PIPE2-EPSILON); \
else if (a > PIPE2-EPSILON) a =
PIPE2-EPSILON; // blocks the
range of angle to straight up/down

struct V3{
float x,y,z;
};
struct M4 {float m[4][4];};

class Camera:
{

V3 _angles; //euler angles (azimuth, elevation and roll)
V3 _lup; //up vector
V3 _lside; // side vector
V3 _lup; // up vector;
V3 _lpos; // camera position in space

void AnglesToDir()
{
REAL CosAz = COS(_angles.y);
REAL CosEl = COS(_angles.x);
REAL SinAz = SIN(_angles.y);
REAL SinEl = SIN(_angles.x);
REAL CosRl = COS(_angles.z);
REAL SinRl = SIN(_angles.z);
_ldir.x = SinAz * CosEl;
_ldir.y = SinEl;
_ldir.z = CosEl * -CosAz;
_lup.x = -CosAz * SinRl - SinAz * SinEl * CosRl;
_lup.y = CosEl * CosRl;
_lup.z = -SinAz * SinRl - SinEl * CosRl * -CosAz;
_lside = VCp(_ldir, _lup);
}

void Rotate(REAL a, REAL e, REAL r)
{
_angles.y += a;
_angles.x -= e;
_angles.z += r;
//ROLLPI(_angles.y);
BLOCKRANGE(_angles.x);
AnglesToDir();
}


}


static M4 MLook(V3& eye, V3& fwd, V3& up, V3& side)
{
M4 mret;
mret[0][0] = side.x; mret[1][0] = side.y; mret[2][0] = side.z; mret[3][0] = 0.0;
mret[0][1] = up.x; mret[1][1] = up.y; mret[2][1] = up.z; mret[3][1] = 0.0;
mret[0][2] = -fwd.x; mret[1][2] = -fwd.y; mret[2][2] = -fwd.z; mret[3][2] = 0.0;
mret[0][3] = 0.0; mret[1][3] = 0.0; mret[2][3] = 0.0; mret[3][3] = 1.0;
mret *= MTranslate(-eye.x, -eye.y, -eye.z);
return mret;
}


then you do:


void Your_RenderScene()
{
Camera cam;

//position

cam._wpos.x= YOUR_XPOS;
cam._wpos.y= YOUR_YPOS;
cam._wpos.z= YOUR_ZPOS;

//rotate
POINT pct;
GetCursorPos(&pct);
int dx = pct.x - pc.x;
int dy = pct.y - pc.y;
cam.Rotate((REAL)dx/128.f,(REAL)dy/128.f,0);
SetCursorPos(pc.x,pc.y);

// transform
cam.AnglesToDir();
M4 tm = MLook(cam._wpos, cam._ldir, cam._lup, cam._lside);
glPushMatrix();
glLoadMatrixf((REAL *)&tm);
//////render your object here
glPopMareix();

}
GeneralFocus grabber Pin
Paul Watson20-Nov-03 5:19
sitebuilderPaul Watson20-Nov-03 5:19 
GeneralRe: Focus grabber Pin
Erik Thompson20-Nov-03 13:50
sitebuilderErik Thompson20-Nov-03 13:50 
GeneralSplash screens Pin
Paul Watson20-Nov-03 20:27
sitebuilderPaul Watson20-Nov-03 20:27 
GeneralRe: Splash screens Pin
J. Dunlap20-Nov-03 20:56
J. Dunlap20-Nov-03 20:56 
GeneralRe: Focus grabber Pin
Michael Dunn21-Nov-03 4:35
sitebuilderMichael Dunn21-Nov-03 4:35 
GeneralRe: Focus grabber Pin
Paul Watson21-Nov-03 11:02
sitebuilderPaul Watson21-Nov-03 11:02 
GeneralRe: Focus grabber Pin
Michael Dunn21-Nov-03 11:17
sitebuilderMichael Dunn21-Nov-03 11:17 
Generaldeveloping an IVR Pin
sahibzada12-Nov-03 8:24
sahibzada12-Nov-03 8:24 
GeneralRe: developing an IVR Pin
Michael P Butler20-Nov-03 5:50
Michael P Butler20-Nov-03 5:50 
GeneralRe: developing an IVR Pin
Monty218-Dec-03 20:00
Monty218-Dec-03 20:00 
GeneralGeneric GUI with multiple test servers. Pin
Mike Pulice11-Nov-03 8:10
Mike Pulice11-Nov-03 8:10 
GeneralRe: Generic GUI with multiple test servers. Pin
Andrew Walker12-Nov-03 18:49
Andrew Walker12-Nov-03 18:49 
GeneralPort Architecture USB\COMM Pin
Mike Pulice11-Nov-03 8:03
Mike Pulice11-Nov-03 8:03 
GeneralRe: Port Architecture USB\COMM Pin
mhmoud rawas15-Nov-03 18:29
mhmoud rawas15-Nov-03 18:29 
GeneralRe: Port Architecture USB\COMM Pin
closecall20-Nov-03 14:46
closecall20-Nov-03 14:46 
QuestionX10 Developers? Pin
ivankslee10-Nov-03 8:07
ivankslee10-Nov-03 8:07 
AnswerRe: X10 Developers? Pin
MultiThread10-Nov-03 17:56
MultiThread10-Nov-03 17:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.