Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - bigsofty

#2566
GLBasic - en / Camera Vector
2007-Apr-14
I want to control the camera direct via a direction vector.

Simply... its not working... the camera view flips when pointing directly up or directly down.
also
when the X axis is added to the equation it spirals the view sometimes....

There must be an easier way to use a direction vector to control the camera angle?

This is what Ive been trying (800x600 windowed)...


Code (glbasic) Select
// View code
TYPE Tvector
x
y
z
magnitude
ENDTYPE

GLOBAL cam_pos AS Tvector; cam_pos.x = 0; cam_pos.y = 0; cam_pos.z = 0 // Camera position
GLOBAL cam_vec AS Tvector; cam_vec.x = 0; cam_vec.y = 0; cam_vec.z = 0 // Camera angle

// Mouse look along vector code...
  MOUSESTATE mx, my, b1, b2
  cam_vec.x = 0; cam_vec.y = 0; cam_vec.z = -1 // Initial view
mx=(mx/800)*3600 // Get an x rotation value
my=(my/600)*3600 // Get an y rotation value
cam_vec = Vector_RotateAroundY(cam_vec, mx/10) // Rotatate around x axis
  cam_vec = Vector_RotateAroundX(cam_vec, my/10) // Rotate around y axis
    X_CAMERA cam_pos.x, cam_pos.y, cam_pos.z, cam_vec.x, cam_vec.y, cam_vec.z
Functions from the vector lib.


Code (glbasic) Select
FUNCTION Vector_RotateAroundX AS Tvector: vec1 AS Tvector, angle
LOCAL result AS Tvector
result.x = vec1.x
result.y = COS(angle) * vec1.y - SIN(angle) * vec1.z
result.z = SIN(angle) * vec1.y + COS(angle) * vec1.z
RETURN result
ENDFUNCTION

FUNCTION Vector_RotateAroundY AS Tvector: vec1 AS Tvector, angle
LOCAL result AS Tvector
result.x  = COS(angle) * vec1.x + SIN(angle) * vec1.z
result.y = vec1.y
result.z = -SIN(angle) * vec1.x + COS(angle) * vec1.z
RETURN result
ENDFUNCTION

FUNCTION Vector_RotateAroundZ AS Tvector: vec1 AS Tvector, angle
LOCAL result AS Tvector
result.x = COS(angle) * vec1.x - SIN(angle) * vec1.y
result.y = SIN(angle) * vec1.x + COS(angle) * vec1.y
result.z = vec1.z
RETURN result
ENDFUNCTION
#2567
GLBasic - en / Toggle Output
2007-Apr-13
One more request, can we get the output window to appear when you press f8 and automatically shut if no compile error/warnings are present? Makes for a quick syntax check in one key press.
#2568
GLBasic - en / Toggle Output
2007-Apr-13
Just noticed this is in... thank you Gernot! :)
#2569
Cool! Thank you... that was simple :)
#2570
The more particles, the more 'artefacts' are shown unfortunately, also if the Z-order is off, it kinda messes with other 3D objects... so a spaceship with particles, for its weapons, can sometimes be seen with shooting away from the camera with particles visible 'within' the spaceship body...

...Ive not given up yet, though, Im converting the system from frame based movement to time based and with this adding more custom OpenGL code to try and minimise this unwanted affect.

P.S. Gernot, is there any way I can get access, via in-line C, to the GLBasic internal data structures, say the pointer to a sprite image in memory?
#2571
Sorry to hear that Gernot... :(

Im not making much headway Im afraid, everything I try is slowing the system down or messing up the graphics... its designed to work in 2D as well, so Ill concentrate on that for now...
#2572
Could I suggest a compromise...

Command line execution of the IDE, to load a project and compile it, outputing compiler messages to a console window(or text file), then quit... this would allow third party IDE editors to load GLBasic Source, edit it and compile it... debug info could be added later...

...just and idea.
#2573
Quote from: GernotFrischOh dear. Of course, if you want it that way, you should be sorting them first, and draw them back to front. later.
Eek! 10000+ particles!,,, I'll look into it, maybe there's an OpenGL solution to this...

Tried disabling the Z-buffer, this fixes the blending artefacts but messes up the draw order...

Idea: maybe use a vertex shader to sort the the vectors with the GPU...?
#2574
Announcements / Super-TYPEs
2007-Apr-09
These are great... cut my code in half and its now much more readable! :)
#2575
Seems to be quite slow compared to my old BOUNDS method for typed arrays?
#2576
Alphamode does not work in 3D, It simply does not blend properly using 'X_SPRITE' for example. Im writing a 3D particle system and its stopping the particles from blending properly. Works fine in 2D mode thought.

I have seen this problem before, as part of the development of Blitz3D, its a depth sorting issue with alpha blended textures... it was sorted by introducing the W-Buffer... not sure if its the same for OpenGL...
#2577
OK Gernot, thanks for giving it a go and its easy to work around.

Now get to bed its late! :P
#2578
Quote from: GernotFrischit's returning a TYPE by reference. That's bad in your case, faster in most others. I'll have to fix it.
So far, make a LOCAL for the return value of add_to_particle_array, and pass this to the function.
:( OK, Ill add, add that bit of code for now Gernot, thanks for looking into it.
#2579
Yep, very good animation too... I'm looking for 2D GFX though.
#2580
"We have considered a Will trade art for code, but not sure how many would be into that."

Id be interested, do you have some samples of your work?