Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F9501351
FROG_Primitives.cpp
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
FROG_Primitives.cpp
View Options
#include
"FROG_Primitives.h"
#ifdef FROG_OPENGL
void
SetNormal
(
float
C1X
,
float
C1Y
,
float
C1Z
,
float
C2X
,
float
C2Y
,
float
C2Z
,
float
C3X
,
float
C3Y
,
float
C3Z
){
#
ifdef
FROG_LIGHTING
float
X
=
(
C1Y
-
C2Y
)
*
(
C2Z
-
C3Z
)
-
(
C1Z
-
C2Z
)
*
(
C2Y
-
C3Y
);
float
Y
=
(
C1Z
-
C2Z
)
*
(
C2X
-
C3X
)
-
(
C1X
-
C2X
)
*
(
C2Z
-
C3Z
);
float
Z
=
(
C1X
-
C2X
)
*
(
C2Y
-
C3Y
)
-
(
C1Y
-
C2Y
)
*
(
C2X
-
C3X
);
float
N
=
sqrt
(
X
*
X
+
Y
*
Y
+
Z
*
Z
);
X
/=
N
;
Y
/=
N
;
Z
/=
N
;
glNormal3f
(
X
,
Y
,
Z
);
#
endif
}
void
DrawNormal
(
float
C1X
,
float
C1Y
,
float
C1Z
,
float
C2X
,
float
C2Y
,
float
C2Z
,
float
C3X
,
float
C3Y
,
float
C3Z
){
/*
glBegin (GL_TRIANGLES);
glVertex3f (C1X,C1Y,C1Z);
glVertex3f (C2X,C2Y,C2Z);
glVertex3f (C3X,C3Y,C3Z);
glEnd();
*/
float
X
=
(
C1Y
-
C2Y
)
*
(
C2Z
-
C3Z
)
-
(
C1Z
-
C2Z
)
*
(
C2Y
-
C3Y
);
float
Y
=
(
C1Z
-
C2Z
)
*
(
C2X
-
C3X
)
-
(
C1X
-
C2X
)
*
(
C2Z
-
C3Z
);
float
Z
=
(
C1X
-
C2X
)
*
(
C2Y
-
C3Y
)
-
(
C1Y
-
C2Y
)
*
(
C2X
-
C3X
);
float
N
=
sqrt
(
X
*
X
+
Y
*
Y
+
Z
*
Z
);
N
/=
25
;
X
/=
N
;
Y
/=
N
;
Z
/=
N
;
glColor3f
(
0
,
1
,
0
);
glBegin
(
GL_LINES
);
glVertex3f
((
C1X
+
C2X
+
C3X
)
/
3
,(
C1Y
+
C2Y
+
C3Y
)
/
3
,(
C1Z
+
C2Z
+
C3Z
)
/
3
);
//+++
glVertex3f
((
C1X
+
C2X
+
C3X
)
/
3
+
X
,(
C1Y
+
C2Y
+
C3Y
)
/
3
+
Y
,(
C1Z
+
C2Z
+
C3Z
)
/
3
+
Z
);
//+-+
glEnd
();
}
void
DrawCube
(
float
C1X
,
float
C1Y
,
float
C1Z
,
float
C2X
,
float
C2Y
,
float
C2Z
,
float
C3X
,
float
C3Y
,
float
C3Z
,
float
C4X
,
float
C4Y
,
float
C4Z
,
float
C5X
,
float
C5Y
,
float
C5Z
,
float
C6X
,
float
C6Y
,
float
C6Z
,
float
C7X
,
float
C7Y
,
float
C7Z
,
float
C8X
,
float
C8Y
,
float
C8Z
){
glBegin
(
GL_QUADS
);
SetNormal
(
C1X
,
C1Y
,
C1Z
,
C4X
,
C4Y
,
C4Z
,
C3X
,
C3Y
,
C3Z
);
glVertex3f
(
C1X
,
C1Y
,
C1Z
);
//+++
glVertex3f
(
C4X
,
C4Y
,
C4Z
);
//+-+
glVertex3f
(
C3X
,
C3Y
,
C3Z
);
//--+
glVertex3f
(
C2X
,
C2Y
,
C2Z
);
//-++
SetNormal
(
C5X
,
C5Y
,
C5Z
,
C6X
,
C6Y
,
C6Z
,
C7X
,
C7Y
,
C7Z
);
glVertex3f
(
C5X
,
C5Y
,
C5Z
);
//++-
glVertex3f
(
C6X
,
C6Y
,
C6Z
);
//-+-
glVertex3f
(
C7X
,
C7Y
,
C7Z
);
//---
glVertex3f
(
C8X
,
C8Y
,
C8Z
);
//+--
SetNormal
(
C1X
,
C1Y
,
C1Z
,
C2X
,
C2Y
,
C2Z
,
C6X
,
C6Y
,
C6Z
);
glVertex3f
(
C1X
,
C1Y
,
C1Z
);
//+++
glVertex3f
(
C2X
,
C2Y
,
C2Z
);
//-++
glVertex3f
(
C6X
,
C6Y
,
C6Z
);
//-+-
glVertex3f
(
C5X
,
C5Y
,
C5Z
);
//++-
SetNormal
(
C4X
,
C4Y
,
C4Z
,
C8X
,
C8Y
,
C8Z
,
C7X
,
C7Y
,
C7Z
);
glVertex3f
(
C4X
,
C4Y
,
C4Z
);
//+-+
glVertex3f
(
C8X
,
C8Y
,
C8Z
);
//+--
glVertex3f
(
C7X
,
C7Y
,
C7Z
);
//---
glVertex3f
(
C3X
,
C3Y
,
C3Z
);
//--+
SetNormal
(
C1X
,
C1Y
,
C1Z
,
C5X
,
C5Y
,
C5Z
,
C8X
,
C8Y
,
C8Z
);
glVertex3f
(
C1X
,
C1Y
,
C1Z
);
//+++
glVertex3f
(
C5X
,
C5Y
,
C5Z
);
//++-
glVertex3f
(
C8X
,
C8Y
,
C8Z
);
//+--
glVertex3f
(
C4X
,
C4Y
,
C4Z
);
//+-+
SetNormal
(
C2X
,
C2Y
,
C2Z
,
C3X
,
C3Y
,
C3Z
,
C7X
,
C7Y
,
C7Z
);
glVertex3f
(
C2X
,
C2Y
,
C2Z
);
//-++
glVertex3f
(
C3X
,
C3Y
,
C3Z
);
//--+
glVertex3f
(
C7X
,
C7Y
,
C7Z
);
//---
glVertex3f
(
C6X
,
C6Y
,
C6Z
);
//-+-
glEnd
();
/*
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(0,100);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin (GL_QUADS);
SetNormal(C1X,C1Y,C1Z,C4X,C4Y,C4Z,C3X,C3Y,C3Z);
glVertex3f (C1X,C1Y,C1Z); //+++
glVertex3f (C4X,C4Y,C4Z); //+-+
glVertex3f (C3X,C3Y,C3Z); //--+
glVertex3f (C2X,C2Y,C2Z); //-++
SetNormal(C5X,C5Y,C5Z,C6X,C6Y,C6Z,C7X,C7Y,C7Z);
glVertex3f (C5X,C5Y,C5Z); //++-
glVertex3f (C6X,C6Y,C6Z); //-+-
glVertex3f (C7X,C7Y,C7Z); //---
glVertex3f (C8X,C8Y,C8Z); //+--
SetNormal(C1X,C1Y,C1Z,C2X,C2Y,C2Z,C6X,C6Y,C6Z);
glVertex3f (C1X,C1Y,C1Z); //+++
glVertex3f (C2X,C2Y,C2Z); //-++
glVertex3f (C6X,C6Y,C6Z); //-+-
glVertex3f (C5X,C5Y,C5Z); //++-
SetNormal(C4X,C4Y,C4Z,C8X,C8Y,C8Z,C7X,C7Y,C7Z);
glVertex3f (C4X,C4Y,C4Z); //+-+
glVertex3f (C8X,C8Y,C8Z); //+--
glVertex3f (C7X,C7Y,C7Z); //---
glVertex3f (C3X,C3Y,C3Z); //--+
SetNormal(C1X,C1Y,C1Z,C5X,C5Y,C5Z,C8X,C8Y,C8Z);
glVertex3f (C1X,C1Y,C1Z); //+++
glVertex3f (C5X,C5Y,C5Z); //++-
glVertex3f (C8X,C8Y,C8Z); //+--
glVertex3f (C4X,C4Y,C4Z); //+-+
SetNormal(C2X,C2Y,C2Z,C3X,C3Y,C3Z,C7X,C7Y,C7Z);
glVertex3f (C2X,C2Y,C2Z); //-++
glVertex3f (C3X,C3Y,C3Z); //--+
glVertex3f (C7X,C7Y,C7Z); //---
glVertex3f (C6X,C6Y,C6Z); //-+-
glEnd();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
*/
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Feb 23, 2:22 PM (7 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4486536
Default Alt Text
FROG_Primitives.cpp (3 KB)
Attached To
rFROGSVN frogsvn
Event Timeline
Log In to Comment