Posted: Thu Apr 09, 2009 9:59 pm Post subject: 3D program, Camera help.
Ok so currently this program will create a rectangular prism at a point and using the arrow keys you can move the camera around the object. What I want to do is now is by using the 'a' and 'd' I want to change the spin for the camera to rotate it. Also I want to change the pitch (vertical angle) with the keys 'w' and 's' . But I don't know how to use Sind / Cos.
If some could maybe spend a couple of min. to help teach me what they do that would be great. Thanks.
Also any help for how to improve this would be great.
Sponsor Sponsor
TokenHerbz
Posted: Sat Apr 11, 2009 10:51 am Post subject: RE:3D program, Camera help.
3D coding isn't about programming, its mostly about math, So unless you have a great understanding on math skills needed, (you can read about it online and learn it) I wouldn't bother with this because it'll overwhelm you.
Learn the math first, the coding isn't nearly as time consuming as the time your spend thinking about what your doing.
None the less, I Wouldn't even run any 3D things on Turing, it's way to slow and crap-tastic..
My two cents
saltpro15
Posted: Sat Apr 11, 2009 11:27 am Post subject: RE:3D program, Camera help.
I agree with Tokenherbz, it'll be way too slow in Turing, I recommend doing it in c++ with openGL if you want it to run smoothly
copthesaint
Posted: Sun Apr 12, 2009 12:57 am Post subject: Re: 3D program, Camera help.
saltpro15 wrote:
I agree with Tokenherbz, it'll be way too slow in Turing, I recommend doing it in c++ with openGL if you want it to run smoothly
I DON'T, care if it runs slow. I want to use a basic program that will require a min of required code use to make this program. Again speed is not an issue.
Now does anyone want to try and help me or just criticize me?
I am willing to spend any amount of time and don't post "well why don't you talk to your teachers" because now of them will ever help me at there own time.
Moderator edit: Removed flaming, for the better.
[Gandalf]
Posted: Sun Apr 12, 2009 1:28 am Post subject: RE:3D program, Camera help.
copthesaint, he wasn't trying to insult you. At least if he was, he definitely wasn't doing a good job of it.
It's simply true that making a 3D engine will require as much math as programming skill, if not more. That's not to discourage you or say you will fail, however you should look into the math before moving on. Especially if you don't even know basic trigonometry.
Keep at it, keep reading about trig, matrices, etc and you'll be well on your way.
saltpro15
Posted: Sun Apr 12, 2009 8:00 am Post subject: RE:3D program, Camera help.
haha alright, but when it's running at 2 fps and you're beating your head off the keyboard, well, don't blame me...
You can pm me if you have any further questions about it because i may forget about this thread
Sponsor Sponsor
copthesaint
Posted: Sun Apr 12, 2009 8:37 pm Post subject: RE:3D program, Camera help.
Thank you Zero-impact, and I will Pm you for help after I've tried to learn from this. Hopefully after two or so weeks, I will understand the concept of 3D better.
The File (Vector3f.t) is not available. you forgot to upload it with demons 3d engine
zero-impact
Posted: Sun Apr 12, 2009 8:47 pm Post subject: RE:3D program, Camera help.
If you search around on that thread you can find it. Good luck!
copthesaint
Posted: Mon Apr 13, 2009 9:48 pm Post subject: RE:3D program, Camera help.
Ok. How would I rotate a 2d square? (Don't be "funny" and say Pic.Rotate.) I want to have it so that the square or polygon, Is actually rotating, AND still staying at its same point. I realized that to make a 3d program, the object will have to rotate at it's x,y, and z axis. doing this you can see all the faces of the shape. Help would be nice :p and thank you to who ever helps me!
I have been tring different things and had in ways some success, but As this is the 4th time typing this post , I cant explain what I've done...
zero-impact
Posted: Mon Apr 13, 2009 10:01 pm Post subject: RE:3D program, Camera help.
Posted: Tue Apr 14, 2009 1:18 pm Post subject: Re: 3D program, Camera help.
Ok I want my square to accually spin. But the square it's self just moves in a circle.
Can someone explain what I have to do to get the sqare to stay in one spot but still rotate?
Turing:
/** Declaration
*Variables, Types, and Constants
*/ type Camera : record
Dis, X, Y :real endrecord var C : Camera
C.Dis :=600
Posted: Wed Apr 15, 2009 1:22 am Post subject: Re: 3D program, Camera help.
you must rotate every vertex in your cube around the center of the cube and you calculate the center of your cube by getting the average of every coordinate like so
centerx= (x1+x2+x3+x4+x5)/5
and so on
copthesaint
Posted: Thu May 21, 2009 1:34 pm Post subject: Re: 3D program, Camera help.
Well Ive kept trying for a while but just recently we started laerning trig. The following code does creat a '3d' shape, but I would like to know what to do next to rotate.
Turing:
module Shape
export ClearData, Prism, Move, Sketch
const ShapeID :=100000 const MaxShapes :=10000%max number of shapes you can have.
type NfoShape :%Shapes Info to be set for each var. record
Type, Sides, ID :int
X, Y, Z, Length, Width, Height :real endrecord var S :array1.. MaxShapes of NfoShape
proc ClearData
for i :1.. MaxShapes
S (i).ID :=100000
S (i).X :=0
S (i).Y :=0
S (i).Z :=0
S (i).Length :=0
S (i).Width :=0
S (i).Height :=0
S (i).Sides :=0
S (i).Type :=0 endfor end ClearData
fcn IDGet :int%Gets The ID of the Shape for i :1.. MaxShapes %Max Number of shapes Allowed if S (i).ID not= ShapeID then if i = MaxShapes then quit%If this Quit is run then you have to many shapes endif elsif S (i).ID = ShapeID then result ShapeID + i
endif endfor end IDGet
fcn IDSave (Num :int):boolean if S (Num).ID not= ShapeID then resultfalse elsif S (Num).ID = ShapeID then
S (Num).ID := ShapeID + Num
resulttrue endif end IDSave
fcn Prism (Length, Width, Height :real, Sides :int):int var Num :int:= IDGet
if IDSave (Num - ShapeID)=truethen
S (Num - ShapeID).Length := Length
S (Num - ShapeID).Width := Width
S (Num - ShapeID).Height := Height
S (Num - ShapeID).Sides := Sides
S (Num - ShapeID).Type :=2 result Num
endif end Prism
proc Move (var Shape :int, X, Y, Z :real)
S (Shape - ShapeID).X := X
S (Shape - ShapeID).Y := Y
S (Shape - ShapeID).Z := Z
end Move
proc Sketch (var Shape :int, Color :int) for z : -180.. 180by(360div S (Shape - ShapeID).Sides)%even angle for the number of sides for o :1.. S (Shape - ShapeID).Sides %for the number of sides %drawline (round (S (Shape - ShapeID).X + (cosd ((o * (360 / S (Shape - ShapeID).Sides))) * ((z * (S (Shape - ShapeID).Width / 360))))), % if you uncomment this a line will be drawn %round (S (Shape - ShapeID).Y + (sind (o * (360 / S (Shape - ShapeID).Sides)) * (z * (S (Shape - ShapeID).Length / 360)))), % from each point to the next %round (S (Shape - ShapeID).X + (cosd ((o * (360 / S (Shape - ShapeID).Sides))) * (((z + (360 / S (Shape - ShapeID).Sides)) * (S (Shape - ShapeID).Width / 360))))), %round (S (Shape - ShapeID).Y + (sind (o * (360 / S (Shape - ShapeID).Sides)) * ((z + (360 / S (Shape - ShapeID).Sides)) * (S (Shape - ShapeID).Length / 360)))), Color) drawfilloval(round(S (Shape - ShapeID).X + (cosd((o *(360 / S (Shape - ShapeID).Sides)))*((z *(S (Shape - ShapeID).Width / 360))))), round(S (Shape - ShapeID).Y + (sind(o *(360 / S (Shape - ShapeID).Sides))*(z *(S (Shape - ShapeID).Length / 360)))), 1,1, Color) delay(1) endfor endfor end Sketch
end Shape
Shape.ClearData
var cube :int:= Shape.Prism (250, 250, 50,45)%the last value changes the sides, max 360 min 1
Shape.Move (cube, maxx / 2, maxy / 2, 0)
Shape.Sketch (cube, brightblue)