Josh Posted May 25, 2011 Share Posted May 25, 2011 Here's an example of a script that will make the entity's color oscillate over time: function actor:Start() self.speed = 1 self.color = Vec4(1) end function actor:Draw() local luminance = (math.sin(Millisecs()*self.speed) / 2 + 0.5) self.entity:SetColor(self.color * luminance) end Basically, I am thinking in terms of what Michael Betke could use. Not to pick on him, but programming is not his area of discipline, nor should it be. With scripts he can attach behaviors to entities and watch it go. Add a couple of these scripts with different speeds set, and you get a random but smooth change in brightness. Quote 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 More sharing options...
Josh Posted May 25, 2011 Author Share Posted May 25, 2011 This version blends between two colors. I actually have it working in the render loop now: function actor:Start() self.speed = 1 self.color = {} self.color[0] = Vec4(1,0.5,0.5,1) self.color[1] = Vec4(0.25,1,1,1) end function actor:Draw() local luminance = (math.sin(Millisecs()*self.speed*0.001) / 2 + 0.5) local color = (self.color[0] * luminance) + (self.color[1] * (1-luminance)) self.entity:SetColor(color) end Quote 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 More sharing options...
Canardia Posted May 25, 2011 Share Posted May 25, 2011 Don't you need to multiply motion values with AppSpeed(). Most hardcore gamers have vsync forced off in the nvidia control panel (John Carmack told us not to use vsync ever, it's evil and bad), so Flip(1) won't do anything for them. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted May 25, 2011 Author Share Posted May 25, 2011 You'd actually want to use AppTime() instead of Millisecs(), and everything would be fine. If you were gradually adding to a value, you would want to modulate it by AppSpeed(). Quote 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 More sharing options...
Josh Posted May 26, 2011 Author Share Posted May 26, 2011 Now it's getting cool: teapot = LoadModel("models/teapot.mdl"); Actor* actor; actor = teapot->AttachScript("ColorOscillate.lua"); actor->SetFloat("speed",4.0); actor = teapot->AttachScript("Mover.lua"); actor->SetVec3("turnspeed",Vec3(0,1,0)); actor->SetBool("global",true); Quote 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 More sharing options...
Recommended Posts
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.