Ӧо
APPLICATION RESEARCH OF COMPUTERS
2000 Vol.17 No.3 P.66-68




OpenGLĳάû
ʯӢ
ժҪIntra3D ǻOpenGLĽʽάͼߣǼ˳ݽṹͼζά㷨ͼûC++COM⡣(1)üڴ(2)ڵάƣ(3)ûơ
ؼʣ ά û
1ǰ
OpenGLǹϹϵ3Dͼιҵ׼UnixPCƽ̨õ㷺Ӧ[1]OpenGLṩٸ⺯ɷػƾʵе3DͼΡʽ3DͼӦͼλֻһ֣Ĺڳݽṹͼζά㷨ͼûϡOpenGL봰ϵͳ޹أṩκνֶΣɳԱԼдеĽܡOpenGL ı̽ӿǵͼCṩɸ(Reuse)ĶӦóܣЧʲ[24]
Ƕ෽3DӲ[1,58]ɻOpenGLĽʽάͼIntra3D 2.0Intra3DĺǼ˳ݽṹͼζά㷨ͼûC++COM(Component Object Model)⣬֧Visual C++Visual BasicDelphiԵӦñ̡Intra3DĺĿĲ㴴һΪ뺯(Basic Objects and Functions)ڶΪͼζ(Graphical Objects)Ϊͼڵ㡱(Scene Graph and Nodes)ĲΪ뽻(Rendering and Interaction)ϵṹͼ1ʾи߲㹹õͲ㹹Ͳ㹹ø߲㹹Intra3D2.0׼Լ25ףĿ7C++ȫûԷ޸ںӦͬIntra3DֲOpenGLĲ㣬ڿٿPCƽ̨Ľʽ3DӦó

ͼ1Intra3K2.0Ŀϵṹ
2Intra3D ĿҪ빦
2.1뺯
òҪ빦ܣ(1)ڶüڴࣻ(2)ʸԪ㣬㷨(3)άʸݿӻͼεݱע(4)ͼԼӳ䣬֧BMPGIFJPEGSGITGAͼʽ(5)üͼԪĻƣ׶򡢻ȣ֧Swept壬Ļƣ(6)ṩ450ֲʡڵĲпԽʽ༭Щʡ
2.2ͼζ
ͼζܽתΪģͲԻƳ[9]Intra3D 2.0ṩͼζ(1)üζ糤塢׶塢Բ塢塢Բ塢Sweptȣ(2)ģͶ󣬿ڻAutodesk˾.3dsģͺWavefront˾.objģͣ(3)ֵͼζͼ״ͼͼͼͼͼͼͼͼȡͼζĿӦأûʹü̳зµͼζ󣬶Ӱ쵽Ĺ
2.3ͼڵ
ͼ(Scene Graph)޻ͼScene GraphҪڵУ(1)SceneNodeнڵĻࡣSceneNodeж˾ֲϵԼӦͼα任ڵĲͬĲʽʵά(2)ڵ(CameraNode)֧ƽͶӰ͸ͶӰֶ֧л(3)Դڵ֣ƽйԴڵ(DirLightNode)Դڵ(PointLightNode)׶Դڵ(SpotLightNode)(4)ڵ(ShapeNode)ͼζйͼζάShapeNode
2.4뽻
Intra3DĽࣺһǶ塢ԴֱӲһʵԵı༭Intra3DĳӴ(SceneView)װ˽ʽƵϸڣϢڵıơزݡ꽻ȡΪ˱ڱ༭ʵԣIntra3DһЩöԻʸԻ(FontDialog)ɫԻ(ColorDialog)ʿԻ(MaterialLibDialog)ʶԻ(MaterialDialog)ԴԻ(DirLightDialog, PointLightDialog, SpotLight Dialog)
3üڴ
еһЩڸӵùϵʱȷͷŶڴ潫úѡȫķöԼжϺʱͷڴ档Intra3D Containerṩüڴԭǣö󱣴һöʱ1ùϵʱȥ1Ϊ0öٱκζãʱöͿɾԼIntra3Dͼζ(GraphicalObject)볡ڵ(SceneNode)ContainerࡣContainerĶ£
class Container
{
public: 
Container(void){ m_cRefrenceCount=1; }
 // 󱻴ʱΪ 1 
void AddRef(void){ m_cRefrenceCount++; }
 // ʱ1 
void Release(void){ m_cRefrenceCount--; 
if(m_cRefrenceCount <= 0) 
{ FinalRelease(); 
delete this; // Ϊ0ɾ 
}
}
protected:
virtual void FinalRelease(void){ } // ඨΪ
int m_cRefrenceCount; // 
}
ABʱӦAAddRefùϵʱӦAReleaseһɾ֮ǰӦӦã˹FinalReleaseɡFinalRelease Protected ͵麯Ϊඨ塣
4ڵά
ͼѧУþʵͼα任44ξͿͳһľʾƽơת任ǾԱʾͼα任״̬̣ǰ󣬾޷жƽתǶ١ɼʹþ㲢㽻ʽ3Dͼϵͳ
Intra3DԪ(Quaternion)ʵת [10,11]ԪǸһչqΪһԪ飬qԱʾ£
q=w+xi+yj+zk=[x y z w]=(s,v)
s=w
v=[x y z]
һת任תΪu(λʸ)תǶΪȡת任ȼ۵ԪqΪ
q=(s, v)
s=cos(/2)
v=u sin(/2)
ת任ĺϳɿԪʾƷǳࡣԪ(x,y,z,w)ֱۣIntra3D ṩӼתṹROTATIONʾת任ʸתṹԪݽṹVECTORROTATIONQUATERNION£

Intra3D ĳڵSceneNodeʹתṹʾת任״̬ʸֱʾƽƱ任任״̬10Ϳȫȷͼα任״̬SceneNodeݽṹʾ
// ݳԱ
protected:
SceneNode*m_pParent// ڵ
Trackballm_trackball// 
VECTORm_position,m_oldPosition
VECTORm_scale,m_oldScale
ROTATIONm_rotation,m_oldRotation
...
Public: // ͼα任
Void SetPosition(float x, float y, float z)
Void SetRotation(float angle, float nx, float ny, float nz)
Void SetScale(float sx, float sy, float sz)
Void Translate(VECTOR trans)
Void Rotate(float angle, VECTOR axis)
Void Scale(float sx, float sy, float sz)
Void ResetTransform(void)
Void TranslateInCamera(VECTOR trans)
Void RotateInCamera(float angle, VECTOR axis)
...
m_positionm_rotationm_scaleֱʾýڵڸڵϵеλתm_oldPosition m_oldRotationm_oldScaleڼ¼ԭʼ״̬ڻָԭ״SceneNodeʮͼα任ûԳڵֱ϶תȲ
5û
Intra3DĳӴSceneViewڿٴʽ3DӦó档SceneView֧SelectingScalingRotatingTranslatingCreatingDeletingʮֲṩڽͼ2ʾ3DӦóķͼ3ʾIntra3D COMеSceneViewһActiveXؼVisual BasicDelphiȱԿӻķʽ3DӦóĿܡ

ͼ2ֱӲά

ͼ3Intra3DӦóʾ
Ϊ˱༭ʵԣڶԻл3D ͼΡMicrosoftĴϵͳṩ3DĶԻڡʹIntra3DWindow3DڶԻд3DӴͼ4ĲʶԻͼ5ĲʿԻʹWindow3Dɫ༭3DͼγõĽԴı༭ʵͨıɫʵֵġҪɫ༭Ľ漰HSVRGBģʽɫתIntġ뽻㡱ʵЩ㣬ṩɫĻ꽻ͼ6ͼ7ʾˡԴԻ͡ɫԻ

ͼ4ʶԻͼ5ƲÿԻ

ͼ6ԴԻͼ7ɫԻ
6С
Intra3D кϹ飬PCӦõĽʽάͼߣ2.0ѾʹáIntra3D2.0׼鼮ʽάͼμơĵĵõʼ Intra3D@ hotmail.com , Intra3D@163.net ϵȡ
(㽭ѧCAD&CGصʵ  310027)
ʯӢ(㽭ѧCAD&CGصʵ  310027)
ο
1 Andries Van Dam and Dick Puk. The History of Computer Graphics Standards Development,Computer Graphics, pp3438, February 1998
2 Mark J.Kilgard. OpenGL Programming for the X Window System, Addison-Wesley, 1996
3 Tom McReynolds and David Blythe. Advanced Graphics Programming Techniques Using OpenGL, SIGGRAPH `98 Course
4 Brian Paul, OpenGL and Window System Integration, Siggraph'97 Course 24, August 6, 1997
5 D. Wang, I. Herman and G.J.Reynolds, The Open Inventor Toolkit and the PREMO Standard, Computer Graphics Forum, Vol.16, No.4, pp159-175,1997
6 David B. Kirk. Interactive 3D Graphics for the Masses, Computer Graphics, pp6264,February 1998
7 Edward Angel. Teaching a Three-Dimensional Computer Graphics Course Using OpenGL, Computer Graphics, pp5455, August 1997
8 Chris Hand. A Survey of 3D Interaction Techniques, Computer Graphics Forum, Vol.16, No.5, pp269281,1997
9 Jonas Gomes, Bruno Costa and Lucia Darsa, Graphical Objects, The Visual Computer (1996)12:269282
10 Loaura Downs, Using Quaternions to Represent Rotation, http://www.cs.berkeley.edu/laura, 1998
11 Donald Hearn and M. Pauline Baker, Computer Graphics C Version , Prentice Hall, 1997
ոڣ19991025
