所以我正在使用这段代码来编写文件(现在只是测试,我稍后会编写一个关卡编辑器):
int main()
{
ofstream file("level.bin", ios::binary);
int ents = 1; //number of entites
file.write((char*)&ents, sizeof(int));
float x = 300; //x and y coords
float y = 500;
file.write((char*)&x, sizeof(float));
file.write((char*)&y, sizeof(float));
int imglength = 12; //strings are prefixed by a length
file.write((char*)&imglength, sizeof(int));
string img = "platform.png"; //string
file.write(img.c_str(), sizeof(img.c_str()));
cout << "wrote\n";
return 0;
}
我用来加载它的代码是这样的:
void SceneManager::LoadScene(std::string filename)
{
std::ifstream file(filename.c_str(), std::ios::binary);
int ents;
file.read((char*)&ents, sizeof(int));
std::cout << ents << std::endl;
for(int i = 0; i < …
Run Code Online (Sandbox Code Playgroud) 所以我有:
class bc_Game
{
public:
//blah
private:
b2World world;
};
bc_Game::bc_Game()
{
//blah, defining variables used
world = b2World(gravity, sleep);
}
现在,我只是得到错误:没有匹配函数调用 'b2World :: b2World()' 注:考生:b2World :: b2World(常量b2Vec2&,布尔)注:b2World :: b2World(常量b2World&)
我不知道如何让它工作,我已经尝试过std :: auto_ptr,新的b2World,我能想到的一切.
b2World是Box2D的一部分,但是这里......
/*
* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted …Run Code Online (Sandbox Code Playgroud) 所以我回来了另一个光线追踪问题.我的代码渲染球体都很好,花花公子,但立方体并没有真正起作用.我正在使用此代码来测试交叉点:http://pastebin.com/qgm6vpdx(这是一个递归函数,t是到交点的距离)边界框定义为:
Cube* c1 = new Cube;
c1->Corner1 = Vec3(100, 100, 100);
c1->Corner2 = Vec3(200, 200, 200);
Run Code Online (Sandbox Code Playgroud)
我已经确认相机不在立方体内.现在,唯一的问题是整个屏幕显示为绿色(指定给立方体的颜色)
我不认为我正在做正确的立方体交叉点,任何人都可以证明我的代码?