Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Instance object problem

Author
Message
Justice
20
Years of Service
User Offline
Joined: 22nd Jun 2004
Location:
Posted: 20th Jan 2015 23:01
Hi,

I have a weird problem when using the instance command.

I have created a matrix and placed trees on it. (from 1-1000 trees)
I used the clone command first to clone the trees and then my character can walk around the landscape (collision works well with trees and any other object I place on my landscape & speed is good).

I next tried replacing the clone object with the instance object command, thinking that this might improve the efficiency of my program. the fps did go up quite a lot but when I got close to any tree it vanished and when I moved away it re-appeared.
The object is still there because collision still works.

This is really weird !!
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 21st Jan 2015 03:17
Some code might help to understand your problem.
I had another issue with istance objects, when setting an Alpha command for an istanced object (static shadows I made on a 2d plane), the source object lose the Alpha value, so I have to make the 1st, hide it or exclude it, then work with the other istances pointing to the hidden/excluded object
The Tall Man
11
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 21st Jan 2015 04:12 Edited at: 21st Jan 2015 04:16
I've had the same problem in DarkGDK (which uses the same source-code as DBPro) - using instancing instead of than cloning - instancing is obviously buggy. I just switched to cloning to resolve it. In my case, only certain instances would vanish - while others worked just fine. It was consistent from run to run, but otherwise seemed random in which instances it affected.

Something you might try to resolve the instancing bug - you could manually set the object scaling for each instance (as one idea). Basically - manually set the instances' parameters to be identical to those of the original object. To play around with things like this, replace the instance command with an instancing subroutine that starts with the instancing command, followed by your code to manually copy other parameters. You could also manually set the instances to Show (as opposed to hide), even though it ~should have~ defaulted to Show anyway.

Judging what we see is the greatest blinder and self-limiter in the universe.

What we perceive is never reality. It is only a story we tell ourselves based on our current perspective, which has far more to do with our beliefs about ourselves than with anything else.
Justice
20
Years of Service
User Offline
Joined: 22nd Jun 2004
Location:
Posted: 21st Jan 2015 07:47
ok thx, ill try your ideas
Justice
20
Years of Service
User Offline
Joined: 22nd Jun 2004
Location:
Posted: 21st Jan 2015 21:56
Problem solved !!

It was darkbasic's scale command which was causing the problem.

I replaced this with :

function scaleobject(ObjID, scX#,scY#,scZ#)
`you must loop through each limb adding to the existing vertex count
for xx = 0 to GetTotalLimbs( ObjID ) -1
LOCK VERTEXDATA FOR LIMB ObjID,xx,2
VertexCount =GET VERTEXDATA VERTEX COUNT()
for v = 0 to VertexCount -1
X# =GET VERTEXDATA POSITION X( v )
Y# =GET VERTEXDATA POSITION Y( v )
Z# =GET VERTEXDATA POSITION Z( v )

SET VERTEXDATA POSITION v, X#*scX#, Y#*scY#, Z#*scZ#
next v
next xx
UNLOCK VERTEXDATA
CALCULATE OBJECT BOUNDS ObjID `ADDED THIS
endfunction

function GetTotalLimbs( ObjID )
`check number of limbs on object
while limb exist(ObjID,LimbCount) = 1
LimbCount = LimbCount + 1
endwhile
endfunction LimbCount


All works great now
The Tall Man
11
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 22nd Jan 2015 01:42
Wonderful!

Judging what we see is the greatest blinder and self-limiter in the universe.

What we perceive is never reality. It is only a story we tell ourselves based on our current perspective, which has far more to do with our beliefs about ourselves than with anything else.

Login to post a reply

Server time is: 2025-05-12 02:58:49
Your offset time is: 2025-05-12 02:58:49