Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 10 11 12 13 14 … 18 Next »
3D Cam, Positioning Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pages (2): 1 2 Next »
Threaded Mode
3D Cam, Positioning Problem
28-10-2015, 02:03 PM,
#1
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
3D Cam, Positioning Problem
I've been trying to position CL models just above the hud but i'm never able to place them like i would holograms and when i get close it moves around when i look around.

I have seen it done before but i never asked how he/she managed to do it.

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
28-10-2015, 05:45 PM,
#2
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: 3D Cam, Positioning Problem
Think of 3D cameras like a completely separate world. Everything rendered inside them is rendered in their space, not the game world's space. You provide the position and angles for the camera in the 3D camera context's world, so you need to position your client-side model to be in view.

I think the most common idiom that makes it easiest, is to use your eye position and aim angles for the context's camera, and then position the client-side model relative to your player's game world position. That will give you something that mimics the game world.
Find
Reply
28-10-2015, 06:44 PM, (This post was last modified: 28-10-2015, 06:44 PM by Destiny's Player.)
#3
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
RE: 3D Cam, Positioning Problem
Here's the way I did something akin to that with an emitter. Needs some tweaking and might be a crutch, but it works.

hook("render","render",function()
if Resources[100] ~= 1 then
PosX = 15*math.cos(math.rad(Owner:ang()[2]))
PosY = 15*math.sin(math.rad(Owner:ang()[2]))
if Resources[2]>=(Resources[1]/2) then
HPCol = {10,100,10}
elseif Resources[2]>=(Resources[1]/8) then
HPCol = {100,70,10}
else
HPCol = {150,10,10}
end
Alert = 1
render.start3D2D(Owner:pos()+Vector(PosX,PosY,60),Angle(0,Owner:ang()[2]-90,90),0.05)
render.clear()
if Page == 1 then
mainMenu()
elseif Page == 2 then
tacticalMenu()
end

render.end3D2D()
end
end)
Find
Reply
28-10-2015, 11:49 PM,
#4
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: 3D Cam, Positioning Problem
Uh thats 3D2D Destiny not 3D, the difference being the that 3D renders models/3D objects

Thanks Person i'll test that and let you know how it goes

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
29-10-2015, 01:19 AM,
#5
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: 3D Cam, Positioning Problem
Tested this code

local Centre = Vector( 0, 0, 0 )
hook( "render", "DrawStuff", function()

render.clearDepth()
local Player = ents.player()
render.start3D( Player:eyePos(), Player:aimVector():Angle(), 75, 0, 0, 1680, 1050, 1, 2048 )
--Start by suppressing the engine lighting.
render.suppressEngineLighting( true )

--Set the light to come from the centre of the world.
render.setLightingOrigin( Centre )
--Set the light to be white (values are 0-1)
render.resetModelLighting( 1, 1, 1 )

--Set the model's colour to white, and alpha to 0.5 (again, values are 0-1)
render.setColorModulation( 1, 1, 1 )
render.setBlend( 1 )

--Add directional lights.
for i = 0, 6 do
render.setModelLighting( i, 1, 1, 1 )
end
--Draw the model.
render.drawWireframeSphere(ents.self():toWorld(Vector(0,0,55)),20,24,24,Color(255,0,0))
--Stop suppressing engine lighting.
render.suppressEngineLighting( false )
render.end3D()
end )

but the result was this

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
29-10-2015, 11:27 AM, (This post was last modified: 29-10-2015, 11:35 AM by Destiny's Player.)
#6
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
RE: 3D Cam, Positioning Problem
(28-10-2015, 11:49 PM)T-17 Wrote: Uh thats 3D2D Destiny not 3D, the difference being the that 3D renders models/3D objects

Thanks Person i'll test that and let you know how it goes

Practically, there's no difference. Just use the formulas that I have in there, and tweak them to how you need them. They simply position the screen in front of the player's face and keep it there, no matter the direction. it's simple enough to do the same with a model just by tweaking the numbers. And also adding a formula for the vertical angle, should be almost the same.
Find
Reply
29-10-2015, 11:38 AM,
#7
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: 3D Cam, Positioning Problem
actually it's a little different because the 3D2D renders inside the game space and 3D doesn't as Person mentioned above, merely positioning it in world space does work but the angles seem screw up the CL model positioning.

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
29-10-2015, 11:42 AM,
#8
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
RE: 3D Cam, Positioning Problem
Hmm... That's curious. Anyway, these formulas might still help you somewhat, at least in calculating the position in the world where all of that should be.
Find
Reply
29-10-2015, 06:24 PM,
#9
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: 3D Cam, Positioning Problem
The way you've positioned it, it will always render in the 3D camera's world at the equivalent position of being 55 units above your chip. Given your 3D camera is using your player camera parameters, you've essentially positioned that sphere in the world at that point, almost exactly like a hologram.

If you want this sphere to be always visible, you have to position it relative to your eyes rather than the chip, so that it's always in view.
Find
Reply
29-10-2015, 06:30 PM,
#10
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: 3D Cam, Positioning Problem
whenever i look around the sphere is offset by the angle, i intended it to be placed like a hologram ie fixed to the position defined but it seems that the 3D rotates as i do and then the virtual ent pos is moved but it shouldn't have been moved

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
« Next Oldest | Next Newest »
Pages (2): 1 2 Next »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.