@@ -127,48 +127,56 @@ int ExportRegionDriver2(CDriver2LevelRegion* region, IVirtualStream* levelFileSt
127127 // walk through all cell data
128128 for (int i = 0 ; i < mapInfo.region_size * mapInfo.region_size ; i++)
129129 {
130- CELL_ITERATOR_D2 iterator ;
131- PACKED_CELL_OBJECT* pco = region->StartIterator (&iterator , i);
130+ CELL_ITERATOR_D2 ci ;
131+ PACKED_CELL_OBJECT* pco = region->StartIterator (&ci , i);
132132
133133 if (!pco)
134134 continue ;
135135
136136 while (pco)
137137 {
138- CELL_OBJECT co;
139- CDriver2LevelMap::UnpackCellObject (co, pco, iterator.nearCell );
140-
141- Vector3D absCellPosition (co.pos .vx * -EXPORT_SCALING, co.pos .vy * -EXPORT_SCALING, co.pos .vz * EXPORT_SCALING);
142- float cellRotationRad = co.yang / 64 .0f * PI_F * 2 .0f ;
138+ for (int i = 0 ; i < 20 ; i++)
139+ {
140+ if (i == 19 )
141+ ci.cellLevel = 100 ; // 100 is the special slot for event object placement
142+ else
143+ ci.cellLevel = i;
143144
144- ModelRef_t* ref = g_levModels.GetModelByIndex (co.type );
145+ CELL_OBJECT co;
146+ CDriver2LevelMap::UnpackCellObject (co, pco, ci.nearCell );
145147
146- if (ref)
147- {
148- if (g_export_worldUnityScript)
149- {
150- String modelName = strlen (ref->name ) > 0 ? String::fromCString (ref->name ) : String::fromPrintf (" MOD_%d" , ref->index );
148+ Vector3D absCellPosition (co.pos .vx * -EXPORT_SCALING, co.pos .vy * -EXPORT_SCALING, co.pos .vz * EXPORT_SCALING);
149+ float cellRotationRad = co.yang / 64 .0f * PI_F * 2 .0f ;
151150
152- float cellRotationDeg = RAD2DEG (cellRotationRad) + 180 ;
151+ ModelRef_t* ref = g_levModels. GetModelByIndex (co. type ) ;
153152
154- levelFileStream->Print (" var reg%d_o%d = Instantiate(%s, new Vector3(%gf,%gf,%gf), Quaternion.Euler(0.0f,%gf,0.0f)) as GameObject;\n " ,
155- region->GetNumber (), numRegionObjects, (char *)modelName, absCellPosition.x , absCellPosition.y , absCellPosition.z , -cellRotationDeg);
156- }
157- else
153+ if (ref)
158154 {
159- // transform objects and save
160- Matrix4x4 transform = translate (absCellPosition);
161- transform = transform * rotateY4 (cellRotationRad) * scale4 (1 .0f , 1 .0f , 1 .0f );
162-
163- WriteMODELToObjStream (levelFileStream, ref->model , ref->size , co.type ,
164- String::fromPrintf (" reg%d" , region->GetNumber ()),
165- false , transform, &lobj_first_v, &lobj_first_t );
155+ if (g_export_worldUnityScript)
156+ {
157+ String modelName = strlen (ref->name ) > 0 ? String::fromCString (ref->name ) : String::fromPrintf (" MOD_%d" , ref->index );
158+
159+ float cellRotationDeg = RAD2DEG (cellRotationRad) + 180 ;
160+
161+ levelFileStream->Print (" var reg%d_o%d = Instantiate(%s, new Vector3(%gf,%gf,%gf), Quaternion.Euler(0.0f,%gf,0.0f)) as GameObject;\n " ,
162+ region->GetNumber (), numRegionObjects, (char *)modelName, absCellPosition.x , absCellPosition.y , absCellPosition.z , -cellRotationDeg);
163+ }
164+ else
165+ {
166+ // transform objects and save
167+ Matrix4x4 transform = translate (absCellPosition);
168+ transform = transform * rotateY4 (cellRotationRad) * scale4 (1 .0f , 1 .0f , 1 .0f );
169+
170+ WriteMODELToObjStream (levelFileStream, ref->model , ref->size , co.type ,
171+ String::fromPrintf (" reg%d" , region->GetNumber ()),
172+ false , transform, &lobj_first_v, &lobj_first_t );
173+ }
166174 }
167- }
168175
169- numRegionObjects++;
176+ numRegionObjects++;
170177
171- pco = levMapDriver2->GetNextPackedCop (&iterator);
178+ pco = levMapDriver2->GetNextPackedCop (&ci);
179+ }
172180 }
173181 }
174182
0 commit comments