Jump to content

Aily

Members
  • Posts

    465
  • Joined

  • Last visited

Everything posted by Aily

  1. Liitle piece of your code will make us understand you much better Show how you UpdateController() function works in your code.
  2. If i would make such game - i will make physics body with form of punch area, attach it to player controller, make it collide with enemyes with responce "2", and on collide callback get enemy entity, get it user data (GameObject class), and do it player_hit() function.
  3. Type TVec3 {value} Field x#,y#,z# {attribute} What's that?
  4. Thanks Naughty Alien. Important thing here is new operator. Couple weeks ago i was looking in to minib3d engine, found that it's turnentity() method does not works correct. Looking in to blitzbasic.com forum found this bugfix, there was functions for quaternion rotations, here's one of those functions: Function MultiplyQuats:TQuaternion(q1:TQuaternion,q2:TQuaternion) Local q:TQuaternion=New TQuaternion q.w = q1.w*q2.w - q1.x*q2.x - q1.y*q2.y - q1.z*q2.z q.x = q1.w*q2.x + q1.x*q2.w + q1.y*q2.z - q1.z*q2.y q.y = q1.w*q2.y + q1.y*q2.w + q1.z*q2.x - q1.x*q2.z q.z = q1.w*q2.z + q1.z*q2.w + q1.x*q2.y - q1.y*q2.x Return q End Function Local q:TQuaternion=New TQuaternion This line is some confuse me, because this means - each time i turn somethig - bMax allocates memory for TQuaternion type, makes it initializations. My test scene have 2000 same time rotating cubes - using this function, at FPS ~ 100 Just for test i reworked this: Global single_q_3:TQuaternion=New TQuaternion Function MultiplyQuats:TQuaternion(q1:TQuaternion,q2:TQuaternion) Local q:TQuaternion=single_q_3 q.w = q1.w*q2.w - q1.x*q2.x - q1.y*q2.y - q1.z*q2.z q.x = q1.w*q2.x + q1.x*q2.w + q1.y*q2.z - q1.z*q2.y q.y = q1.w*q2.y + q1.y*q2.w + q1.z*q2.x - q1.x*q2.z q.z = q1.w*q2.z + q1.z*q2.w + q1.x*q2.y - q1.y*q2.x Return q End Function As you can see - i creating temporary Global single_q_3:TQuaternion=New TQuaternion and use just like in source function. Yes, i'm lost some cool OOP thing - returning new TQuaternion, but - nothing breakes there in test, and same 2000 cubes start to run at 130(!!!!)FPS... This means - ~30% faster. So i know whell - better do not use constructions like PositionEntity(entity,vec3(1,2,3)) in Leadwerks too.
  5. I'm just interesting. It's something like this: function vec3:tvec3(x#=0,y#=0,z#=0) local v=new tvec3 v.x=x v.y=y v.z=z return v end function ?
  6. It's possible if set texture as render target, than draw on it by using shader, just like any shader drawing on screen. Here's my old demo test about it, it's in bMax, but i think it easy to convert to c++.
  7. Or any another idea, what to do with scripts on load another scene (level 2,3,4....)
  8. You can try to SetBodyVelocity(...) to charachter that you want to push.
  9. First of all you need to write script for camera movement smooth path. Here's good example, but in actionscript. http://actionsnippet.com/?p=1031 In result you must get path object that will be store all points on path, and one function to return smooth coordinates along path, where path will be started at 0 and finish on 1 And while camera will moves along this path, point it to target. Like (in lua) ...... path=create_path() path.add_point(x,y,z) path.add_point(x,y,z) path.add_point(x,y,z) path.add_point(x,y,z) path.add_point(x,y,z) path.build() t=0 while KeyHit(KEY_ESCAPE)~=1 or t<1 do t=t+.01 xyz=path.get_coords(t) PositionEntity(camera,xyz) PointEntity(camera,target) RenderWorld() Flip(1) end
  10. I can turn on Lua in bMax just like local LuaState:byte ptr = luaL_newstate() and then run my own scripts with this. Leadwerks on start creating own Lua state, and attach all of own methods to it. Do anyone knows, how can i get current Lua state in bMax?
  11. It easy to hack your engine for you Josh Just add funtion LoadUniqueMesh that will be add system time value to mesh,materials and shaders filenames before loading it. And engine will think - that it's absolute separate mesh with separate materials. And all will be happy
  12. Last news This function don't have entity, and don't be work as we supposed. Wiki is wrong, wee need always look only to http://www.leadwerks.com/werkspace/page/Documentation/le2/_/command-reference/ I maked not instanced materials, but for this i creating copy of mesh on HDD, load id, delete from HDD - have not instanced model, but materials is instaced. Parse all it surfaces, and same write copyes of materials to HDD, load it, assign, delete from HDD. Same with shaders... Looks like there is no another way.
  13. As you can see - in my function in BMax - i don't do any with entity, line inside function is commented. And error spawn on renderworld. Good if it works in C. P.S. Yeah, i'm some mistaked with callback names before...
  14. http://leadwerks.com/wiki/index.php?title=SetEntityCallback ENTITYCALLBACK_UPDATEMATRIX - will be called whenever an entity rotates or moves. ENTITYCALLBACK_FREE - will be called when the entity is freed. ENTITYCALLBACK_COLLISION - will be called when the entity collides with another entity (bodies and terrain only). ENTITYCALLBACK_UPDATE - will be called once each time UpdateWorld() is called. ENTITYCALLBACK_MESSAGERECEIVE - will be called when the entity receives a message. it's not here
  15. So then how in this callback to get from what entity was callback called? Because with only one material parameter seems it is unusfull for us
  16. This code is printing ............. Camera Directionallight Camera Directionallight Camera Directionallight Camera Directionallight Camera Directionallight Camera Directionallight Camera Directionallight Camera ........... Framework leadwerks.engine registerabstractpath AppDir Graphics 800,600 createworld cp=createpivot() cam=createcamera() entityparent cam,cp moveentity cam,vec3(0,5,-5) pointentity cam,cp b=createbuffer(800,600,BUFFER_COLOR|BUFFER_NORMAL|BUFFER_DEPTH) lt=createdirectionallight() moveentity lt,vec3(1,2,3) pointentity lt,cp c=createcube() mat=creatematerial() setmaterialcolor mat,vec4(1,0,0,1) paintentity c,mat Function on_paint(mat:tmaterial,ee:TList) For e:tentity=EachIn ee Print getentitykey(e,"class") Next End Function setMaterialCallback mat,on_paint,MATERIALCALLBACK_ENABLE Repeat If KeyHit(27) Or AppTerminate() End turnentity cp,vec3(0,.1,0) setbuffer b renderworld setbuffer backbuffer() renderlights b Flip 1 Forever seems like second function parameter is the list of cameras\lights Want to know how to use it myself
  17. leMoveEntity(...) is not big deal. Working with Xors3D all commands are same, just "x" prefix there, so no big trouble with this.
  18. With this code walking 15 NPC at same time, and all is correct. But it makes sense... will think about it. Think at get next point we can store distance from current NPC position to it, and while move forward check not distance to target point, but length of way that passed NPC. Like this: if obj.target~=nil then if EntityDistance(obj.body,obj.prev_point_pos)>obj.path_lenght then PositionEntity(obj.prev_point_pos,EntityPosition(obj.body)) -- store prev point position get_next_point(obj) obj.path_lenght=EntityDistance(obj.body,obj.target) -- distance to new target return end PositionEntity(obj.head,EntityPosition(obj.body)) obj.head:Point(obj.target,3,obj.turn_smooth,0) obj.body:Update(EntityRotation(obj.head).y,obj.walk_speed,0,0,40,1,0) end PositionEntity(obj.mesh,EntityPosition(obj.body)) RotateEntity(obj.mesh,Vec3(0,EntityRotation(obj.head).y-180,0)) This can free such lag. P.S. maybe this code is wrong, not checked, just concept.
  19. My NPC have controller,head pivot and mesh Each UpdatePhysics i have one current NPC target, and i do this: 1. set head pivot to controller position 2. point head smooth to current target waypoint 3. move controller forward using head.Y as controller turn Something like that. Movement is smooth enough. On NPC creation function create_bot(obj) obj.body=CreateController(obj.height,obj.width,obj.step_height,obj.max_slope) SetBodyMass(obj.body,1) EntityType(obj.body,COLLISION_CHARACTER) obj.head=CreatePivot() refresh_mesh(obj,GetEntityKey(obj.model,"mesh")) if obj.mesh==nil then obj.mesh=CreatePivot() end PositionEntity(obj.body,EntityPosition(obj.model)) PositionEntity(obj.head,EntityPosition(obj.model)) RotateEntity(obj.head,Vec3(0,EntityRotation(obj.model).y,0)) end and on PhysicsUpdate if obj.target~=nil then if EntityDistance(obj.body,obj.target)<.5 then get_next_point(obj) return end PositionEntity(obj.head,EntityPosition(obj.body)) obj.head:Point(obj.target,3,obj.turn_smooth,0) obj.body:Update(EntityRotation(obj.head).y,obj.walk_speed,0,0,40,1,0) end PositionEntity(obj.mesh,EntityPosition(obj.body)) RotateEntity(obj.mesh,Vec3(0,EntityRotation(obj.head).y-180,0))
  20. TextureFilter(tex,TEXFILTER_SMOOTH) ?
  21. Yeah, i saw thais, but im making this by LUA, and such method is impossible there, you know it yourself That's why ask Josh to fix this.
  22. Thanks for turbo reply Even if i use? textureCubeLod(LW_CUBEMAP,cubecoord,0) So then any way to build mipmaps after buffer render? (let it be so, let it be so....... )
×
×
  • Create New...