usable camera
BlitzMax Forums/OpenGL Module/usable camera
| ||
Hi, I started ripping the basic out of my GL code last night so you could see how my camera & hierarchy works. Here's something to mess about with, I'll add in the get x/y/z pitch/yaw/roll stuff later. Check the source for keys to use in this demo, and have a good mess abotu and see how the parenting looks & works. I've tried to keep it as close to Blitz3Ds as possible. Which reminds me, you really have to appreciate Marks entity functions in Blitz3D, I've NEVER come across such a cool system in any sample code out there on the net. Well done BRL! :P Sorry for sloppy code, I'm absolutely full of flu and can't even enjoy a holiday beer because of medication, BLEH!!! :) Oh, and I use 2 space tabs in my IDE... |
| ||
That's very good. Bravo. Now if I can get the Nehe tutorial 13 to load meshes into this, I might get a jump-start on finally making games in 3d. Splendid work, my friend. |
| ||
Updated with entity.getX() Y & Z, entity.getPitch() Yaw & Roll |
| ||
Tom - good work on the camera sample. Drew - I am Just curious how you are going to implement collision detection. Are you going use bounding boxes (or other primitives) only, or some type of polygon to polygon collision test also? |
| ||
I am almost certain I will go with the most basic aproach I can get away with. That would be points and planes. I have most of the mechanics worked out and I'm testing different methods like mad. This seems to be the easiest and most reliable solution for me. |
| ||
do a search for loadbsp I did theres some ray to poly collision code, didnt work with the bsp sometimes (maybe odd bsp winding) If its useful I could tidy it up a bit |
| ||
@tom The light dawns! If yawV <> 0.0 glRotatef yawV , mat.m[1], mat.m[5], mat.m[9] If pitchV<> 0.0 glRotatef pitchV, mat.m[0], mat.m[4], mat.m[8] If rollV <> 0.0 glRotatef rollV , mat.m[2], mat.m[6], mat.m[10] neat work tom! |
| ||
Updated, scaling is in. I just realised I was doing it wrong too, sorted! :) Use square brackets to scale cube2 |
| ||
Added PointAt() |
| ||
nice work tom, thanks for sharing, at this rate no ones gonna want to buy the 3d module ;) |
| ||
Hell, I will! :) I hope it comes out sooner rather than later though. Might go bug Mark for an update on it actualy. |
| ||
had troubles with view ports that overlap, ie say 1 full screen with 1 smaller window over the top of it, how do you clear the smaller viewport so it cant be seen through... |
| ||
Haven't tried overlapping yet, will see what happens. |
| ||
There seems to be a problem with getPitch it will sometimes return NAN I notice its calculated in a different way to getYaw and getRoll, which two matrix elements you I need to use for pitch? |
| ||
This is a very nice piece of work. Thanks for sharing! I was reading through the code and noticed some inconsistencies though. May be just because the code needs some cleaning up. For instance, in the tEntity.SetParent() method, there is a code block that is never executed. ... Else 'Parent Globaly *WORKING* 'Remove Self from any existing parents childlist 'and multiply the matrix to leave it in its current 'world space position and rotation If parent Local gpa:tEntity = parent 'Transform matrix into world space While gpa mat.Multiply(gpa.mat) gpa = gpa.parent Wend 'Remove Self from the old Parents list RemoveLink parentLink parentLink = Null parent = Null End If The part between 'If parent..' and 'end if' will never be called, since a few lines up you are performing: If parent RemoveLink parentLink parentLink = Null parent = Null End If So if it reaches the first posted snippet, parent will always be Null. Nothing Important, but may be worth cleaning up sometime to make it easier to read. Oh, and the tCamera.ScreenProject() method isn't finished :) And another one: the RenderEntity() method has a type-o If ThisScaleMode = 1 glEnable GL_RESCALE_NORMAL Else If ThisScaleMode = 2 glEnable GL_NORMZLIZE End If End Select 'glEnable GL_NORMZLIZE' should be 'glEnable GL_NORMALIZE'. |
| ||
Well spotted, prize is in the post :P |
| ||
glEnable GL_NORMZLIZE thats why we have Strict :) |
| ||
I like the wireframe cameras... very cool! :) Great stuff Tom Dabz |