Jump to content

cubemap for reflects with Lua


Gilmer
 Share

Recommended Posts

Hello, I'm having a doubt it and that I can not solve.

 

How can I create cubemap for reflexes? I made a model of a car recently, and I would add it on the map specular reflections. But it has one but, as I do it through the .lua?

 

I saw an example of the water in C + + that comes with the engine, but I wonder how I can configure it for .lua, which already has a few lines to hide the camera, creating another camera...

 

thanks

Link to comment
Share on other sites

Then, in reality, what I want, is as follows:

 

Create a reflex to a model, with a metallic material. But i want this reflex update, showing all objects already of reflex. I think this, would a "dynamic cubemap", right?!

 

That example "Reflect_water.cpp", is a example of dynamic cubemap? I try pass it to Lua, but the problem is the cameras. How i can access the main camera of game, if the file .lua is only a "complement" of model, whith the command of framewerk for this?

 

thanks

Link to comment
Share on other sites

I think this imagem show exactly what i want make. I want the reflect of scene, show in the car, and when it is moving, update the texture:

 

2m43gy1.png

 

And two more question that arose:

 

1. In this model, i make the glasses, with intention to put a transparency in it, but dont with 100% transparency, and only half, to appear the interior side. I made the pilots, and the benchs, but they not appears. What material configuration i need set to made a half transparency?? I put in the alpha channel texture dds of the diffuse, a gray color, but in this, it have some bugs, and render the models aways from the car.

 

furshy.png

 

 

2. To physics car, i copy the sample file of the ViperScout. Only change some parameters of suspension and rigidity, but the problem is that sometimes the car model make a slipped in the road, like is slippery. Is some configuration to the tires?? I try change the both parameters to the friction, but dont solved the problem with this...

 

 

thanks

  • Upvote 1
Link to comment
Share on other sites

I think this imagem show exactly what i want make. I want the reflect of scene, show in the car, and when it is moving, update the texture:

It is possible to do what you describe with the existing command set.

 

1. In this model, i make the glasses, with intention to put a transparency in it, but dont with 100% transparency, and only half, to appear the interior side. I made the pilots, and the benchs, but they not appears. What material configuration i need set to made a half transparency?? I put in the alpha channel texture dds of the diffuse, a gray color, but in this, it have some bugs, and render the models aways from the car.

There's a tutorial on transparency and refraction.

 

2. To physics car, i copy the sample file of the ViperScout. Only change some parameters of suspension and rigidity, but the problem is that sometimes the car model make a slipped in the road, like is slippery. Is some configuration to the tires?? I try change the both parameters to the friction, but dont solved the problem with this...

If you can demonstrate the issue, I will look at it, and make some enhancements to let you control the tire slippage more. No one has attempted a serious racing game yet.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Thanks Josh, for your help..

 

The question of the transparency, i could solved, by the tutorial...

 

The question of the cubemap, i have not tried it yet. Anything i post here...

 

now the car, the source i using this:

 

require("scripts/class")
require("scripts/loop")
require("scripts/math/math")

local class=CreateClass(...)

function class:CreateObject(model)
       local object=self.super:CreateObject(model)     

       function object:UpdateMatrix()
               self:UpdateTires()
       end

       function object:UpdateTires()
               local speed
               for n=0,3 do
                       if self.tire[n]~=nil then
                               self.tire[n]:SetMatrix( self.vehicle:GetTireMatrix(n) )
                               if self.emitter[n]~=nil then
                                       self.emitter[n]:SetMatrix(self.vehicle:GetTireMatrix(n))
                                       self.emitter[n]:Pause()
                                       if self.vehicle:TireIsAirborne(n)==0 then
                                               speed = math.abs(self.model:GetVelocity(0).z)
                                               speed = (speed - 4) / 20.0
                                               speed = Clamp( speed, 0, 1 ) * 0.1
                                               if speed>0 then
                                                       self.emitter[n]:Resume()
                                                      self.emitter[n]:SetColorf(1,1,1,speed)
                                               end
                                       end
                               end
                       end
               end
       end

       local pivot
       local suspensionlength=0.2	--0.2	-- Altura da suspensao
       local springconstant=10.0	--50.0	-- Rigidez da suspensao
       local springdamper=500.0	--300.0	-- Força da mola

       object.vehicle=CreateVehicle(object.model)
       object.tire={}
       object.emitter={}

       pivot=object.model:FindChild("tire2")
       if pivot~=nil then
	tireradius=pivot.aabb.h/2.0
               object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
               object.tire[0]=LoadMesh("abstract::tire_left.gmf",object.model)
	pivot:Hide()
       end

       pivot=object.model:FindChild("tire1")
       if pivot~=nil then
               tireradius=pivot.aabb.h/2.0
               object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
               object.tire[2]=LoadMesh("abstract::tire_left.gmf",object.model)
               pivot:Hide()
       end     

       pivot=object.model:FindChild("tire4")
       if pivot~=nil then
               tireradius=pivot.aabb.h/2.0
               object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
               object.tire[1]=LoadMesh("abstract::tire_right.gmf",object.model)
               pivot:Hide()
       end


       pivot=object.model:FindChild("tire3")
       if pivot~=nil then
               tireradius=pivot.aabb.h/2.0
               object.vehicle:AddTire(TFormPoint(pivot.position,pivot.parent,model),tireradius,suspensionlength,springconstant,springdamper)
               object.tire[3]=LoadMesh("abstract::tire_right.gmf",object.model)
               pivot:Hide()
       end     

       object.emitter={}
       object:UpdateTires()

       if world_transparency~=nil then
               if world_main~=nil then
                       SetWorld(world_transparency)
                       for n=0,3 do
                               if object.tire[n]~=nil then
                                      object.emitter[n]=CreateEmitter(50,2000,Vec3(0,1,0),0,object.tire[n])
                                       object.emitter[n]:SetPosition(Vec3(0,-object.tire[n].aabb.h/2.0,0))
                                       object.emitter[n]:SetParent(model,1)
                                       object.emitter[n]:SetRadius(1,6)
                                       object.emitter[n]:SetWaver(1.0)
                                       object.emitter[n]:Paint(LoadMaterial("abstract::roaddust.mat"))
                                       object.emitter[n]:SetRotationSpeed(0.1)
                                       object.emitter[n]:Pause()
                               end
                       end
                       SetWorld(world_main)
               end
       end


       object.model.buoyant=0
       object.model:SetKey("collisiontype",COLLISION_PROP)
       object.model:SetKey("mass",5.0)
--object.model:SetKey("friction","1,0")
       object:UpdateTires()
end

 

 

And this, the main to start game:

 

require("Scripts/constants/keycodes")
require("Scripts/linkedlist")
require("Scripts/filesystem")
require("scripts/math/math")
require("scripts/constants/engine_const")

FlushKeys()
HideMouse()

local camera = fw.main.camera

chassis=LoadModel("abstract::pista1_models_carro_carro1.gmf")
carobject=objecttable[chassis]
car=carobject.vehicle
--chassis:Turnf(0,180,0)
car:Hide()


if car==nil then
Notify("Vehicle object not found.",1)
chassis:Free()
return
end

chassis:SetPosition(TFormPoint(Vec3(0,-1,10),fw.main.camera,nil))
chassis:SetRotationf(0,camera.rotation.y+180.0,0)

--Variables
local dx=0.0
local dy=0.0
local camerapitch=camera.rotation.x
local camerayaw=camera.rotation.y
local move=0.0
local strafe=0.0
local steering = 0.0
local torque = 0.0
local steerlimit = 30.0
local steerrate = 2.0
local steerangle=0.0

MoveMouse(Round(GraphicsWidth()/2),Round(GraphicsHeight()/2))

while KeyHit(KEY_ESCAPE)==0 do	

--Camera look
gx=Round(GraphicsWidth()/2)
gy=Round(GraphicsHeight()/2)
dx=Curve((MouseX()-gx)/4.0,dx,3.0/AppSpeed())
dy=Curve((MouseY()-gy)/4.0,dy,3.0/AppSpeed())
MoveMouse(gx,gy)
camerapitch=camerapitch+dy
camerayaw=camerayaw-dx
camerapitch=math.min(camerapitch,90)
camerapitch=math.max(camerapitch,-90)
fw.main.camera:SetRotationf(camerapitch,camerayaw,0,1)

local tirespeed=-(KeyDown(KEY_W)-KeyDown(KEY_S))*70.0
car:AddTireTorque(tirespeed,0)
car:AddTireTorque(tirespeed,1)
car:AddTireTorque(tirespeed,2)
car:AddTireTorque(tirespeed,3)

steermode=0
if KeyDown(KEY_A)==1 then steermode=steermode+1 end
if KeyDown(KEY_D)==1 then steermode=steermode-1 end

if steermode==1 then
	steerangle=steerangle+4.0*AppSpeed()
elseif steermode==-1 then
	steerangle=steerangle-4.0*AppSpeed()
else
	if steerangle>1 then
		steerangle=steerangle-4.0*AppSpeed()
		if steerangle<0.0 then steerangle=0.0 end
	else
		steerangle=steerangle+4.0*AppSpeed()
		if steerangle>0.0 then steerangle=0.0 end
	end
end
steerangle=Clamp(steerangle,-25,25)

car:SetSteerAngle(steerangle,0)
car:SetSteerAngle(steerangle,1)

fw:Update()

local campos=TFormPoint(Vec3(0,1,0),chassis,nil)

fw.main.camera:SetPosition(campos)
fw.main.camera:Move(Vec3(0,0,-10))

local t=TFormVector(Vec3(0,0,1),camera,chassis)
a=-math.deg(math.atan2(t.x,t.z))+180.0



chassis:Hide()
local pick = LinePick(campos,camera.position,0.5,COLLISION_PROP)
chassis:Show()
if pick~=nil then
	camera:SetPosition(pick.position)
end

fw:Render()
Flip(0)
end

chassis:Free()
chassis=nil
camera=nil

ShowMouse()

 

 

I sending to your email (support@leadwerks) the files of the car. I sending like "udco@unidev.com.br", ok?!

 

Thanks for support and help josh... (:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...