Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Spawn Model on ground

  1. #1
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts

    Spawn Model on ground

    Hello Guys!
    Can I spawn a model, which is perfect on the surface (ground)?

    I mean that's a bit shit...
    Click image for larger version. 

Name:	shit.png 
Views:	87 
Size:	718.1 KB 
ID:	660

  2. #2
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Unfortunately, no - you can't. I've encountered this several times in my own work. In COD2, the surface which will return a solid entity using bullettrace() is often under a brush/texture and you end up with models hanging in the air. In COD4, this was fixed, and you can get the angles of geometry in a map. But, not in COD2.

  3. The Following User Says Thank You to Tally For This Useful Post:

    Loveboy (3rd March 2014)

  4. #3
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    model should be good :P

  5. #4
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Ah ok :/, thank you Tally

  6. #5
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by Tally View Post
    Unfortunately, no - you can't. I've encountered this several times in my own work. In COD2, the surface which will return a solid entity using bullettrace() is often under a brush/texture and you end up with models hanging in the air. In COD4, this was fixed, and you can get the angles of geometry in a map. But, not in COD2.
    Huh?

    couldn't you just use the stock SD bomb plant function?

  7. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by serthy View Post
    Huh?

    couldn't you just use the stock SD bomb plant function?
    You mean maps\mp\_utility::getplant()? Yeah, been there, seen it, done it. Got the hat to testify! It's not fool-proof. It's the way the COD2 map editor can lay textures on geometry and for the "solid" parts to register below the textures. It does it with walls as well - the decals are slightly forward of the "solid" geo behind them.

    This function I converted from COD4 is the best to find solid ground to spawn models on in COD2:

    Code:
    getGroundpoint( entity )
    {
    	trace = bullettrace( entity.origin+(0,0,10), entity.origin + (0,0,-2000), false, entity );
    	groundpoint = trace["position"];
    	
    	finalz = groundpoint[2];
    	
    	for( angleCounter = 0; angleCounter < 10; angleCounter++ )
    	{
    		angle = angleCounter / 10.0 * 360.0;
    			
    		pos = entity.origin + (cos( angle ), sin( angle ), 0);
    			
    		trace = bullettrace( pos+(0,0,10), pos + (0,0,-2000), false, entity );
    		hitpos = trace["position"];
    			
    		if( hitpos[2] > finalz && hitpos[2] < groundpoint[2] + 15 )
    			finalz = hitpos[2];
    	}
    	
    	return( groundpoint[0], groundpoint[1], finalz );
    }
    Last edited by Tally; 3rd March 2014 at 17:33.

  8. #7
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Use trace["normal"] to find the normal-vector of the surface.

    That does work, and im using it in my cod4mod
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  9. #8
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    Use trace["normal"] to find the normal-vector of the surface.

    That does work, and im using it in my cod4mod
    Yep, tried that, and again it is not fool proof.

  10. #9
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Hmmm.. I tried it Tally, but it didn't worked xD

    Edit: I know that I make there something wrong xD
    Last edited by Loveboy; 3rd March 2014 at 19:41.

  11. #10
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    To "align" the angles (not position), like IzNoGod said, you need the trace["normal"]:

    PHP Code:
    orientToNormalnormal )
    {
        
    hor_normal = ( normal], normal], );
        
    hor_length lengthhor_normal );

        if ( !
    hor_length )
            return( 
    00);

        
    hor_dir vectornormalizehor_normal );
        
    neg_height normal] * - 1;
        
    tangent = ( hor_dir] * neg_heighthor_dir] * neg_heighthor_length );
        
    plant_angle vectortoanglestangent );

        
    //println("^6hor_normal is ", hor_normal);
        //println("^6hor_length is ", hor_length);
        //println("^6hor_dir is ", hor_dir);
        //println("^6neg_height is ", neg_height);
        //println("^6tangent is ", tangent);
        //println("^6plant_angle is ", plant_angle);

        
    return plant_angle;
    }


    // ... somewhere in your code...
    minigun.angles orientToNormal(trace["normal"]); 
    timescale 0.01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •