File: SceneObject.h

package info (click to toggle)
mygui 3.4.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 38,800 kB
  • sloc: cpp: 122,825; ansic: 30,231; xml: 15,792; cs: 12,601; tcl: 776; python: 397; makefile: 38
file content (79 lines) | stat: -rw-r--r-- 2,065 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*!
	@file
	@author		Albert Semenov
	@date		12/2009
*/

#ifndef SCENE_OBJECT_H_
#define SCENE_OBJECT_H_

#ifdef MYGUI_OGRE_PLATFORM

#include <OgrePrerequisites.h>

namespace demo
{

	class SceneObject
	{
	public:
		SceneObject();
		virtual ~SceneObject();

	public:
		void setEntity(const std::string& _value);
		void setMaterial(const std::string& _value);
		void setSceneManager(const std::string& _value);
		void setCamera(const std::string& _value);

	protected:
		void setTextureName(const std::string& _name);

		bool pickPositionInObject(int& _x, int& _y, int _view_width, int _view_height, int _texture_width, int _texture_height) const;

	private:
		// Code found in Wiki: www.ogre3d.org/wiki/index.php/RetrieveVertexData
		void GetMeshInformation(
			const Ogre::MeshPtr mesh,
			size_t& vertex_count,
			Ogre::Vector3* &vertices,
			size_t& index_count,
			unsigned long* &indices,
			Ogre::Vector2* &coords,
			const Ogre::Vector3& position,
			const Ogre::Quaternion& orient,
			const Ogre::Vector3& scale,
			const std::string& _material);
		void clear();

		bool isIntersectMesh(int& _x, int& _y, const Ogre::Ray& _ray, int _texture_width, int _texture_height) const;
		Ogre::Vector2 getCoordByTriangle(Ogre::Vector3 _position, const Ogre::Vector3& _corner0, const Ogre::Vector3& _corner1, const Ogre::Vector3& _corner2) const;
		Ogre::Vector2 getCoordByRel(Ogre::Vector2 _position, const Ogre::Vector2& _corner0, const Ogre::Vector2& _corner1, const Ogre::Vector2& _corner2) const;

		void updateData();

		Ogre::SceneManager* getSceneManager() const;
		Ogre::Camera* getCamera() const;

	private:
		Ogre::Vector2* mTextureCoords;
		Ogre::Vector3* mVertices;
		unsigned long* mIndices;
		size_t mVertexCount;
		size_t mIndexCount;
		float mUScale;
		float mVScale;
		mutable Ogre::RaySceneQuery* mRaySceneQuery;
		std::string mEntityName;
		std::string mMaterialName;
		std::string mTextureName;
		std::string mSceneManager;
		std::string mCamera;
		Ogre::TextureUnitState* mTextureUnit;
	};

} // namespace demo

#endif

#endif // SCENE_OBJECT_H_