Jump to content

how can I do this in c++?


shadmar
 Share

Recommended Posts

In lua I would do this :

--index which vary on each recurisive run.
local mid=-dim..":"..-df..":"..dim..":"..df..":"..xfactor..":"..yfactor..":"..division..":"..factor..":"..orientation.x..":"..orientation.y..":"..orientation.z

--create model if the index "mid" doesn't exist in table models
if models[mid]==nil then
	model = Model:Create()
    model:SetRotation(orientation)
    models[mid] = model
end

 

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

#include <stdio.h>
#include <unordered_map>
unordered_map<std::string, Model*> models;
...
  
std::stringstream mid_stream;
mid_stream << -dim << ":" << -df << ":" << dim << (...)
std::string mid = mid_stream.str();
if (models.find(mid) == models.end())
{
    Model* model = Model::Create();
    model->SetRotation(orientation);
    models[mid] = model;
}

Edit: meh, 5 minutes too late ;)

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...