浏览代码

add model for stone tool item

Kolja Strohm 2 年之前
父节点
当前提交
4df5155854
共有 3 个文件被更改,包括 40 次插入48 次删除
  1. 2 44
      FactoryCraft/Entity.cpp
  2. 38 4
      FactoryCraft/Load.cpp
  3. 二进制
      FactoryCraft/data_release/models/items.m3

+ 2 - 44
FactoryCraft/Entity.cpp

@@ -421,49 +421,8 @@ bool Entity::tick(double time)
 					break;
 				}
 			}
-			double t = MIN(totalTime, currentFrame.duration);
-			speed = { 0, 0, speed.z };
-			if ((currentFrame.movementFlags | 1) == currentFrame.movementFlags)
-			{
-				speed += {currentFrame.direction.x, currentFrame.direction.y, 0};
-			}
-			if ((currentFrame.movementFlags | 2) == currentFrame.movementFlags)
-			{
-				Vec2<float> norm = { currentFrame.direction.x, currentFrame.direction.y };
-				norm.CCW90().normalize();
-				speed += {norm.x, norm.y, 0};
-			}
-			if ((currentFrame.movementFlags | 4) == currentFrame.movementFlags)
-			{
-				speed += {-currentFrame.direction.x, -currentFrame.direction.y, 0};
-			}
-			if ((currentFrame.movementFlags | 8) == currentFrame.movementFlags)
-			{
-				Vec2<float> norm = { currentFrame.direction.x, currentFrame.direction.y };
-				norm.CW90().normalize();
-				speed += {norm.x, norm.y, 0};
-			}
-			if ((currentFrame.movementFlags | 16) == currentFrame.movementFlags)
-			{
-				speed.z = -maxMovementSpeed;
-			}
-			else if ((currentFrame.movementFlags | 32) == currentFrame.movementFlags)
-			{
-				speed.z = maxMovementSpeed;
-			}
-			else
-			{
-				speed.z = 0.f;
-			}
-			Vec2<float> norm = { speed.x, speed.y };
-			if (norm.getLengthSq() != 0)
-			{
-				norm.normalize();
-				speed.x = norm.x * maxMovementSpeed;
-				speed.y = norm.y * maxMovementSpeed;
-			}
-			// TODO: collision check
-			pos += speed * (float)t;
+			double t = min(currentFrame.duration, totalTime);
+			pos += (currentFrame.targetPosition - pos) * (float)(t / currentFrame.duration);
 			currentFrame.duration -= t;
 			totalTime -= t;
 			if (currentFrame.duration <= 0)
@@ -472,7 +431,6 @@ bool Entity::tick(double time)
 			}
 			rend = 1;
 		}
-
 	}
 	return Model3D::tick(time);
 }

+ 38 - 4
FactoryCraft/Load.cpp

@@ -1,13 +1,15 @@
-#include "Load.h"
-#include "Initialisierung.h"
 #include <AsynchronCall.h>
 #include <Datei.h>
 #include <Array.h>
 #include <DateiSystem.h>
 #include <Text.h>
-#include "Globals.h"
 #include <Textur.h>
 #include <GraphicsApi.h>
+#include <M3Datei.h>
+
+#include "Load.h"
+#include "Initialisierung.h"
+#include "Globals.h"
 #include "Login.h"
 
 void createDefaultCube(Bildschirm* zScreen)
@@ -466,7 +468,7 @@ LoadMenu::LoadMenu(Bildschirm* zScreen)
 	new AsynchronCall("Load Menu", [this, zScreen]()
 		{
 			Sleep(1000);
-			all->setAktionAnzahl(1);
+			all->setAktionAnzahl(2);
 			all->reset();
 			// loading textures
 			Datei texturF;
@@ -499,7 +501,39 @@ LoadMenu::LoadMenu(Bildschirm* zScreen)
 				}
 				files->release();
 			}
+			all->aktionPlus();
+			// loading models
+			stage->setAktionAnzahl(1);
+			Datei modelF;
+			modelF.setDatei("data/models");
+			files = modelF.getDateiListe();
+			if (files)
+			{
+				int count = 0;
+				for (Text* fileName : *files)
+				{
+					M3Datei dat(Text("data/models/") + *fileName);
+					dat.leseDaten();
+					count += dat.getModelAnzahl();
+				}
+				stage->setAktionAnzahl(count + 1);
+				stage->reset();
+				for (Text* fileName : *files)
+				{
+					M3Datei dat(Text("data/models/") + *fileName);
+					dat.leseDaten();
+					for (int i = 0; i < dat.getModelAnzahl(); i++)
+					{
+						step->reset();
+						Model3DData* d = dat.ladeModel(dat.zModelName(i)->getText(), zScreen->zGraphicsApi(), *fileName + "/" + *dat.zModelName(i));
+						d->release();
+						stage->aktionPlus();
+					}
+				}
+				files->release();
+			}
 			createModels(zScreen);
+			stage->aktionPlus();
 			all->aktionPlus();
 			stage->reset();
 			zScreen->lock();

二进制
FactoryCraft/data_release/models/items.m3