Hello everyone, I am experimenting with 3D and for some reason whenever I draw the mesh, it draws REALLY small, what is happening?
Can you post some code? Without looking, it’s most likely to be around your camera / perspective setting (either that or your z values are really big)
Ok sure hang on
Here:
function setup()
parameter.number("Size",50,500,150)
parameter.number("Camera", 0, 1000, 300)
parameter.number("Angle",-360, 360, 0)
parameter.number("FOV", 10, 140, 45)
local vertices = {
vec3(-0.5, -0.5, 0.5), -- Left bottom front
vec3( 0.5, -0.5, 0.5), -- Right bottom front
vec3( 0.5, 0.5, 0.5), -- Right top front
vec3(-0.5, 0.5, 0.5), -- Left top front
vec3(-0.5, -0.5, -0.5), -- Left bottom back
vec3( 0.5, -0.5, -0.5), -- Right bottom back
vec3( 0.5, 0.5, -0.5), -- Right top back
vec3(-0.5, 0.5, -0.5), -- Left top back
}
local cVert = { -- Front
vertices[1], vertices[2], vertices[3],
vertices[1], vertices[3], vertices[4],
-- Right
vertices[2], vertices[6], vertices[7],
vertices[2], vertices[7], vertices[3],
-- Back
vertices[6], vertices[5], vertices[8],
vertices[6], vertices[8], vertices[7],
-- Left
vertices[5], vertices[1], vertices[4],
vertices[5], vertices[4], vertices[8],
-- Top
vertices[4], vertices[3], vertices[7],
vertices[4], vertices[7], vertices[8],
-- Bottom
vertices[5], vertices[6], vertices[2],
vertices[5], vertices[2], vertices[1],
}
m=mesh()
m.vertices = cVert
end
function draw()
perspective(FOV, WIDTH/HEIGHT)
camera(-500,Camera,-300, 0,0,0, 0,1,0)
background(0)
translate(WIDTH/2, HEIGHT/2, 0)
rotate(Angle, 0,0,1)
translate(0,-Size/2,0)
m:draw()
end
I’m still getting used to the 3D graphics engine and its features
Your object is 1 unit wide. Your camera is several hundred units away. Make the object bigger, or move the camera and object closer to each other.
Why did you think this was a “bug”?
I’d recommend having a look at @Ignatz’s ebook / demo project on 3D in Codea (have a quick search on the forum).
Looking at your code I suspect it’s because your vertices are very close together (+0.5 → -0.5) yet your camera is set back 300 units (see the last parameter to the camera() function.
I changed the initial camera to 0, it still tiny. I need help. Please
Just how to fix It
I told you how to fix it. Your camera is still hundreds of units away. Take out the translate, or just translate to 0,0,0, then put the camera at 0,0,5 or something.
You are wasting our time asking about stuff that you could learn yourself, if you took the trouble to look online, read ebooks (I wrote one specifically on 3D in Codea) or look at other people’s code.
Please don’t waste our time complaining that you don’t understand, when you can’t be bothered to find explanations for yourself.
Additionally, 3D is very complex, and way too advanced for you, since you can barely program. You should spend a lot more time getting familiar with Codea before attempting this.
Ummm, isn’t this just the 3D Lab demo?
@Ignatz Yep. And for some reason, why does everyone think I can barely program? I’m starting to program 3D, I’m learning 3D. So I can barely program at 3D.
Two days ago, you didn’t know how to “stop drawing” an ellipse. You don’t understand how Codea draws, and that (and similar questions you asked) means you are a beginner.
That’s not an insult - everyone starts as a beginner - but beginners shouldn’t be trying to program 3D - and if you do try, you need to do a lot of reading first.
Ok @Ignatz I get it, the point is, I never learnt HOW to stop drawing an ellipse. I thought draw drew things 60 fps. I have never learnt how to stop drawing for some reason.
@LL_Phoenix456 - that’s fine, any beginner would have that problem - but a competent Codea programmer would not.
Just accept that you are a beginner, take things slow, read and practise, and don’t go way over your head to start with.
Because if you try things that are too hard, and pester forum users for answers to unnecessary (because the answers are in the wiki, tutorials, sample code etc) questions, as you did above, you will just irritate them.
Ok, thanks. I have learnt how to stop drawing an ellipse or rect. I AM a beginner, well, I’m not like the beginner that’s learning how to use functions, but I am not too experienced. So don’t worry. I also realise answers are on the wiki. And I will now take time to practice. And @Ignatz , sorry if I did pester you for answers. I feel really guilty now.
Don’t waste time feeling guilty, just learn as much as you can from everything you can find!
Ok, thanks for the inspiration @Ignatz ! I’m on it!