Comments (13)
It looks like you're using incorrect vertex winding. Backface culling works by only drawing faces with vertices in clockwise order, so e.g. left and right faces need to be drawn in opposite order.
from crafti.
Oh, I had a feeling it might be something like that, so what order should I draw it in? Since clockwise doesn't exactly apply to 3D space...
from crafti.
oh wait, I think I understand what you meant
from crafti.
When you look at the front of a face, the vertices have to be in clockwise order. That means that the backside automatically has them in CCW order. This is how it's determined what the front side of a face is.
from crafti.
Great, I just re-aranged my drawing order and it fixed the problem, thanks!
Also, just wondering, would it be possible to create particles from within a block renderer?
from crafti.
The block renderer methods are only called for dirty chunks, i.e. after a block was changed. That means the particles will only spawn after something explicitly triggered such a change, e.g. placing a block in the chunk. If that's fine for your use case, you can call addParticle
in any render function.
If not, you could render them as animation, like the torch flame. That also has the benefit that it can immediately react to changes to the source block, unlike particles which are immutable from the outside.
from crafti.
Does the tick function not happen every tick?
Also, what is the difference between local_x and just x in blockrenderer functions?
from crafti.
Yes, every 10 frames. If you want to spawn particles in there, they'd need to have a lifetime of at most 10 frames, otherwise they'd start to accumulate. It's also possible to disable ticks ("World: static"), in which case the particles would be missing entirely.
from crafti.
So I'm guessing that animations are like ticks, except with configurable frame-steppiness (frames_per_step)
from crafti.
Lastly, just wondering
- What is the difference between setBlock and changeBlock?
- What is the difference between local_x and then just x in renderer functions?
Also, I'm trying to give TNT particles, but it doesn't seem to be working:
void TNTRenderer::explode(const int local_x, const int local_y, const int local_z, Chunk &c)
{
c.setGlobalBlockRelative(local_x, local_y, local_z, BLOCK_AIR);
Particle p;
p.size = 14;
p.tae = terrain_atlas[1][1].current;
// Use the center quarter of the texture
const int tex_width = p.tae.right - p.tae.left,
tex_height = p.tae.bottom - p.tae.top;
p.tae.left += tex_width / 4;
p.tae.right -= tex_width / 4;
p.tae.top += tex_height / 4;
p.tae.bottom -= tex_height / 4;
// Random value between 0 and max (not including max)
const auto randMax = [](GLFix max) { return max * (rand() & 0xFF) / 0xFF; };
// Get the center of the block contents (chunk relative coordinates)
const auto aabb = global_block_renderer.getAABB(getBLOCK(c.getGlobalBlockRelative(local_x, local_y, local_z)), local_x * BLOCK_SIZE, local_y * BLOCK_SIZE, local_z * BLOCK_SIZE);
auto center = VECTOR3{(aabb.low_x + aabb.high_x) / 2, (aabb.low_y + aabb.high_y) / 2, (aabb.low_z + aabb.high_z) / 2};
center.x -= local_x;
center.y -= local_y;
center.z -= local_z;
// Spawn four particles at the center with random velocity and offset
for(int i = 0; i < 4; ++i)
{
p.vel = {randMax(10) - 5, randMax(5), randMax(10) - 5};
p.pos = center;
p.pos.x += randMax(100) - 50;
p.pos.y += randMax(100) - 50;
p.pos.z += randMax(100) - 50;
c.addParticle(p);
}
Thanks in advance
from crafti.
Also, what is the difference between local_x and just x in blockrenderer functions?
renderSpecialBlock
and getAABB
work with coordinates (GLFix
), while the other methods work with block indexes within a chunk (int
).
So I'm guessing that animations are like ticks, except with configurable frame-steppiness (frames_per_step)
The animation callback is run every frame, it's responsible for drawing whatever it needs to whenever it wants to.
What is the difference between setBlock and changeBlock?
setBlock
is a bit lower level than changeBlock
. The latter triggers the addedBlock
and removedBlock
notifications, which are important for some types of blocks.
from crafti.
I think
center.x -= local_x;
center.y -= local_y;
center.z -= local_z;
is wrong. At that point, center
is already in chunk-relative coordinates.
from crafti.
it seems to work now, (positioning is a little off, but that's something I can fix later)
thanks!
from crafti.
Related Issues (20)
- Won't open on TI-Nspire CX II CAS Handheld or Student Software HOT 1
- Redstone wire uses cobweb texture HOT 4
- Bug found HOT 8
- Suggestion: more redstone blocks, fly HOT 1
- Compile to take advantage of the new 396 megahertz processor. HOT 10
- Redstone lamp bug HOT 1
- Scrollable inventory HOT 3
- Questions regarding source and float alternative HOT 8
- Special Block Data? HOT 16
- Lever/Switch, texture questions HOT 2
- I accidentally opened this issue, view the real one: https://github.com/Vogtinator/crafti/issues/24 HOT 1
- "TI-Nspire CX II, TI- Nspire CX CAS II" has "64 MB of RAM, 100 MB of Flash ROM" and "ARM9 @ 396 MHz CPU" Please make an upgraded version that makes use of this extra power! HOT 3
- Transforming terrain.png into c byte array HOT 1
- Doors, switches and other HOT 2
- TI-Nspire: Document format not supported HOT 1
- New Tech, upgrade graphics?? HOT 1
- Can't turn my head. Is that normal? HOT 16
- Calculator crashes after opening crafti for a second time HOT 5
- Cannot transfer not ".tns" files to Calculator HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crafti.