Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Alex

Pages: [1]
1
General Discussion / Re: Some question ^^
« on: February 10, 2010, 05:44:38 PM »
Is it possible to group multiple meshes in a model using lua script ?
Yes, there is no particular problem.


Or even group multiple models together in the same(local) coordinate space, that would be nice :D
Never tried, but that should work...

Which example describes this ?

2
General Discussion / Re: Some question ^^
« on: February 08, 2010, 05:09:09 PM »
Is it possible to group multiple meshes in a model using lua script ?

Or even group multiple models together in the same(local) coordinate space, that would be nice :D

3
General Discussion / Re: Some question ^^
« on: February 08, 2010, 02:18:02 AM »
Hi,

I tried to make box model out of 6 planes. The idea is to encapsulate 6 planes in parent object and make some method to change material of individual plane. So far box is created but it seams `HYP_Object.AddChild` is not enough to make a composite object.

here is test code:
Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<geexlab>
<scene name="test" show_ref_grid="TRUE" display_fps="TRUE">
<window_size width="960" height="640" width_offset="30" height_offset="50" fullscreen="FALSE" />
<ref_grid_color r="0.423" g="0.423" b="1.0" />
</scene>

<camera name="myCamera" fov="60.0" navigation_mode="EXAMINE" near_plane="1.0" far_plane="40000.0" inertia="FALSE">
<lookat x="0.0" y="0.0" z="0.0" w="1.0" />
<position x="0.0" y="31.0" z="-15.0" />
<bkg_color r="0.0" g="0.0" b="0.0" />
</camera>

<light name="myLight">
<ambient r="0.2" g="0.2" b="0.2" a="1.0" />
<specular r="0.1" g="0.1" b="0.1" a="1.0" />
<orientation pitch="-0.7" yaw="-0.70" roll="-0.70" />
<position x="1.0" y="40.0" z="1.0" />
<diffuse r="2.0" g="2.0" b="2.0" a="1.0" />
</light>

<texture name="imageJPG" filename="room.jpg" pixel_format="BGR" />       

<material name="constuctionPlaneMat" >
<add_texture name="imageJPG" />
</material>

<!--
<mesh name="plane1" shape_type="PLANE" render="TRUE" lighting="FALSE"
back_face_culling="FALSE" >
<plane x_size="150.0" z_size="128.0"  />
<position x="0.0" y="0.0" z="0.0" />
<orientation pitch="90.0" />
<attach_material name="constuctionPlaneMat" />
</mesh>
-->

<script name="logging.lua" filename="logging.lua" run_mode="INIT" />
<script name="class_structure.lua" filename="class_structure.lua" run_mode="INIT" />
<script name="box.lua" filename="box.lua" run_mode="INIT" />
<script name="test_init.lua" filename="test_init.lua" run_mode="INIT" />

<!--
<script name="update_frame.lua" filename="mainloop.lua" run_mode="FRAME" />
-->

</geexlab>


box.lua
Code: [Select]

CustomBox = GenericClass:new()

function CustomBox.new(self, width, height, depth)
log( " Creating new box ..."..width..', '..height..', '..depth )
local new = getmetatable(self).new(self)
if not depth then depth=0 end
if not height then height=0 end
if not width then width=0 end
new.width, new.height, new.depth = width, height, depth

-- replacing this call:
--    new.id = HYP_Mesh.CreateBox(width, height, depth, 1, 1, 1)
-- creating 6 planes to represent a box
local material = HYP_Object.GetId("constuctionPlaneMat")
new.sides = {}
new.sides[0] = new:CreatePlane(height, depth, 1, 1, CustomBox.PLANE_TYPE_YZ, material)
new.sides[1] = new:CreatePlane(height, depth, 1, 1, CustomBox.PLANE_TYPE_YZ, material)
HYP_Object.SetPosition(new.sides[0], width/2, 0, 0)
HYP_Object.SetPosition(new.sides[1], -width/2, 0, 0)

new.sides[2] = new:CreatePlane(width, depth, 1, 1, CustomBox.PLANE_TYPE_XZ, material)
new.sides[3] = new:CreatePlane(width, depth, 1, 1, CustomBox.PLANE_TYPE_XZ, material)
HYP_Object.SetPosition(new.sides[2], 0, height/2, 0)
HYP_Object.SetPosition(new.sides[3], 0, -height/2, 0)

new.sides[4] = new:CreatePlane(width, height, 1, 1, CustomBox.PLANE_TYPE_XY, material)
new.sides[5] = new:CreatePlane(width, height, 1, 1, CustomBox.PLANE_TYPE_XY, material)
HYP_Object.SetPosition(new.sides[4], 0, 0, depth/2)
HYP_Object.SetPosition(new.sides[5], 0, 0, -depth/2)

log( " Making box out of planes ..." )
-- reparent sides to form a box model
--    There is no method to create empty model obj. to hold this meshes, will try with gizmo ;)
local parent = HYP_Object.CreateGizmo()
for index = 0, 6 do
HYP_Object.AddChild( parent, new.sides[index] )
end

new.model = parent

return new
end

CustomBox.PLANE_TYPE_XZ = 0
CustomBox.PLANE_TYPE_XY = 1
CustomBox.PLANE_TYPE_YZ = 2

-- somehow HYP_Mesh.CreatePlane`s fifth parameter doesnot work ... so here we make a litle zbudz
function CustomBox.CreatePlane(self, w, h, w_segs, h_segs, plane_type, material)
local ret = HYP_Mesh.CreatePlane(w, h, w_segs, h_segs, PLANE_XZ)
log("new plane: "..w..', '..h..', '..plane_type)
log("mat id: ".. tostring(material))

HYP_Object.ClearAllMaterials(ret)
if material then HYP_Object.SetMaterial(ret, material) end
if plane_type == CustomBox.PLANE_TYPE_XY then
log("rotate about X")
HYP_Object.SetPitch(ret, 90, 2)
elseif plane_type == CustomBox.PLANE_TYPE_YZ then
log("rotate about Z")
HYP_Object.SetRoll(ret, 90, 2)
end
return ret
end

test_init.lua
Code: [Select]
our_box = CustomBox:new(1, 3, 7)

HYP_Object.SetPosition(our_box.model, 10, 0, 0)

`HYP_Object.SetPosition(our_box.model, 10, 0, 0)` is intended to move the whole box to new position, but i didn`t reparent those planes properly ...

logging.lua
Code: [Select]
LOG_USE_FILE = false

if LOG_USE_FILE == true then
local f = assert(io.open("app.log", "ab"))
f:write('\n\n\n\n\n\n\n\n\n\n\n\n\n logging started ..............................\n')
f:flush()
end

function log(msg)
HYP_Debug.Trace(msg)
if LOG_USE_FILE == true then
f:write(msg .. '\n')
f:flush()
end
end

class_structure.lua
Code: [Select]
GenericClass = {
new = function(self, obj)
local obj = obj or {}
setmetatable(obj, self)
self.__index = self
return obj
end
}

-- return a copy of the table t
function Clone(t)
local new = {}
local i, v = next(t, nil)
while i do
new[i] = v
i, v = next(t, i)
end
setmetatable(new, getmetatable(t) or {})
return new
end

-- return a copy of the table t
function DeepClone(t)
local new = {}             -- create a new table
local i, v = next(t, nil)  -- i is an index of t, v = t[i]
while i do
if type(v) == "table" then v = DeepClone(v) end
new[i] = v
i, v = next(t, i)        -- get next index
end
setmetatable(new, getmetatable(t) or {})
return new
end

4
General Discussion / Can we get a wiki
« on: February 07, 2010, 11:56:24 PM »
Hi JeGX,

Can You setup some wiki for geexlab users ? trac or something like that ... then we can move and expand documentation.

Cheers

5
General Discussion / Re: Access command line parameters
« on: November 28, 2009, 12:02:00 AM »
example:
Code: [Select]
myprogam.exe -size 1680 1050 -multiplayer

6
General Discussion / Access command line parameters
« on: November 22, 2009, 07:50:03 PM »

Is there a way to access command line parameters inside lua script ?

Thanks.

7
Thanks

8
General Discussion / Beginners Work In Progress: Space, shooter minigame
« on: November 14, 2009, 02:51:24 PM »
Hi all,

Here is small video of current game progress :
http://www.youtube.com/watch?v=DDQe46Imcas

There is also roadmap defined but its not in english, so i will try to summarize:

 - belongs to action / duengon / strategy / one-line shooter genre
 - planed to make game menu so player can choose game type according to his/her age
 - going to limit object movement in one plane. As I am convinced that it is tiresome for human players to think in 3D
 - for strategy mode there are great details for ship classes and technologies that you can put on ships. Ship class list:
         - Utility         
         - Interceptor      
         - Gunboat         
         - Heavy Gunship      
         - Corvette         
         - Frigate         
         - Lineship/Carrier   
         - Destroyer         
         - Cruiser         
         - Battlecruiser      
         - Battleship      
         - Dreadnought      
         - Leviathan         
         - Titan            
         - Death star      
   every advanced ship class can take greather number of technologies.

There are very few visual effects in game right now. Planed to add laser, gun, damage, etc .. effects after gameplay is done.


9
General Discussion / Object shadows
« on: November 10, 2009, 06:11:58 PM »
Hi,
I am looking at `Shadow_Mapping` and `Shadow_Volumes` demos to see how it works.

What does that `shadow_caster="TRUE"` do?

Simply adding `shadow_caster="TRUE"` to my models introduces their shadows in the scene. So shader programs used in demos somehow add to that builtin shadow_caster functionality ?

How can every model cast shadow using one of those two techniques ?
Maybe iterating through every model, apply `HYP_Object.SetShadowCasterState`, apply shader program for every material in every mesh

Thanks

10
General Discussion / Re: commandline
« on: October 12, 2009, 01:20:39 AM »
Thanks  :)

11
General Discussion / commandline
« on: October 11, 2009, 02:01:23 PM »
Hi,

Is there some commandline options so that we can start demo from notepad++`s run dialog ?

12
General Discussion / Re: 2D physix
« on: October 10, 2009, 09:38:57 AM »
here is that code
Code: [Select]
local z,x,c = HYP_PhysX.GetActorLinearVelocity(body)
HYP_PhysX.SetActorLinearVelocity(body, z, 0, c)
z,x,c = HYP_PhysX.GetActorGlobalPosition(body)
HYP_PhysX.SetActorGlobalPosition(body, z, 0, c)
z,x,c = HYP_PhysX.GetActorAngularVelocity(body)
HYP_PhysX.SetActorAngularVelocity(body, 0.0, x, 0.0)
Runs in every frame.

When objects colide there is slight change in actor`s direction vector, it is no longer in game plane.

But what if there is function `HYP_PhysX.GetActorGlobalOrientation( )` then we could do this
Code: [Select]
local angle, x, y, z = HYP_PhysX.GetActorGlobalOrientation(body)
HYP_PhysX.SetActorGlobalOrientation(body, angle, x, y, z)
And then it can be done in every couple of seconds, not in every frame.

I tried with `HYP_Object.GetDirection` to retrieve current direction vector of body and failed.

13
General Discussion / 2D physix
« on: October 08, 2009, 10:17:36 PM »
Can we limit physics simulation to one plane ?
What would be the nice way to fix object y coordinate ?

14
General Discussion / Screenshots
« on: October 07, 2009, 09:30:43 AM »
The minigame has elements:
 - object movement. Done by `HYP_PhysX.AddSphereActorToScene`
 - shooting.
    - laser effect with `HYP_Primitive.CreateLine`
    - sound effect
    - and if there is target a particle effect on hit position

a screenshot:


Particle effect is working as expected, could not find doc about it in api reference.

Laser effect is not working. `HYP_Primitive.CreateLine` does return valid id (id > 0) but is not rendered, here is code :
Code: [Select]
line = HYP_Primitive.CreateLine('dzebana')
log('laser created : '.. line)
HYP_Primitive.SetLineVertexPosition(line, 0, pos.x, pos.y, pos.z)
HYP_Primitive.SetLineVertexPosition(line, 1, target.x, target.y, target.z)
HYP_Primitive.SetLineVertexColor(line, 0, 1, 0, 0, 0.7)
HYP_Primitive.SetLineVertexColor(line, 1, 1, 0, 0, 0.7)

For every sound effect (when ship fires you can hear 'zaap') I use load so user can hear effects overlapping :
Code: [Select]
local effect = HYP_Sound.Load('data/sound/zap.wav', 0)
HYP_Sound.SetSourcePosition(effect, pos.x, pos.y, pos.z)
HYP_Sound.Play(effect)
I do not know whether to always create a new sound.

For collision detection I use `HYP_Scene.CastRay`. To better the detection model has sort of bounding box around it, with material that has alpha == 0 and white color. Somehow that material is not loaded properly or was lost during export from google sketchup to 3ds.
Maybe if I add boundingbox mesh manualy to model and set its material in script ..

Ideally, I would calculate collision with physix actors but I didn`t found the way to do it.

I like to define model in xml and then use it as template for instancing objects with the same model. In this case clone function comes handy. And I don`t know if it is good to use `HYP_Model.Load`every time when new element is inserted in scene.

Also there is another model far to the right but is not visible somehow.

Cheers


15
General Discussion / porting from demoniak3d
« on: October 06, 2009, 10:42:16 AM »
Hi all,

I ported my minigame from demoniak3d.
Cloning function is missing, not listed in api doc and program crashes on `HYP_Object.Clone` call.
Switched from `HYP_Object.Clone` to `HYP_Model.Load` is that good practice ?
Physix is working ok.
I have polygons that are visible now and they was transparent in demoniak3d with alpha.
Also models not rendering when in some particular position/camera distance.

Cheers

Pages: [1]