示例#1
0
static Querier* generateQuery(QueryHandler* handler, const BoundingBox3& region, bool static_queries, const SolidAngle& qmin, const SolidAngle& qmax, const float q_distance, uint32 q_max_results) {
    Vector3 qpos = generatePosition(region);
    Vector3 qvel = generateDirection(!static_queries);

    MotionPath::MotionVectorListPtr mpl(new MotionPath::MotionVectorList());
    mpl->push_back(MotionVector3(Time::null(), qpos, qvel));

    Querier* querier = new Querier(handler,
        MotionPath(Vector3(0,0,0), mpl),
        generateQueryBounds(),
        generateQueryRadius(),
        generateQueryAngle(qmin, qmax),
        q_distance,
        q_max_results
    );
    return querier;
}
示例#2
0
bool Scenes::Menu::initialize()
{
	Shader.reset(new PMX::PMXShader);
	assert(Shader);
	if (!Shader->InitializeBuffers(Renderer->GetDevice(), nullptr))
		return false;
	Shader->SetLightCount(1);
	Shader->SetLights(DirectX::XMVectorSplatOne(), DirectX::XMVectorSplatOne(), DirectX::XMVectorSplatOne(), DirectX::XMVectorSet(-1.0f, -1.0f, 1.0f, 0.0f), DirectX::XMVectorZero(), 0);

	auto &Viewport = Renderer->getViewport();
	Camera.reset(new Renderer::Camera(DirectX::XM_PIDIV4, (float)Viewport.Width / (float)Viewport.Height, Renderer::SCREEN_NEAR, Renderer::SCREEN_DEPTH));
	assert(Camera);
	Camera->SetPosition(0, 10.0f, 0.0f);

	Frustum.reset(new Renderer::ViewFrustum);
	assert(Frustum);

	// Create a list of motions to be used as idle animations
	fs::directory_iterator EndIterator;
	fs::path MotionPath(L"./Data/Motions/Idle/");
	for (fs::directory_iterator Entry(MotionPath); Entry != EndIterator; Entry++) {
		if (fs::is_regular_file(Entry->status()) && Entry->path().extension().wstring().compare(L".vmd") == 0) {
			KnownMotions.emplace_back(Entry->path().generic_wstring());
		}
	}

	DirectX::XMMATRIX View, Projection;
	Camera->setFocalDistance(-35.0f);
	Camera->update(0.0f);
	Camera->getViewMatrix(View);
	Camera->getProjectionMatrix(Projection);

	Frustum->Construct(Renderer::SCREEN_DEPTH, Projection, View);

	Shader->SetEyePosition(Camera->GetPosition());
	Shader->SetMatrices(DirectX::XMMatrixIdentity(), View, Projection);

	// Initializes the model
	// Pause the physics environment, to prevent resource race
	Physics->pause();
	// Select a model to be displayed
#if 1
	auto ModelList = ModelHandler->getKnownModels();
	do {
		size_t Index = RandomGenerator() % ModelList.size();
		for (auto &ModelPath : ModelList) {
			if (Index-- == 0) {
				Model = ModelHandler->loadModel(ModelPath.first, Physics);
				ModelList.erase(ModelPath.first);
				break;
			}
		}
	} while (!Model);
#else
	Model = ModelHandler->loadModel(L"Tda式改変WIMミク ver.2.9", Physics);
	Model->SetDebugFlags(PMX::Model::DebugFlags::RenderBones);
#endif
	Model->SetShader(Shader);

	if (!Model->Initialize(Renderer, Physics))
		return false;
	Physics->resume();

	return true;
}