Announcement

Collapse
No announcement yet.

2D draw with 3d coords?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2D draw with 3d coords?

    Is it possible to implement 2D drawing but with 3D coords? (you draw in the 3D world but see it over all other things, like EF_NODEPTHTEST) but without depth at all (ie: the graphic always is at the same 2D size).


    Anyway, is it possible to implement some like EF_NODEPTHTEST but with DEPTHTEST serverside only? So the model is drawn over all the things but the server continues doing depth test so it don't send that to the client if it is not visible.

    That things will be useful for augumented reality indicators.

  • #2
    like this?

    Code:
    int qglProject (float objx, float objy, float objz, float *model, float *proj, int *view, float* winx, float* winy, float* winz) 
    {
    	float in[4], out[4], dist, scale;
    	int i;
    	vec3_t org;
    
    	org[0] = objx; org[1] = objy; org[2] = objz;
    	in[0] = objx; in[1] = objy; in[2] = objz; in[3] = 1.0;
    
    	if (R_CullSphere (org, 1))
    		return 0;
    
    	dist = VectorDistance(r_refdef.vieworg, org);	
    
    	if (dist > r_farclip.value)
    		return 0;
    
    	for (i = 0; i < 4; i++)
    		out[i] = in[0] * model[0 * 4 + i] + in[1] * model[1 * 4 + i] + in[2] * model[2 * 4 + i] + in[3] * model[3 * 4 + i];
    
    	for (i = 0; i < 4; i++)
    		in[i] =	out[0] * proj[0 * 4 + i] + out[1] * proj[1 * 4 + i] + out[2] * proj[2 * 4 + i] + out[3] * proj[3 * 4 + i];
    
    	if (!in[3])
    		return 0;
    
    	VectorScale(in, 1 / in[3], in);
    	
    	*winx = view[0] + (1 + in[0]) * view[2] / 2;
    	*winy = view[1] + (1 + in[1]) * view[3] / 2;
    
    	scale = (0.5 / (dist / 128.0f));//this starts out small then gets big then small again....
    
    	if (scale < 0.1)
    		return 0;
    
    	scale = bound(0.5f, scale, 2);
    	
    	*winz = scale;
    	return 1;
    }
    i use this for 2d strings over entities in the realtime renderd world

    its late so my mind is wondering but i can provide code if u just want 2d context for 3d objects,,,,
    www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

    Comment


    • #3
      Draw the Z and the Y and not the X ? Sprites are 2d.

      DP has a setattachment feature that makes the entity only visble to its client I believe.

      Comment


      • #4
        csqc has both project and unproject builtins available to it. you can draw separate views/overlays with no world visible if desired, with either models, sprites, or custom polygons. Alternatively you can just add the nodepthtest flag clientside.
        there's no support for such things for ssqc.

        sidenote: the server does pvs culling/traceline culling and never depth testing. the server has no depth buffer.
        Some Game Thing

        Comment


        • #5
          I can't lie, you blow me away Spike. I get it, you are a hella talented programmer and 3d engine developer but, how do you remember all of this stuff? I've been programming in AS3 ever since it was invented (8/9 years). I am even certified to teach AS3 but, if I step away from the plate for even just a couple months on one of my projects I have to go back and familiarize myself with the scope. I'm sure you probably dont step away from the plate but your project is big enough that there should be plenty that you haven't revisited in a while yet you never seem to forget anything.

          Everyone I know is amazed with my memory and I'm amazed with yours.


          When I went back to parsing delimiters after a hiatus I read my own script and was like 'Crap, I have no freakin clue how this is all working together' I spent a good day rescoping. That was just one class. I'm sure everything FTE combined is a hell of lot more than one class yet, you seem to have the entire "package" for your work stored in your head.

          I'm really not looking forward to going back to my security/database management system. I know it's gonna be like Chinese to me when I get back to it. It's also quite massive (for what it is). I did one thing right though. I completed it in every regard and made damn sure it worked before I set it to the side. At least going back to it wont also include figuring out where I stopped and/or correcting anything.
          Last edited by MadGypsy; 04-26-2014, 11:36 AM.
          http://www.nextgenquake.com

          Comment


          • #6
            Originally posted by Spike View Post
            csqc has both project and unproject builtins available to it. you can draw separate views/overlays with no world visible if desired, with either models, sprites, or custom polygons. Alternatively you can just add the nodepthtest flag clientside.
            there's no support for such things for ssqc.

            sidenote: the server does pvs culling/traceline culling and never depth testing. the server has no depth buffer.
            Ok ok, thanks. Good to know that, I misunderstood it. But you take the point: I want the server do culling, but the client draw it with no depth test.
            Anyway, I don't know how to use cs_unproject and cs_project (What is the expected "effect" of that?)

            Thank you @ROOk too, for your code, that was something what I am expecting too.

            @Cobalt, it is just more than that, because if the indicator must be over a 3D object in the world, it need to know all coords in 3D space. But next it need to be projected over a 2d plane to stay in 2D, and in the correct place over the other model seen in the 3D world. So, it is a little more complex than just taking only two coords.


            @MadGypsy I guess when you develop something you are taking the attention for each portion of the project but not memorizing it all the time. That happened to me a lot of times too. But sometimes I lost my work (energy failure, disk failure...) and that forced me to remake that portions. It give me the knowledge of we must pay more attention to the things we are doing, so later we can remember more easily. And, if you did the things twice, you will have more chance to remember it too.


            Thank to all of you for the replies.

            Comment


            • #7
              I think my probllem actually stems from not working on one thing from beginning to end. I switch languages and project ideas monthly. It is always to go back to an idea that already has some progress but, it still stands that I am not keeping one project in my head, I'm keeping a very loose familiarization with ample projects and only turn on my brain for a specific language for the time I am programming in it. Once I "turn a language off" everything I just did starts melting away in my head.

              Right now I am coming back to a display engine I started long ago, from the first few chapters of an armature book I want to write, which was preceded by a database and security management system. I am a project whore. I feel so dirty. I wonder if PHP can forgive me for fondling AS3 out of my keyboard. PHP knows I'll be back. I always go back. I like 3 ways and SQL is always down. I can also hit AJAX for some girl on girl action and PHP seems fine with that. I think PHP just wants to be a part of the action. I'll be introducing it to AS3 soon enough.

              "Get and send, baby! Get and send! Yeeeaaaaah, push that array!"

              HAH!
              Last edited by MadGypsy; 04-26-2014, 03:18 PM.
              http://www.nextgenquake.com

              Comment

              Working...
              X