xref: /haiku/src/apps/glteapot/GLObject.h (revision 25a7b01d15612846f332751841da3579db313082)
1c8c44fa0SJérôme Duval /*
2552bd60cSAlexandre Deckner  * Copyright 2008 Haiku Inc. All rights reserved.
3552bd60cSAlexandre Deckner  * Distributed under the terms of the MIT License.
4552bd60cSAlexandre Deckner  *
5552bd60cSAlexandre Deckner  * Authors:
6552bd60cSAlexandre Deckner  *		Alexandre Deckner
7552bd60cSAlexandre Deckner  *
8552bd60cSAlexandre Deckner  */
9552bd60cSAlexandre Deckner 
10552bd60cSAlexandre Deckner /*
11552bd60cSAlexandre Deckner  * Original Be Sample source modified to use a quaternion for the object's orientation
12552bd60cSAlexandre Deckner  */
13552bd60cSAlexandre Deckner 
14552bd60cSAlexandre Deckner /*
15c8c44fa0SJérôme Duval 	Copyright 1999, Be Incorporated.   All Rights Reserved.
16c8c44fa0SJérôme Duval 	This file may be used under the terms of the Be Sample Code License.
17c8c44fa0SJérôme Duval */
18552bd60cSAlexandre Deckner 
19be98a602SStefano Ceccherini #ifndef GL_OBJECT_H
20be98a602SStefano Ceccherini #define GL_OBJECT_H
21c8c44fa0SJérôme Duval 
22c8c44fa0SJérôme Duval #include "ObjectView.h"
23be98a602SStefano Ceccherini #include "util.h"
24552bd60cSAlexandre Deckner #include "Quaternion.h"
25c8c44fa0SJérôme Duval 
26c8c44fa0SJérôme Duval struct point {
27c8c44fa0SJérôme Duval 	float x,y,z;
28c8c44fa0SJérôme Duval 	float nx,ny,nz;
29c8c44fa0SJérôme Duval 	float tu,tv;
30c8c44fa0SJérôme Duval };
31c8c44fa0SJérôme Duval 
32c8c44fa0SJérôme Duval struct tri {
33c8c44fa0SJérôme Duval 	int p1,p2,p3;
34c8c44fa0SJérôme Duval };
35c8c44fa0SJérôme Duval 
36c8c44fa0SJérôme Duval struct quadStrip {
37c8c44fa0SJérôme Duval 	int numpts;
38c8c44fa0SJérôme Duval 	int *pts;
39c8c44fa0SJérôme Duval };
40c8c44fa0SJérôme Duval 
41c8c44fa0SJérôme Duval 
42c8c44fa0SJérôme Duval class GLObject {
43c8c44fa0SJérôme Duval 	public:
44c8c44fa0SJérôme Duval 						GLObject(ObjectView* ov);
45c8c44fa0SJérôme Duval 		virtual			~GLObject();
46c8c44fa0SJérôme Duval 		virtual void	Draw(bool forID, float IDcolor[]);
47552bd60cSAlexandre Deckner 
48c8c44fa0SJérôme Duval 		virtual bool	SpinIt();
49552bd60cSAlexandre Deckner 		void			Spin(float rx, float ry);
50552bd60cSAlexandre Deckner 		void 			RotateWorldSpace(float rx, float ry);
51c8c44fa0SJérôme Duval 		virtual void	MenuInvoked(BPoint point);
DoDrawing(bool forID)52c8c44fa0SJérôme Duval 		virtual void	DoDrawing(bool forID) {};
53552bd60cSAlexandre Deckner 		int				Solidity() const;
54be98a602SStefano Ceccherini 
55be98a602SStefano Ceccherini 		float			x, y, z;
56552bd60cSAlexandre Deckner 		Quaternion		fRotation;
57450bb3e5SStephan Aßmus 
58450bb3e5SStephan Aßmus 	protected:
59552bd60cSAlexandre Deckner 
60552bd60cSAlexandre Deckner 		float			spinX, spinY;
61552bd60cSAlexandre Deckner 		int				solidity;
62450bb3e5SStephan Aßmus 		int				color;
63be98a602SStefano Ceccherini 		bool			changed;
64450bb3e5SStephan Aßmus 
65450bb3e5SStephan Aßmus 	private:
66450bb3e5SStephan Aßmus 		ObjectView*		fObjView;
67c8c44fa0SJérôme Duval };
68c8c44fa0SJérôme Duval 
69c8c44fa0SJérôme Duval class TriangleObject : public GLObject {
70c8c44fa0SJérôme Duval 	public:
71*1bc51c23SAleksas Pantechovskis 							TriangleObject(ObjectView* ov);
72c8c44fa0SJérôme Duval 		virtual				~TriangleObject();
73*1bc51c23SAleksas Pantechovskis 		status_t			InitCheck() const;
74c8c44fa0SJérôme Duval 		virtual void		DoDrawing(bool forID);
75be98a602SStefano Ceccherini 
76450bb3e5SStephan Aßmus 	private:
77*1bc51c23SAleksas Pantechovskis 		status_t				fStatus;
78450bb3e5SStephan Aßmus 		BufferArray<point>		fPoints;
79450bb3e5SStephan Aßmus 		BufferArray<tri>		fTriangles;
80450bb3e5SStephan Aßmus 		BufferArray<quadStrip>	fQs;
81c8c44fa0SJérôme Duval };
82be98a602SStefano Ceccherini 
83be98a602SStefano Ceccherini #endif // GL_OBJECT_H
84