Node access problems in delta3d

Source: Internet
Author: User

When I was a beginner at delta3d, I encountered a problem when I tried to develop it two days ago, that is, I could not find the switch node. As a result, I read the program that was originally written using Vega. The name is correct, and the type is correct. It was a bit confused for a moment. Later, I checked the code after the model is converted to OSG in the stage and found that the node is not changed to OSG: switch, but osgsim :: multiswitch, no matter what happens, the cause of the error is finally known. Continue the analysis.

Someone on delta3d's official website says this problem using dtutil: nodecollector could not find multiswtich. A solution is provided, that is, access using nodevisitor of the previous OSG. I am very lazy. I always feel that OSG is too difficult to write. I always want to find a convenient method. And I will use this method to find the Degree of Freedom node in a short time (ER, I am a cainiao, I only used Vega, I was just a month ago, I was not familiar with graphics, and I still don't know what Transformation Matrix I got) looking for a switch node using another method is not very comfortable. So Google continued to find that someone on SourceForge gave the modified dtutil: nodecollector program supports multiswitch and has been added to version 2.4. This is a good time to come down. Who would think that compilation is not the case? I still can't do it. I'm dizzy. It's not torture me. I can't even steal a lazy one. Analysis Code (open-source power) found that the new nodecollector added a new function in its own nodevisitor

Virtual void apply (osgsim: multiswitch & pmultiswitch)

The problem should be solved here, because nodevisitor does not define this interface.

Trace the source and check the node: accept function.

Void node: accept (nodevisitor & NV) <br/>{< br/> If (NV. validnodemask (* This) <br/>{< br/> NV. pushontonodepath (this); <br/> NV. apply (* This); <br/> NV. popfromnodepath (); <br/>}< br/>}

Because the apply overload function with the multiswitch parameter is not defined in nodevistor, NV here. apply Is the function corresponding to OSG: group called. Therefore, multiple nodes are naturally added to the group. Therefore, according to this modification program

Dtcore: refptr <OSG: group> mmultiswitch; <br/> dtcore: refptr <dtutil: nodecollector> mosgcollector = new dtutil: nodecollector (getgameactorproxy (). getgameactor (). getosgnode (), dtutil: nodecollector: groupflag | dtutil: nodecollector: doftransformflag); <br/> mmultiswitch = mosgcollector-> getgroup ("SW1 "); <br/> osgsim: multiswitch * mMulti = dynamic_cast <osgsim: multiswitch *> (mmultiswitch. get (); <br/> mMulti-> setsinglechildon (0, true); <br/>

 

Run successfully

The bare pointer code is used here, which is not very standard and has potential security risks. Please note that

 

I modified the nodecollector source code and made a dynamic type judgment in virtual void apply (OSG: Group & group ).

However, the result is no effect. Therefore, it is assumed that OSG should process osgsim: in the case of multiswitch, it should be processed as a group directly.

 

After talking about it for half a day, you just need to make a type conversion. It only means that you are too busy to figure out the overall operation of OSG. You can check it carefully before finding it.

 

Finally, because I am a newbie, I do not have in-depth understanding of delta3d and OSG, so it is inevitable that there will be some errors.

Please give me more advice and hope to have a chance to communicate with you.

It seems that it's quite late. I have to play the game tomorrow morning to clean up and sleep.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.