• R/O
  • SSH
  • HTTPS

vima19: Commit


Commit MetaInfo

Revisión2544 (tree)
Tiempo2023-09-25 05:05:49
Autorhgtterry

Log Message

GameDirectorSB 24-09-23 [v1.26] Object Picking

Cambiar Resumen

Diferencia incremental

--- WorldEditor/WorldEditor/AB_App.cpp (revision 2543)
+++ WorldEditor/WorldEditor/AB_App.cpp (revision 2544)
@@ -97,6 +97,7 @@
9797 CLSB_Physics = nullptr;
9898 CLSB_Environment = nullptr;
9999 CLSB_SoundMgr = nullptr;
100+ CLSB_Picking = nullptr;
100101
101102 AppBackground = NULL;
102103 BlackBrush = NULL;
@@ -299,7 +300,8 @@
299300 CLSB_Physics = new SB_Physics();
300301 CLSB_Environment = new SB_Environment();
301302 CLSB_SoundMgr = new SB_SoundMgr();
302-
303+
304+
303305 InitCommonControls();
304306
305307 hInst =NULL;
@@ -422,6 +424,14 @@
422424 }
423425
424426 // *************************************************************************
427+// * Beep_Win:- Terry and Hazel Flanigan 2023 *
428+// *************************************************************************
429+void SB_App::Beep_Win()
430+{
431+ Beep(440, 100);
432+}
433+
434+// *************************************************************************
425435 // * Say_Int:- Terry and Hazel Flanigan 2023 *
426436 // *************************************************************************
427437 void SB_App::Say_Int(int Value)
--- WorldEditor/WorldEditor/AB_App.h (revision 2543)
+++ WorldEditor/WorldEditor/AB_App.h (revision 2544)
@@ -99,6 +99,7 @@
9999 #include "SB_Physics.h"
100100 #include "SB_Environment.h"
101101 #include "SB_SoundMgr.h"
102+#include "SB_Picking.h"
102103
103104 class SB_App
104105 {
@@ -176,8 +177,8 @@
176177 SB_Physics* CLSB_Physics;
177178 SB_Environment* CLSB_Environment;
178179 SB_SoundMgr* CLSB_SoundMgr;
180+ SB_Picking* CLSB_Picking;
179181
180-
181182 bool InitApp(void);
182183 void InitMFC(void);
183184
@@ -186,6 +187,7 @@
186187
187188 void Start_Dialogs();
188189
190+ void Beep_Win();
189191 void Say(const char* Message, char* Message2 = NULL);
190192 void Say_Int(int Value);
191193 void Say_Float(float Value);
--- WorldEditor/WorldEditor/A_File.cpp (revision 2543)
+++ WorldEditor/WorldEditor/A_File.cpp (revision 2544)
@@ -339,7 +339,7 @@
339339
340340 AddCameraEntityToLevel();
341341
342- App->m_pDoc->DoGeneralSelect();
342+ App->CLSB_Doc->DoGeneralSelect();
343343
344344 return GE_TRUE;
345345 LoadError:
--- WorldEditor/WorldEditor/A_TabsTemplates_Dlg.cpp (revision 2543)
+++ WorldEditor/WorldEditor/A_TabsTemplates_Dlg.cpp (revision 2544)
@@ -180,7 +180,7 @@
180180
181181 }
182182
183- App->m_pDoc->DoGeneralSelect();
183+ App->CLSB_Doc->DoGeneralSelect();
184184
185185 App->CL_World->Reset_Editor();
186186
--- WorldEditor/WorldEditor/A_TextureDialog.cpp (revision 2543)
+++ WorldEditor/WorldEditor/A_TextureDialog.cpp (revision 2544)
@@ -506,7 +506,7 @@
506506 }
507507
508508 char buf[255];
509- sprintf(buf, "%i X %i", BasePicWidth, BasePicHeight);
509+ sprintf(buf, "Index = %i %i X %i", Index, BasePicWidth, BasePicHeight);
510510 SetDlgItemText(TextureDlg_Hwnd, IDC_STWIDTHHEIGHT, (LPCTSTR)buf);
511511
512512 //IDC_STWIDTHHEIGHT
--- WorldEditor/WorldEditor/CollisionTools.cpp (revision 2543)
+++ WorldEditor/WorldEditor/CollisionTools.cpp (revision 2544)
@@ -1,9 +1,11 @@
11 /******************************************************************************************
2-MOC - Minimal Ogre Collision v 1.0 beta
2+MOC - Minimal Ogre Collision v 1.0
33 The MIT License
44
5-Copyright (c) 2008 MouseVolcano (Thomas Gradl, Esa Kylli, Erik Biermann, Karolina Sefyrin)
5+Copyright (c) 2008, 2009 MouseVolcano (Thomas Gradl, Karolina Sefyrin), Esa Kylli
66
7+Thanks to Erik Biermann for the help with the Videos, SEO and Webwork
8+
79 Permission is hereby granted, free of charge, to any person obtaining a copy
810 of this software and associated documentation files (the "Software"), to deal
911 in the Software without restriction, including without limitation the rights
@@ -22,15 +24,38 @@
2224 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2325 THE SOFTWARE.
2426 ******************************************************************************************/
25-#include "StdAfx.h"
27+#include "stdafx.h"
2628 #include "CollisionTools.h"
2729
2830 namespace MOC {
2931
32+#ifdef ETM_TERRAIN
33+CollisionTools::CollisionTools(Ogre::SceneManager *sceneMgr, const ET::TerrainInfo* terrainInfo)
34+{
35+ mRaySceneQuery = sceneMgr->createRayQuery(Ogre::Ray());
36+ if (NULL == mRaySceneQuery)
37+ {
38+ // LOG_ERROR << "Failed to create Ogre::RaySceneQuery instance" << ENDLOG;
39+ return;
40+ }
41+ mRaySceneQuery->setSortByDistance(true);
42+
43+ mTSMRaySceneQuery = NULL;
44+
45+ mTerrainInfo = terrainInfo;
46+
47+ _heightAdjust = 0.0f;
48+
49+ pentity = NULL;
50+ distToColl = 0;
51+ myResult = Ogre::Vector3::ZERO;
52+}
53+#endif
54+
3055 CollisionTools::CollisionTools(Ogre::SceneManager *sceneMgr)
3156 {
3257 mSceneMgr = sceneMgr;
33-
58+
3459 mRaySceneQuery = mSceneMgr->createRayQuery(Ogre::Ray());
3560 if (NULL == mRaySceneQuery)
3661 {
@@ -38,11 +63,11 @@
3863 return;
3964 }
4065 mRaySceneQuery->setSortByDistance(true);
41-
66+
4267 mTSMRaySceneQuery = mSceneMgr->createRayQuery(Ogre::Ray());
43-
44- _heightAdjust = 0.0f;
4568
69+ _heightAdjust = 0.0f;
70+
4671 pentity = NULL;
4772 distToColl = 0;
4873 myResult = Ogre::Vector3::ZERO;
@@ -52,35 +77,40 @@
5277 {
5378 if (mRaySceneQuery != NULL)
5479 delete mRaySceneQuery;
55-
80+
5681 if (mTSMRaySceneQuery != NULL)
5782 delete mTSMRaySceneQuery;
5883 }
5984
60-//bool CollisionTools::raycastFromCamera(RenderWindow* rw, Camera* camera, const OIS::MouseEvent &e, Vector3 &result, ulong &target,float &closest_distance, const uint32 queryMask)
61-//{
62-// // Create the ray to test
63-// Real tx = (Real) e.state.X.abs / (Real) rw->getWidth();
64-// Real ty = (Real) e.state.Y.abs / (Real) rw->getHeight();
65-// Ray ray = camera->getCameraToViewportRay(tx, ty);
66-//
67-// return raycast(ray, result, target, closest_distance, queryMask);
68-//}
85+bool CollisionTools::raycastFromCamera(Ogre::RenderWindow* rw, Ogre::Camera* camera, const Ogre::Vector2 &mousecoords, Ogre::Vector3 &result, Ogre::Entity* &target,float &closest_distance, const Ogre::uint32 queryMask)
86+{
87+ return raycastFromCamera(rw, camera, mousecoords, result, (Ogre::MovableObject*&) target, closest_distance, queryMask);
88+}
6989
70-bool CollisionTools::collidesWithEntity(const Vector3& fromPoint, const Vector3& toPoint, const float collisionRadius, const float rayHeightLevel, const uint32 queryMask)
90+bool CollisionTools::raycastFromCamera(Ogre::RenderWindow* rw, Ogre::Camera* camera, const Ogre::Vector2 &mousecoords, Ogre::Vector3 &result, Ogre::MovableObject* &target,float &closest_distance, const Ogre::uint32 queryMask)
7191 {
72- Vector3 fromPointAdj(fromPoint.x, fromPoint.y + rayHeightLevel, fromPoint.z);
73- Vector3 toPointAdj(toPoint.x, toPoint.y + rayHeightLevel, toPoint.z);
74- Vector3 normal = toPointAdj - fromPointAdj;
92+ // Create the ray to test
93+ Ogre::Real tx = mousecoords.x / (Ogre::Real) rw->getWidth();
94+ Ogre::Real ty = mousecoords.y / (Ogre::Real) rw->getHeight();
95+ Ogre::Ray ray = camera->getCameraToViewportRay(tx, ty);
96+
97+ return raycast(ray, result, target, closest_distance, queryMask);
98+}
99+
100+bool CollisionTools::collidesWithEntity(const Ogre::Vector3& fromPoint, const Ogre::Vector3& toPoint, const float collisionRadius, const float rayHeightLevel, const Ogre::uint32 queryMask)
101+{
102+ Ogre::Vector3 fromPointAdj(fromPoint.x, fromPoint.y + rayHeightLevel, fromPoint.z);
103+ Ogre::Vector3 toPointAdj(toPoint.x, toPoint.y + rayHeightLevel, toPoint.z);
104+ Ogre::Vector3 normal = toPointAdj - fromPointAdj;
75105 float distToDest = normal.normalise();
76106
77- myResult = Ogre::Vector3::ZERO;;
78- Ogre::Entity* myObject = NULL;
107+ Ogre::Vector3 myResult(0, 0, 0);
108+ Ogre::MovableObject* myObject = NULL;
79109 distToColl = 0.0f;
80110
81- if (raycastFromPoint(fromPointAdj, normal, myResult, (ulong&)myObject, distToColl, queryMask))
111+ if (raycastFromPoint(fromPointAdj, normal, myResult, myObject, distToColl, queryMask))
82112 {
83- distToColl -= collisionRadius;
113+ distToColl -= collisionRadius;
84114 return (distToColl <= distToDest);
85115 }
86116 else
@@ -92,37 +122,37 @@
92122 float CollisionTools::getTSMHeightAt(const float x, const float z) {
93123 float y=0.0f;
94124
95- static Ray updateRay;
96-
97- updateRay.setOrigin(Vector3(x,9999,z));
98- updateRay.setDirection(Vector3::NEGATIVE_UNIT_Y);
99-
125+ static Ogre::Ray updateRay;
126+
127+ updateRay.setOrigin(Ogre::Vector3(x,9999,z));
128+ updateRay.setDirection(Ogre::Vector3::NEGATIVE_UNIT_Y);
129+
100130 mTSMRaySceneQuery->setRay(updateRay);
101- RaySceneQueryResult& qryResult = mTSMRaySceneQuery->execute();
102-
103- RaySceneQueryResult::iterator i = qryResult.begin();
131+ Ogre::RaySceneQueryResult& qryResult = mTSMRaySceneQuery->execute();
132+
133+ Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
104134 if (i != qryResult.end() && i->worldFragment)
105135 {
106- y=i->worldFragment->singleIntersection.y;
107- }
136+ y=i->worldFragment->singleIntersection.y;
137+ }
108138 return y;
109139 }
110140
111-void CollisionTools::calculateY(SceneNode *n, const bool doTerrainCheck, const bool doGridCheck, const float gridWidth, const uint32 queryMask)
141+void CollisionTools::calculateY(Ogre::SceneNode *n, const bool doTerrainCheck, const bool doGridCheck, const float gridWidth, const Ogre::uint32 queryMask)
112142 {
113- Vector3 pos = n->getPosition();
114-
143+ Ogre::Vector3 pos = n->getPosition();
144+
115145 float x = pos.x;
116146 float z = pos.z;
117147 float y = pos.y;
118-
119- Vector3 myResult(0,0,0);
120- Ogre::Entity *myObject=NULL;
121- float distToColl = 0.0f;
122148
149+ Ogre::Vector3 myResult(0,0,0);
150+ Ogre::MovableObject *myObject=NULL;
151+ distToColl = 0.0f;
152+
123153 float terrY = 0, colY = 0, colY2 = 0;
124154
125- if( raycastFromPoint(Vector3(x,y,z),Vector3::NEGATIVE_UNIT_Y,myResult,(ulong&)myObject, distToColl, queryMask)){
155+ if( raycastFromPoint(Ogre::Vector3(x,y,z),Ogre::Vector3::NEGATIVE_UNIT_Y,myResult,myObject, distToColl, queryMask)){
126156 if (myObject != NULL) {
127157 colY = myResult.y;
128158 } else {
@@ -129,26 +159,26 @@
129159 colY = -99999;
130160 }
131161 }
132-
162+
133163 //if doGridCheck is on, repeat not to fall through small holes for example when crossing a hangbridge
134- if (doGridCheck) {
135- if( raycastFromPoint(Vector3(x,y,z)+(n->getOrientation()*Vector3(0,0,gridWidth)),Vector3::NEGATIVE_UNIT_Y,myResult,(ulong&)myObject, distToColl, queryMask)){
164+ if (doGridCheck) {
165+ if( raycastFromPoint(Ogre::Vector3(x,y,z)+(n->getOrientation()*Ogre::Vector3(0,0,gridWidth)),Ogre::Vector3::NEGATIVE_UNIT_Y,myResult, myObject, distToColl, queryMask)){
136166 if (myObject != NULL) {
137167 colY = myResult.y;
138168 } else {
139169 colY = -99999;
140- }
170+ }
141171 }
142172 if (colY<colY2) colY = colY2;
143173 }
144-
174+
145175 // set the parameter to false if you are not using ETM or TSM
146176 if (doTerrainCheck) {
147-
177+
148178 #ifdef ETM_TERRAIN
149179 // ETM height value
150180 terrY = mTerrainInfo->getHeightAt(x,z);
151-#else
181+#else
152182 // TSM height value
153183 terrY = getTSMHeightAt(x,z);
154184 #endif
@@ -167,11 +197,21 @@
167197 // raycast from a point in to the scene.
168198 // returns success or failure.
169199 // on success the point is returned in the result.
170-bool CollisionTools::raycastFromPoint(const Vector3 &point,
171- const Vector3 &normal,
172- Vector3 &result,ulong &target,float &closest_distance,
173- const uint32 queryMask)
200+bool CollisionTools::raycastFromPoint(const Ogre::Vector3 &point,
201+ const Ogre::Vector3 &normal,
202+ Ogre::Vector3 &result,Ogre::Entity* &target,
203+ float &closest_distance,
204+ const Ogre::uint32 queryMask)
174205 {
206+ return raycastFromPoint(point, normal, result,(Ogre::MovableObject*&) target, closest_distance, queryMask);
207+}
208+
209+bool CollisionTools::raycastFromPoint(const Ogre::Vector3 &point,
210+ const Ogre::Vector3 &normal,
211+ Ogre::Vector3 &result,Ogre::MovableObject* &target,
212+ float &closest_distance,
213+ const Ogre::uint32 queryMask)
214+{
175215 // create the ray to test
176216 static Ogre::Ray ray;
177217 ray.setOrigin(point);
@@ -180,8 +220,14 @@
180220 return raycast(ray, result, target, closest_distance, queryMask);
181221 }
182222
183-bool CollisionTools::raycast(const Ray &ray, Vector3 &result,ulong &target,float &closest_distance, const uint32 queryMask)
223+bool CollisionTools::raycast(const Ogre::Ray &ray, Ogre::Vector3 &result,Ogre::Entity* &target,float &closest_distance, const Ogre::uint32 queryMask)
184224 {
225+ MessageBox(NULL, "poo", "poo", MB_OK);
226+ return raycast(ray, result, (Ogre::MovableObject*&)target, closest_distance, queryMask);
227+}
228+
229+bool CollisionTools::raycast(const Ogre::Ray &ray, Ogre::Vector3 &result,Ogre::MovableObject* &target,float &closest_distance, const Ogre::uint32 queryMask)
230+{
185231 target = NULL;
186232
187233 // check we are initialised
@@ -200,16 +246,18 @@
200246 }
201247 else
202248 {
249+ // MessageBox(NULL, "poo", "poo", MB_OK);
203250 //LOG_ERROR << "Cannot raycast without RaySceneQuery instance" << ENDLOG;
204251 return (false);
205- }
252+ }
206253
254+ // MessageBox(NULL, "poo", "poo", MB_OK);
207255 // at this point we have raycast to a series of different objects bounding boxes.
208256 // we need to test these different objects to see which is the first polygon hit.
209257 // there are some minor optimizations (distance based) that mean we wont have to
210258 // check all of the objects most of the time, but the worst case scenario is that
211259 // we need to test every triangle of every object.
212- //Ogre::Real closest_distance = -1.0f;
260+ //Ogre::Ogre::Real closest_distance = -1.0f;
213261 closest_distance = -1.0f;
214262 Ogre::Vector3 closest_result;
215263 Ogre::RaySceneQueryResult &query_result = mRaySceneQuery->getLastResults();
@@ -225,26 +273,26 @@
225273
226274 // only check this result if its a hit against an entity
227275 if ((query_result[qr_idx].movable != NULL) &&
228- (query_result[qr_idx].movable->getMovableType().compare("Entity") == 0))
276+ (query_result[qr_idx].movable->getMovableType().compare("Entity") == 0))
229277 {
230278 // get the entity to check
231- pentity = static_cast<Ogre::Entity*>(query_result[qr_idx].movable);
232-
233- // mesh data to retrieve
279+ pentity = static_cast<Ogre::MovableObject*>(query_result[qr_idx].movable);
280+
281+ // mesh data to retrieve
234282 size_t vertex_count;
235283 size_t index_count;
236284 Ogre::Vector3 *vertices;
237- unsigned long *indices;
285+ Ogre::uint32 *indices;
238286
239287 // get the mesh information
240- GetMeshInformation(pentity->getMesh(), vertex_count, vertices, index_count, indices,
241- pentity->getParentNode()->getPosition(),
242- pentity->getParentNode()->getOrientation(),
243- pentity->getParentNode()->getScale());
288+ GetMeshInformation(((Ogre::Entity*)pentity)->getMesh(), vertex_count, vertices, index_count, indices,
289+ pentity->getParentNode()->_getDerivedPosition(),
290+ pentity->getParentNode()->_getDerivedOrientation(),
291+ pentity->getParentNode()->_getDerivedScale());
244292
245293 // test for hitting individual triangles on the mesh
246294 bool new_closest_found = false;
247- for (int i = 0; i < static_cast<int>(index_count); i += 3)
295+ for (size_t i = 0; i < index_count; i += 3)
248296 {
249297 // check for a hit against this triangle
250298 std::pair<bool, Ogre::Real> hit = Ogre::Math::intersects(ray, vertices[indices[i]],
@@ -271,10 +319,10 @@
271319 // closest_result before moving on to the next object.
272320 if (new_closest_found)
273321 {
274- target = (ulong)pentity;
275- closest_result = ray.getPoint(closest_distance);
322+ target = pentity;
323+ closest_result = ray.getPoint(closest_distance);
276324 }
277- }
325+ }
278326 }
279327
280328 // return the result
@@ -282,7 +330,6 @@
282330 {
283331 // raycast success
284332 result = closest_result;
285- Point = closest_result;
286333 return (true);
287334 }
288335 else
@@ -289,7 +336,7 @@
289336 {
290337 // raycast failed
291338 return (false);
292- }
339+ }
293340 }
294341
295342
@@ -299,7 +346,7 @@
299346 size_t &vertex_count,
300347 Ogre::Vector3* &vertices,
301348 size_t &index_count,
302- unsigned long* &indices,
349+ Ogre::uint32* &indices,
303350 const Ogre::Vector3 &position,
304351 const Ogre::Quaternion &orient,
305352 const Ogre::Vector3 &scale)
@@ -338,7 +385,7 @@
338385
339386 // Allocate space for the vertices and indices
340387 vertices = new Ogre::Vector3[vertex_count];
341- indices = new unsigned long[index_count];
388+ indices = new Ogre::uint32[index_count];
342389
343390 added_shared = false;
344391
@@ -366,10 +413,10 @@
366413 unsigned char* vertex =
367414 static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
368415
369- // There is _no_ baseVertexPointerToElement() which takes an Ogre::Real or a double
370- // as second argument. So make it float, to avoid trouble when Ogre::Real will
416+ // There is _no_ baseVertexPointerToElement() which takes an Ogre::Ogre::Real or a double
417+ // as second argument. So make it float, to avoid trouble when Ogre::Ogre::Real will
371418 // be comiled/typedefed as double:
372- // Ogre::Real* pReal;
419+ // Ogre::Ogre::Real* pOgre::Real;
373420 float* pReal;
374421
375422 for( size_t j = 0; j < vertex_data->vertexCount; ++j, vertex += vbuf->getVertexSize())
@@ -392,7 +439,7 @@
392439
393440 bool use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
394441
395- unsigned long* pLong = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
442+ Ogre::uint32* pLong = static_cast<Ogre::uint32*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
396443 unsigned short* pShort = reinterpret_cast<unsigned short*>(pLong);
397444
398445
@@ -402,7 +449,7 @@
402449 {
403450 for ( size_t k = 0; k < numTris*3; ++k)
404451 {
405- indices[index_offset++] = pLong[k] + static_cast<unsigned long>(offset);
452+ indices[index_offset++] = pLong[k] + static_cast<Ogre::uint32>(offset);
406453 }
407454 }
408455 else
@@ -409,8 +456,8 @@
409456 {
410457 for ( size_t k = 0; k < numTris*3; ++k)
411458 {
412- indices[index_offset++] = static_cast<unsigned long>(pShort[k]) +
413- static_cast<unsigned long>(offset);
459+ indices[index_offset++] = static_cast<Ogre::uint32>(pShort[k]) +
460+ static_cast<Ogre::uint32>(offset);
414461 }
415462 }
416463
@@ -427,4 +474,4 @@
427474 return _heightAdjust;
428475 }
429476
430-};
477+};
\ No newline at end of file
--- WorldEditor/WorldEditor/CollisionTools.h (revision 2543)
+++ WorldEditor/WorldEditor/CollisionTools.h (revision 2544)
@@ -1,9 +1,11 @@
11 /******************************************************************************************
2-MOC - Minimal Ogre Collision v 1.0 beta
2+MOC - Minimal Ogre Collision v 1.0
33 The MIT License
44
5-Copyright (c) 2008 MouseVolcano (Thomas Gradl, Esa Kylli, Erik Biermann, Karolina Sefyrin)
5+Copyright (c) 2008, 2009 MouseVolcano (Thomas Gradl, Karolina Sefyrin), Esa Kylli
66
7+Thanks to Erik Biermann for the help with the Videos, SEO and Webwork
8+
79 Permission is hereby granted, free of charge, to any person obtaining a copy
810 of this software and associated documentation files (the "Software"), to deal
911 in the Software without restriction, including without limitation the rights
@@ -22,16 +24,12 @@
2224 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2325 THE SOFTWARE.
2426 ******************************************************************************************/
25-#pragma once
2627 #ifndef COLLISIONTOOLS_H
2728 #define COLLISIONTOOLS_H
2829
29-#pragma warning (disable : 4530)
30-
3130 #include <Ogre.h>
32-//#include <OIS\OISMouse.h>
3331
34-// comment if you dont use ETM as terrainmanager
32+// uncomment if you want to use ETM as terrainmanager
3533 //#define ETM_TERRAIN
3634
3735 #ifdef ETM_TERRAIN
@@ -38,8 +36,6 @@
3836 #include "ETTerrainInfo.h"
3937 #endif
4038
41-using namespace Ogre;
42-
4339 namespace MOC {
4440
4541 class CollisionTools {
@@ -46,33 +42,39 @@
4642 public:
4743 Ogre::RaySceneQuery *mRaySceneQuery;
4844 Ogre::RaySceneQuery *mTSMRaySceneQuery;
49-
50- SceneManager *mSceneMgr;
51- Ogre::Entity *pentity;
45+
46+ Ogre::SceneManager *mSceneMgr;
47+ Ogre::MovableObject *pentity;
5248 float distToColl;
53- Vector3 myResult;
54- Vector3 Point;
55-
56-#ifdef ETM_TERRAIN
49+ Ogre::Vector3 myResult;
50+ Ogre::Vector3 Point;
51+
52+#ifdef ETM_TERRAIN
5753 const ET::TerrainInfo* mTerrainInfo;
5854 CollisionTools(Ogre::SceneManager *sceneMgr, const ET::TerrainInfo* terrainInfo);
5955 #endif
6056
6157 CollisionTools(Ogre::SceneManager *sceneMgr);
62- ~CollisionTools();
58+ ~CollisionTools();
6359
64-// bool raycastFromCamera(RenderWindow* rw, Camera* camera, const OIS::MouseEvent &e, Vector3 &result, ulong &target,float &closest_distance, const uint32 queryMask = 0xFFFFFFFF);
60+ bool raycastFromCamera(Ogre::RenderWindow* rw, Ogre::Camera* camera, const Ogre::Vector2 &mousecoords, Ogre::Vector3 &result, Ogre::MovableObject* &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
61+ // convenience wrapper with Ogre::Entity to it:
62+ bool raycastFromCamera(Ogre::RenderWindow* rw, Ogre::Camera* camera, const Ogre::Vector2 &mousecoords, Ogre::Vector3 &result, Ogre::Entity* &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
6563
66- bool collidesWithEntity(const Vector3& fromPoint, const Vector3& toPoint, const float collisionRadius = 2.5f, const float rayHeightLevel = 0.0f, const Ogre::uint32 queryMask = 0xFFFFFFFF);
64+ bool collidesWithEntity(const Ogre::Vector3& fromPoint, const Ogre::Vector3& toPoint, const float collisionRadius = 2.5f, const float rayHeightLevel = 0.0f, const Ogre::uint32 queryMask = 0xFFFFFFFF);
6765
68- void calculateY(SceneNode *n, const bool doTerrainCheck = true, const bool doGridCheck = true, const float gridWidth = 1.0f, const Ogre::uint32 queryMask = 0xFFFFFFFF);
66+ void calculateY(Ogre::SceneNode *n, const bool doTerrainCheck = true, const bool doGridCheck = true, const float gridWidth = 1.0f, const Ogre::uint32 queryMask = 0xFFFFFFFF);
67+
68+ float getTSMHeightAt(const float x, const float z);
6969
70- float getTSMHeightAt(const float x, const float z);
70+ bool raycastFromPoint(const Ogre::Vector3 &point, const Ogre::Vector3 &normal, Ogre::Vector3 &result,Ogre::MovableObject* &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
71+ // convenience wrapper with Ogre::Entity to it:
72+ bool raycastFromPoint(const Ogre::Vector3 &point, const Ogre::Vector3 &normal, Ogre::Vector3 &result,Ogre::Entity* &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
73+
74+ bool raycast(const Ogre::Ray &ray, Ogre::Vector3 &result, Ogre::MovableObject* &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
75+ // convenience wrapper with Ogre::Entity to it:
76+ bool raycast(const Ogre::Ray &ray, Ogre::Vector3 &result, Ogre::Entity* &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
7177
72- bool raycastFromPoint(const Vector3 &point, const Vector3 &normal, Vector3 &result,ulong &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
73-
74- bool raycast(const Ray &ray, Vector3 &result,ulong &target,float &closest_distance, const Ogre::uint32 queryMask = 0xFFFFFFFF);
75-
7678 void setHeightAdjust(const float heightadjust);
7779 float getHeightAdjust(void);
7880
@@ -84,7 +86,7 @@
8486 size_t &vertex_count,
8587 Ogre::Vector3* &vertices,
8688 size_t &index_count,
87- unsigned long* &indices,
89+ Ogre::uint32* &indices,
8890 const Ogre::Vector3 &position,
8991 const Ogre::Quaternion &orient,
9092 const Ogre::Vector3 &scale);
--- WorldEditor/WorldEditor/FUSIONDoc.cpp (revision 2543)
+++ WorldEditor/WorldEditor/FUSIONDoc.cpp (revision 2544)
@@ -902,7 +902,7 @@
902902
903903 App->CLSB_Doc->AddCameraEntityToLevel ();
904904
905- DoGeneralSelect();
905+ App->CLSB_Doc->DoGeneralSelect();
906906 return GE_TRUE;
907907 LoadError:
908908 if (NewLevel != NULL)
@@ -1048,7 +1048,7 @@
10481048 // fake a move
10491049 App->CLSB_Doc->DoneMove();
10501050 // Back to select mode
1051- DoGeneralSelect();
1051+ App->CLSB_Doc->DoGeneralSelect();
10521052 // ~MS
10531053 SetModifiedFlag();
10541054 }
@@ -1889,7 +1889,7 @@
18891889 void CFusionDoc::OnToolsToggleadjustmode()
18901890 {
18911891 //MS change to select mode before changing to face adjustment
1892- DoGeneralSelect();
1892+ App->CLSB_Doc->DoGeneralSelect();
18931893 if( /*mModeTool == ID_GENERALSELECT &&
18941894 !IsSelectionLocked() && */
18951895 App->CLSB_Doc->mCurrentTool == CURTOOL_NONE )
@@ -1902,7 +1902,7 @@
19021902 void CFusionDoc::OnUpdateToolsToggleadjustmode(CCmdUI* pCmdUI)
19031903 {
19041904 //MS change to select mode before changing to face adjustment
1905- DoGeneralSelect();
1905+ App->CLSB_Doc->DoGeneralSelect();
19061906 if( /*mModeTool == ID_GENERALSELECT &&
19071907 !IsSelectionLocked() && */
19081908 App->CLSB_Doc->mCurrentTool == CURTOOL_NONE )
@@ -1912,125 +1912,6 @@
19121912
19131913 }
19141914
1915-void CFusionDoc::DoBrushSelection(Brush * pBrush,BrushSel nSelType) // brushSelToggle | brushSelAlways)
1916-{
1917- int ModelId = 0;
1918- geBoolean ModelLocked;
1919- ModelInfo_Type *ModelInfo;
1920- GroupListType *Groups;
1921- int GroupId = 0;
1922- geBoolean GroupLocked;
1923- BrushList *BList;
1924- Brush *pBParent=NULL;
1925-
1926- ModelInfo = Level_GetModelInfo (App->CLSB_Doc->pLevel);
1927- Groups = Level_GetGroups (App->CLSB_Doc->pLevel);
1928- BList = Level_GetBrushes (App->CLSB_Doc->pLevel);
1929-
1930- if(Brush_GetParent(BList, pBrush, &pBParent))
1931- {
1932- pBrush =pBParent;
1933- }
1934-
1935- ModelLocked = GE_FALSE;
1936- GroupLocked = FALSE;
1937-// if(mAdjustMode != ADJUST_MODE_FACE)
1938- {
1939- // don't do this stuff if we're in face mode...
1940- ModelId = Brush_GetModelId (pBrush);
1941- if (ModelId != 0)
1942- {
1943- Model *pModel;
1944-
1945- pModel = ModelList_FindById (ModelInfo->Models, ModelId);
1946- if (pModel != NULL)
1947- {
1948- ModelLocked = Model_IsLocked (pModel);
1949- }
1950- }
1951-
1952- if (!ModelLocked)
1953- {
1954- GroupId = Brush_GetGroupId (pBrush);
1955- if (GroupId != 0)
1956- {
1957- GroupLocked = Group_IsLocked (Groups, GroupId);
1958- }
1959- }
1960- }
1961-
1962- if( nSelType == brushSelToggle && BrushIsSelected (pBrush) )
1963- {
1964- if (ModelLocked)
1965- {
1966- // model is locked, so deselect everything in the model
1967- SelectModelBrushes (FALSE, ModelId);
1968- }
1969- else if (GroupLocked)
1970- {
1971- // group is locked, so deselect entire group
1972- SelectGroupBrushes (FALSE, GroupId);
1973- }
1974- else
1975- {
1976- SelBrushList_Remove (App->CLSB_Doc->pSelBrushes, pBrush);
1977-// changed QD Actors
1978- if(strstr(App->CL_Brush->Brush_GetName(pBrush),".act")!=NULL)
1979- {
1980- CEntityArray *Entities = Level_GetEntities (App->CLSB_Doc->pLevel);
1981-
1982- for(int i=0;i < Entities->GetSize();i++)
1983- {
1984- Brush *b=(*Entities)[i].GetActorBrush();
1985- if(b!=NULL)
1986- if(SelBrushList_Find (App->CLSB_Doc->pSelBrushes, b))
1987- if ((*Entities)[i].IsSelected())
1988- {
1989- (*Entities)[i].DeSelect();
1990- --App->CLSB_Doc->NumSelEntities;
1991- }
1992- }
1993- }
1994-// end change
1995- }
1996- }
1997- else
1998- {
1999- if (ModelLocked)
2000- {
2001- // model is locked, so select everything in the model
2002- SelectModelBrushes (TRUE, ModelId);
2003- }
2004- else if (GroupLocked)
2005- {
2006- // group is locked. Select everything in the group
2007- SelectGroupBrushes (TRUE, GroupId);
2008- }
2009- else
2010- {
2011- SelBrushList_Add (App->CLSB_Doc->pSelBrushes, pBrush);
2012-// changed QD Actors
2013- if(strstr(App->CL_Brush->Brush_GetName(pBrush),".act")!=NULL)
2014- {
2015- CEntityArray *Entities = Level_GetEntities (App->CLSB_Doc->pLevel);
2016-
2017- for(int i=0;i < Entities->GetSize();i++)
2018- {
2019- Brush *b=(*Entities)[i].GetActorBrush();
2020- if(b!=NULL)
2021- if(SelBrushList_Find (App->CLSB_Doc->pSelBrushes, b))
2022- if (!(*Entities)[i].IsSelected())
2023- {
2024- (*Entities)[i].Select();
2025- ++App->CLSB_Doc->NumSelEntities;
2026- }
2027- }
2028- }
2029-// end change
2030- }
2031- }
2032-}/* CFusionDoc::DoBrushSelection */
2033-
20341915 void CFusionDoc::SelectEntity
20351916 (
20361917 CEntity *pEntity
@@ -2076,52 +1957,7 @@
20761957 }
20771958 }
20781959
2079-void CFusionDoc::DoEntitySelection
2080- (
2081- CEntity *pEntity
2082- )
2083-{
2084- // an entity is closest. Select/deselect it.
2085- int GroupId;
2086- geBoolean GroupLocked;
2087- GroupListType *Groups = Level_GetGroups (App->CLSB_Doc->pLevel);
20881960
2089- assert (pEntity != NULL);
2090-
2091- GroupLocked = FALSE;
2092- GroupId = pEntity->GetGroupId ();
2093- if (GroupId != 0)
2094- {
2095- GroupLocked = Group_IsLocked (Groups, GroupId);
2096- }
2097-
2098-
2099- if (pEntity->IsSelected ())
2100- {
2101- if (GroupLocked)
2102- {
2103- // deselect entire group
2104- SelectGroupBrushes (FALSE, GroupId);
2105- }
2106- else
2107- {
2108- DeselectEntity (pEntity);
2109- }
2110- }
2111- else
2112- {
2113- if (GroupLocked)
2114- {
2115- // select entire group
2116- SelectGroupBrushes (TRUE, GroupId);
2117- }
2118- else
2119- {
2120- SelectEntity (pEntity);
2121- }
2122- }
2123-}
2124-
21251961 static geBoolean fdocSelectEntity (CEntity &Ent, void *lParam)
21261962 {
21271963 CFusionDoc *pDoc = (CFusionDoc *)lParam;
@@ -2159,7 +1995,7 @@
21591995
21601996 void CFusionDoc::SelectAllBrushes (void)
21611997 {
2162- DoGeneralSelect ();
1998+ App->CLSB_Doc->DoGeneralSelect ();
21631999
21642000 Level_EnumBrushes (App->CLSB_Doc->pLevel, this, ::fdocSelectBrush);
21652001
@@ -2168,7 +2004,7 @@
21682004
21692005 void CFusionDoc::SelectAllEntities (void)
21702006 {
2171- DoGeneralSelect ();
2007+ App->CLSB_Doc->DoGeneralSelect ();
21722008
21732009 App->CLSB_Doc->NumSelEntities = 0;
21742010 Level_EnumEntities (App->CLSB_Doc->pLevel, this, ::fdocSelectEntity);
@@ -2178,7 +2014,7 @@
21782014
21792015 void CFusionDoc::SelectAllFacesInBrushes (void)
21802016 {
2181- DoGeneralSelect ();
2017+ App->CLSB_Doc->DoGeneralSelect ();
21822018
21832019 // Select all faces on all selected brushes
21842020 int iBrush;
@@ -2347,7 +2183,7 @@
23472183 Max = Render_OrthoWorldToView ( v, &bbox->Max );
23482184 if( viewRect.PtInRect( Min ) && viewRect.PtInRect( Max ) ) // If Brush ENTIRELY in rect...
23492185 {
2350- DoBrushSelection( pBrush, brushSelAlways ) ;
2186+ App->CLSB_Doc->DoBrushSelection( pBrush, brushSelAlways ) ;
23512187 bSelectedSomething = GE_TRUE ;
23522188 }
23532189 }
@@ -2367,7 +2203,7 @@
23672203 {
23682204 if( viewRect.PtInRect( EntPosView ) )
23692205 {
2370- DoEntitySelection( pEnt );
2206+ App->CLSB_Doc->DoEntitySelection( pEnt );
23712207 bSelectedSomething = GE_TRUE ;
23722208 }
23732209 }
@@ -2739,7 +2575,7 @@
27392575 {
27402576 App->CLSB_Doc->ResetAllSelections();
27412577 }
2742- DoEntitySelection(&(*Entities)[CurEnt]);
2578+ App->CLSB_Doc->DoEntitySelection(&(*Entities)[CurEnt]);
27432579 EntitySelected =GE_TRUE;
27442580 }
27452581 }
@@ -2812,11 +2648,11 @@
28122648 // We found the hit face.
28132649 if (App->CLSB_Doc->mAdjustMode == ADJUST_MODE_BRUSH)
28142650 {
2815- DoBrushSelection (fsData.pFoundBrush, brushSelToggle);
2651+ App->CLSB_Doc->DoBrushSelection (fsData.pFoundBrush, brushSelToggle);
28162652 }
28172653 else
28182654 {
2819- DoBrushSelection (fsData.pFoundBrush, brushSelAlways);
2655+ App->CLSB_Doc->DoBrushSelection (fsData.pFoundBrush, brushSelAlways);
28202656 // if the face is already in the list, then remove it
28212657 if (SelFaceList_Remove (App->CLSB_Doc->pSelFaces, fsData.pFoundFace))
28222658 {
@@ -3687,118 +3523,6 @@
36873523 }
36883524 }
36893525
3690-void CFusionDoc::DoneRotate(void)
3691-{
3692- int i;
3693- geFloat RSnap;
3694- geXForm3d rm;
3695- geVec3d RotationPoint;
3696- geVec3d TemplateReversalRot;
3697-
3698- TemplateReversalRot = App->CLSB_Doc->FinalRot;
3699-
3700- App->CLSB_Doc->mLastOp =BRUSH_ROTATE;
3701-
3702- App->CLSB_Doc->TempDeleteSelected();
3703- TempCopySelectedBrushes();
3704-
3705- GetRotationPoint (&RotationPoint);
3706-
3707- if((App->CLSB_Doc->SelState & NOENTITIES) && Level_UseGrid (App->CLSB_Doc->pLevel))
3708- {
3709- RSnap =Units_DegreesToRadians ((float)Level_GetRotationSnap (App->CLSB_Doc->pLevel));
3710- App->CLSB_Doc->FinalRot.X =((float)((int)(App->CLSB_Doc->FinalRot.X / RSnap))) * RSnap;
3711- App->CLSB_Doc->FinalRot.Y =((float)((int)(App->CLSB_Doc->FinalRot.Y / RSnap))) * RSnap;
3712- App->CLSB_Doc->FinalRot.Z =((float)((int)(App->CLSB_Doc->FinalRot.Z / RSnap))) * RSnap;
3713- }
3714-
3715- if(App->CLSB_Doc->mModeTool == ID_TOOLS_TEMPLATE)
3716- geVec3d_Subtract(&App->CLSB_Doc->FinalRot, &TemplateReversalRot, &App->CLSB_Doc->FinalRot);
3717-
3718- geXForm3d_SetEulerAngles(&rm, &App->CLSB_Doc->FinalRot);
3719-
3720- if(App->CLSB_Doc->mModeTool == ID_TOOLS_TEMPLATE)
3721- {
3722- if (App->CLSB_Doc->TempEnt)
3723- {
3724- }
3725- else
3726- {
3727- Brush_Rotate (App->CLSB_Doc->CurBrush, &rm, &RotationPoint);
3728- }
3729- return;
3730- }
3731-
3732- int NumSelBrushes = SelBrushList_GetSize (App->CLSB_Doc->pSelBrushes);
3733-
3734- for(i=0;i < NumSelBrushes;i++)
3735- {
3736- Brush *pBrush;
3737-
3738- pBrush = SelBrushList_GetBrush (App->CLSB_Doc->pTempSelBrushes, i);
3739-// changed QD Actors
3740-// don't rotate ActorBrushes
3741- if(strstr(App->CL_Brush->Brush_GetName(pBrush),".act")!=NULL)
3742- continue;
3743-// end change
3744-
3745- Brush_Rotate (pBrush, &rm, &RotationPoint);
3746- }
3747- if(i < NumSelBrushes)
3748- {
3749- App->CLSB_Doc->TempDeleteSelected();
3750- }
3751- else
3752- {
3753- BrushList *BList = Level_GetBrushes (App->CLSB_Doc->pLevel);
3754- for(i=0;i < NumSelBrushes;i++)
3755- {
3756- // Replace the sel list brushes with the TSelList brushes
3757- Brush *TempBrush, *OldBrush;
3758-
3759- TempBrush = SelBrushList_GetBrush (App->CLSB_Doc->pTempSelBrushes, 0);
3760- OldBrush = SelBrushList_GetBrush (App->CLSB_Doc->pSelBrushes, 0);
3761-// changed QD Actors
3762- if(strstr(App->CL_Brush->Brush_GetName(OldBrush),".act")!=NULL)
3763- {
3764- BrushList_Remove (BList, TempBrush);
3765- SelBrushList_Remove (App->CLSB_Doc->pTempSelBrushes, TempBrush);
3766- continue;
3767- }
3768-// end change
3769-
3770- BrushList_Remove (BList, TempBrush);
3771- BrushList_InsertAfter (BList, OldBrush, TempBrush);
3772- BrushList_Remove (BList, OldBrush);
3773-
3774- SelBrushList_Remove (App->CLSB_Doc->pSelBrushes, OldBrush);
3775- SelBrushList_Remove (App->CLSB_Doc->pTempSelBrushes, TempBrush);
3776-
3777- SelBrushList_Add (App->CLSB_Doc->pSelBrushes, TempBrush);
3778-
3779- Brush_Destroy (&OldBrush);
3780- }
3781- }
3782- App->CLSB_Doc->UpdateSelected();
3783-
3784- UpdateSelectedModel (BRUSH_ROTATE, &App->CLSB_Doc->FinalRot);
3785-
3786- geVec3d_Clear (&App->CLSB_Doc->FinalRot);
3787-
3788- // Find the camera entity and update the rendered view's camera position
3789- {
3790- CEntity *pCameraEntity = App->CLSB_Camera_WE->FindCameraEntity();
3791-
3792- if (pCameraEntity != NULL)
3793- {
3794- geVec3d Angles;
3795-
3796- pCameraEntity->GetAngles( &Angles, Level_GetEntityDefs (App->CLSB_Doc->pLevel) ) ;
3797- SetRenderedViewCamera( &(pCameraEntity->mOrigin), &Angles) ;
3798- }
3799- }
3800-}
3801-
38023526 void CFusionDoc::UpdateSelectedModel
38033527 (
38043528 int MoveRotate,
@@ -4005,17 +3729,9 @@
40053729
40063730 void CFusionDoc::OnGeneralselect()
40073731 {
4008- DoGeneralSelect ();
3732+ App->CLSB_Doc->DoGeneralSelect ();
40093733 }
40103734
4011-void CFusionDoc::DoGeneralSelect (void)
4012-{
4013- App->CLSB_Doc->mCurrentTool =CURTOOL_NONE;
4014- App->CLSB_Doc->mModeTool =ID_GENERALSELECT;
4015- App->CLSB_Doc->ConfigureCurrentTool();
4016- //mpMainFrame->m_wndTabControls->m_pBrushEntityDialog->Update(this);
4017-}
4018-
40193735 void CFusionDoc::OnUpdateGeneralselect(CCmdUI* pCmdUI)
40203736 {
40213737 pCmdUI->SetCheck ((App->CLSB_Doc->mModeTool == ID_GENERALSELECT) ? 1 : 0);
@@ -4639,51 +4355,33 @@
46394355 return GE_TRUE;
46404356 }
46414357
4642-typedef struct
4643-{
4644- int ModelId;
4645- BOOL Select;
4646- CFusionDoc *pDoc;
4647-} fdocBrushSelectData;
4358+//typedef struct
4359+//{
4360+// int ModelId;
4361+// BOOL Select;
4362+// CFusionDoc *pDoc;
4363+//} fdocBrushSelectData;
4364+//
4365+//static geBoolean fdocSelectBrushCallback (Brush *pBrush, void *lParam)
4366+//{
4367+// fdocBrushSelectData *pData;
4368+//
4369+// pData = (fdocBrushSelectData *)lParam;
4370+// if (Brush_GetModelId (pBrush) == pData->ModelId)
4371+// {
4372+// if (pData->Select)
4373+// {
4374+// SelBrushList_Add (App->CLSB_Doc->pSelBrushes, pBrush);
4375+// }
4376+// else
4377+// {
4378+// SelBrushList_Remove (App->CLSB_Doc->pSelBrushes, pBrush);
4379+// }
4380+// }
4381+// return GE_TRUE;
4382+//}
46484383
4649-static geBoolean fdocSelectBrushCallback (Brush *pBrush, void *lParam)
4650-{
4651- fdocBrushSelectData *pData;
46524384
4653- pData = (fdocBrushSelectData *)lParam;
4654- if (Brush_GetModelId (pBrush) == pData->ModelId)
4655- {
4656- if (pData->Select)
4657- {
4658- SelBrushList_Add (App->CLSB_Doc->pSelBrushes, pBrush);
4659- }
4660- else
4661- {
4662- SelBrushList_Remove (App->CLSB_Doc->pSelBrushes, pBrush);
4663- }
4664- }
4665- return GE_TRUE;
4666-}
4667-
4668-void CFusionDoc::SelectModelBrushes
4669- (
4670- BOOL Select,
4671- int ModelId
4672- )
4673-{
4674- fdocBrushSelectData bsData;
4675-
4676- bsData.Select = Select;
4677- bsData.ModelId = ModelId;
4678- bsData.pDoc = this;
4679-
4680- // Go through the brush list and add all brushes that have
4681- // this model's id to the selection list.
4682- Level_EnumBrushes (App->CLSB_Doc->pLevel, &bsData, ::fdocSelectBrushCallback);
4683-
4684- App->CLSB_Doc->UpdateSelected ();
4685-}
4686-
46874385 /******************************************************
46884386 BRUSH GROUP SUPPORT
46894387 *******************************************************/
--- WorldEditor/WorldEditor/FUSIONDoc.h (revision 2543)
+++ WorldEditor/WorldEditor/FUSIONDoc.h (revision 2544)
@@ -65,13 +65,6 @@
6565 fctBRUSH
6666 };
6767
68-enum BrushSel
69-{
70- brushSelToggle,
71- brushSelAlways,
72- brushDeselAlways
73-} ;
74-
7568 enum GridFlags
7669 {
7770 USE_GRID =1,
@@ -111,8 +104,8 @@
111104 geBoolean BrushIsVisible( const Brush * pBrush ) const ;
112105 geBoolean EntityIsVisible( const CEntity *pEntity ) const ;
113106 void TempCopySelectedBrushes();
114- void DoneRotate(void);
115107
108+
116109 void SnapScaleNearest(int sides, int inidx, ViewVars *v);
117110
118111 void SetCurrentBrushTexture();
@@ -132,10 +125,10 @@
132125 void SelectAllFacesInBrushes();
133126
134127 void SelectGroupBrushes (BOOL Select, int WhichGroup);
135- void SelectModelBrushes (BOOL Select, int ModelId);
136128
129+
137130 void OnBrushAddtoworld();
138- void DoGeneralSelect (void);
131+
139132 void CreateEntity(char const *pEntityName);
140133
141134
@@ -183,6 +176,7 @@
183176 void UpdateGridInformation();
184177 void MoveEntity(geVec3d *);
185178
179+
186180 void DoneRotateBrush();
187181 void OnSelectedTypeCmdUI(CCmdUI* pCmdUI);
188182 int AreBrushesSelected();
@@ -228,9 +222,8 @@
228222
229223 geBoolean BrushIsSelected (Brush const *pBrush);
230224
231- void DoBrushSelection (Brush *pBrush, BrushSel nSelType ) ;
232- void DoEntitySelection (CEntity *pEntity);
233225
226+
234227 geBoolean fdocShowBrush( Brush const *b, Box3d const *ViewBox ) ;
235228
236229 geBoolean bShowLeakFinder(void) { return bShowLeak; }
@@ -448,13 +441,13 @@
448441 int mCurrentBrushId;
449442 public:
450443 void RotateSelectedBrushList (SelBrushList *pList, geVec3d const *v);
451-private:
452444
445+
446+public:
453447 void GetRotationPoint (geVec3d *pVec);
454- void CreateNewTemplateBrush (Brush *pBrush);
455448
456449 private:
457-
450+ void CreateNewTemplateBrush (Brush *pBrush);
458451 void SetupDefaultFilename (void);
459452
460453 public:
--- WorldEditor/WorldEditor/FUSIONView.cpp (revision 2543)
+++ WorldEditor/WorldEditor/FUSIONView.cpp (revision 2544)
@@ -1007,7 +1007,7 @@
10071007 // Do what has to be done
10081008 DoneMovingBrushes ();
10091009 // switch bach to Select mode
1010- GetDocument()->DoGeneralSelect();
1010+ App->CLSB_Doc->DoGeneralSelect();
10111011 // ~MS
10121012 IsCopying = FALSE;
10131013 }
@@ -1456,7 +1456,7 @@
14561456 App->CLSB_Doc->UpdateSelected();
14571457 if ((GetModeTool () == ID_GENERALSELECT) || (GetModeTool () == ID_TOOLS_TEMPLATE))
14581458 {
1459- pDoc->DoneRotate ();
1459+ App->CLSB_Doc->DoneRotate ();
14601460 }
14611461 }
14621462
@@ -2380,7 +2380,7 @@
23802380 pDoc->SetModifiedFlag();
23812381 }
23822382
2383- pDoc->DoGeneralSelect();
2383+ App->CLSB_Doc->DoGeneralSelect();
23842384 }
23852385
23862386 void CFusionView::OnUpdateToolsAddtolevel(CCmdUI* pCmdUI)
--- WorldEditor/WorldEditor/SB_Bt_Render.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_Bt_Render.h (revision 2544)
@@ -30,7 +30,7 @@
3030 float x,y,z;
3131 }Mvertex_type;
3232
33-class GD_Bt_Render : public btIDebugDraw,public RenderQueueListener
33+class GD_Bt_Render : public btIDebugDraw,public Ogre::RenderQueueListener
3434 {
3535 int m_debugMode;
3636
@@ -98,10 +98,10 @@
9898
9999 protected:
100100
101- virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const String& invocation,
101+ virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation,
102102 bool& skipThisInvocation);
103103
104- virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const String& invocation,
104+ virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation,
105105 bool& repeatThisInvocation);
106106
107107 void PreRender();
--- WorldEditor/WorldEditor/SB_Doc.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Doc.cpp (revision 2544)
@@ -273,7 +273,7 @@
273273 {
274274 case fctBRUSH:
275275 {
276- App->m_pDoc->DoBrushSelection(pMinBrush, brushSelToggle);
276+ DoBrushSelection(pMinBrush, brushSelToggle);
277277 if (App->CLSB_Brushes->Dimensions_Dlg_Running == 1)
278278 {
279279 App->CLSB_Brushes->Update_Pos_Dlg(App->CLSB_Brushes->Dimensions_Dlg_hWnd);
@@ -281,7 +281,7 @@
281281 break;
282282 }
283283 case fctENTITY:
284- App->m_pDoc->DoEntitySelection(pMinEntity);
284+ DoEntitySelection(pMinEntity);
285285 break;
286286 default:
287287 // bad value returned from FindClosestThing
@@ -531,7 +531,7 @@
531531 {
532532 App->Get_Current_Document();
533533
534- App->m_pDoc->DoGeneralSelect();
534+ DoGeneralSelect();
535535
536536 NumSelEntities = 0;
537537 Level_EnumEntities(pLevel, this, fdocSelectEntity);
@@ -724,10 +724,7 @@
724724 // *************************************************************************
725725 void SB_Doc::ResetAllSelectedEntities()
726726 {
727- App->Get_Current_Document();
728-
729- App->m_pDoc->DoGeneralSelect();
730-
727+ DoGeneralSelect();
731728 Level_EnumEntities(pLevel, this, fdocDeselectEntity);
732729 }
733730
@@ -1028,6 +1025,125 @@
10281025 }
10291026
10301027 // *************************************************************************
1028+// * DoneRotate:- Terry and Hazel Flanigan 2023 *
1029+// *************************************************************************
1030+void SB_Doc::DoneRotate(void)
1031+{
1032+ App->Get_Current_Document();
1033+
1034+ int i;
1035+ geFloat RSnap;
1036+ geXForm3d rm;
1037+ geVec3d RotationPoint;
1038+ geVec3d TemplateReversalRot;
1039+
1040+ TemplateReversalRot = FinalRot;
1041+
1042+ mLastOp = BRUSH_ROTATE;
1043+
1044+ TempDeleteSelected();
1045+
1046+ App->m_pDoc->TempCopySelectedBrushes();
1047+
1048+ App->m_pDoc->GetRotationPoint(&RotationPoint);
1049+
1050+ if ((App->CLSB_Doc->SelState & NOENTITIES) && Level_UseGrid(pLevel))
1051+ {
1052+ RSnap = Units_DegreesToRadians((float)Level_GetRotationSnap(pLevel));
1053+ FinalRot.X = ((float)((int)(FinalRot.X / RSnap))) * RSnap;
1054+ FinalRot.Y = ((float)((int)(FinalRot.Y / RSnap))) * RSnap;
1055+ FinalRot.Z = ((float)((int)(FinalRot.Z / RSnap))) * RSnap;
1056+ }
1057+
1058+ if (mModeTool == ID_TOOLS_TEMPLATE)
1059+ geVec3d_Subtract(&FinalRot, &TemplateReversalRot, &FinalRot);
1060+
1061+ geXForm3d_SetEulerAngles(&rm, &FinalRot);
1062+
1063+ if (mModeTool == ID_TOOLS_TEMPLATE)
1064+ {
1065+ if (TempEnt)
1066+ {
1067+ }
1068+ else
1069+ {
1070+ Brush_Rotate(CurBrush, &rm, &RotationPoint);
1071+ }
1072+ return;
1073+ }
1074+
1075+ int NumSelBrushes = SelBrushList_GetSize(pSelBrushes);
1076+
1077+ for (i = 0; i < NumSelBrushes; i++)
1078+ {
1079+ Brush* pBrush;
1080+
1081+ pBrush = SelBrushList_GetBrush(pTempSelBrushes, i);
1082+ // changed QD Actors
1083+ // don't rotate ActorBrushes
1084+ if (strstr(App->CL_Brush->Brush_GetName(pBrush), ".act") != NULL)
1085+ continue;
1086+ // end change
1087+
1088+ Brush_Rotate(pBrush, &rm, &RotationPoint);
1089+ }
1090+ if (i < NumSelBrushes)
1091+ {
1092+ App->CLSB_Doc->TempDeleteSelected();
1093+ }
1094+ else
1095+ {
1096+ BrushList* BList = Level_GetBrushes(pLevel);
1097+ for (i = 0; i < NumSelBrushes; i++)
1098+ {
1099+ // Replace the sel list brushes with the TSelList brushes
1100+ Brush* TempBrush, * OldBrush;
1101+
1102+ TempBrush = SelBrushList_GetBrush(pTempSelBrushes, 0);
1103+ OldBrush = SelBrushList_GetBrush(pSelBrushes, 0);
1104+ // changed QD Actors
1105+ if (strstr(App->CL_Brush->Brush_GetName(OldBrush), ".act") != NULL)
1106+ {
1107+ BrushList_Remove(BList, TempBrush);
1108+ SelBrushList_Remove(pTempSelBrushes, TempBrush);
1109+ continue;
1110+ }
1111+ // end change
1112+
1113+ BrushList_Remove(BList, TempBrush);
1114+ BrushList_InsertAfter(BList, OldBrush, TempBrush);
1115+ BrushList_Remove(BList, OldBrush);
1116+
1117+ SelBrushList_Remove(pSelBrushes, OldBrush);
1118+ SelBrushList_Remove(pTempSelBrushes, TempBrush);
1119+
1120+ SelBrushList_Add(pSelBrushes, TempBrush);
1121+
1122+ Brush_Destroy(&OldBrush);
1123+ }
1124+ }
1125+
1126+ UpdateSelected();
1127+
1128+ App->m_pDoc->UpdateSelectedModel(BRUSH_ROTATE, &FinalRot);
1129+
1130+ geVec3d_Clear(&FinalRot);
1131+
1132+ // Find the camera entity and update the rendered view's camera position
1133+ {
1134+ CEntity* pCameraEntity = App->CLSB_Camera_WE->FindCameraEntity();
1135+
1136+ if (pCameraEntity != NULL)
1137+ {
1138+ geVec3d Angles;
1139+
1140+ pCameraEntity->GetAngles(&Angles, Level_GetEntityDefs(pLevel));
1141+ App->m_pDoc->SetRenderedViewCamera(&(pCameraEntity->mOrigin), &Angles);
1142+ }
1143+ }
1144+}
1145+
1146+// *************************************************************************
10311147 // * TempDeleteSelected:- Terry and Hazel Flanigan 2023 *
10321148 // *************************************************************************
10331149 BOOL SB_Doc::TempDeleteSelected(void)
@@ -1306,7 +1422,7 @@
13061422 pFace = Brush_GetFace(pBrush, iFace);
13071423 if (Face_IsSelected(pFace))
13081424 {
1309- pDoc->DoBrushSelection(pBrush, brushSelAlways);
1425+ App->CLSB_Doc->DoBrushSelection(pBrush, brushSelAlways);
13101426 break;
13111427 }
13121428 }
@@ -1462,3 +1578,230 @@
14621578 }
14631579 }
14641580
1581+// *************************************************************************
1582+// * DoGeneralSelect:- Terry and Hazel Flanigan 2023 *
1583+// *************************************************************************
1584+void SB_Doc::DoGeneralSelect(void)
1585+{
1586+ mCurrentTool = CURTOOL_NONE;
1587+ mModeTool = ID_GENERALSELECT;
1588+ ConfigureCurrentTool();
1589+ //mpMainFrame->m_wndTabControls->m_pBrushEntityDialog->Update(this);
1590+}
1591+
1592+// *************************************************************************
1593+// * DoEntitySelection:- Terry and Hazel Flanigan 2023 *
1594+// *************************************************************************
1595+void SB_Doc::DoEntitySelection(CEntity* pEntity)
1596+{
1597+ App->Get_Current_Document();
1598+
1599+ // an entity is closest. Select/deselect it.
1600+ int GroupId;
1601+ geBoolean GroupLocked;
1602+ GroupListType* Groups = Level_GetGroups(pLevel);
1603+
1604+ assert(pEntity != NULL);
1605+
1606+ GroupLocked = FALSE;
1607+ GroupId = pEntity->GetGroupId();
1608+ if (GroupId != 0)
1609+ {
1610+ GroupLocked = Group_IsLocked(Groups, GroupId);
1611+ }
1612+
1613+
1614+ if (pEntity->IsSelected())
1615+ {
1616+ if (GroupLocked)
1617+ {
1618+ // deselect entire group
1619+ App->m_pDoc->SelectGroupBrushes(FALSE, GroupId);
1620+ }
1621+ else
1622+ {
1623+ App->m_pDoc->DeselectEntity(pEntity);
1624+ }
1625+ }
1626+ else
1627+ {
1628+ if (GroupLocked)
1629+ {
1630+ // select entire group
1631+ App->m_pDoc->SelectGroupBrushes(TRUE, GroupId);
1632+ }
1633+ else
1634+ {
1635+ App->m_pDoc->SelectEntity(pEntity);
1636+ }
1637+ }
1638+}
1639+
1640+// *************************************************************************
1641+// * DoBrushSelection:- Terry and Hazel Flanigan 2023 *
1642+// *************************************************************************
1643+void SB_Doc::DoBrushSelection(Brush* pBrush, BrushSel nSelType) // brushSelToggle | brushSelAlways)
1644+{
1645+ App->Get_Current_Document();
1646+
1647+ int ModelId = 0;
1648+ geBoolean ModelLocked;
1649+ ModelInfo_Type* ModelInfo;
1650+ GroupListType* Groups;
1651+ int GroupId = 0;
1652+ geBoolean GroupLocked;
1653+ BrushList* BList;
1654+ Brush* pBParent = NULL;
1655+
1656+ ModelInfo = Level_GetModelInfo(pLevel);
1657+ Groups = Level_GetGroups(pLevel);
1658+ BList = Level_GetBrushes(pLevel);
1659+
1660+ if (Brush_GetParent(BList, pBrush, &pBParent))
1661+ {
1662+ pBrush = pBParent;
1663+ }
1664+
1665+ ModelLocked = GE_FALSE;
1666+ GroupLocked = FALSE;
1667+ // if(mAdjustMode != ADJUST_MODE_FACE)
1668+ {
1669+ // don't do this stuff if we're in face mode...
1670+ ModelId = Brush_GetModelId(pBrush);
1671+ if (ModelId != 0)
1672+ {
1673+ Model* pModel;
1674+
1675+ pModel = ModelList_FindById(ModelInfo->Models, ModelId);
1676+ if (pModel != NULL)
1677+ {
1678+ ModelLocked = Model_IsLocked(pModel);
1679+ }
1680+ }
1681+
1682+ if (!ModelLocked)
1683+ {
1684+ GroupId = Brush_GetGroupId(pBrush);
1685+ if (GroupId != 0)
1686+ {
1687+ GroupLocked = Group_IsLocked(Groups, GroupId);
1688+ }
1689+ }
1690+ }
1691+
1692+ if (nSelType == brushSelToggle && App->m_pDoc->BrushIsSelected(pBrush))
1693+ {
1694+ if (ModelLocked)
1695+ {
1696+ // model is locked, so deselect everything in the model
1697+ SelectModelBrushes(FALSE, ModelId);
1698+ }
1699+ else if (GroupLocked)
1700+ {
1701+ // group is locked, so deselect entire group
1702+ App->m_pDoc->SelectGroupBrushes(FALSE, GroupId);
1703+ }
1704+ else
1705+ {
1706+ SelBrushList_Remove(pSelBrushes, pBrush);
1707+
1708+ if (strstr(App->CL_Brush->Brush_GetName(pBrush), ".act") != NULL)
1709+ {
1710+ CEntityArray* Entities = Level_GetEntities(pLevel);
1711+
1712+ for (int i = 0; i < Entities->GetSize(); i++)
1713+ {
1714+ Brush* b = (*Entities)[i].GetActorBrush();
1715+ if (b != NULL)
1716+ if (SelBrushList_Find(pSelBrushes, b))
1717+ if ((*Entities)[i].IsSelected())
1718+ {
1719+ (*Entities)[i].DeSelect();
1720+ --NumSelEntities;
1721+ }
1722+ }
1723+ }
1724+ }
1725+ }
1726+ else
1727+ {
1728+ if (ModelLocked)
1729+ {
1730+ // model is locked, so select everything in the model
1731+ SelectModelBrushes(TRUE, ModelId);
1732+ }
1733+ else if (GroupLocked)
1734+ {
1735+ // group is locked. Select everything in the group
1736+ App->m_pDoc->SelectGroupBrushes(TRUE, GroupId);
1737+ }
1738+ else
1739+ {
1740+ SelBrushList_Add(pSelBrushes, pBrush);
1741+
1742+ if (strstr(App->CL_Brush->Brush_GetName(pBrush), ".act") != NULL)
1743+ {
1744+ CEntityArray* Entities = Level_GetEntities(pLevel);
1745+
1746+ for (int i = 0; i < Entities->GetSize(); i++)
1747+ {
1748+ Brush* b = (*Entities)[i].GetActorBrush();
1749+ if (b != NULL)
1750+ if (SelBrushList_Find(pSelBrushes, b))
1751+ if (!(*Entities)[i].IsSelected())
1752+ {
1753+ (*Entities)[i].Select();
1754+ ++NumSelEntities;
1755+ }
1756+ }
1757+ }
1758+ }
1759+ }
1760+}
1761+
1762+typedef struct
1763+{
1764+ int ModelId;
1765+ BOOL Select;
1766+ CFusionDoc* pDoc;
1767+} fdocBrushSelectData;
1768+
1769+static geBoolean fdocSelectBrushCallback(Brush* pBrush, void* lParam)
1770+{
1771+ fdocBrushSelectData* pData;
1772+
1773+ pData = (fdocBrushSelectData*)lParam;
1774+ if (Brush_GetModelId(pBrush) == pData->ModelId)
1775+ {
1776+ if (pData->Select)
1777+ {
1778+ SelBrushList_Add(App->CLSB_Doc->pSelBrushes, pBrush);
1779+ }
1780+ else
1781+ {
1782+ SelBrushList_Remove(App->CLSB_Doc->pSelBrushes, pBrush);
1783+ }
1784+ }
1785+ return GE_TRUE;
1786+}
1787+
1788+// *************************************************************************
1789+// * SelectModelBrushes:- Terry and Hazel Flanigan 2023 *
1790+// *************************************************************************
1791+void SB_Doc::SelectModelBrushes(BOOL Select,int ModelId)
1792+{
1793+ App->Get_Current_Document();
1794+
1795+ fdocBrushSelectData bsData;
1796+
1797+ bsData.Select = Select;
1798+ bsData.ModelId = ModelId;
1799+ bsData.pDoc = App->m_pDoc;
1800+
1801+ // Go through the brush list and add all brushes that have
1802+ // this model's id to the selection list.
1803+ Level_EnumBrushes(App->CLSB_Doc->pLevel, &bsData, fdocSelectBrushCallback);
1804+
1805+ App->CLSB_Doc->UpdateSelected();
1806+}
1807+
--- WorldEditor/WorldEditor/SB_Doc.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_Doc.h (revision 2544)
@@ -2,6 +2,13 @@
22
33 #include "SelFaceList.h"
44
5+enum BrushSel
6+{
7+ brushSelToggle,
8+ brushSelAlways,
9+ brushDeselAlways
10+};
11+
512 enum fdocAdjustEnum
613 {
714 ADJUST_MODE_TOGGLE,
@@ -30,7 +37,12 @@
3037 void DoneResize(int sides, int inidx);
3138 void DoneMove(void);
3239 void DoneMoveEntity(void);
40+ void DoneRotate(void);
3341
42+ void DoGeneralSelect(void);
43+ void DoEntitySelection(CEntity* pEntity);
44+ void DoBrushSelection(Brush* pBrush, BrushSel nSelType); // brushSelToggle | brushSelAlways)
45+
3446 void Lock_AllTextures(void);
3547
3648 void SelectAll(void);
@@ -65,6 +77,8 @@
6577 void SetAdjustmentMode(fdocAdjustEnum nCmdIDMode);
6678 void ConfigureCurrentTool(void);
6779
80+ void SelectModelBrushes(BOOL Select, int ModelId);
81+
6882 // ----------------------------------------------------------- Varibles
6983 fdocAdjustEnum mAdjustMode;
7084
--- WorldEditor/WorldEditor/SB_Environment.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Environment.cpp (revision 2544)
@@ -27,6 +27,39 @@
2727
2828 SB_Environment::SB_Environment(void)
2929 {
30+ Show_PropertyEditor = 0;
31+ PropertyEditor_Page = 0;
32+
33+ Ambient_Int_Red = 0;
34+ Ambient_Int_Green = 0;
35+ Ambient_Int_Blue = 0;
36+
37+ Fog_Colour_Int_Red = 0;
38+ Fog_Colour_Int_Green = 0;
39+ Fog_Colour_Int_Blue = 0;
40+
41+ Float_PosX = 0;
42+ Float_PosY = 0;
43+ Float_StartPos = 0;
44+
45+ Eviron_Index = 0;
46+
47+ Is_Teleport = 0;
48+
49+ ClickOnTrack = 0;
50+ ClickOnVolume = 0;
51+ ClickOnPlay = 0;
52+ ClickOnLoop = 0;
53+
54+ ClickOnFogVisible = 0;
55+ ClickOnFogMode = 0;
56+ ClickOnFogColour = 0;
57+ ClickOnFogStart = 0;
58+ ClickOnFogEnd = 0;
59+
60+ ClickOnSkyEnabled = 0;
61+ ClickOnSkyTiling = 0;
62+ ClickOnSkyCurve = 0;
3063 }
3164
3265 SB_Environment::~SB_Environment(void)
@@ -129,7 +162,7 @@
129162 //App->SBC_Scene->UniqueID_Object_Counter++;
130163 App->CLSB_Scene->Object_Count++;
131164
132- //App->SBC_FileView->Set_FolderActive(App->SBC_FileView->FV_Sounds_Folder);
165+ //App->CLSB_FileView->Set_FolderActive(App->CLSB_FileView->FV_Sounds_Folder);
133166 return 1;
134167 }
135168
@@ -222,8 +255,8 @@
222255
223256 if (PlayMusic == 1)
224257 {
225- /*char buff[1024];
226- strcpy(buff, App->CLSB_SoundMgr->Default_Folder);
258+ char buff[1024];
259+ strcpy(buff, App->WorldEditor_Directory);
227260 strcat(buff, "\\Media\\Sounds\\");
228261
229262 if (App->CLSB_Scene->V_Object[Index]->S_Environ[0]->Play == 1)
@@ -230,15 +263,15 @@
230263 {
231264 strcat(buff, App->CLSB_Scene->V_Object[Index]->S_Environ[0]->Sound_File);
232265
233- App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile = App->SBC_SoundMgr->SoundEngine->play2D(buff, App->SBC_Scene->V_Object[Index]->S_Environ[0]->Loop, true, true);
266+ App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile = App->CLSB_SoundMgr->SoundEngine->play2D(buff, App->CLSB_Scene->V_Object[Index]->S_Environ[0]->Loop, true, true);
234267
235- App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile->setVolume(App->SBC_Scene->V_Object[Index]->S_Environ[0]->SndVolume);
268+ App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile->setVolume(App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndVolume);
236269 App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile->setIsPaused(false);
237- }*/
270+ }
238271 }
239272 else
240273 {
241- /*if (App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile == NULL)
274+ if (App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile == NULL)
242275 {
243276 }
244277 else
@@ -246,7 +279,7 @@
246279 App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile->setIsPaused(true);
247280 App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile->drop();
248281 App->CLSB_Scene->V_Object[Index]->S_Environ[0]->SndFile = NULL;
249- }*/
282+ }
250283 }
251284
252285 return 1;
@@ -405,7 +438,7 @@
405438 strcpy(App->CLSB_SoundMgr->Access_File, App->CLSB_Scene->V_Object[Eviron_Index]->S_Environ[0]->Sound_File);
406439
407440 App->CLSB_Environment->Set_Environment_By_Index(0, Eviron_Index);
408- //App->CLSB_SoundMgr->Dialog_SoundFile();
441+ App->CLSB_SoundMgr->Dialog_SoundFile();
409442
410443 if (App->CLSB_SoundMgr->IsCancelled == 0)
411444 {
--- WorldEditor/WorldEditor/SB_Equity.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Equity.cpp (revision 2544)
@@ -220,7 +220,9 @@
220220
221221 if (LOWORD(wParam) == ID_DEBUG_GENERAL)
222222 {
223- if (App->CLSB_Ogre->RenderListener->ShowBoundingGroup == 1)
223+ App->CLSB_Ogre->RenderListener->JustTexture_ID++;
224+
225+ /*if (App->CLSB_Ogre->RenderListener->ShowBoundingGroup == 1)
224226 {
225227 App->CLSB_Ogre->RenderListener->ShowBoundingGroup = 0;
226228 }
@@ -227,7 +229,7 @@
227229 else
228230 {
229231 App->CLSB_Ogre->RenderListener->ShowBoundingGroup = 1;
230- }
232+ }*/
231233
232234 return TRUE;
233235 }
@@ -963,6 +965,8 @@
963965 App->CLSB_Ogre->OgreListener->Pl_Cent500X = p.x;
964966 App->CLSB_Ogre->OgreListener->Pl_Cent500Y = p.y;
965967
968+ App->CLSB_Picking->Mouse_Pick_Entity();
969+
966970 SetCapture(App->ViewGLhWnd);// Bernie
967971 SetCursorPos(App->CursorPosX, App->CursorPosY);
968972
--- WorldEditor/WorldEditor/SB_Export_Ogre3D.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Export_Ogre3D.cpp (revision 2544)
@@ -1015,3 +1015,166 @@
10151015
10161016 return 1;
10171017 }
1018+
1019+// *************************************************************************
1020+// * Write_XML_WE_File:- Terry and Hazel Flanigan 2023 *
1021+// *************************************************************************
1022+bool SB_Export_Ogre3D::Write_WE_XML_File()
1023+{
1024+ S_XMLStore[0] = new XMLStore_Type;
1025+ S_XMLStore[0]->SortedPolyCount = 0;
1026+
1027+ char XmlFileName[256];
1028+ char XFIle[256];
1029+
1030+ strcpy(XmlFileName, App->CLSB_Model->JustName);
1031+
1032+ strcpy(XmlMeshFileName, XmlFileName);
1033+ strcpy(XmlScriptFileName, XmlFileName);
1034+ strcpy(XmlSkellFileName, XmlFileName);
1035+ strcpy(XmlSkellTagName, XmlFileName);
1036+
1037+ strcpy(XFIle, XmlFileName);
1038+
1039+ strcat(XmlScriptFileName, "_");
1040+ strcat(XmlSkellTagName, "_");
1041+
1042+ strcpy(XFIle, XmlMeshFileName);
1043+
1044+ strcat(XmlMeshFileName, ".mesh.xml");
1045+ strcat(XmlScriptFileName, ".material");
1046+ strcat(XmlSkellFileName, ".skeleton.xml");
1047+ strcat(XmlSkellTagName, ".skeleton");
1048+
1049+ WritePolyFile = nullptr;
1050+
1051+ WritePolyFile = fopen(XmlMeshFileName, "wt");
1052+ if (!WritePolyFile)
1053+ {
1054+ return 0;
1055+ }
1056+
1057+ fprintf(WritePolyFile, "%s\n", "<mesh>");
1058+ fprintf(WritePolyFile, "%s\n", " <submeshes>");
1059+
1060+ int Count = 0;
1061+ int BrushCount = App->CLSB_Model->XBrushCount;
1062+
1063+ while (Count < BrushCount)
1064+ {
1065+ int FaceCount = 0;
1066+ int BrushLoop = 0;
1067+ int SubBrushCount = App->CLSB_Model->B_XBrush[Count]->Brush_Count;
1068+
1069+ while (BrushLoop < SubBrushCount)
1070+ {
1071+ FaceCount = 0;
1072+
1073+ while (FaceCount < App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Face_Count)
1074+ {
1075+ FaceCount++;
1076+ }
1077+ }
1078+
1079+ Render_WE_ToXML(Count);
1080+ WriteNewXML(Count);
1081+ Count++;
1082+ }
1083+
1084+
1085+ fprintf(WritePolyFile, "%s\n", " </submeshes>");
1086+
1087+ /*if (DoSkell == 1)
1088+ {
1089+ fprintf(WritePolyFile, "%s%s%s\n", " <skeletonlink name=\"", XmlSkellTagName, "\" />");
1090+ }*/
1091+
1092+ fprintf(WritePolyFile, "%s\n", "</mesh>");
1093+
1094+ fclose(WritePolyFile);
1095+
1096+ if (S_XMLStore[0])
1097+ {
1098+ delete S_XMLStore[0];
1099+ S_XMLStore[0] = NULL;
1100+
1101+ }
1102+
1103+ return 1;
1104+}
1105+
1106+// *************************************************************************
1107+// * Render_WE_ToXML:- Terry and Hazel Flanigan 2023 *
1108+// *************************************************************************
1109+bool SB_Export_Ogre3D::Render_WE_ToXML(int GroupIndex)
1110+{
1111+ int FaceCount = 0;
1112+ int XMLCount = 0;
1113+ int Face = 0;
1114+
1115+ int A = 0;
1116+ int B = 0;
1117+ int C = 0;
1118+
1119+ while (FaceCount < App->CLSB_Model->Group[GroupIndex]->GroupFaceCount)
1120+ {
1121+ A = App->CLSB_Model->Group[GroupIndex]->Face_Data[FaceCount].a;
1122+ B = App->CLSB_Model->Group[GroupIndex]->Face_Data[FaceCount].b;
1123+ C = App->CLSB_Model->Group[GroupIndex]->Face_Data[FaceCount].c;
1124+
1125+ // first vector in face and vertic + normal and uv
1126+ S_XMLStore[0]->XMLvertex[XMLCount].x = App->CLSB_Model->Group[GroupIndex]->vertex_Data[A].x;
1127+ S_XMLStore[0]->XMLvertex[XMLCount].y = App->CLSB_Model->Group[GroupIndex]->vertex_Data[A].y;
1128+ S_XMLStore[0]->XMLvertex[XMLCount].z = App->CLSB_Model->Group[GroupIndex]->vertex_Data[A].z;
1129+
1130+ S_XMLStore[0]->mapcoord[XMLCount].u = App->CLSB_Model->Group[GroupIndex]->MapCord_Data[A].u;
1131+ S_XMLStore[0]->mapcoord[XMLCount].v = App->CLSB_Model->Group[GroupIndex]->MapCord_Data[A].v;
1132+
1133+ S_XMLStore[0]->XMLnormal[XMLCount].x = App->CLSB_Model->Group[GroupIndex]->Normal_Data[A].x;
1134+ S_XMLStore[0]->XMLnormal[XMLCount].y = App->CLSB_Model->Group[GroupIndex]->Normal_Data[A].y;
1135+ S_XMLStore[0]->XMLnormal[XMLCount].z = App->CLSB_Model->Group[GroupIndex]->Normal_Data[A].z;
1136+
1137+ S_XMLStore[0]->BoneIndex[XMLCount] = 0;// SN[cube.polygon[Count].a].BoneIndex;
1138+ S_XMLStore[0]->XMLpolygon[Face].a = XMLCount;
1139+ XMLCount++;
1140+
1141+ // second vector in face and vertic + normal and uv
1142+ S_XMLStore[0]->XMLvertex[XMLCount].x = App->CLSB_Model->Group[GroupIndex]->vertex_Data[B].x;
1143+ S_XMLStore[0]->XMLvertex[XMLCount].y = App->CLSB_Model->Group[GroupIndex]->vertex_Data[B].y;
1144+ S_XMLStore[0]->XMLvertex[XMLCount].z = App->CLSB_Model->Group[GroupIndex]->vertex_Data[B].z;
1145+
1146+ S_XMLStore[0]->mapcoord[XMLCount].u = App->CLSB_Model->Group[GroupIndex]->MapCord_Data[B].u;
1147+ S_XMLStore[0]->mapcoord[XMLCount].v = App->CLSB_Model->Group[GroupIndex]->MapCord_Data[B].v;
1148+
1149+ S_XMLStore[0]->XMLnormal[XMLCount].x = App->CLSB_Model->Group[GroupIndex]->Normal_Data[B].x;
1150+ S_XMLStore[0]->XMLnormal[XMLCount].y = App->CLSB_Model->Group[GroupIndex]->Normal_Data[B].y;
1151+ S_XMLStore[0]->XMLnormal[XMLCount].z = App->CLSB_Model->Group[GroupIndex]->Normal_Data[B].z;
1152+
1153+ S_XMLStore[0]->BoneIndex[XMLCount] = 0;// SN[cube.polygon[Count].a].BoneIndex;
1154+ S_XMLStore[0]->XMLpolygon[Face].b = XMLCount;
1155+ XMLCount++;
1156+
1157+ // third vector in face and vertic + normal and uv
1158+ S_XMLStore[0]->XMLvertex[XMLCount].x = App->CLSB_Model->Group[GroupIndex]->vertex_Data[C].x;
1159+ S_XMLStore[0]->XMLvertex[XMLCount].y = App->CLSB_Model->Group[GroupIndex]->vertex_Data[C].y;
1160+ S_XMLStore[0]->XMLvertex[XMLCount].z = App->CLSB_Model->Group[GroupIndex]->vertex_Data[C].z;
1161+
1162+ S_XMLStore[0]->mapcoord[XMLCount].u = App->CLSB_Model->Group[GroupIndex]->MapCord_Data[C].u;
1163+ S_XMLStore[0]->mapcoord[XMLCount].v = App->CLSB_Model->Group[GroupIndex]->MapCord_Data[C].v;
1164+
1165+ S_XMLStore[0]->XMLnormal[XMLCount].x = App->CLSB_Model->Group[GroupIndex]->Normal_Data[C].x;
1166+ S_XMLStore[0]->XMLnormal[XMLCount].y = App->CLSB_Model->Group[GroupIndex]->Normal_Data[C].y;
1167+ S_XMLStore[0]->XMLnormal[XMLCount].z = App->CLSB_Model->Group[GroupIndex]->Normal_Data[C].z;
1168+
1169+ S_XMLStore[0]->BoneIndex[XMLCount] = 0;// SN[cube.polygon[Count].a].BoneIndex;
1170+ S_XMLStore[0]->XMLpolygon[Face].c = XMLCount;
1171+ XMLCount++;
1172+ Face++;
1173+
1174+ FaceCount++;
1175+ }
1176+
1177+ S_XMLStore[0]->SXMLCount = XMLCount;
1178+
1179+ return 1;
1180+}
--- WorldEditor/WorldEditor/SB_Export_Ogre3D.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_Export_Ogre3D.h (revision 2544)
@@ -93,8 +93,13 @@
9393 bool CreateDirectoryMesh(void);
9494 bool DecompileTextures(void);
9595 void CreateMaterialFile(char* MatFileName);
96+
9697 bool Write_XML_File();
98+ bool Write_WE_XML_File();
99+
97100 bool RenderToXML(int GroupIndex);
101+ bool Render_WE_ToXML(int GroupIndex);
102+
98103 bool WriteNewXML(int GroupIndex);
99104 bool WriteSubMesh(int GroupIndex);
100105 bool Convert_To_Mesh();
--- WorldEditor/WorldEditor/SB_Grid.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Grid.cpp (revision 2544)
@@ -250,6 +250,21 @@
250250 App->CLSB_Ogre->mCamera->lookAt(Ogre::Vector3(0, 30, 0));
251251 }
252252
253+// *************************************************************************
254+// * Load_Gizmo:- Terry and Hazel Flanigan 2022 *
255+// *************************************************************************
256+void SB_Grid::Load_Gizmo(void)
257+{
258+
259+ Sight_Entity = App->CLSB_Ogre->mSceneMgr->createEntity("Arrow23", "axes.mesh", App->CLSB_Ogre->App_Resource_Group);
260+ Sight_Node = App->CLSB_Ogre->mSceneMgr->getRootSceneNode()->createChildSceneNode();
261+ Sight_Node->attachObject(Sight_Entity);
253262
263+ Sight_Node->setPosition(0, 0, 0);
264+ Sight_Node->setVisible(true);
265+ Sight_Node->setScale(1, 1, 1);
266+}
254267
255268
269+
270+
--- WorldEditor/WorldEditor/SB_Grid.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_Grid.h (revision 2544)
@@ -39,6 +39,7 @@
3939 void Hair_SetVisible(bool Option);
4040
4141 void Reset_View(void);
42+ void Load_Gizmo(void);
4243
4344 Ogre::ColourValue ColourMain;
4445 Ogre::ColourValue ColourHairZ;
@@ -62,13 +63,13 @@
6263 int Scale_Y;
6364 int Scale_Z;
6465
65- ManualObject* GridManual;
66- SceneNode* GridNode;
66+ Ogre::ManualObject* GridManual;
67+ Ogre::SceneNode* GridNode;
6768
68- ManualObject* HairManual;
69- SceneNode* HairNode;
69+ Ogre::ManualObject* HairManual;
70+ Ogre::SceneNode* HairNode;
7071
71- SceneNode* DummyNode;
72+ Ogre::SceneNode* DummyNode;
7273
7374 Ogre::Entity* Crosshair_Ent;
7475 Ogre::SceneNode* Crosshair_Node;
@@ -76,6 +77,9 @@
7677 Ogre::Entity* Selection_Ent;
7778 Ogre::SceneNode* Selection_Node;
7879
80+ Ogre::Entity* Sight_Entity;
81+ Ogre::SceneNode* Sight_Node;
82+
7983 bool ShowGridFlag;
8084 bool ShowDivisions;
8185 bool ShowHair;
--- WorldEditor/WorldEditor/SB_ImGui.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_ImGui.cpp (revision 2544)
@@ -302,6 +302,15 @@
302302 ImGui::Text("Motions:- %i", App->CLSB_Model->MotionCount);
303303 ImGui::Text(" --------------------------- Brushes ");
304304 ImGui::Text("XBrushes:- %i", App->CLSB_Model->XBrushCount);
305+ ImGui::Text("Texture Count:- %i", App->CLSB_Scene->AdjustedIndex_Count);
306+
307+ int Count = 0;
308+ while (Count < App->CLSB_Scene->AdjustedIndex_Count)
309+ {
310+ ImGui::Text("Texture ID:- %i", App->CLSB_Scene->AdjusedIndex_Store[Count]);
311+ Count++;
312+ }
313+
305314 ImGui::Text(" ");
306315
307316 ImVec2 Size = ImGui::GetWindowSize();
--- WorldEditor/WorldEditor/SB_Ogre.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Ogre.cpp (revision 2544)
@@ -83,8 +83,8 @@
8383 // Set Up Grid Functions
8484 App->CLSB_Grid->Grid_Update(1);
8585 App->CLSB_Grid->Hair_Update(1);
86+ App->CLSB_Grid->Load_Gizmo();
8687
87-
8888 App->CLSB_Grid->DummyNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
8989
9090 m_imgui.Init(mSceneMgr, RenderHwnd);
--- WorldEditor/WorldEditor/SB_OgreListener.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_OgreListener.cpp (revision 2544)
@@ -84,7 +84,9 @@
8484
8585 Animate_Ogre = 0;
8686 AnimationScale = 1;
87-
87+
88+ App->CLSB_Picking = new SB_Picking(App->CLSB_Ogre->mSceneMgr);
89+
8890 mCollisionTools = new MOC::CollisionTools(App->CLSB_Ogre->mSceneMgr);
8991 mCollisionTools->setHeightAdjust(3.5f);
9092 DistanceToCollision = 0;
--- WorldEditor/WorldEditor/SB_OgreListener.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_OgreListener.h (revision 2544)
@@ -33,7 +33,7 @@
3333
3434 //using namespace Ogre;
3535
36-class SB_OgreListener : public FrameListener
36+class SB_OgreListener : public Ogre::FrameListener
3737 {
3838 public:
3939 SB_OgreListener(void);
@@ -40,9 +40,9 @@
4040 ~SB_OgreListener(void);
4141
4242 void Reset_Class(void);
43- bool frameStarted(const FrameEvent& evt);
44- bool frameEnded(const FrameEvent& evt);
45- bool frameRenderingQueued(const FrameEvent& evt);
43+ bool frameStarted(const Ogre::FrameEvent& evt);
44+ bool frameEnded(const Ogre::FrameEvent& evt);
45+ bool frameRenderingQueued(const Ogre::FrameEvent& evt);
4646
4747 bool Update_Game_Logic(float DeltaTime);
4848
@@ -73,11 +73,11 @@
7373
7474 Ogre::Camera* mCam;
7575 Ogre::Camera* Pl_mDummyCamera;
76- Vector3 Pl_mDummyTranslateVector;
76+ Ogre::Vector3 Pl_mDummyTranslateVector;
7777
78- Radian mRotX;
79- Radian mRotY;
80- Vector3 mTranslateVector;
78+ Ogre::Radian mRotX;
79+ Ogre::Radian mRotY;
80+ Ogre::Vector3 mTranslateVector;
8181 int Wheel;
8282 double toggleTimer;
8383
--- WorldEditor/WorldEditor/SB_Picking.cpp (nonexistent)
+++ WorldEditor/WorldEditor/SB_Picking.cpp (revision 2544)
@@ -0,0 +1,315 @@
1+/*
2+Copyright (c) 2023 World Editor -- HGT Software W.T.Flanigan H.C.Flanigan
3+
4+This software is provided 'as-is', without any express or implied
5+warranty. In no event will the authors be held liable for any damages
6+arising from the use of this software.
7+
8+Permission is granted to anyone to use this software for any purpose,
9+including commercial applications, and to alter it and redistribute it
10+freely, subject to the following restrictions:
11+
12+1. The origin of this software must not be misrepresented; you must not
13+claim that you wrote the original software. If you use this software
14+in a product, an acknowledgment in the product documentation would be
15+appreciated but is not required.
16+
17+2. Altered source versions must be plainly marked as such, and must not be
18+misrepresented as being the original software.
19+
20+3. This notice may not be removed or altered from any source
21+distribution.
22+*/
23+
24+#include "stdafx.h"
25+#include "AB_App.h"
26+#include "SB_Picking.h"
27+
28+SB_Picking::SB_Picking(Ogre::SceneManager* sceneMgr)
29+{
30+ mSceneMgr = sceneMgr;
31+
32+ mRaySceneQuery = mSceneMgr->createRayQuery(Ogre::Ray());
33+ if (NULL == mRaySceneQuery)
34+ {
35+ App->Say("No Ray Query");
36+ return;
37+ }
38+ mRaySceneQuery->setSortByDistance(true);
39+
40+ pentity = NULL;
41+}
42+
43+SB_Picking::~SB_Picking()
44+{
45+ if (mRaySceneQuery != NULL)
46+ {
47+ delete mRaySceneQuery;
48+ }
49+}
50+
51+// *************************************************************************
52+// * Mouse_Pick_Entity::Terry and Hazel Flanigan 2023 *
53+// *************************************************************************
54+void SB_Picking::Mouse_Pick_Entity()
55+{
56+ HitVertices = Ogre::Vector3(0, 0, 0);
57+
58+ Ogre::RenderWindow* rw = App->CLSB_Ogre->mWindow;
59+ Ogre::Camera* camera = App->CLSB_Ogre->mCamera;
60+
61+ ImGuiIO& io = ImGui::GetIO();
62+
63+ Ogre::Real tx = io.MousePos.x / (Ogre::Real)rw->getWidth();
64+ Ogre::Real ty = io.MousePos.y / (Ogre::Real)rw->getHeight();
65+
66+ Ogre::Ray ray = camera->getCameraToViewportRay(tx, ty);
67+
68+ Ogre::uint32 queryMask = -1;
69+ Ogre::Vector3 result = Ogre::Vector3(0,0,0);
70+ Ogre::MovableObject* target = NULL;
71+ float closest_distance = 0;
72+
73+ if (App->CLSB_Picking->raycast(ray, result, target, closest_distance, queryMask))
74+ {
75+ App->Beep_Win();
76+ App->CLSB_Grid->Sight_Node->setPosition(result);
77+ }
78+
79+}
80+
81+// *************************************************************************
82+// * raycast *
83+// *************************************************************************
84+bool SB_Picking::raycast(const Ogre::Ray& ray, Ogre::Vector3& result, Ogre::MovableObject*& target, float& closest_distance, const Ogre::uint32 queryMask)
85+{
86+ target = NULL;
87+
88+ if (mRaySceneQuery != NULL)
89+ {
90+ mRaySceneQuery->setRay(ray);
91+ mRaySceneQuery->setSortByDistance(true);
92+ mRaySceneQuery->setQueryMask(queryMask);
93+ // execute the query, returns a vector of hits
94+ if (mRaySceneQuery->execute().size() <= 0)
95+ {
96+ // raycast did not hit an objects bounding box
97+ return (false);
98+ }
99+ }
100+ else
101+ {
102+
103+ App->Say("No Ray Query");
104+ return (false);
105+ }
106+
107+ // at this point we have raycast to a series of different objects bounding boxes.
108+ // we need to test these different objects to see which is the first polygon hit.
109+ // there are some minor optimizations (distance based) that mean we wont have to
110+ // check all of the objects most of the time, but the worst case scenario is that
111+ // we need to test every triangle of every object.
112+ //Ogre::Ogre::Real closest_distance = -1.0f;
113+ closest_distance = -1.0f;
114+ Ogre::Vector3 closest_result;
115+ Ogre::RaySceneQueryResult& query_result = mRaySceneQuery->getLastResults();
116+ for (size_t qr_idx = 0; qr_idx < query_result.size(); qr_idx++)
117+ {
118+ // stop checking if we have found a raycast hit that is closer
119+ // than all remaining entities
120+ if ((closest_distance >= 0.0f) &&
121+ (closest_distance < query_result[qr_idx].distance))
122+ {
123+ break;
124+ }
125+
126+ // only check this result if its a hit against an entity
127+ if ((query_result[qr_idx].movable != NULL) &&
128+ (query_result[qr_idx].movable->getMovableType().compare("Entity") == 0))
129+ {
130+ // get the entity to check
131+ pentity = static_cast<Ogre::MovableObject*>(query_result[qr_idx].movable);
132+
133+ // mesh data to retrieve
134+ size_t vertex_count;
135+ size_t index_count;
136+ Ogre::Vector3* vertices;
137+ Ogre::uint32* indices;
138+
139+ // get the mesh information
140+ GetMeshInformation(((Ogre::Entity*)pentity)->getMesh(), vertex_count, vertices, index_count, indices,
141+ pentity->getParentNode()->_getDerivedPosition(),
142+ pentity->getParentNode()->_getDerivedOrientation(),
143+ pentity->getParentNode()->_getDerivedScale());
144+
145+ // test for hitting individual triangles on the mesh
146+ bool new_closest_found = false;
147+ for (size_t i = 0; i < index_count; i += 3)
148+ {
149+ // check for a hit against this triangle
150+ std::pair<bool, Ogre::Real> hit = Ogre::Math::intersects(ray, vertices[indices[i]],
151+ vertices[indices[i + 1]], vertices[indices[i + 2]], true, false);
152+
153+ // if it was a hit check if its the closest
154+ if (hit.first)
155+ {
156+ if ((closest_distance < 0.0f) ||
157+ (hit.second < closest_distance))
158+ {
159+ // this is the closest so far, save it off
160+ closest_distance = hit.second;
161+ new_closest_found = true;
162+
163+ float X = vertices[indices[i]].x;
164+ //HitVertices.x = (Ogre::Real(vertices[indices[i]]));
165+ }
166+ }
167+ }
168+
169+ // free the verticies and indicies memory
170+ delete[] vertices;
171+ delete[] indices;
172+
173+ // if we found a new closest raycast for this object, update the
174+ // closest_result before moving on to the next object.
175+ if (new_closest_found)
176+ {
177+ target = pentity;
178+ closest_result = ray.getPoint(closest_distance);
179+ }
180+ }
181+ }
182+
183+ // return the result
184+ if (closest_distance >= 0.0f)
185+ {
186+ // raycast success
187+ result = closest_result;
188+ return (true);
189+ }
190+ else
191+ {
192+ // raycast failed
193+ return (false);
194+ }
195+}
196+
197+// *************************************************************************
198+// * GetMeshInformation *
199+// *************************************************************************
200+void SB_Picking::GetMeshInformation(const Ogre::MeshPtr mesh,size_t& vertex_count,Ogre::Vector3*& vertices,size_t& index_count,Ogre::uint32*& indices,const Ogre::Vector3& position,const Ogre::Quaternion& orient,const Ogre::Vector3& scale)
201+{
202+ bool added_shared = false;
203+ size_t current_offset = 0;
204+ size_t shared_offset = 0;
205+ size_t next_offset = 0;
206+ size_t index_offset = 0;
207+
208+ vertex_count = index_count = 0;
209+
210+ // Calculate how many vertices and indices we're going to need
211+ for (unsigned short i = 0; i < mesh->getNumSubMeshes(); ++i)
212+ {
213+ Ogre::SubMesh* submesh = mesh->getSubMesh(i);
214+
215+ // We only need to add the shared vertices once
216+ if (submesh->useSharedVertices)
217+ {
218+ if (!added_shared)
219+ {
220+ vertex_count += mesh->sharedVertexData->vertexCount;
221+ added_shared = true;
222+ }
223+ }
224+ else
225+ {
226+ vertex_count += submesh->vertexData->vertexCount;
227+ }
228+
229+ // Add the indices
230+ index_count += submesh->indexData->indexCount;
231+ }
232+
233+
234+ // Allocate space for the vertices and indices
235+ vertices = new Ogre::Vector3[vertex_count];
236+ indices = new Ogre::uint32[index_count];
237+
238+ added_shared = false;
239+
240+ // Run through the submeshes again, adding the data into the arrays
241+ for (unsigned short i = 0; i < mesh->getNumSubMeshes(); ++i)
242+ {
243+ Ogre::SubMesh* submesh = mesh->getSubMesh(i);
244+
245+ Ogre::VertexData* vertex_data = submesh->useSharedVertices ? mesh->sharedVertexData : submesh->vertexData;
246+
247+ if ((!submesh->useSharedVertices) || (submesh->useSharedVertices && !added_shared))
248+ {
249+ if (submesh->useSharedVertices)
250+ {
251+ added_shared = true;
252+ shared_offset = current_offset;
253+ }
254+
255+ const Ogre::VertexElement* posElem =
256+ vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
257+
258+ Ogre::HardwareVertexBufferSharedPtr vbuf =
259+ vertex_data->vertexBufferBinding->getBuffer(posElem->getSource());
260+
261+ unsigned char* vertex =
262+ static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
263+
264+ // There is _no_ baseVertexPointerToElement() which takes an Ogre::Ogre::Real or a double
265+ // as second argument. So make it float, to avoid trouble when Ogre::Ogre::Real will
266+ // be comiled/typedefed as double:
267+ // Ogre::Ogre::Real* pOgre::Real;
268+ float* pReal;
269+
270+ for (size_t j = 0; j < vertex_data->vertexCount; ++j, vertex += vbuf->getVertexSize())
271+ {
272+ posElem->baseVertexPointerToElement(vertex, &pReal);
273+
274+ Ogre::Vector3 pt(pReal[0], pReal[1], pReal[2]);
275+
276+ vertices[current_offset + j] = (orient * (pt * scale)) + position;
277+ }
278+
279+ vbuf->unlock();
280+ next_offset += vertex_data->vertexCount;
281+ }
282+
283+
284+ Ogre::IndexData* index_data = submesh->indexData;
285+ size_t numTris = index_data->indexCount / 3;
286+ Ogre::HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;
287+
288+ bool use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);
289+
290+ Ogre::uint32* pLong = static_cast<Ogre::uint32*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
291+ unsigned short* pShort = reinterpret_cast<unsigned short*>(pLong);
292+
293+
294+ size_t offset = (submesh->useSharedVertices) ? shared_offset : current_offset;
295+
296+ if (use32bitindexes)
297+ {
298+ for (size_t k = 0; k < numTris * 3; ++k)
299+ {
300+ indices[index_offset++] = pLong[k] + static_cast<Ogre::uint32>(offset);
301+ }
302+ }
303+ else
304+ {
305+ for (size_t k = 0; k < numTris * 3; ++k)
306+ {
307+ indices[index_offset++] = static_cast<Ogre::uint32>(pShort[k]) +
308+ static_cast<Ogre::uint32>(offset);
309+ }
310+ }
311+
312+ ibuf->unlock();
313+ current_offset = next_offset;
314+ }
315+}
--- WorldEditor/WorldEditor/SB_Picking.h (nonexistent)
+++ WorldEditor/WorldEditor/SB_Picking.h (revision 2544)
@@ -0,0 +1,45 @@
1+#pragma once
2+
3+/*
4+Copyright (c) 2023 World Editor -- HGT Software W.T.Flanigan H.C.Flanigan
5+
6+This software is provided 'as-is', without any express or implied
7+warranty. In no event will the authors be held liable for any damages
8+arising from the use of this software.
9+
10+Permission is granted to anyone to use this software for any purpose,
11+including commercial applications, and to alter it and redistribute it
12+freely, subject to the following restrictions:
13+
14+1. The origin of this software must not be misrepresented; you must not
15+claim that you wrote the original software. If you use this software
16+in a product, an acknowledgment in the product documentation would be
17+appreciated but is not required.
18+
19+2. Altered source versions must be plainly marked as such, and must not be
20+misrepresented as being the original software.
21+
22+3. This notice may not be removed or altered from any source
23+distribution.
24+*/
25+
26+class SB_Picking
27+{
28+public:
29+ SB_Picking(Ogre::SceneManager* sceneMgr);
30+ ~SB_Picking();
31+
32+ void SB_Picking::Mouse_Pick_Entity();
33+
34+private:
35+ bool raycast(const Ogre::Ray& ray, Ogre::Vector3& result, Ogre::MovableObject*& target, float& closest_distance, const Ogre::uint32 queryMask);
36+ void GetMeshInformation(const Ogre::MeshPtr mesh, size_t& vertex_count, Ogre::Vector3*& vertices, size_t& index_count, Ogre::uint32*& indices, const Ogre::Vector3& position, const Ogre::Quaternion& orient, const Ogre::Vector3& scale);
37+
38+ Ogre::SceneManager* mSceneMgr;
39+ Ogre::RaySceneQuery* mRaySceneQuery;
40+
41+ Ogre::MovableObject* pentity;
42+
43+ Ogre::Vector3 HitVertices;
44+};
45+
--- WorldEditor/WorldEditor/SB_Render.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Render.cpp (revision 2544)
@@ -53,6 +53,8 @@
5353 Show_HideGroup = 0;
5454 Show_Crosshair = 0;
5555
56+ JustTexture_ID = 0;
57+
5658 Selected_Group = 0;
5759 GroupNumber = 0;
5860 //TestLight();
@@ -382,7 +384,7 @@
382384
383385 glColor3f(1, 1, 1);
384386
385- int BrushCount = App->CLSB_Model->XBrushCount;;
387+ int BrushCount = App->CLSB_Model->XBrushCount;
386388
387389 while (Count < BrushCount)
388390 {
@@ -501,28 +503,30 @@
501503 OldId = App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->TextID_Data[FaceCount].ID;
502504 }
503505
506+ //if (App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->TextID_Data[FaceCount].ID == JustTexture_ID)
507+ {
508+ A = App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Face_Data[FaceCount].a;
509+ B = App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Face_Data[FaceCount].b;
510+ C = App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Face_Data[FaceCount].c;
504511
505- A = App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Face_Data[FaceCount].a;
506- B = App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Face_Data[FaceCount].b;
507- C = App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Face_Data[FaceCount].c;
512+ glBegin(GL_POLYGON);
508513
509- glBegin(GL_POLYGON);
514+ //-----------------------------------------------
515+ glTexCoord2f(App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[A].u, App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[A].v);
516+ glNormal3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Normal_Data[A].x);
517+ glVertex3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->vertex_Data[A].x);
510518
511- //-----------------------------------------------
512- glTexCoord2f(App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[A].u, App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[A].v);
513- glNormal3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Normal_Data[A].x);
514- glVertex3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->vertex_Data[A].x);
519+ //-----------------------------------------------
520+ glTexCoord2f(App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[B].u, App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[B].v);
521+ glNormal3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Normal_Data[B].x);
522+ glVertex3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->vertex_Data[B].x);
515523
516- //-----------------------------------------------
517- glTexCoord2f(App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[B].u, App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[B].v);
518- glNormal3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Normal_Data[B].x);
519- glVertex3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->vertex_Data[B].x);
524+ //-----------------------------------------------
525+ glTexCoord2f(App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[C].u, App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[C].v);
526+ glNormal3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Normal_Data[C].x);
527+ glVertex3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->vertex_Data[C].x);
528+ }
520529
521- //-----------------------------------------------
522- glTexCoord2f(App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[C].u, App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->MapCord_Data[C].v);
523- glNormal3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->Normal_Data[C].x);
524- glVertex3fv(&App->CLSB_Model->B_XBrush[Count]->B_Brush[BrushLoop]->vertex_Data[C].x);
525-
526530 FaceCount++;
527531
528532 glEnd();
--- WorldEditor/WorldEditor/SB_Render.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_Render.h (revision 2544)
@@ -25,7 +25,7 @@
2525
2626 #include "Ogre.h"
2727
28-class SB_Render : public RenderQueueListener
28+class SB_Render : public Ogre::RenderQueueListener
2929 {
3030 public:
3131 SB_Render();
@@ -59,6 +59,8 @@
5959 bool Show_HideGroup;
6060 bool Show_Crosshair;
6161
62+ int JustTexture_ID;
63+
6264 int Selected_Group;
6365 int GroupNumber;
6466
@@ -71,10 +73,10 @@
7173
7274 protected:
7375
74- virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const String& invocation,
76+ virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation,
7577 bool& skipThisInvocation);
7678
77- virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const String& invocation,
79+ virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation,
7880 bool& repeatThisInvocation);
7981
8082 void PreRender();
--- WorldEditor/WorldEditor/SB_Scene.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_Scene.cpp (revision 2544)
@@ -307,6 +307,7 @@
307307 bool SB_Scene::Level_Build_G3ds(Level3* pLevel, const char* Filename, BrushList* BList, int ExpSelected, geBoolean ExpLights, int GroupID)
308308 {
309309 App->CLSB_Model->XBrushCount = 0;
310+ AdjustedIndex_Count = 0;
310311
311312 int i;
312313 geBoolean* WrittenTex;
@@ -333,7 +334,10 @@
333334
334335 }
335336 }
337+
336338
339+ AdjustedIndex_Count = AdjustedIndex;
340+
337341 BrushList_Export(BList, GE_FALSE);
338342
339343 free(WrittenTex);
--- WorldEditor/WorldEditor/SB_Scene.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_Scene.h (revision 2544)
@@ -57,6 +57,7 @@
5757 int Object_Count;
5858
5959 int AdjusedIndex_Store[500];
60+ int AdjustedIndex_Count;
6061
6162 bool FullScreenMode_Flag;
6263 bool SameBrush;
--- WorldEditor/WorldEditor/SB_SoundMgr.cpp (revision 2543)
+++ WorldEditor/WorldEditor/SB_SoundMgr.cpp (revision 2544)
@@ -50,312 +50,316 @@
5050 {
5151 }
5252
53-//// *************************************************************************
54-//// * Dialog_SoundFile() Terry Bernie *
55-//// *************************************************************************
56-//bool SB_SoundMgr::Dialog_SoundFile()
57-//{
58-// IsCancelled = 0;
59-// SndFile = nullptr;
60-//
61-// DialogBox(App->hInst,(LPCTSTR)IDD_GD_SOUNDPLAYER,App->Fdlg,(DLGPROC)Dialog_SoundFile_Proc);
62-// return 1;
63-//}
64-//// *************************************************************************
65-//// * Dialog_SoundFile_Proc Terry Bernie *
66-//// *************************************************************************
67-//LRESULT CALLBACK SB_SoundMgr::Dialog_SoundFile_Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
68-//{
69-//
70-// switch (message)
71-// {
72-// case WM_INITDIALOG:
73-// {
74-// App->SetTitleBar(hDlg);
75-//
76-// HFONT Font;
77-// Font = CreateFont( -15,0,0,0,FW_BOLD,0,0,0,0,OUT_TT_ONLY_PRECIS ,0,0,0, "Aerial Black");
78-// SendDlgItemMessage(hDlg,IDC_TITLENAME, WM_SETFONT, (WPARAM)App->Font_Arial20, MAKELPARAM(TRUE, 0));
79-// SendDlgItemMessage(hDlg,IDC_SOUNDLIST, WM_SETFONT, (WPARAM)App->Font_CB15, MAKELPARAM(TRUE, 0));
80-// SendDlgItemMessage(hDlg,IDC_EDITINT, WM_SETFONT, (WPARAM)App->Font_CB15, MAKELPARAM(TRUE, 0));
81-//
82-// SetDlgItemText(hDlg,IDC_TITLENAME,(LPCTSTR)"Sound Player");
83-//
84-//
85-// App->SBC_SoundMgr->GetSoundFiles(hDlg,"*.ogg");
86-// App->SBC_SoundMgr->GetSoundFiles(hDlg,"*.wav");
87-//
88-// char Sound[MAX_PATH];
89-// HWND ListHwnd = GetDlgItem(hDlg, IDC_SOUNDLIST);
90-//
91-// SendMessage(ListHwnd, LB_SETCURSEL, 0, (LPARAM)(LPCTSTR)0);
92-// SendDlgItemMessage(hDlg, IDC_SOUNDLIST, LB_GETTEXT, (WPARAM) 0, (LPARAM)Sound);
93-// SetDlgItemText(hDlg, IDC_EDITINT, (LPTSTR)Sound);
94-//
95-// //int Sel = SendMessage(GetDlgItem(hDlg, IDC_SOUNDLIST), LB_SELECTSTRING, -1, (LPARAM)App->SBC_SoundMgr->Current_Object_Sound);
96-//
97-// //char buff[255];
98-// //SendDlgItemMessage(hDlg, IDC_SOUNDLIST, LB_GETTEXT, (WPARAM)Sel, (LPARAM)buff);
99-// //SetDlgItemText(hDlg, IDC_EDITINT, (LPTSTR)buff);
100-//
101-// int VolPer = int(App->SBC_SoundMgr->SndVolume*10);
102-//
103-// HWND Slider =GetDlgItem(hDlg,IDC_SLVOLUME);
104-// SendMessage(Slider, TBM_SETRANGE, (WPARAM) TRUE,(LPARAM) MAKELONG(0,10));
105-// SendMessage(Slider, TBM_SETPOS, (WPARAM) 1,(LPARAM)VolPer);
106-//
107-// VolPer = VolPer*10;
108-//
109-// char buf[10];
110-// sprintf(buf,"%i",VolPer);
111-// SetDlgItemText(hDlg,IDC_VOLBOX,(LPCTSTR)buf);
112-//
113-// if (App->SBC_SoundMgr->Accessed == 1)
114-// {
115-// SendMessage(GetDlgItem(hDlg, IDC_SOUNDLIST), LB_SELECTSTRING, -1, (LPARAM)App->SBC_SoundMgr->Access_File);
116-// }
117-//
118-// return TRUE;
119-// }
120-// case WM_CTLCOLORSTATIC:
121-// {
122-// /*if(GetDlgItem(hDlg,IDC_STPER) == (HWND)lParam)
123-// {
124-// SetBkColor((HDC) wParam, RGB(0, 255, 0));
125-// SetTextColor((HDC) wParam, RGB(0,0,0));
126-// SetBkMode((HDC) wParam, TRANSPARENT);
127-// return (UINT) App->AppBackground;
128-// }*/
129-// if(GetDlgItem(hDlg,IDC_STVOLUME) == (HWND)lParam)
130-// {
131-// SetBkColor((HDC) wParam, RGB(0, 255, 0));
132-// SetTextColor((HDC) wParam, RGB(0,0,0));
133-// SetBkMode((HDC) wParam, TRANSPARENT);
134-// return (UINT) App->DialogBackGround;
135-// }
136-// if(GetDlgItem(hDlg,IDC_VOLBOX) == (HWND)lParam)
137-// {
138-// SetBkColor((HDC) wParam, RGB(0, 255, 0));
139-// SetTextColor((HDC) wParam, RGB(0,0,0));
140-// SetBkMode((HDC) wParam, TRANSPARENT);
141-// return (UINT) App->Brush_White;
142-// }
143-// if(GetDlgItem(hDlg,IDC_EDITINT) == (HWND)lParam)
144-// {
145-// SetBkColor((HDC) wParam, RGB(0, 255, 0));
146-// SetTextColor((HDC) wParam, RGB(0,0,0));
147-// SetBkMode((HDC) wParam, TRANSPARENT);
148-// return (UINT) App->Brush_White;
149-// }
150-// if(GetDlgItem(hDlg,IDC_SLVOLUME) == (HWND)lParam)
151-// {
152-// SetBkColor((HDC) wParam, RGB(0, 255, 0));
153-// SetTextColor((HDC) wParam, RGB(0,0,255));
154-// SetBkMode((HDC) wParam, TRANSPARENT);
155-// return (UINT) App->DialogBackGround;
156-// }
157-// if(GetDlgItem(hDlg,IDC_TITLENAME) == (HWND)lParam)
158-// {
159-// SetBkColor((HDC) wParam, RGB(0, 255, 0));
160-// SetTextColor((HDC) wParam, RGB(0,0,0));
161-// SetBkMode((HDC) wParam, TRANSPARENT);
162-// return (UINT) App->DialogBackGround;
163-// }
164-// return FALSE;
165-// }
166-//
167-// case WM_CTLCOLORDLG:
168-// {
169-// return (LONG)App->DialogBackGround;
170-// }
171-// case WM_HSCROLL :
172-// {
173-// HWND Slider = GetDlgItem(hDlg,IDC_SLVOLUME);
174-// int pos = 0;
175-// int Percent = 0;
176-// char buf[20];
177-// pos = SendMessage(Slider, TBM_GETPOS, (WPARAM) 0,(LPARAM)0);
178-// Percent = pos*10;
179-// sprintf(buf,"%i",Percent);
180-// SetDlgItemText(hDlg,IDC_VOLBOX,(LPCTSTR)buf);
181-//
182-// float sum2 = float(Percent) / 100;
183-// App->SBC_SoundMgr->SndVolume = sum2;
184-//
185-// if (App->SBC_SoundMgr->SndFile)
186-// {
187-// App->SBC_SoundMgr->SndFile->setVolume(sum2);
188-// }
189-//
190-// return 1;
191-// }
192-//
193-// case WM_NOTIFY:
194-// {
195-// LPNMHDR nmhdr = (LPNMHDR) lParam;
196-//
197-// if (nmhdr->idFrom == IDC_PLAY && nmhdr->code == NM_CUSTOMDRAW)
198-// {
199-// LPNMCUSTOMDRAW item = (LPNMCUSTOMDRAW)nmhdr;
200-// App->Custom_Button_Normal(item);
201-// return CDRF_DODEFAULT;
202-// }
203-//
204-// if (nmhdr->idFrom == IDOK && nmhdr->code == NM_CUSTOMDRAW)
205-// {
206-// LPNMCUSTOMDRAW item = (LPNMCUSTOMDRAW)nmhdr;
207-// App->Custom_Button_Normal(item);
208-// return CDRF_DODEFAULT;
209-// }
210-//
211-// if (nmhdr->idFrom == IDCANCEL && nmhdr->code == NM_CUSTOMDRAW)
212-// {
213-// LPNMCUSTOMDRAW item = (LPNMCUSTOMDRAW)nmhdr;
214-// App->Custom_Button_Normal(item);
215-// return CDRF_DODEFAULT;
216-// }
217-//
218-// }break;
219-//
220-// case WM_COMMAND:
221-//
222-//
223-// if (LOWORD(wParam) == IDC_BT_STOP)
224-// {
225-// App->SBC_SoundMgr->SndFile->stop();
226-//
227-// return TRUE;
228-// }
229-//
230-// if (LOWORD(wParam) == IDC_BT_PAUSE)
231-// {
232-// bool Paused = App->SBC_SoundMgr->SndFile->getIsPaused();
233-// if (Paused == 1)
234-// {
235-// App->SBC_SoundMgr->SndFile->setIsPaused(0);
236-// }
237-// else
238-// {
239-// App->SBC_SoundMgr->SndFile->setIsPaused(1);
240-// }
241-//
242-// return TRUE;
243-// }
244-//
245-// if (LOWORD(wParam) == IDC_SOUNDLIST)
246-// {
247-// char buff[256];
248-// int Index=0;
249-// Index = SendDlgItemMessage(hDlg,IDC_SOUNDLIST,LB_GETCURSEL, (WPARAM)0, (LPARAM)0);
250-//
251-// if (Index==-1)
252-// {
253-// return 1;
254-// }
255-//
256-// SendDlgItemMessage(hDlg,IDC_SOUNDLIST,LB_GETTEXT, (WPARAM)Index, (LPARAM)buff);
257-//
258-// SetDlgItemText(hDlg,IDC_EDITINT,(LPTSTR)buff);
259-//
260-// if (App->SBC_SoundMgr->Accessed == 1)
261-// {
262-// strcpy(App->SBC_SoundMgr->Access_File, buff);
263-// }
264-//
265-// return TRUE;
266-// }
267-//
268-// if (LOWORD(wParam) == IDOK)
269-// {
270-// if (App->SBC_SoundMgr->SndFile==NULL)
271-// {
272-// }
273-// else
274-// {
275-// App->SBC_SoundMgr->SndFile->stop();
276-// App->SBC_SoundMgr->SndFile=NULL;
277-// }
278-//
279-// App->SBC_SoundMgr->IsCancelled = 0;
280-//
281-// char file[256];
282-// GetDlgItemText(hDlg,IDC_EDITINT,(LPTSTR)file,256);
283-// strcpy(App->SBC_SoundMgr->mSoundFile,file);
284-// App->SBC_SoundMgr->Remeber_SoundFile(file);
285-//
286-// App->SBC_SoundMgr->Accessed = 0;
287-// EndDialog(hDlg, LOWORD(wParam));
288-// return TRUE;
289-// }
290-//
291-// if (LOWORD(wParam)== IDCANCEL)
292-// {
293-// if (App->SBC_SoundMgr->SndFile == NULL)
294-// {
295-// }
296-// else
297-// {
298-// App->SBC_SoundMgr->SndFile->stop();
299-// App->SBC_SoundMgr->SndFile->drop();
300-// App->SBC_SoundMgr->SndFile = NULL;
301-//
302-// }
303-//
304-// App->SBC_SoundMgr->Accessed = 0;
305-// App->SBC_SoundMgr->IsCancelled = 1;
306-// EndDialog(hDlg, LOWORD(wParam));
307-// return TRUE;
308-// }
309-//
310-// if (LOWORD(wParam)== IDC_PLAY)
311-// {
312-//
313-// GetDlgItemText(hDlg,IDC_EDITINT,(LPTSTR)App->SBC_SoundMgr->m_Current_Sound_file,MAX_PATH);
314-//
315-// if (App->SBC_SoundMgr->SndFile==NULL)
316-// {
317-// }
318-// else
319-// {
320-// App->SBC_SoundMgr->SndFile->stop();
321-// App->SBC_SoundMgr->SndFile=NULL;
322-// }
323-//
324-// int result=1;
325-// result = strcmp(App->SBC_SoundMgr->m_Current_Sound_file,"");
326-// if (result == 0)
327-// {
328-//
329-// }
330-// else
331-// {
332-// result = strcmp(App->SBC_SoundMgr->m_Current_Sound_file,"None");
333-// if (result == 0)
334-// {
335-//
336-// }
337-// else
338-// {
339-// char Sound[1024];
340-// strcpy(Sound,App->SBC_SoundMgr->Default_Folder);
341-// strcat(Sound,"\\Media\\Sounds\\");
342-// strcat(Sound, App->SBC_SoundMgr->m_Current_Sound_file);
343-//
344-// App->SBC_SoundMgr->SndFile = App->SBC_SoundMgr->SoundEngine->play2D(Sound,false,true,true);
345-// App->SBC_SoundMgr->SndFile->setVolume(App->SBC_SoundMgr->SndVolume);
346-// App->SBC_SoundMgr->SndFile->setIsPaused(false);
347-// }
348-// }
349-// return TRUE;
350-// }
351-//
352-// break;
353-//
354-// }
355-// return FALSE;
356-//}
357-//
35853 // *************************************************************************
54+// * Dialog_SoundFile() Terry Bernie *
55+// *************************************************************************
56+bool SB_SoundMgr::Dialog_SoundFile()
57+{
58+ IsCancelled = 0;
59+ SndFile = nullptr;
60+
61+ DialogBox(App->hInst,(LPCTSTR)IDD_SB_SOUNDPLAYER,App->Equity_Dlg_hWnd,(DLGPROC)Dialog_SoundFile_Proc);
62+ return 1;
63+}
64+// *************************************************************************
65+// * Dialog_SoundFile_Proc Terry Bernie *
66+// *************************************************************************
67+LRESULT CALLBACK SB_SoundMgr::Dialog_SoundFile_Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
68+{
69+
70+ switch (message)
71+ {
72+ case WM_INITDIALOG:
73+ {
74+ //App->SetTitleBar(hDlg);
75+
76+ HFONT Font;
77+ Font = CreateFont( -15,0,0,0,FW_BOLD,0,0,0,0,OUT_TT_ONLY_PRECIS ,0,0,0, "Aerial Black");
78+ SendDlgItemMessage(hDlg,IDC_TITLENAME, WM_SETFONT, (WPARAM)App->Font_Arial20, MAKELPARAM(TRUE, 0));
79+ SendDlgItemMessage(hDlg,IDC_SOUNDLIST, WM_SETFONT, (WPARAM)App->Font_CB15, MAKELPARAM(TRUE, 0));
80+ SendDlgItemMessage(hDlg,IDC_EDITINT, WM_SETFONT, (WPARAM)App->Font_CB15, MAKELPARAM(TRUE, 0));
81+
82+ SendDlgItemMessage(hDlg, IDC_PLAY, WM_SETFONT, (WPARAM)App->Font_CB15, MAKELPARAM(TRUE, 0));
83+ SendDlgItemMessage(hDlg, IDC_BT_PAUSE, WM_SETFONT, (WPARAM)App->Font_CB15, MAKELPARAM(TRUE, 0));
84+ SendDlgItemMessage(hDlg, IDC_BT_STOP, WM_SETFONT, (WPARAM)App->Font_CB15, MAKELPARAM(TRUE, 0));
85+
86+ SetDlgItemText(hDlg,IDC_TITLENAME,(LPCTSTR)"Sound Player");
87+
88+
89+ App->CLSB_SoundMgr->GetSoundFiles(hDlg,"*.ogg");
90+ App->CLSB_SoundMgr->GetSoundFiles(hDlg,"*.wav");
91+
92+ char Sound[MAX_PATH];
93+ HWND ListHwnd = GetDlgItem(hDlg, IDC_SOUNDLIST);
94+
95+ SendMessage(ListHwnd, LB_SETCURSEL, 0, (LPARAM)(LPCTSTR)0);
96+ SendDlgItemMessage(hDlg, IDC_SOUNDLIST, LB_GETTEXT, (WPARAM) 0, (LPARAM)Sound);
97+ SetDlgItemText(hDlg, IDC_EDITINT, (LPTSTR)Sound);
98+
99+ //int Sel = SendMessage(GetDlgItem(hDlg, IDC_SOUNDLIST), LB_SELECTSTRING, -1, (LPARAM)App->SBC_SoundMgr->Current_Object_Sound);
100+
101+ //char buff[255];
102+ //SendDlgItemMessage(hDlg, IDC_SOUNDLIST, LB_GETTEXT, (WPARAM)Sel, (LPARAM)buff);
103+ //SetDlgItemText(hDlg, IDC_EDITINT, (LPTSTR)buff);
104+
105+ int VolPer = int(App->CLSB_SoundMgr->SndVolume*10);
106+
107+ HWND Slider =GetDlgItem(hDlg,IDC_SLVOLUME);
108+ SendMessage(Slider, TBM_SETRANGE, (WPARAM) TRUE,(LPARAM) MAKELONG(0,10));
109+ SendMessage(Slider, TBM_SETPOS, (WPARAM) 1,(LPARAM)VolPer);
110+
111+ VolPer = VolPer*10;
112+
113+ char buf[10];
114+ sprintf(buf,"%i",VolPer);
115+ SetDlgItemText(hDlg,IDC_VOLBOX,(LPCTSTR)buf);
116+
117+ if (App->CLSB_SoundMgr->Accessed == 1)
118+ {
119+ SendMessage(GetDlgItem(hDlg, IDC_SOUNDLIST), LB_SELECTSTRING, -1, (LPARAM)App->CLSB_SoundMgr->Access_File);
120+ }
121+
122+ return TRUE;
123+ }
124+ case WM_CTLCOLORSTATIC:
125+ {
126+ /*if(GetDlgItem(hDlg,IDC_STPER) == (HWND)lParam)
127+ {
128+ SetBkColor((HDC) wParam, RGB(0, 255, 0));
129+ SetTextColor((HDC) wParam, RGB(0,0,0));
130+ SetBkMode((HDC) wParam, TRANSPARENT);
131+ return (UINT) App->AppBackground;
132+ }*/
133+ if(GetDlgItem(hDlg,IDC_STVOLUME) == (HWND)lParam)
134+ {
135+ SetBkColor((HDC) wParam, RGB(0, 255, 0));
136+ SetTextColor((HDC) wParam, RGB(0,0,0));
137+ SetBkMode((HDC) wParam, TRANSPARENT);
138+ return (UINT) App->AppBackground;
139+ }
140+ if(GetDlgItem(hDlg,IDC_VOLBOX) == (HWND)lParam)
141+ {
142+ SetBkColor((HDC) wParam, RGB(0, 255, 0));
143+ SetTextColor((HDC) wParam, RGB(0,0,0));
144+ SetBkMode((HDC) wParam, TRANSPARENT);
145+ return (UINT) App->Brush_White;
146+ }
147+ if(GetDlgItem(hDlg,IDC_EDITINT) == (HWND)lParam)
148+ {
149+ SetBkColor((HDC) wParam, RGB(0, 255, 0));
150+ SetTextColor((HDC) wParam, RGB(0,0,0));
151+ SetBkMode((HDC) wParam, TRANSPARENT);
152+ return (UINT) App->Brush_White;
153+ }
154+ if(GetDlgItem(hDlg,IDC_SLVOLUME) == (HWND)lParam)
155+ {
156+ SetBkColor((HDC) wParam, RGB(0, 255, 0));
157+ SetTextColor((HDC) wParam, RGB(0,0,255));
158+ SetBkMode((HDC) wParam, TRANSPARENT);
159+ return (UINT) App->AppBackground;
160+ }
161+ if(GetDlgItem(hDlg,IDC_TITLENAME) == (HWND)lParam)
162+ {
163+ SetBkColor((HDC) wParam, RGB(0, 255, 0));
164+ SetTextColor((HDC) wParam, RGB(0,0,0));
165+ SetBkMode((HDC) wParam, TRANSPARENT);
166+ return (UINT) App->AppBackground;
167+ }
168+ return FALSE;
169+ }
170+
171+ case WM_CTLCOLORDLG:
172+ {
173+ return (LONG)App->AppBackground;
174+ }
175+ case WM_HSCROLL :
176+ {
177+ HWND Slider = GetDlgItem(hDlg,IDC_SLVOLUME);
178+ int pos = 0;
179+ int Percent = 0;
180+ char buf[20];
181+ pos = SendMessage(Slider, TBM_GETPOS, (WPARAM) 0,(LPARAM)0);
182+ Percent = pos*10;
183+ sprintf(buf,"%i",Percent);
184+ SetDlgItemText(hDlg,IDC_VOLBOX,(LPCTSTR)buf);
185+
186+ float sum2 = float(Percent) / 100;
187+ App->CLSB_SoundMgr->SndVolume = sum2;
188+
189+ if (App->CLSB_SoundMgr->SndFile)
190+ {
191+ App->CLSB_SoundMgr->SndFile->setVolume(sum2);
192+ }
193+
194+ return 1;
195+ }
196+
197+ case WM_NOTIFY:
198+ {
199+ LPNMHDR nmhdr = (LPNMHDR) lParam;
200+
201+ if (nmhdr->idFrom == IDC_PLAY && nmhdr->code == NM_CUSTOMDRAW)
202+ {
203+ LPNMCUSTOMDRAW item = (LPNMCUSTOMDRAW)nmhdr;
204+ App->Custom_Button_Normal(item);
205+ return CDRF_DODEFAULT;
206+ }
207+
208+ if (nmhdr->idFrom == IDOK && nmhdr->code == NM_CUSTOMDRAW)
209+ {
210+ LPNMCUSTOMDRAW item = (LPNMCUSTOMDRAW)nmhdr;
211+ App->Custom_Button_Normal(item);
212+ return CDRF_DODEFAULT;
213+ }
214+
215+ if (nmhdr->idFrom == IDCANCEL && nmhdr->code == NM_CUSTOMDRAW)
216+ {
217+ LPNMCUSTOMDRAW item = (LPNMCUSTOMDRAW)nmhdr;
218+ App->Custom_Button_Normal(item);
219+ return CDRF_DODEFAULT;
220+ }
221+
222+ }break;
223+
224+ case WM_COMMAND:
225+
226+
227+ if (LOWORD(wParam) == IDC_BT_STOP)
228+ {
229+ App->CLSB_SoundMgr->SndFile->stop();
230+
231+ return TRUE;
232+ }
233+
234+ if (LOWORD(wParam) == IDC_BT_PAUSE)
235+ {
236+ bool Paused = App->CLSB_SoundMgr->SndFile->getIsPaused();
237+ if (Paused == 1)
238+ {
239+ App->CLSB_SoundMgr->SndFile->setIsPaused(0);
240+ }
241+ else
242+ {
243+ App->CLSB_SoundMgr->SndFile->setIsPaused(1);
244+ }
245+
246+ return TRUE;
247+ }
248+
249+ if (LOWORD(wParam) == IDC_SOUNDLIST)
250+ {
251+ char buff[256];
252+ int Index=0;
253+ Index = SendDlgItemMessage(hDlg,IDC_SOUNDLIST,LB_GETCURSEL, (WPARAM)0, (LPARAM)0);
254+
255+ if (Index==-1)
256+ {
257+ return 1;
258+ }
259+
260+ SendDlgItemMessage(hDlg,IDC_SOUNDLIST,LB_GETTEXT, (WPARAM)Index, (LPARAM)buff);
261+
262+ SetDlgItemText(hDlg,IDC_EDITINT,(LPTSTR)buff);
263+
264+ if (App->CLSB_SoundMgr->Accessed == 1)
265+ {
266+ strcpy(App->CLSB_SoundMgr->Access_File, buff);
267+ }
268+
269+ return TRUE;
270+ }
271+
272+ if (LOWORD(wParam) == IDOK)
273+ {
274+ if (App->CLSB_SoundMgr->SndFile==NULL)
275+ {
276+ }
277+ else
278+ {
279+ App->CLSB_SoundMgr->SndFile->stop();
280+ App->CLSB_SoundMgr->SndFile=NULL;
281+ }
282+
283+ App->CLSB_SoundMgr->IsCancelled = 0;
284+
285+ char file[256];
286+ GetDlgItemText(hDlg,IDC_EDITINT,(LPTSTR)file,256);
287+ strcpy(App->CLSB_SoundMgr->mSoundFile,file);
288+ App->CLSB_SoundMgr->Remeber_SoundFile(file);
289+
290+ App->CLSB_SoundMgr->Accessed = 0;
291+ EndDialog(hDlg, LOWORD(wParam));
292+ return TRUE;
293+ }
294+
295+ if (LOWORD(wParam)== IDCANCEL)
296+ {
297+ if (App->CLSB_SoundMgr->SndFile == NULL)
298+ {
299+ }
300+ else
301+ {
302+ App->CLSB_SoundMgr->SndFile->stop();
303+ App->CLSB_SoundMgr->SndFile->drop();
304+ App->CLSB_SoundMgr->SndFile = NULL;
305+
306+ }
307+
308+ App->CLSB_SoundMgr->Accessed = 0;
309+ App->CLSB_SoundMgr->IsCancelled = 1;
310+ EndDialog(hDlg, LOWORD(wParam));
311+ return TRUE;
312+ }
313+
314+ if (LOWORD(wParam)== IDC_PLAY)
315+ {
316+
317+ GetDlgItemText(hDlg,IDC_EDITINT,(LPTSTR)App->CLSB_SoundMgr->m_Current_Sound_file,MAX_PATH);
318+
319+ if (App->CLSB_SoundMgr->SndFile==NULL)
320+ {
321+ }
322+ else
323+ {
324+ App->CLSB_SoundMgr->SndFile->stop();
325+ App->CLSB_SoundMgr->SndFile=NULL;
326+ }
327+
328+ int result=1;
329+ result = strcmp(App->CLSB_SoundMgr->m_Current_Sound_file,"");
330+ if (result == 0)
331+ {
332+
333+ }
334+ else
335+ {
336+ result = strcmp(App->CLSB_SoundMgr->m_Current_Sound_file,"None");
337+ if (result == 0)
338+ {
339+
340+ }
341+ else
342+ {
343+ char Sound[1024];
344+ strcpy(Sound,App->WorldEditor_Directory);
345+ strcat(Sound,"\\Media\\Sounds\\");
346+ strcat(Sound, App->CLSB_SoundMgr->m_Current_Sound_file);
347+
348+ App->CLSB_SoundMgr->SndFile = App->CLSB_SoundMgr->SoundEngine->play2D(Sound,false,true,true);
349+ App->CLSB_SoundMgr->SndFile->setVolume(App->CLSB_SoundMgr->SndVolume);
350+ App->CLSB_SoundMgr->SndFile->setIsPaused(false);
351+ }
352+ }
353+ return TRUE;
354+ }
355+
356+ break;
357+
358+ }
359+ return FALSE;
360+}
361+
362+// *************************************************************************
359363 // * InitSound_Defaults Terry Bernie *
360364 // *************************************************************************
361365 bool SB_SoundMgr::InitSound_Defaults(int Index)
@@ -375,13 +379,13 @@
375379 // *************************************************************************
376380 bool SB_SoundMgr::GetSoundFiles(HWND hDlg,char *Extention)
377381 {
378- /*HWND ListHwnd = GetDlgItem(hDlg,IDC_SOUNDLIST);
382+ HWND ListHwnd = GetDlgItem(hDlg,IDC_SOUNDLIST);
379383
380384 WIN32_FIND_DATA ffd;
381385 HANDLE hFind = INVALID_HANDLE_VALUE;
382386
383387 char SearchName[1024];
384- strcpy(SearchName,Default_Folder);
388+ strcpy(SearchName, App->WorldEditor_Directory);
385389 strcat(SearchName,"\\Media\\Sounds\\");
386390 strcat(SearchName,Extention);
387391
@@ -392,7 +396,7 @@
392396 while (FindNextFile(hFind, &ffd) != 0)
393397 {
394398 SendMessage(ListHwnd,LB_ADDSTRING, 0, (LPARAM) (LPCTSTR)ffd.cFileName);
395- }*/
399+ }
396400
397401 return 1;
398402 }
--- WorldEditor/WorldEditor/SB_SoundMgr.h (revision 2543)
+++ WorldEditor/WorldEditor/SB_SoundMgr.h (revision 2544)
@@ -36,6 +36,7 @@
3636 bool GetSoundFiles(HWND hDlg,char *Extention);
3737 bool Remeber_SoundFile(char* File);
3838 bool Play_StartUp_Sound();
39+ bool Dialog_SoundFile();
3940
4041 char mSoundFile[255];
4142 char Current_Object_Sound[255];
@@ -58,7 +59,7 @@
5859 std::vector<std::string> Sound_File;
5960
6061 protected:
61-
62+ static LRESULT CALLBACK Dialog_SoundFile_Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
6263
6364 };
6465
--- WorldEditor/WorldEditor/resource.h (revision 2543)
+++ WorldEditor/WorldEditor/resource.h (revision 2544)
@@ -172,6 +172,7 @@
172172 #define IDB_BITMAP2 344
173173 #define IDB_FVFOLDERRED 344
174174 #define IDD_SB_TRUEFALSE 345
175+#define IDD_SB_SOUNDPLAYER 347
175176 #define IDC_RESET_ALL 1000
176177 #define IDC_EDIT1 1001
177178 #define IDC_EDIT10 1002
@@ -614,11 +615,13 @@
614615 #define IDC_BT_LOWERRIGHT 1364
615616 #define IDC_BUTTON8 1364
616617 #define IDC_BTFACEPREVIOUS 1364
618+#define IDC_BT_PAUSE 1364
617619 #define IDC_STTEXT 1365
618620 #define IDC_GD_SPHEROID_PRIMITIVE 1365
619621 #define IDC_BT_FOLDER_NAME 1365
620622 #define IDC_CKSLOW 1365
621623 #define IDC_BT_LOWERLEFT 1365
624+#define IDC_BT_STOP 1365
622625 #define IDC_STMESSAGE 1366
623626 #define IDC_GD_CONE_PRIMITIVE 1366
624627 #define IDC_STTEXT2 1366
@@ -844,6 +847,13 @@
844847 #define IDC_BT_ENVIRONMENT 1539
845848 #define IDC_TITLENAME 1540
846849 #define IDC_CHECKYES 1541
850+#define IDC_SOUNDLIST 1542
851+#define IDC_EDITINT 1543
852+#define IDC_PLAY 1544
853+#define IDC_SLVOLUME 1545
854+#define IDC_EDITINT2 1546
855+#define IDC_VOLBOX 1546
856+#define IDC_STVOLUME 1547
847857 #define ID_BRUSH_PRIMITIVES_CUBE 32771
848858 #define ID_BRUSH_PRIMITIVES_PYRAMID 32772
849859 #define ID_BRUSH_PRIMITIVES_SPHEROID 32773
@@ -1057,9 +1067,9 @@
10571067 #ifdef APSTUDIO_INVOKED
10581068 #ifndef APSTUDIO_READONLY_SYMBOLS
10591069 #define _APS_3D_CONTROLS 1
1060-#define _APS_NEXT_RESOURCE_VALUE 347
1070+#define _APS_NEXT_RESOURCE_VALUE 349
10611071 #define _APS_NEXT_COMMAND_VALUE 33092
1062-#define _APS_NEXT_CONTROL_VALUE 1542
1072+#define _APS_NEXT_CONTROL_VALUE 1548
10631073 #define _APS_NEXT_SYMED_VALUE 112
10641074 #endif
10651075 #endif
Show on old repository browser