Hi i was making a voxel engine. That needed player destroy and place blocks.
But how i can do that.
I made map system loads from array.
But i want player dynamically place and remove blocks
with freeglut no other libraries.
What i needed.
My math isn't very good. So i just using very basic math.
What is simpliest way.
Also this will help other users that makes game with dynamic world elements.
If do you want i can give credit you in Gamejolt game page.
Also i want a cube generated at cursor position z position will get from tra_z variable.
That keyboard controlled z position.
But i don't want cube move with mouse when i click it will be must done.
It must not follow mouse or player.
It just like copies variable values to drawCube(=mouseX,=mouseY,=tra_z);
like that i don't want use variable i want copy value of variable to inside to drawCube
and when copies it's must be done no follow must happen when player moves.
When player moves cube must stay at where it's placed.
well, presumably you have some kind of voxel class, which should have a position, color/texture, whatever stuff about it, and maybe some sort of placer object (a container of voxels with coordinates defined from its center, eg a sphere of voxels defined by its center or a cube, etc, could be little more than a vector and a coordinate setting constructor).
And what I suggest after this is (one or many) collapsed meta voxel container(s). That is, as you create placer objects via user input, the meta container will lump all the voxels into the new container(s), eliminate repeated voxels, and produce a deduplicated container(s) of all the placed voxels. You will also iterate this container(s) efficiently by coordinates to destroy voxels upon user command to do so, and if the destruction is in an area of effect (again, usually a simple geometric volume) you need a way to id and clobber the correct ones efficiently, which means some clever way to organize them by their coordinates. How you organize it is critical to performance, so this is where you need to think hard. Also, there shouldn't be too much math here, just xyz coordinate math.
i've made with lambda .
But i want when user presses g key on keyboard.
It needed be drawn but it's not seen.
what is problem.
You know standart glut keyboard thing you can see in glut examples.
qqq(); was lambda containing. Thing.
But i wan't also when i press g it needed make new variable instert player position into int and draw the cube but with lambda only i can do one cube. I want when object
draw on player position. when player moves and presses g again it will needed draw cube at player position.
it will be needed unlimied amounts of cube must generated by pressing g key or mouse.
So i do needed use
like if i needed 10 cubes i neded 10x3 = 30 variables copy copy repaste etc.
To make limited amoundts and very cumbersome thing.
But i want infinite amounts of cubes generated like in minecraft.
I was searching voxel placement like what Minecraft does.
This is a little hard to follow. I know english is hard for you, but we may need more words or some code to unravel what you are even asking.
like if i needed 10 cubes i neded 10x3 = 30 variables copy copy repaste etc.
-- I don't know because you didn't give us your design. I would hope NOT. I would hope if you need 10 cubes, you have 1 variable, of a container type like a vector or list or such, that holds 10 cubes. Each of the 10 cubes may in turn hold many other variables, but you should only have 1 access point for all this data.
But i want infinite amounts of cubes generated like in minecraft.
-- computers are finite, but I get you. Ok, so the above still works for that. At some point you need, as I said above, to organize your voxels for performance reasons, but technically, you can just dump them all in one container and have billions. And again, how you organize them matters as it is going to need to be very clean for high speed.
I was searching voxel placement like what Minecraft does.
I have no clue how it does things, and can't help there.